Previous

10.3.4.8. Choice patterns

10.3.4.8.1. Syntax a) NEST integral choice pattern{A341c } : NEST insertion{A341d } , letter c{94a} symbol, NEST praglit{c} list brief pack.

b) NEST boolean choice pattern{A341c } : NEST insertion{A341d } , boolean marker{A344b} , brief begin{94f } token, NEST praglit{c}, and also{94f } token, NEST praglit{c}, brief end{94f } token, pragment{92a} sequence option.

c) NEST praglit{a,b} : pragment{92a } sequence option, NEST literal{A341i } . {Examples:

}

a)
120kc("mon", "tues", "wednes", "thurs", "fri", "satur", "sun")
b)
b("","error")
c)
"mon"
{

aa) A value V is output using a picture P whose pattern C was yielded by an integral-choice-pattern Q, as follows:

· the insertion of Q is staticized {10.3.4.1.1.dd } and performed {10.3.4.1.1.ee };

If the mode of V is specified by INT, if V > 0 and if the number of constituent literals in the praglit-list-pack of Q is at least V,
then


· the literal yielded by the V-th literal is staticized and performed;

otherwise,


· the event routine corresponding to on value error is called;

· if this returns false, V is output using put and undefined is called;

· the insertion of P is staticized and performed.

bb) A value is input to a name N using a picture P whose pattern Q was yielded by an integral-choice-pattern Q as follows:

· the insertion of Q is staticized and performed,

· each of the literals yielded by the constituent literals of the praglit-list-pack of C is staticized and "searched for" {cc } in turn:

If the mode of N is specified by REF INT and the i-th literal is the first one present.
then I is assigned to N:
otherwise,


· the event routine corresponding to on value error is called;

· if this returns false, undefined is called;

· the insertion of P is staticized and performed.

cc) A literal is "searched for" by reading characters and matching them against successive characters of the literal. If the end of the current line or the logical end of the file is reached, or if a character fails to match, the search is unsuccessful and the current position is returned to where it started from.

dd) A value V is output using a picture P whose pattern Q was yielded by a boolean-choice-pattern C as follows:

· the insertion of Q is staticized and performed:

If the mode of V is specified by BOOL,
then


· if V is true (false), the literal yielded by the first (second) constituent literal of C is staticized and performed:

otherwise,


· the event routine corresponding to on value error is called;

· if this returns false, V is output using put and undefined is called;

· the insertion of P is staticized and performed.

ee) A value is input to a name N using a picture P whose pattern Q was yielded by a boolean-choice-pattern C as follows:

· the insertion of Q is staticized and performed;

· each of the literals yielded by the constituent literals of C is staticized and searched for in turn:

If the mode of N is specified by REF BOOL, and the first second) insertion is present,
then true (false) is assigned to N:
otherwise,


· the event routine corresponding to on value error is called;

· if this returns false, undefined is called;

· the insertion of P is staticized and performed.}


10.3.4.8.2. Semantics The yield of a choice-pattern P is a structured value W whose mode is 'CPATTERN', determined as follows:

· let n be the number of constituent NEST-literals of the praglit-list-pack of P;

· let Si, i = 1, ..., n, be a NEST-insertion akin {1.1.3.2.k } to the i-th of those constituent NEST-literals:

· the insertion I of P and all of S1, ... , Sn are elaborated collaterally:

· the fields of W, taken in order, are

· {i} the yield of I:

· {type} 1 (2) if P is a boolean- (integral-) -choice-pattern;

· {c} a multiple value whose mode is 'row of INSERTION', having a descriptor ((1, n)) and n elements, that selected by (i), i = 1, ... n, being the yield of Si.



 
Next