21 Constant(register struct node **pnd;)
23 register struct node **nd = pnd;
27 Sign(nd) { nd = &((*nd)->nd_right); }
32 ConstantIdentifier(nd)
34 { (void) ChkConstant(*pnd); }
36 STRING { *pnd = MkLeaf(Value, &dot);
37 if( ((*pnd)->nd_type = toktype) != char_type )
42 Sign(register struct node **pnd;):
43 ['+' | '-'] { *pnd = MkLeaf(Uoper, &dot); }
46 UnsignedNumber(register struct node **pnd;):
47 [INTEGER | REAL] { *pnd = MkLeaf(Value, &dot);
48 (*pnd)->nd_type = toktype;
52 ConstantIdentifier(register struct node **pnd;):
53 IDENT { *pnd = MkLeaf(Name, &dot);
57 /* ISO section 6.7.1, p. 121 */
58 Expression(register struct node **pnd;):
61 /* RelationalOperator substituted inline */
62 [ '=' | NOTEQUAL | '<' | '>' | LESSEQUAL | GREATEREQUAL | IN ]
63 { *pnd = MkNode(Boper, *pnd, NULLNODE, &dot); }
64 SimpleExpression(&((*pnd)->nd_right))
68 SimpleExpression(register struct node **pnd;):
69 /* ISO 6.7.1: The signs and the adding-operators have equal precedence,
70 and are left-associative.
74 Term(&((*pnd)->nd_right))
79 /* AddingOperator substituted inline */
81 { *pnd = MkNode(Boper, *pnd, NULLNODE, &dot); }
82 Term(&((*pnd)->nd_right))
86 Term(register struct node **pnd;):
89 /* MultiplyingOperator substituted inline */
90 [ '*' | '/' | DIV | MOD | AND ]
91 { *pnd = MkNode(Boper, *pnd, NULLNODE, &dot); }
92 Factor(&((*pnd)->nd_right))
96 Factor(register struct node **pnd;)
98 register struct def *df;
100 /* This is a changed rule, because the grammar as specified in the
101 * reference is not LL(1), and this gives conflicts.
104 %prefer /* solve conflicts on IDENT and UnsignedConstant */
105 IDENT { *pnd = MkLeaf(Name, &dot); }
107 /* ISO section 6.7.3, p. 126
108 * IDENT is a FunctionIdentifier
111 *pnd = MkNode(Call, *pnd, NULLNODE, &dot);
113 ActualParameterList(&((*pnd)->nd_right))
115 /* IDENT can be a BoundIdentifier or a ConstantIdentifier or
116 * a FunctionIdentifier (no parameterlist), in which case
117 * VariableAccessTail is empty.
118 * It could also be the beginning of a normal VariableAccess
123 df = lookfor(*pnd, CurrVis, 1);
124 /* df->df_flags |= D_USED; */
125 if( df->df_type->tp_fund & T_ROUTINE ) {
126 /* This part is context-sensitive:
127 is the occurence of the proc/func name
130 if( df->df_type == std_type )
134 *pnd = MkNode(class, *pnd, NULLNODE, &dot);
135 (*pnd)->nd_symb = '(';
139 VariableAccessTail(pnd)
142 UnsignedConstant(pnd)
146 '(' { /* dummy node to force ChkVariable */
147 *pnd = MkLeaf(Uoper, &dot);
149 Expression(&((*pnd)->nd_right))
152 NOT { *pnd = MkLeaf(Uoper, &dot); }
153 Factor(&((*pnd)->nd_right))
156 UnsignedConstant(register struct node **pnd;):
159 STRING { *pnd = MkLeaf(Value, &dot);
160 if( ((*pnd)->nd_type = toktype) != char_type )
164 ConstantIdentifier(pnd)
166 NIL { *pnd = MkLeaf(Value, &dot);
167 (*pnd)->nd_type = nil_type;
168 /* to evaluate NIL = NIL */
173 SetConstructor(register struct node **pnd;)
175 register struct node *nd;
177 '[' { dot.tk_symb = SET;
178 *pnd = nd = MkLeaf(Xset, &dot);
183 { nd = nd->nd_right; }
184 ',' MemberDesignator(nd)
190 MemberDesignator(register struct node *nd;)
195 [ UPTO { nd1 = MkNode(Link, nd1, NULLNODE, &dot); }
196 Expression(&(nd1->nd_right))
198 { nd->nd_right = MkNode(Link, nd1, NULLNODE, &dot);
199 nd->nd_right->nd_symb = ',';
203 /* ISO section 6.7.2.1, p. 123 */
204 BooleanExpression(register struct node **pnd;):
206 { if( ChkExpression(*pnd) &&
207 (*pnd)->nd_type != bool_type )
208 node_error(*pnd, "boolean expression expected");
213 ActualParameterList(register struct node **pnd;)
215 register struct node *nd;
218 /* ActualParameter substituted inline */
219 Expression(pnd) { *pnd = nd =
220 MkNode(Link, *pnd, NULLNODE, &dot);
224 ',' { nd->nd_right = MkLeaf(Link, &dot);
227 Expression(&(nd->nd_left))
232 /* ISO section 6.5.1, p. 105 */
233 VariableAccess(register struct node **pnd;):
234 /* This is a changed rule, because the grammar as specified in the
235 * reference is not LL(1), and this gives conflicts.
237 * IDENT is an EntireVariable or
238 * a FieldDesignatorIdentifier (see also 6.8.3.10, p. 132).
240 IDENT { *pnd = MkLeaf(Name, &dot); }
241 VariableAccessTail(pnd) { (void) ChkVariable(*pnd); }
244 VariableAccessTail(register struct node **pnd;):
245 /* This is a new rule because the grammar specified by the standard
246 * is not exactly LL(1).
251 /* PointerVariable or FileVariable
254 '^' { *pnd = MkNode(Arrow, NULLNODE, *pnd, &dot); }
256 /* At this point the VariableAccess is an IdentifiedVariable
257 * ISO section 6.5.4, p. 107 (IdentifiedVariable: PointerVariable '^'),
259 * it is a BufferVariable
260 * ISO section 6.5.5, p. 107 (BufferVariable: FileVariable '^').
263 VariableAccessTail(pnd)
268 '[' { *pnd = MkNode(Arrsel, *pnd, NULLNODE, &dot); }
269 /* IndexExpression substituted inline */
270 Expression(&((*pnd)->nd_right))
272 ',' { *pnd = MkNode(Arrsel, *pnd, NULLNODE, &dot);
273 (*pnd)->nd_symb = '[';
275 Expression(&((*pnd)->nd_right))
279 /* At this point the VariableAccess is an IndexedVariable
280 * ISO section 6.5.3.2, p. 106
283 VariableAccessTail(pnd)
288 '.' { *pnd = MkNode(Link, *pnd, NULLNODE, &dot); }
289 /* FieldSpecifier & FieldIdentifier substituted inline */
290 IDENT { (*pnd)->nd_IDF = dot.TOK_IDF; }
292 /* At this point the VariableAccess is a FieldDesignator
293 * ISO section 6.5.3.3, p. 107
296 VariableAccessTail(pnd)