]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /*;-*-C-*-; |
2 | ** Copyright (c) Massachusetts Institute of Technology 1994-1998. | |
3 | ** All Rights Reserved. | |
4 | ** Unpublished rights reserved under the copyright laws of | |
5 | ** the United States. | |
6 | ** | |
7 | ** THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
8 | ** OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
9 | ** | |
10 | ** This code is distributed freely and may be used freely under the | |
11 | ** following conditions: | |
12 | ** | |
13 | ** 1. This notice may not be removed or altered. | |
14 | ** | |
15 | ** 2. Works derived from this code are not distributed for | |
16 | ** commercial gain without explicit permission from MIT | |
17 | ** (for permission contact lclint-request@sds.lcs.mit.edu). | |
18 | */ | |
19 | /* | |
20 | ** Copyright (c) Massachusetts Institute of Technology, 1993 | |
21 | ** All Rights Reserved. Unpublished rights reserved | |
22 | ** under the copyright laws of the United States. | |
23 | **++ | |
24 | ** FACILITY: LSLC | |
25 | ** | |
26 | ** MODULE DESCRIPTION: | |
27 | ** | |
28 | ** FILENAME: llgramar.y | |
29 | ** | |
30 | ** PURPOSE: bison grammar for LCL language. | |
31 | ** | |
32 | ** AUTHORS: | |
33 | ** Yang Meng Tan, Massachusetts Institute of Technology | |
34 | */ | |
35 | ||
36 | %{ | |
37 | ||
38 | # include "lclintMacros.nf" | |
39 | # include "llbasic.h" | |
40 | # include "lclscan.h" | |
41 | # include "checking.h" | |
42 | # include "lslparse.h" | |
43 | # include "lh.h" | |
44 | # include "usymtab_interface.h" | |
45 | ||
46 | /*@-noparams@*/ | |
47 | static /*@unused@*/ void yyprint (); | |
48 | /*@=noparams@*/ | |
49 | ||
50 | /*@-redecl@*/ | |
51 | void ylerror (char *) /*@modifies *g_msgstream@*/ ; | |
52 | /*@=redecl@*/ | |
53 | ||
54 | bool g_inTypeDef = FALSE; | |
55 | ||
56 | /*@constant int YYDEBUG;@*/ | |
57 | # define YYDEBUG 1 | |
58 | ||
59 | /*@notfunction@*/ | |
60 | # define YYPRINT(file, type, value) yyprint (file, type, value) | |
61 | ||
62 | /* | |
63 | ** This is necessary, or else when the bison-generated code #include's malloc.h, | |
64 | ** there will be a parse error. | |
65 | ** | |
66 | ** Unfortunately, it means the error checking on malloc, etc. is lost for allocations | |
67 | ** in bison-generated files under Win32. | |
68 | */ | |
69 | ||
70 | # ifdef WIN32 | |
71 | # undef malloc | |
72 | # undef calloc | |
73 | # undef realloc | |
74 | # endif | |
75 | ||
76 | %} | |
77 | ||
78 | %union | |
79 | { | |
80 | ltoken ltok; /* a leaf is also an ltoken */ | |
81 | qual typequal; | |
82 | unsigned int count; | |
83 | /*@only@*/ ltokenList ltokenList; | |
84 | /*@only@*/ abstDeclaratorNode abstDecl; | |
85 | /*@only@*/ declaratorNode declare; | |
86 | /*@only@*/ declaratorNodeList declarelist; | |
87 | /*@only@*/ typeExpr typeexpr; | |
88 | /*@only@*/ arrayQualNode array; | |
89 | /*@only@*/ quantifierNode quantifier; | |
90 | /*@only@*/ quantifierNodeList quantifiers; | |
91 | /*@only@*/ varNode var; | |
92 | /*@only@*/ varNodeList vars; | |
93 | /*@only@*/ storeRefNode storeref; | |
94 | /*@only@*/ storeRefNodeList storereflist; | |
95 | /*@only@*/ termNode term; | |
96 | /*@only@*/ termNodeList termlist; | |
97 | /*@only@*/ programNode program; | |
98 | /*@only@*/ stmtNode stmt; | |
99 | /*@only@*/ claimNode claim; | |
100 | /*@only@*/ typeNode type; | |
101 | /*@only@*/ iterNode iter; | |
102 | /*@only@*/ fcnNode fcn; | |
103 | /*@only@*/ fcnNodeList fcns; | |
104 | /*@only@*/ letDeclNode letdecl; | |
105 | /*@only@*/ letDeclNodeList letdecls; | |
106 | /*@only@*/ lclPredicateNode lclpredicate; | |
107 | /*@only@*/ modifyNode modify; | |
108 | /*@only@*/ paramNode param; | |
109 | /*@only@*/ paramNodeList paramlist; | |
110 | /*@only@*/ declaratorInvNodeList declaratorinvs; | |
111 | /*@only@*/ declaratorInvNode declaratorinv; | |
112 | /*@only@*/ abstBodyNode abstbody; | |
113 | /*@only@*/ abstractNode abstract; | |
114 | /*@only@*/ exposedNode exposed; | |
115 | /* taggedUnionNode taggedunion; */ | |
116 | /*@only@*/ globalList globals; | |
117 | /*@only@*/ constDeclarationNode constdeclaration; | |
118 | /*@only@*/ varDeclarationNode vardeclaration; | |
119 | /*@only@*/ varDeclarationNodeList vardeclarationlist; | |
120 | /*@only@*/ initDeclNodeList initdecls; | |
121 | /*@only@*/ initDeclNode initdecl; | |
122 | /*@only@*/ stDeclNodeList structdecls; | |
123 | /*@only@*/ stDeclNode structdecl; | |
124 | /*@only@*/ strOrUnionNode structorunion; | |
125 | /*@only@*/ enumSpecNode enumspec; | |
126 | /*@only@*/ lclTypeSpecNode lcltypespec; | |
127 | /*@only@*/ typeNameNode typname; | |
128 | /*@only@*/ opFormNode opform; | |
129 | /*@only@*/ sigNode signature; | |
130 | /*@only@*/ nameNode name; | |
131 | /*@only@*/ typeNameNodeList namelist; | |
132 | /*@only@*/ replaceNode replace; | |
133 | /*@only@*/ replaceNodeList replacelist; | |
134 | /*@only@*/ renamingNode renaming; | |
135 | /*@only@*/ traitRefNode traitref; | |
136 | /*@only@*/ traitRefNodeList traitreflist; | |
137 | /*@only@*/ importNode import; | |
138 | /*@only@*/ importNodeList importlist; | |
139 | /*@only@*/ interfaceNode iface; | |
140 | /*@only@*/ interfaceNodeList interfacelist; | |
141 | /*@only@*/ CTypesNode ctypes; | |
142 | } | |
143 | ||
144 | /* Order of precedence is increasing going down the list */ | |
145 | ||
146 | %left simpleOp | |
147 | %right PREFIX_OP | |
148 | %left POSTFIX_OP | |
149 | %left LLT_MULOP | |
150 | /* as arithmetic binary operator, or as iteration construct in claims */ | |
151 | %left LLT_SEMI | |
152 | %left LLT_VERTICALBAR | |
153 | %nonassoc ITERATION_OP /* two * cannot follow each other */ | |
154 | %left LLT_LPAR LLT_LBRACKET selectSym | |
155 | /* to allow mixing if-then-else with other kinds of terms */ | |
156 | %left LLT_IF_THEN_ELSE | |
157 | %left logicalOp | |
158 | ||
159 | /* Note: the grammar parses b = p /\ q as (b = p) /\ q, that is, | |
160 | = has higher precedence than logicalOp. | |
161 | Reminder: = > logicalOp >= if_then_else > == (present in LSL) */ | |
162 | ||
163 | /* Precedence of claim operators: ( > * > | >; (| and; left-assoc) */ | |
164 | ||
165 | /* These are not needed in the grammar, | |
166 | but needed in init files and lclscanline.c */ | |
167 | ||
168 | %token <ltok> eqSepSym /* \eqsep */ | |
169 | %token <ltok> equationSym /* \equals or == */ | |
170 | %token <ltok> commentSym /* \comment */ | |
171 | %token <ltok> LLT_WHITESPACE | |
172 | %token <ltok> LLT_EOL /*@-varuse@*/ /* yacc declares yytranslate here */ | |
173 | /* used to bypass parsing problems in C types */ | |
174 | %token <ltok> LLT_TYPEDEF_NAME /*@=varuse@*/ | |
175 | ||
176 | /* LSL reserved extension symbols */ | |
177 | ||
178 | %token <ltok> quantifierSym /* \forall */ | |
179 | %token <ltok> logicalOp /* \implies, \and, \not, \or */ | |
180 | %token <ltok> selectSym /* \select */ | |
181 | %token <ltok> openSym /* \( */ | |
182 | %token <ltok> closeSym /* \) */ | |
183 | %token <ltok> sepSym /* \, */ | |
184 | ||
185 | %token <ltok> simpleId /* \: id-char +, Ordinary Identifier */ | |
186 | %token <ltok> mapSym /* \arrow, -> */ | |
187 | %token <ltok> markerSym /* \marker, __ */ | |
188 | %token <ltok> preSym /* \pre */ | |
189 | %token <ltok> postSym /* \post */ | |
190 | %token <ltok> anySym /* \any */ | |
191 | ||
192 | /* Generic LSL operators */ | |
193 | ||
194 | %token <ltok> simpleOp /* opSym - reserved */ | |
195 | ||
196 | /* Reserved special symbols */ | |
197 | ||
198 | %token <ltok> LLT_COLON /* : */ | |
199 | %token <ltok> LLT_COMMA /* , */ | |
200 | %token <ltok> LLT_EQUALS /* = */ | |
201 | %token <ltok> LLT_LBRACE /* { */ | |
202 | %token <ltok> LLT_RBRACE /* } */ | |
203 | %token <ltok> LLT_LBRACKET /* [ */ | |
204 | %token <ltok> LLT_RBRACKET /* ] */ | |
205 | %token <ltok> LLT_LPAR /* ( */ | |
206 | %token <ltok> LLT_RPAR /* ) */ | |
207 | %token <ltok> LLT_QUOTE /* ' */ | |
208 | %token <ltok> LLT_SEMI /*; */ | |
209 | %token <ltok> LLT_VERTICALBAR /* | */ | |
210 | ||
211 | /* C operator tokens and Combined C/LSL operator tokens */ | |
212 | ||
213 | %token <ltok> eqOp /* \eq, \neq, ==, != */ | |
214 | %token <ltok> LLT_MULOP /* * */ | |
215 | ||
216 | /* LCL C literal tokens */ | |
217 | ||
218 | %token <ltok> LLT_CCHAR | |
219 | %token <ltok> LLT_CFLOAT | |
220 | %token <ltok> LLT_CINTEGER | |
221 | %token <ltok> LLT_LCSTRING | |
222 | ||
223 | /* LCL reserved words */ | |
224 | ||
225 | %token <ltok> LLT_ALL | |
226 | %token <ltok> LLT_ANYTHING | |
227 | %token <ltok> LLT_BE | |
228 | %token <ltok> LLT_BODY | |
229 | %token <ltok> LLT_CLAIMS | |
230 | %token <ltok> LLT_CHECKS | |
231 | %token <ltok> LLT_CONSTANT | |
232 | %token <ltok> LLT_ELSE | |
233 | %token <ltok> LLT_ENSURES | |
234 | %token <ltok> LLT_FOR | |
235 | %token <ltok> LLT_FRESH | |
236 | %token <ltok> LLT_IF | |
237 | %token <ltok> LLT_IMMUTABLE | |
238 | %token <ltok> LLT_IMPORTS | |
239 | %token <ltok> LLT_CONSTRAINT /* was INVARIANT */ | |
240 | %token <ltok> LLT_ISSUB | |
241 | %token <ltok> LLT_LET | |
242 | %token <ltok> LLT_MODIFIES | |
243 | %token <ltok> LLT_MUTABLE | |
244 | %token <ltok> LLT_NOTHING | |
245 | %token <ltok> LLT_INTERNAL | |
246 | %token <ltok> LLT_FILESYS | |
247 | %token <ltok> LLT_OBJ | |
248 | %token <ltok> LLT_OUT | |
249 | %token <ltok> LLT_SEF | |
250 | %token <ltok> LLT_ONLY LLT_PARTIAL LLT_OWNED LLT_DEPENDENT LLT_KEEP LLT_KEPT LLT_TEMP | |
251 | %token <ltok> LLT_SHARED LLT_UNIQUE LLT_UNUSED | |
252 | %token <ltok> LLT_EXITS LLT_MAYEXIT LLT_NEVEREXIT LLT_TRUEEXIT LLT_FALSEEXIT | |
253 | %token <ltok> LLT_UNDEF LLT_KILLED | |
254 | %token <ltok> LLT_CHECKMOD LLT_CHECKED LLT_UNCHECKED LLT_CHECKEDSTRICT | |
255 | %token <ltok> LLT_TRUENULL | |
256 | %token <ltok> LLT_FALSENULL | |
257 | %token <ltok> LLT_LNULL | |
258 | %token <ltok> LLT_LNOTNULL | |
259 | %token <ltok> LLT_RETURNED | |
260 | %token <ltok> LLT_OBSERVER | |
261 | %token <ltok> LLT_EXPOSED | |
262 | %token <ltok> LLT_REFCOUNTED | |
263 | %token <ltok> LLT_REFS | |
264 | %token <ltok> LLT_RELNULL | |
265 | %token <ltok> LLT_RELDEF | |
266 | %token <ltok> LLT_KILLREF | |
1ac6313d | 267 | %token <ltok> LLT_NULLTERMINATED |
885824d3 | 268 | %token <ltok> LLT_TEMPREF |
269 | %token <ltok> LLT_NEWREF | |
270 | %token <ltok> LLT_PRIVATE | |
271 | %token <ltok> LLT_REQUIRES | |
272 | %token <ltok> LLT_RESULT | |
273 | %token <ltok> LLT_SIZEOF | |
274 | %token <ltok> LLT_SPEC | |
275 | %token <ltok> LLT_TAGGEDUNION /* keep it for other parts of LCL checker */ | |
276 | %token <ltok> LLT_THEN | |
277 | %token <ltok> LLT_TYPE | |
278 | %token <ltok> LLT_TYPEDEF | |
279 | %token <ltok> LLT_UNCHANGED | |
280 | %token <ltok> LLT_USES | |
281 | ||
282 | /* LCL C keywords */ | |
283 | ||
284 | %token <ltok> LLT_CHAR | |
285 | %token <ltok> LLT_CONST | |
286 | %token <ltok> LLT_DOUBLE | |
287 | %token <ltok> LLT_ENUM | |
288 | %token <ltok> LLT_FLOAT | |
289 | %token <ltok> LLT_INT | |
290 | %token <ltok> LLT_ITER | |
291 | %token <ltok> LLT_YIELD | |
292 | %token <ltok> LLT_LONG | |
293 | %token <ltok> LLT_SHORT | |
294 | %token <ltok> LLT_SIGNED | |
295 | %token <ltok> LLT_UNKNOWN | |
296 | %token <ltok> LLT_STRUCT | |
297 | %token <ltok> LLT_TELIPSIS | |
298 | %token <ltok> LLT_UNION | |
299 | %token <ltok> LLT_UNSIGNED | |
300 | %token <ltok> LLT_VOID | |
301 | %token <ltok> LLT_VOLATILE | |
302 | ||
303 | %token <ltok> LLT_PRINTFLIKE LLT_SCANFLIKE LLT_MESSAGELIKE | |
304 | ||
305 | %type <interfacelist> interface externals optDeclarations declarations | |
306 | %type <iface> external declaration imports uses export private private2 | |
307 | %type <type> type | |
308 | %type <fcn> fcn | |
309 | %type <fcns> fcns | |
310 | %type <claim> claim | |
311 | %type <iter> iter | |
312 | %type <vardeclaration> varDeclaration globalDecl privateInit | |
313 | %type <globals> globals | |
314 | %type <ltokenList> interfaceNameList traitIdList domain sortList | |
315 | %type <import> importName | |
316 | %type <importlist> importNameList | |
317 | %type <traitreflist> traitRefNodeList | |
318 | %type <traitref> traitRef | |
319 | %type <renaming> renaming | |
320 | %type <namelist> nameList | |
321 | %type <name> name | |
322 | %type <replacelist> replaceNodeList | |
323 | %type <replace> replace | |
324 | %type <opform> opForm | |
325 | %type <signature> signature | |
326 | %type <typname> typeName | |
327 | %type <count> middle placeList pointers | |
328 | %type <abstDecl> optAbstDeclarator | |
329 | %type <lcltypespec> lclTypeSpec lclType sortSpec | |
330 | %type <ltokenList> enumeratorList postfixOps | |
331 | %type <ctypes> CTypes typeSpecifier | |
332 | %type <structorunion> structOrUnionSpec | |
333 | %type <enumspec> enumSpec | |
334 | %type <declare> declarator | |
335 | %type <typeexpr> notype_decl after_type_decl abstDeclarator parameter_decl | |
336 | %type <declarelist> declaratorList | |
337 | %type <structdecls> structDecls | |
338 | %type <structdecl> structDecl | |
339 | %type <constdeclaration> constDeclaration | |
340 | %type <initdecls> initDecls | |
341 | %type <initdecl> initDecl | |
342 | %type <vardeclarationlist> privateInits | |
343 | %type <abstract> abstract | |
344 | %type <exposed> exposed | |
345 | %type <declaratorinvs> declaratorInvs | |
346 | %type <declaratorinv> declaratorInv | |
347 | %type <abstbody> abstBody optExposedBody | |
348 | %type <lclpredicate> optClaim optEnsure optRequire optChecks lclPredicate | |
349 | %type <lclpredicate> optTypeInv typeInv | |
350 | %type <modify> optModify | |
351 | %type <letdecls> optLetDecl beDeclList | |
352 | %type <letdecl> beDecl | |
353 | %type <term> term constLclExpr initializer value equalityTerm | |
354 | %type <term> simpleOpTerm prefixOpTerm secondary primary lclPrimary | |
355 | %type <term> bracketed sqBracketed matched term0 cLiteral | |
356 | %type <termlist> args infixOpPart valueList termList | |
357 | %type <program> optBody callExpr | |
358 | %type <stmt> stmt | |
359 | %type <storereflist> storeRefList | |
360 | %type <storeref> storeRef | |
361 | %type <var> quantified | |
362 | %type <vars> quantifiedList | |
363 | %type <quantifier> quantifier | |
364 | %type <quantifiers> quantifiers | |
365 | %type <array> arrayQual | |
366 | %type <paramlist> optParamList paramList realParamList iterParamList realIterParamList | |
367 | %type <param> param iterParam | |
368 | %type <ltok> open close anyOp separator simpleOp2 stateFcn | |
369 | %type <ltok> interfaceName | |
370 | %type <ltok> varId fcnId tagId claimId sortId traitId opId CType optTagId | |
371 | %type <ltok> simpleIdOrTypedefName | |
372 | %type <typequal> specialQualifier special | |
373 | ||
374 | /* | |
375 | ** Conventions in calling static semantic routines: | |
376 | ** The inputs are in strict order (in AST) as well as in the position of | |
377 | ** the call to the static semantic routine. | |
378 | */ | |
379 | ||
380 | %% | |
381 | ||
382 | interface | |
383 | : externals { lhExternals ($1); } optDeclarations | |
384 | { interfaceNodeList_free ($1); interfaceNodeList_free ($3); } | |
385 | ||
386 | externals | |
387 | : /* empty */ { $$ = interfaceNodeList_new (); } | |
388 | | externals external { $$ = interfaceNodeList_addh ($1, $2);} | |
389 | ||
390 | external | |
391 | : imports | |
392 | | uses | |
393 | ||
394 | optDeclarations | |
395 | : /* empty */ { $$ = interfaceNodeList_new (); } | |
396 | | export declarations { $$ = consInterfaceNode ($1, $2);} | |
397 | | private declarations { $$ = consInterfaceNode ($1, $2);} | |
398 | ||
399 | declarations | |
400 | : /* empty */ { $$ = interfaceNodeList_new (); } | |
401 | | declarations declaration { $$ = interfaceNodeList_addh ($1, $2);} | |
402 | ||
403 | declaration | |
404 | : export | |
405 | | private | |
406 | | uses | |
407 | ||
408 | imports | |
409 | : LLT_IMPORTS importNameList LLT_SEMI | |
410 | { $$ = makeInterfaceNodeImports ($2); | |
411 | /* assume subspecs are already processed, symbol table info in external file */ | |
412 | } | |
413 | ||
414 | uses | |
415 | : LLT_USES traitRefNodeList LLT_SEMI | |
416 | { $$ = makeInterfaceNodeUses ($2); readlsignatures ($$);} | |
417 | ||
418 | export | |
419 | : constDeclaration | |
420 | { declareConstant ($1); $$ = interfaceNode_makeConst ($1); } | |
421 | | varDeclaration | |
422 | { declareVar ($1); $$ = interfaceNode_makeVar ($1); } | |
423 | | type | |
424 | { declareType ($1); $$ = interfaceNode_makeType ($1); } | |
425 | | fcn | |
426 | { declareFcn ($1, typeId_invalid); $$ = interfaceNode_makeFcn ($1); } | |
427 | | claim | |
428 | { $$ = interfaceNode_makeClaim ($1); } | |
429 | | iter | |
430 | { declareIter ($1); $$ = interfaceNode_makeIter ($1); } | |
431 | ||
432 | iter | |
433 | : LLT_ITER varId LLT_LPAR iterParamList LLT_RPAR LLT_SEMI | |
434 | { $$ = makeIterNode ($2, $4); } | |
435 | ||
436 | iterParamList | |
437 | : /* empty */ { $$ = paramNodeList_new (); } | |
438 | | realIterParamList { $$ = $1; } | |
439 | ||
440 | realIterParamList | |
441 | : iterParam | |
442 | { $$ = paramNodeList_add (paramNodeList_new (), $1); } | |
443 | | realIterParamList LLT_COMMA iterParam | |
444 | { $$ = paramNodeList_add ($1,$3); } | |
445 | ||
446 | iterParam | |
447 | : LLT_YIELD param { $$ = markYieldParamNode ($2); } | |
448 | | param { $$ = $1; } | |
449 | ||
450 | private | |
451 | : LLT_SPEC { symtable_export (g_symtab, FALSE); } private2 | |
452 | { $$ = $3; symtable_export (g_symtab, TRUE); } | |
453 | ||
454 | private2 | |
455 | : constDeclaration | |
456 | { declarePrivConstant ($1); $$ = interfaceNode_makePrivConst ($1); } | |
457 | | varDeclaration | |
458 | { declarePrivVar ($1); $$ = interfaceNode_makePrivVar ($1); } | |
459 | | type | |
460 | { declarePrivType ($1); $$ = interfaceNode_makePrivType ($1); } | |
461 | | fcn | |
462 | { declarePrivFcn ($1, typeId_invalid); $$ = interfaceNode_makePrivFcn ($1); } | |
463 | ||
464 | constDeclaration | |
465 | : LLT_CONSTANT lclTypeSpec initDecls LLT_SEMI | |
466 | { $$ = makeConstDeclarationNode ($2, $3); } | |
467 | ||
468 | varDeclaration | |
469 | : lclTypeSpec initDecls LLT_SEMI | |
470 | { $$ = makeVarDeclarationNode ($1, $2, FALSE, FALSE); $$->qualifier = QLF_NONE; } | |
471 | | LLT_CONST lclTypeSpec initDecls LLT_SEMI | |
472 | { $$ = makeVarDeclarationNode ($2, $3, FALSE, FALSE); $$->qualifier = QLF_CONST; } | |
473 | | LLT_VOLATILE lclTypeSpec initDecls LLT_SEMI | |
474 | { $$ = makeVarDeclarationNode ($2, $3, FALSE, FALSE); $$->qualifier = QLF_VOLATILE; } | |
475 | ||
476 | type | |
477 | : abstract { $$ = makeAbstractTypeNode ($1); } | |
478 | | exposed { $$ = makeExposedTypeNode ($1); } | |
479 | ||
480 | special | |
481 | : LLT_PRINTFLIKE { $$ = qual_createPrintfLike (); } | |
482 | | LLT_SCANFLIKE { $$ = qual_createScanfLike (); } | |
483 | | LLT_MESSAGELIKE { $$ = qual_createMessageLike (); } | |
484 | ||
485 | fcn | |
486 | : lclTypeSpec declarator globals { enteringFcnScope ($1, $2, $3); } LLT_LBRACE | |
487 | privateInits optLetDecl optChecks optRequire optModify optEnsure optClaim LLT_RBRACE | |
488 | { $$ = makeFcnNode (qual_createUnknown (), $1, $2, $3, $6, $7, | |
489 | $8, $9, $10, $11, $12); | |
490 | /* type, declarator, glovbls, privateinits, | |
491 | lets, checks, requires, modifies, ensures, claims */ | |
492 | symtable_exitScope (g_symtab); | |
493 | } | |
494 | | special lclTypeSpec declarator globals { enteringFcnScope ($2, $3, $4); } | |
495 | LLT_LBRACE | |
496 | privateInits optLetDecl optChecks optRequire optModify optEnsure optClaim | |
497 | LLT_RBRACE | |
498 | { $$ = makeFcnNode ($1, $2, $3, $4, $7, | |
499 | $8, $9, $10, $11, $12, $13); | |
500 | /* type, declarator, glovbls, privateinits, | |
501 | lets, checks, requires, modifies, ensures, claims */ | |
502 | symtable_exitScope (g_symtab); | |
503 | } | |
504 | ||
505 | ||
506 | claim | |
507 | : LLT_CLAIMS claimId LLT_LPAR optParamList LLT_RPAR globals | |
508 | { enteringClaimScope ($4, $6); } | |
509 | LLT_LBRACE optLetDecl optRequire optBody optEnsure LLT_RBRACE | |
510 | { $$ = makeClaimNode ($2, $4, $6, $9, $10, $11, $12); | |
511 | symtable_exitScope (g_symtab); } | |
512 | | LLT_CLAIMS fcnId claimId LLT_SEMI | |
513 | { $$ = (claimNode) 0; } | |
514 | ||
515 | abstract | |
516 | : LLT_MUTABLE {g_inTypeDef = TRUE; } LLT_TYPE LLT_TYPEDEF_NAME {g_inTypeDef = FALSE; } abstBody | |
517 | { $$ = makeAbstractNode ($1, $4, TRUE, FALSE, $6); } | |
518 | | LLT_MUTABLE {g_inTypeDef = TRUE; } LLT_REFCOUNTED LLT_TYPE | |
519 | LLT_TYPEDEF_NAME {g_inTypeDef = FALSE; } abstBody | |
520 | { $$ = makeAbstractNode ($1, $5, TRUE, TRUE, $7); } | |
521 | | LLT_REFCOUNTED LLT_MUTABLE {g_inTypeDef = TRUE; } LLT_TYPE | |
522 | LLT_TYPEDEF_NAME {g_inTypeDef = FALSE; } abstBody | |
523 | { $$ = makeAbstractNode ($2, $5, TRUE, TRUE, $7); } | |
524 | | LLT_IMMUTABLE {g_inTypeDef = TRUE; } LLT_TYPE LLT_TYPEDEF_NAME {g_inTypeDef = FALSE; } abstBody | |
525 | { $$ = makeAbstractNode ($1, $4, FALSE, FALSE, $6); } | |
526 | ||
527 | exposed | |
528 | : LLT_TYPEDEF lclTypeSpec { g_inTypeDef = TRUE; setExposedType ($2); } declaratorInvs | |
529 | { g_inTypeDef = FALSE; } LLT_SEMI | |
530 | { $$ = makeExposedNode ($1, $2, $4); /* to support mutually recursive types */ } | |
531 | | structOrUnionSpec LLT_SEMI | |
532 | { $$ = makeExposedNode ($2, makeLclTypeSpecNodeSU ($1), declaratorInvNodeList_new ()); } | |
533 | | enumSpec LLT_SEMI | |
534 | { $$ = makeExposedNode ($2, makeLclTypeSpecNodeEnum ($1), declaratorInvNodeList_new ()); } | |
535 | ||
536 | /* evs - 26 Feb 1995 (changed to be consistent with C grammar) | |
537 | | STRUCT tagId LLT_SEMI | |
538 | { (void) checkAndEnterTag (TAG_FWDSTRUCT, ltoken_copy ($2)); | |
539 | lhForwardStruct ($2); $$ = (exposedNode)0; | |
540 | } | |
541 | | UNION tagId LLT_SEMI | |
542 | { (void) checkAndEnterTag (TAG_FWDUNION, ltoken_copy ($2)); | |
543 | lhForwardUnion ($2); | |
544 | $$ = (exposedNode)0; | |
545 | } | |
546 | */ | |
547 | ||
548 | importNameList | |
549 | : importName | |
550 | { $$ = importNodeList_add (importNodeList_new (), $1); } | |
551 | | importNameList LLT_COMMA importName | |
552 | { $$ = importNodeList_add ($1, $3); } | |
553 | ||
554 | importName | |
555 | : interfaceName { $$ = importNode_makePlain ($1); } | |
556 | | simpleOp interfaceName simpleOp | |
557 | { checkBrackets ($1, $3); $$ = importNode_makeBracketed ($2); } | |
558 | | LLT_LCSTRING { $$ = importNode_makeQuoted ($1); } | |
559 | ||
560 | interfaceNameList | |
561 | : interfaceName { $$ = ltokenList_singleton ($1); } | |
562 | | interfaceNameList LLT_COMMA interfaceName { $$ = ltokenList_push ($1, $3); } | |
563 | ||
564 | interfaceName | |
565 | : simpleIdOrTypedefName | |
566 | /* to allow module names to be the same as LCL type names */ | |
567 | ||
568 | traitRefNodeList | |
569 | : traitRef | |
570 | { $$ = traitRefNodeList_add (traitRefNodeList_new (), $1); } | |
571 | | traitRefNodeList LLT_COMMA traitRef | |
572 | { $$ = traitRefNodeList_add ($1, $3); } | |
573 | ||
574 | traitRef | |
575 | : traitId | |
576 | { $$ = makeTraitRefNode (ltokenList_singleton ($1), (renamingNode)0); } | |
577 | | traitId LLT_LPAR renaming LLT_RPAR | |
578 | { $$ = makeTraitRefNode (ltokenList_singleton ($1), $3); } | |
579 | | LLT_LPAR traitIdList LLT_RPAR | |
580 | { $$ = makeTraitRefNode ($2, (renamingNode)0); } | |
581 | | LLT_LPAR traitIdList LLT_RPAR LLT_LPAR renaming LLT_RPAR | |
582 | { $$ = makeTraitRefNode ($2, $5); } | |
583 | ||
584 | traitIdList | |
585 | : traitId { $$ = ltokenList_singleton ($1); } | |
586 | | traitIdList LLT_COMMA traitId { $$ = ltokenList_push ($1, $3); } | |
587 | ||
588 | renaming | |
589 | : replaceNodeList | |
590 | { $$ = makeRenamingNode (typeNameNodeList_new (), $1); } | |
591 | | nameList | |
592 | { $$ = makeRenamingNode ($1, replaceNodeList_new ()); } | |
593 | | nameList LLT_COMMA replaceNodeList { $$ = makeRenamingNode ($1, $3); } | |
594 | ||
595 | nameList | |
596 | : typeName | |
597 | { $$ = typeNameNodeList_add (typeNameNodeList_new (), $1); } | |
598 | | nameList LLT_COMMA typeName { $$ = typeNameNodeList_add ($1, $3); } | |
599 | ||
600 | replaceNodeList | |
601 | : replace | |
602 | { $$ = replaceNodeList_add (replaceNodeList_new (), $1); } | |
603 | | replaceNodeList LLT_COMMA replace { $$ = replaceNodeList_add ($1, $3); } | |
604 | ||
605 | replace | |
606 | : typeName LLT_FOR CType { $$ = makeReplaceNode ($2, $1, TRUE, $3, NULL, NULL); } | |
607 | | typeName LLT_FOR name { $$ = makeReplaceNameNode ($2, $1, $3); } | |
608 | | typeName LLT_FOR name signature { $$ = makeReplaceNode ($2, $1, FALSE, ltoken_undefined, | |
609 | $3, $4); } | |
610 | ||
611 | name | |
612 | : opId { $$ = makeNameNodeId ($1); } | |
613 | | opForm { $$ = makeNameNodeForm ($1); } | |
614 | ||
615 | initializer : constLclExpr | |
616 | ||
617 | constLclExpr : term | |
618 | ||
619 | initDecls | |
620 | : initDecl | |
621 | { $$ = initDeclNodeList_add (initDeclNodeList_new (), $1); } | |
622 | | initDecls LLT_COMMA initDecl | |
623 | { $$ = initDeclNodeList_add ($1, $3); } | |
624 | ||
625 | initDecl | |
626 | : declarator { $$ = makeInitDeclNode ($1, (termNode)0); } | |
627 | | declarator LLT_EQUALS initializer { $$ = makeInitDeclNode ($1, $3); } | |
628 | ||
629 | globals | |
630 | : /* empty */ /* has the same structure */ | |
631 | { $$ = varDeclarationNodeList_new (); } | |
632 | | globals globalDecl | |
633 | { varDeclarationNodeList_addh ($1, $2); $$ = $1; } | |
634 | ||
635 | globalDecl | |
636 | : lclTypeSpec initDecls LLT_SEMI { $$ = makeVarDeclarationNode ($1, $2, TRUE, FALSE); } | |
637 | | LLT_INTERNAL LLT_SEMI { $$ = makeInternalStateNode (); } | |
638 | | LLT_FILESYS LLT_SEMI { $$ = makeFileSystemNode (); } | |
639 | ||
640 | privateInits | |
641 | : /* empty */ { $$ = varDeclarationNodeList_new (); } | |
642 | | privateInits privateInit { varDeclarationNodeList_addh ($1, $2); $$ = $1; } | |
643 | ||
644 | privateInit | |
645 | : LLT_PRIVATE lclTypeSpec initDecls LLT_SEMI | |
646 | { $$ = makeVarDeclarationNode ($2, $3, FALSE, TRUE); } | |
647 | ||
648 | optLetDecl | |
649 | : /* empty */ { $$ = letDeclNodeList_new (); } | |
650 | | LLT_LET beDeclList LLT_SEMI { $$ = $2; } | |
651 | ||
652 | beDeclList | |
653 | : beDecl { $$ = letDeclNodeList_add (letDeclNodeList_new (), $1); } | |
654 | | beDeclList LLT_COMMA beDecl { $$ = letDeclNodeList_add ($1, $3); } | |
655 | ||
656 | beDecl | |
657 | : varId LLT_COLON sortSpec LLT_BE term { $$ = makeLetDeclNode ($1, $3, $5); } | |
658 | | varId LLT_BE term { $$ = makeLetDeclNode ($1, (lclTypeSpecNode)0, $3); } | |
659 | ||
660 | sortSpec : lclTypeSpec | |
661 | ||
662 | optChecks | |
663 | : /* empty */ { $$ = (lclPredicateNode)0; } | |
664 | | LLT_CHECKS lclPredicate LLT_SEMI { checkLclPredicate ($1, $2); $$ = makeChecksNode ($1, $2); } | |
665 | ||
666 | optRequire | |
667 | : /* empty */ { $$ = (lclPredicateNode)0; } | |
668 | | LLT_REQUIRES lclPredicate LLT_SEMI { checkLclPredicate ($1, $2); $$ = makeRequiresNode ($1, $2);} | |
669 | ||
670 | optModify | |
671 | : /* empty */ { $$ = (modifyNode)0; } | |
672 | | LLT_MODIFIES LLT_NOTHING LLT_SEMI { $$ = makeModifyNodeSpecial ($1, TRUE); } | |
673 | | LLT_MODIFIES LLT_ANYTHING LLT_SEMI { $$ = makeModifyNodeSpecial ($1, FALSE); } | |
674 | | LLT_MODIFIES storeRefList LLT_SEMI { $$ = makeModifyNodeRef ($1, $2); } | |
675 | ||
676 | storeRefList | |
677 | : storeRef { $$ = storeRefNodeList_add (storeRefNodeList_new (), $1); } | |
678 | | storeRefList LLT_COMMA storeRef { $$ = storeRefNodeList_add ($1, $3); } | |
679 | ||
680 | storeRef | |
681 | : term { $$ = makeStoreRefNodeTerm ($1); } | |
682 | | lclType { $$ = makeStoreRefNodeType ($1, FALSE); } | |
683 | | LLT_OBJ lclType { $$ = makeStoreRefNodeType ($2, TRUE); } | |
684 | | LLT_INTERNAL { $$ = makeStoreRefNodeInternal (); } | |
685 | | LLT_FILESYS { $$ = makeStoreRefNodeSystem (); } | |
686 | ||
687 | optEnsure | |
688 | : /* empty */ { $$ = (lclPredicateNode)0; } | |
689 | | LLT_ENSURES lclPredicate LLT_SEMI { checkLclPredicate ($1, $2); $$ = makeEnsuresNode ($1, $2);} | |
690 | ||
691 | optClaim | |
692 | : /* empty */ { $$ = (lclPredicateNode)0; } | |
693 | | LLT_CLAIMS lclPredicate LLT_SEMI { checkLclPredicate ($1, $2); $$ = makeIntraClaimNode ($1, $2);} | |
694 | ||
695 | optParamList | |
696 | : /* empty */ { $$ = paramNodeList_new (); } | |
697 | | realParamList { $$ = $1; } | |
698 | ||
699 | realParamList | |
700 | : paramList | |
701 | | LLT_TELIPSIS { $$ = paramNodeList_add (paramNodeList_new (), paramNode_elipsis ()); } | |
702 | | paramList LLT_COMMA LLT_TELIPSIS { $$ = paramNodeList_add ($1, paramNode_elipsis ()); } | |
703 | ||
704 | paramList | |
705 | : param { $$ = paramNodeList_single ($1); } | |
706 | | paramList LLT_COMMA param { $$ = paramNodeList_add ($1, $3); } | |
707 | ||
708 | optBody | |
709 | : /* empty */ { $$ = (programNode)0; } | |
710 | | LLT_BODY LLT_LBRACE callExpr LLT_RBRACE { $$ = $3; } | |
711 | | LLT_BODY LLT_LBRACE callExpr LLT_SEMI LLT_RBRACE { $$ = $3; } | |
712 | ||
713 | callExpr | |
714 | : stmt { $$ = makeProgramNode ($1); } | |
715 | | LLT_LPAR callExpr LLT_RPAR | |
716 | /* may need to make a copy of $2 */ | |
717 | { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
718 | | callExpr LLT_MULOP %prec ITERATION_OP | |
719 | { programNodeList x = programNodeList_new (); | |
720 | programNodeList_addh (x, $1); | |
721 | $$ = makeProgramNodeAction (x, ACT_ITER); | |
722 | } | |
723 | | callExpr LLT_VERTICALBAR callExpr | |
724 | { programNodeList x = programNodeList_new (); | |
725 | programNodeList_addh (x, $1); | |
726 | programNodeList_addh (x, $3); | |
727 | $$ = makeProgramNodeAction (x, ACT_ALTERNATE); | |
728 | } | |
729 | | callExpr LLT_SEMI callExpr | |
730 | { programNodeList x = programNodeList_new (); | |
731 | programNodeList_addh (x, $1); | |
732 | programNodeList_addh (x, $3); | |
733 | $$ = makeProgramNodeAction (x, ACT_SEQUENCE); | |
734 | } | |
735 | ||
736 | stmt | |
737 | : fcnId LLT_LPAR valueList LLT_RPAR | |
738 | { $$ = makeStmtNode (ltoken_undefined, $1, $3); } | |
739 | | fcnId LLT_LPAR LLT_RPAR | |
740 | { $$ = makeStmtNode (ltoken_undefined, $1, termNodeList_new ()); } | |
741 | | varId LLT_EQUALS fcnId LLT_LPAR LLT_RPAR | |
742 | { $$ = makeStmtNode ($1, $3, termNodeList_new ()); } | |
743 | | varId LLT_EQUALS fcnId LLT_LPAR valueList LLT_RPAR | |
744 | { $$ = makeStmtNode ($1, $3, $5); } | |
745 | ||
746 | valueList | |
747 | : value { $$ = termNodeList_push (termNodeList_new (), $1); } | |
748 | | valueList LLT_COMMA value { $$ = termNodeList_push ($1, $3); } | |
749 | ||
750 | value | |
751 | : cLiteral | |
752 | | varId { $$ = makeSimpleTermNode ($1); } | |
753 | | simpleOp value %prec PREFIX_OP { $$ = makePrefixTermNode ($1, $2); } | |
754 | | value simpleOp %prec POSTFIX_OP { $$ = makePostfixTermNode2 ($1, $2); } | |
755 | | value simpleOp value /* infix */ { $$ = makeInfixTermNode ($1, $2, $3); } | |
756 | | LLT_LPAR value LLT_RPAR { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
757 | | fcnId LLT_LPAR LLT_RPAR | |
758 | { $$ = makeOpCallTermNode ($1, $2, termNodeList_new (), $3); } | |
759 | | fcnId LLT_LPAR valueList LLT_RPAR | |
760 | { $$ = makeOpCallTermNode ($1, $2, $3, $4); } | |
761 | ||
762 | abstBody | |
763 | : LLT_SEMI { $$ = (abstBodyNode)0; } | |
764 | | LLT_LBRACE fcns LLT_RBRACE { $$ = makeAbstBodyNode ($1, $2); } | |
765 | | LLT_LBRACE interfaceNameList LLT_RBRACE LLT_SEMI { $$ = makeAbstBodyNode2 ($1, $2); } | |
766 | | LLT_LBRACE LLT_RBRACE LLT_SEMI { $$ = (abstBodyNode)0; } | |
767 | ||
768 | fcns | |
769 | : /* empty */ { $$ = fcnNodeList_new (); } | |
770 | | fcns fcn { $$ = fcnNodeList_add ($1, $2); } | |
771 | ||
772 | optTypeInv | |
773 | : /* empty */ { $$ = (lclPredicateNode)0; } | |
774 | | typeInv | |
775 | ||
776 | typeInv | |
777 | : LLT_CONSTRAINT { g_inTypeDef = FALSE; } quantifier LLT_LPAR lclPredicate LLT_RPAR | |
778 | { $5->tok = $1; $5->kind = LPD_CONSTRAINT; | |
779 | checkLclPredicate ($1, $5); | |
780 | $$ = $5; | |
781 | symtable_exitScope (g_symtab); | |
782 | g_inTypeDef = TRUE; | |
783 | } | |
784 | ||
785 | declaratorInvs | |
786 | : declaratorInv { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (), $1); } | |
787 | | declaratorInvs LLT_COMMA declaratorInv | |
788 | { $$ = declaratorInvNodeList_add ($1, $3); } | |
789 | ||
790 | declaratorInv | |
791 | : declarator { declareForwardType ($1); } optExposedBody | |
792 | { $$ = makeDeclaratorInvNode ($1, $3); } | |
793 | ||
794 | optExposedBody | |
795 | : /* empty */ { $$ = (abstBodyNode)0; } | |
796 | | LLT_LBRACE optTypeInv LLT_RBRACE { $$ = makeExposedBodyNode ($1, $2); } | |
797 | ||
798 | CType | |
799 | : LLT_VOID { $$ = $1; ltoken_setIntField ($$, fixBits (TS_VOID, 0)); } | |
800 | | LLT_CHAR { $$ = $1; ltoken_setIntField ($$, fixBits (TS_CHAR, 0)); } | |
801 | | LLT_DOUBLE { $$ = $1; ltoken_setIntField ($$, fixBits (TS_DOUBLE, 0)); } | |
802 | | LLT_FLOAT { $$ = $1; ltoken_setIntField ($$, fixBits (TS_FLOAT, 0)); } | |
803 | | LLT_INT { $$ = $1; ltoken_setIntField ($$, fixBits (TS_INT, 0)); } | |
804 | | LLT_LONG { $$ = $1; ltoken_setIntField ($$, fixBits (TS_LONG, 0)); } | |
805 | | LLT_SHORT { $$ = $1; ltoken_setIntField ($$, fixBits (TS_SHORT, 0)); } | |
806 | | LLT_SIGNED { $$ = $1; ltoken_setIntField ($$, fixBits (TS_SIGNED, 0)); } | |
807 | | LLT_UNSIGNED { $$ = $1; ltoken_setIntField ($$, fixBits (TS_UNSIGNED, 0)); } | |
808 | | LLT_UNKNOWN { $$ = $1; ltoken_setIntField ($$, fixBits (TS_UNKNOWN, 0)); } | |
809 | ||
810 | /* | |
811 | ** CTypes allow "unsigned short int" but we drop all C type qualifiers | |
812 | ** and storage class except TYPEDEF | |
813 | */ | |
814 | ||
815 | CTypes | |
816 | : CType { $$ = makeCTypesNode ((CTypesNode)0, $1); } | |
817 | | CTypes CType { $$ = makeCTypesNode ($1, $2); } | |
818 | ||
819 | /* Add abstract type names and typedef names */ | |
820 | ||
821 | typeSpecifier | |
822 | : LLT_TYPEDEF_NAME | |
823 | { $$ = makeTypeSpecifier ($1); } | |
824 | | CTypes | |
825 | { $$ = $1; $$->sort = sort_lookupName (lclctype_toSort ($1->intfield)); } | |
826 | ||
827 | /* Add struct and enum types */ | |
828 | ||
829 | specialQualifier | |
830 | : LLT_OUT { $$ = qual_createOut (); } | |
831 | | LLT_UNUSED { $$ = qual_createUnused (); } | |
832 | | LLT_SEF { $$ = qual_createSef (); } | |
833 | | LLT_ONLY { $$ = qual_createOnly (); } | |
834 | | LLT_OWNED { $$ = qual_createOwned (); } | |
835 | | LLT_DEPENDENT { $$ = qual_createDependent (); } | |
836 | | LLT_KEEP { $$ = qual_createKeep (); } | |
837 | | LLT_KEPT { $$ = qual_createKept (); } | |
838 | | LLT_OBSERVER { $$ = qual_createObserver (); } | |
839 | | LLT_EXITS { $$ = qual_createExits (); } | |
840 | | LLT_MAYEXIT { $$ = qual_createMayExit (); } | |
841 | | LLT_TRUEEXIT { $$ = qual_createTrueExit (); } | |
842 | | LLT_FALSEEXIT { $$ = qual_createFalseExit (); } | |
843 | | LLT_NEVEREXIT { $$ = qual_createNeverExit (); } | |
844 | | LLT_TEMP { $$ = qual_createOnly (); } | |
845 | | LLT_SHARED { $$ = qual_createShared (); } | |
846 | | LLT_UNIQUE { $$ = qual_createUnique (); } | |
847 | | LLT_CHECKED { $$ = qual_createChecked (); } | |
848 | | LLT_UNCHECKED { $$ = qual_createUnchecked (); } | |
849 | | LLT_CHECKEDSTRICT { $$ = qual_createCheckedStrict (); } | |
850 | | LLT_TRUENULL { $$ = qual_createTrueNull (); } | |
851 | | LLT_FALSENULL { $$ = qual_createFalseNull (); } | |
852 | | LLT_RELNULL { $$ = qual_createRelNull (); } | |
853 | | LLT_RELDEF { $$ = qual_createRelDef (); } | |
854 | | LLT_REFCOUNTED{ $$ = qual_createRefCounted (); } | |
855 | | LLT_REFS { $$ = qual_createRefs (); } | |
856 | | LLT_NEWREF { $$ = qual_createNewRef (); } | |
857 | | LLT_KILLREF { $$ = qual_createKillRef (); } | |
858 | | LLT_LNULL { $$ = qual_createNull (); } | |
859 | | LLT_LNOTNULL { $$ = qual_createNotNull (); } | |
860 | | LLT_RETURNED { $$ = qual_createReturned (); } | |
861 | | LLT_EXPOSED { $$ = qual_createExposed (); } | |
862 | | LLT_PARTIAL { $$ = qual_createPartial (); } | |
1ac6313d | 863 | | LLT_NULLTERMINATED { $$ = qual_createNullTerminated () ; } |
885824d3 | 864 | | LLT_UNDEF { $$ = qual_createUndef (); } |
865 | | LLT_KILLED { $$ = qual_createKilled (); } | |
866 | ||
867 | lclTypeSpec | |
868 | : typeSpecifier | |
869 | { $$ = makeLclTypeSpecNodeType ($1); } /* does not process CONST at all */ | |
870 | | structOrUnionSpec | |
871 | { $$ = makeLclTypeSpecNodeSU ($1); } | |
872 | | enumSpec | |
873 | { $$ = makeLclTypeSpecNodeEnum ($1); } | |
874 | | specialQualifier lclTypeSpec | |
875 | { $$ = lclTypeSpecNode_addQual ($2, $1); } | |
876 | | LLT_VERTICALBAR lclType LLT_COLON lclType LLT_VERTICALBAR | |
877 | { $$ = makeLclTypeSpecNodeConj ($2, $4); } | |
878 | ||
879 | /* | |
880 | ** Add pointers to the right, only used in StoreRef, maybe should throw | |
881 | ** out and replace its use in StoreRef by CTypeName | |
882 | */ | |
883 | ||
884 | lclType | |
885 | : lclTypeSpec | |
886 | | lclTypeSpec pointers | |
887 | { llassert (lclTypeSpecNode_isDefined ($1)); | |
888 | $1->pointers = $2; $$ = $1; } | |
889 | ||
890 | pointers | |
891 | : LLT_MULOP { $$ = 1; } | |
892 | | pointers LLT_MULOP { $$ = $1 + 1; } | |
893 | ||
894 | structOrUnionSpec | |
895 | : LLT_STRUCT optTagId | |
896 | { (void) checkAndEnterTag (TAG_FWDSTRUCT, ltoken_copy ($2)); } | |
897 | LLT_LBRACE structDecls LLT_RBRACE | |
898 | { $$ = makestrOrUnionNode ($1, SU_STRUCT, $2, $5); } | |
899 | | LLT_UNION optTagId | |
900 | { (void) checkAndEnterTag (TAG_FWDUNION, ltoken_copy ($2)); } | |
901 | LLT_LBRACE structDecls LLT_RBRACE | |
902 | { $$ = makestrOrUnionNode ($1, SU_UNION, $2, $5); } | |
903 | | LLT_STRUCT tagId | |
904 | { $$ = makeForwardstrOrUnionNode ($1, SU_STRUCT, $2); } | |
905 | | LLT_UNION tagId | |
906 | { $$ = makeForwardstrOrUnionNode ($1, SU_UNION, $2); } | |
907 | ||
908 | optTagId | |
909 | : /* empty */ { $$ = ltoken_undefined; } | |
910 | | tagId | |
911 | ||
912 | structDecls | |
913 | : structDecl { $$ = stDeclNodeList_add (stDeclNodeList_new (), $1); } | |
914 | | structDecls structDecl { $$ = stDeclNodeList_add ($1, $2); } | |
915 | ||
916 | /* We don't allow specification of field size */ | |
917 | ||
918 | structDecl | |
919 | : lclTypeSpec declaratorList LLT_SEMI { $$ = makestDeclNode ($1, $2); } | |
920 | ||
921 | declaratorList | |
922 | : declarator | |
923 | { $$ = declaratorNodeList_add (declaratorNodeList_new (), $1); } | |
924 | | declaratorList LLT_COMMA declarator | |
925 | { $$ = declaratorNodeList_add ($1, $3); } | |
926 | ||
927 | optCOMMA | |
928 | : /* empty */ { ; } | |
929 | | LLT_COMMA { ; } | |
930 | ||
931 | enumSpec | |
932 | : LLT_ENUM optTagId LLT_LBRACE enumeratorList optCOMMA LLT_RBRACE | |
933 | { $$ = makeEnumSpecNode ($1, $2, $4); } | |
934 | | LLT_ENUM tagId | |
935 | { $$ = makeEnumSpecNode2 ($1, $2); } | |
936 | ||
937 | enumeratorList | |
938 | : simpleId { $$ = ltokenList_singleton ($1); } | |
939 | | enumeratorList LLT_COMMA simpleId { $$ = ltokenList_push ($1, $3); } | |
940 | ||
941 | /* This part of declarator rules is adapted from GCC (2.2.1)'s C grammar */ | |
942 | ||
943 | /* An after_type_decl is a declarator that is allowed only after an explicit | |
944 | typeSpecifier, an id can be typedef'd here. | |
945 | A notype_decl is a declarator that may not have seen a typeSpecifier | |
946 | preceding it; it cannot typedef'd an id. */ | |
947 | ||
948 | declarator | |
949 | : after_type_decl { $$ = makeDeclaratorNode ($1); } | |
950 | | notype_decl { $$ = makeDeclaratorNode ($1); } | |
951 | ||
952 | notype_decl | |
953 | : varId { $$ = makeTypeExpr ($1); } | |
954 | | LLT_LPAR notype_decl LLT_RPAR { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
955 | | LLT_MULOP notype_decl { $$ = makePointerNode ($1, $2); } | |
956 | | notype_decl arrayQual { $$ = makeArrayNode ($1, $2); } | |
957 | | notype_decl LLT_LPAR LLT_RPAR { $$ = makeFunctionNode ($1, paramNodeList_new ()); } | |
958 | | notype_decl LLT_LPAR realParamList LLT_RPAR { $$ = makeFunctionNode ($1, $3); } | |
959 | ||
960 | after_type_decl | |
961 | : LLT_TYPEDEF_NAME { $$ = makeTypeExpr ($1); } | |
962 | | LLT_LPAR after_type_decl LLT_RPAR { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
963 | | LLT_MULOP after_type_decl { $$ = makePointerNode ($1, $2); } | |
964 | | after_type_decl arrayQual { $$ = makeArrayNode ($1, $2); } | |
965 | | after_type_decl LLT_LPAR LLT_RPAR { $$ = makeFunctionNode ($1, paramNodeList_new ()); } | |
966 | | after_type_decl LLT_LPAR realParamList LLT_RPAR { $$ = makeFunctionNode ($1, $3); } | |
967 | ||
968 | /* A parameter_decl is a decl that can appear in a parameter list. | |
969 | We disallow the old C way of giving only the id names without types. | |
970 | A parameter_decl is like an after_type_decl except that it does not | |
971 | allow a TYPEDEF_NAME to appear in parens. It will conflict with a | |
972 | a function with that typedef as an argument */ | |
973 | ||
974 | parameter_decl | |
975 | : LLT_TYPEDEF_NAME { $$ = makeTypeExpr ($1); } | |
976 | | LLT_MULOP parameter_decl /* %prec UNARY */ { $$ = makePointerNode ($1, $2); } | |
977 | | parameter_decl arrayQual { $$ = makeArrayNode ($1, $2); } | |
978 | | parameter_decl LLT_LPAR LLT_RPAR { $$ = makeFunctionNode ($1, paramNodeList_new ()); } | |
979 | | parameter_decl LLT_LPAR realParamList LLT_RPAR { $$ = makeFunctionNode ($1, $3); } | |
980 | ||
981 | /* param : the last production allows C types to be generated without the | |
982 | parameter name */ | |
983 | ||
984 | param | |
985 | : lclTypeSpec parameter_decl { $$ = makeParamNode ($1, $2); } | |
986 | | lclTypeSpec notype_decl { $$ = makeParamNode ($1, $2); } | |
987 | | lclTypeSpec optAbstDeclarator { $$ = makeParamNode ($1, $2); } | |
988 | /* | |
989 | ** | OUT lclTypeSpec parameter_decl { $$ = makeOutParamNode ($1, $2, $3); } | |
990 | ** | OUT lclTypeSpec notype_decl { $$ = makeOutParamNode ($1, $2, $3); } | |
991 | ** | OUT lclTypeSpec optAbstDeclarator { $$ = makeOutParamNode ($1, $2, $3); } | |
992 | */ | |
993 | ||
994 | /* typeName is only used in trait parameter renaming */ | |
995 | ||
996 | typeName | |
997 | : lclTypeSpec optAbstDeclarator { $$ = makeTypeNameNode (FALSE, $1, $2); } | |
998 | | LLT_OBJ lclTypeSpec optAbstDeclarator { $$ = makeTypeNameNode (TRUE, $2, $3); } | |
999 | | opForm { $$ = makeTypeNameNodeOp ($1); } | |
1000 | ||
1001 | /* Abstract declarator is like a declarator, but with no identifier */ | |
1002 | ||
1003 | optAbstDeclarator | |
1004 | : /* empty */ { $$ = (abstDeclaratorNode)0; } | |
1005 | | abstDeclarator { $$ = (abstDeclaratorNode)$1; } | |
1006 | ||
1007 | abstDeclarator | |
1008 | : LLT_LPAR abstDeclarator LLT_RPAR { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
1009 | | LLT_MULOP abstDeclarator { $$ = makePointerNode ($1, $2); } | |
1010 | | LLT_MULOP { $$ = makePointerNode ($1, (typeExpr)0); } | |
1011 | | arrayQual { $$ = makeArrayNode ((typeExpr)0, $1); } | |
1012 | | abstDeclarator arrayQual { $$ = makeArrayNode ($1, $2); } | |
1013 | | abstDeclarator LLT_LPAR LLT_RPAR { $$ = makeFunctionNode ($1, paramNodeList_new ()); } | |
1014 | | LLT_LPAR realParamList LLT_RPAR { $$ = makeFunctionNode ((typeExpr)0, $2); } | |
1015 | | abstDeclarator LLT_LPAR realParamList LLT_RPAR { $$ = makeFunctionNode ($1, $3); } | |
1016 | ||
1017 | arrayQual | |
1018 | : LLT_LBRACKET LLT_RBRACKET { $$ = makeArrayQualNode ($1, (termNode)0); } | |
1019 | | LLT_LBRACKET constLclExpr LLT_RBRACKET { $$ = makeArrayQualNode ($1, $2); } | |
1020 | ||
1021 | opForm | |
1022 | : LLT_IF markerSym LLT_THEN markerSym LLT_ELSE markerSym | |
1023 | { $$ = makeOpFormNode ($1, OPF_IF, opFormUnion_createMiddle (0), ltoken_undefined); } | |
1024 | | anyOp | |
1025 | { $$ = makeOpFormNode ($1, OPF_ANYOP, opFormUnion_createAnyOp ($1), ltoken_undefined); } | |
1026 | | markerSym anyOp | |
1027 | { $$ = makeOpFormNode ($1, OPF_MANYOP, opFormUnion_createAnyOp ($2), ltoken_undefined); } | |
1028 | | anyOp markerSym | |
1029 | { $$ = makeOpFormNode ($1, OPF_ANYOPM, opFormUnion_createAnyOp ($1), ltoken_undefined); } | |
1030 | | markerSym anyOp markerSym | |
1031 | { $$ = makeOpFormNode ($1, OPF_MANYOPM, | |
1032 | opFormUnion_createAnyOp ($2), ltoken_undefined); } | |
1033 | | open middle close | |
1034 | { $$ = makeOpFormNode ($1, OPF_MIDDLE, opFormUnion_createMiddle ($2), $3); } | |
1035 | | markerSym open middle close | |
1036 | { $$ = makeOpFormNode ($1, OPF_MMIDDLE, opFormUnion_createMiddle ($3), $4); } | |
1037 | | open middle close markerSym | |
1038 | { $$ = makeOpFormNode ($1, OPF_MIDDLEM, opFormUnion_createMiddle ($2), $3); } | |
1039 | | markerSym open middle close markerSym | |
1040 | { $$ = makeOpFormNode ($2, OPF_MMIDDLEM, opFormUnion_createMiddle ($3), $4); } | |
1041 | | LLT_LBRACKET middle LLT_RBRACKET | |
1042 | { $$ = makeOpFormNode ($1, OPF_BMIDDLE, opFormUnion_createMiddle ($2), $3); } | |
1043 | | LLT_LBRACKET middle LLT_RBRACKET markerSym | |
1044 | { $$ = makeOpFormNode ($1, OPF_BMIDDLEM, opFormUnion_createMiddle ($2), $3); } | |
1045 | ||
1046 | /* added the next 6 productions (wrt old checker) to complete LSL grammar | |
1047 | ** LSL treats '[' and '{' as openSym but LCL treats them as LLT_LBRACKET and | |
1048 | ** LLT_LBRACE, and hence the need for these separate productions | |
1049 | */ | |
1050 | ||
1051 | | markerSym LLT_LBRACKET middle LLT_RBRACKET | |
1052 | { $$ = makeOpFormNode ($2, OPF_BMMIDDLE, opFormUnion_createMiddle ($3), $4); } | |
1053 | | markerSym LLT_LBRACKET middle LLT_RBRACKET markerSym | |
1054 | { $$ = makeOpFormNode ($2, OPF_BMMIDDLEM, opFormUnion_createMiddle ($3), $4); } | |
1055 | | selectSym simpleIdOrTypedefName | |
1056 | { $$ = makeOpFormNode ($1, OPF_SELECT, | |
1057 | opFormUnion_createAnyOp ($2), ltoken_undefined); } | |
1058 | | mapSym simpleIdOrTypedefName | |
1059 | { $$ = makeOpFormNode ($1, OPF_MAP, | |
1060 | opFormUnion_createAnyOp ($2), ltoken_undefined); } | |
1061 | | markerSym selectSym simpleIdOrTypedefName | |
1062 | { $$ = makeOpFormNode ($1, OPF_MSELECT, | |
1063 | opFormUnion_createAnyOp ($3), ltoken_undefined); } | |
1064 | | markerSym mapSym simpleIdOrTypedefName | |
1065 | { $$ = makeOpFormNode ($1, OPF_MMAP, | |
1066 | opFormUnion_createAnyOp ($3), ltoken_undefined); } | |
1067 | ||
1068 | open | |
1069 | : openSym | |
1070 | | LLT_LBRACE | |
1071 | ||
1072 | close | |
1073 | : closeSym | |
1074 | | LLT_RBRACE | |
1075 | ||
1076 | anyOp | |
1077 | : simpleOp2 | |
1078 | | logicalOp | |
1079 | | eqOp | |
1080 | ||
1081 | middle | |
1082 | : /* empty */ { $$ = 0; } | |
1083 | | placeList | |
1084 | ||
1085 | placeList | |
1086 | : markerSym { $$ = 1; } | |
1087 | | placeList separator markerSym { $$ = $1 + 1; } | |
1088 | ||
1089 | separator | |
1090 | : LLT_COMMA | |
1091 | | sepSym | |
1092 | ||
1093 | signature | |
1094 | : LLT_COLON domain mapSym sortId { $$ = makesigNode ($1, $2, $4); } | |
1095 | ||
1096 | domain | |
1097 | : /* empty */ { $$ = ltokenList_new (); } | |
1098 | | sortList | |
1099 | ||
1100 | sortList | |
1101 | : sortId { $$ = ltokenList_singleton ($1); } | |
1102 | | sortList LLT_COMMA sortId { $$ = ltokenList_push ($1, $3); } | |
1103 | ||
1104 | lclPredicate | |
1105 | : term { $$ = makeLclPredicateNode (ltoken_undefined, $1, LPD_PLAIN);} | |
1106 | ||
1107 | term | |
1108 | : term0 { $$ = checkSort ($1); } | |
1109 | ||
1110 | /* When "if <term> then <term> else <term> . <logicalOp> <term>" | |
1111 | shift instead of reduce */ | |
1112 | ||
1113 | term0 | |
1114 | : LLT_IF term0 LLT_THEN term0 LLT_ELSE term0 %prec LLT_IF_THEN_ELSE | |
1115 | { $$ = makeIfTermNode ($1,$2,$3,$4,$5,$6); } | |
1116 | | equalityTerm | |
1117 | | term0 logicalOp term0 { $$ = makeInfixTermNode ($1, $2, $3); } | |
1118 | ||
1119 | equalityTerm | |
1120 | : simpleOpTerm /* was | quantifiers LLT_LPAR term LLT_RPAR */ | |
1121 | | quantifiers LLT_LPAR lclPredicate LLT_RPAR | |
1122 | /* temp fix, should change interface in future, add lclPredicateKind too */ | |
1123 | { checkLclPredicate ($2, $3); $$ = makeQuantifiedTermNode ($1, $2, $3->predicate, $4); | |
1124 | symtable_exitScope (g_symtab); | |
1125 | } | |
1126 | | simpleOpTerm eqOp simpleOpTerm | |
1127 | { $$ = makeInfixTermNode ($1, $2, $3);} | |
1128 | | simpleOpTerm LLT_EQUALS simpleOpTerm | |
1129 | { $$ = makeInfixTermNode ($1, $2, $3);} | |
1130 | ||
1131 | simpleOpTerm | |
1132 | : prefixOpTerm | |
1133 | | secondary postfixOps { $$ = makePostfixTermNode ($1, $2); } | |
1134 | | secondary infixOpPart { $$ = CollapseInfixTermNode ($1, $2); } | |
1135 | ||
1136 | simpleOp2 | |
1137 | : simpleOp | |
1138 | | LLT_MULOP | |
1139 | ||
1140 | prefixOpTerm | |
1141 | : secondary | |
1142 | | simpleOp2 prefixOpTerm { $$ = makePrefixTermNode ($1, $2); } | |
1143 | ||
1144 | postfixOps | |
1145 | : simpleOp2 { $$ = ltokenList_singleton ($1); } | |
1146 | | postfixOps simpleOp2 { $$ = ltokenList_push ($1, $2); } | |
1147 | ||
1148 | infixOpPart | |
1149 | : simpleOp2 secondary { $$ = pushInfixOpPartNode (termNodeList_new (), $1, $2); } | |
1150 | | infixOpPart simpleOp2 secondary { $$ = pushInfixOpPartNode ($1, $2, $3); } | |
1151 | ||
1152 | secondary | |
1153 | : primary | |
1154 | | bracketed { $$ = computePossibleSorts ($1); } | |
1155 | | bracketed primary { $$ = updateMatchedNode ((termNode)0, $1, $2); } | |
1156 | | primary bracketed { $$ = updateMatchedNode ($1, $2, (termNode)0); } | |
1157 | | primary bracketed primary { $$ = updateMatchedNode ($1, $2, $3); } | |
1158 | | sqBracketed { $$ = computePossibleSorts ($1); } | |
1159 | | sqBracketed primary { $$ = updateSqBracketedNode ((termNode)0, $1, $2); } | |
1160 | ||
1161 | bracketed | |
1162 | : matched LLT_COLON sortId { $$ = $1; $$->sort = sort_lookupName (ltoken_getText ($3)); } | |
1163 | | matched | |
1164 | ||
1165 | sqBracketed | |
1166 | : LLT_LBRACKET args LLT_RBRACKET LLT_COLON sortId | |
1167 | { $$ = makeSqBracketedNode ($1, $2, $3); | |
1168 | $$->given = sort_lookupName (ltoken_getText ($5)); } | |
1169 | | LLT_LBRACKET args LLT_RBRACKET | |
1170 | { $$ = makeSqBracketedNode ($1, $2, $3); } | |
1171 | | LLT_LBRACKET LLT_RBRACKET LLT_COLON sortId | |
1172 | { $$ = makeSqBracketedNode ($1, termNodeList_new (), $2); | |
1173 | $$->given = sort_lookupName (ltoken_getText ($4)); | |
1174 | } | |
1175 | | LLT_LBRACKET LLT_RBRACKET | |
1176 | { $$ = makeSqBracketedNode ($1, termNodeList_new (), $2); } | |
1177 | ||
1178 | matched | |
1179 | : open args close { $$ = makeMatchedNode ($1, $2, $3); } | |
1180 | | open close { $$ = makeMatchedNode ($1, termNodeList_new (), $2); } | |
1181 | ||
1182 | args | |
1183 | : term { $$ = termNodeList_push (termNodeList_new (), $1); } | |
1184 | | args separator term { $$ = termNodeList_push ($1, $3); } | |
1185 | ||
1186 | primary | |
1187 | : LLT_LPAR term0 LLT_RPAR /* may need to make a copy of $2 */ | |
1188 | { $$ = $2; $$->wrapped = $$->wrapped + 1; } | |
1189 | | varId | |
1190 | { $$ = makeSimpleTermNode ($1); } | |
1191 | | opId LLT_LPAR termList LLT_RPAR | |
1192 | { $$ = makeOpCallTermNode ($1, $2, $3, $4); } | |
1193 | | lclPrimary | |
1194 | | primary stateFcn | |
1195 | { $$ = makePostfixTermNode2 ($1, $2); } | |
1196 | | primary selectSym simpleIdOrTypedefName | |
1197 | { ltoken_markOwned ($3); $$ = makeSelectTermNode ($1, $2, $3); } | |
1198 | | primary mapSym simpleIdOrTypedefName | |
1199 | { ltoken_markOwned ($3); $$ = makeMapTermNode ($1, $2, $3); } | |
1200 | | primary LLT_LBRACKET LLT_RBRACKET | |
1201 | { $$ = updateSqBracketedNode ($1, makeSqBracketedNode ($2, termNodeList_new (), $3), | |
1202 | (termNode)0); } | |
1203 | | primary LLT_LBRACKET termList LLT_RBRACKET | |
1204 | { $$ = updateSqBracketedNode ($1, makeSqBracketedNode ($2, $3, $4), (termNode)0); } | |
1205 | | primary LLT_COLON sortId | |
1206 | { $$ = $1; $$->given = sort_lookupName (ltoken_getText ($3)); } | |
1207 | ||
1208 | termList | |
1209 | : term0 { $$ = termNodeList_push (termNodeList_new (), $1); } | |
1210 | | termList LLT_COMMA term0 { $$ = termNodeList_push ($1, $3); } | |
1211 | ||
1212 | stateFcn | |
1213 | : preSym | |
1214 | | postSym | |
1215 | | anySym | |
1216 | | LLT_QUOTE | |
1217 | ||
1218 | lclPrimary | |
1219 | : cLiteral | |
1220 | | LLT_RESULT { $$ = makeSimpleTermNode ($1); } | |
1221 | | LLT_FRESH LLT_LPAR termList LLT_RPAR { $$ = makeOpCallTermNode ($1, $2, $3, $4); } | |
1222 | | LLT_UNCHANGED LLT_LPAR LLT_ALL LLT_RPAR { $$ = makeUnchangedTermNode1 ($1, $3); } | |
1223 | | LLT_UNCHANGED LLT_LPAR storeRefList LLT_RPAR { $$ = makeUnchangedTermNode2 ($1, $3); } | |
1224 | | LLT_SIZEOF LLT_LPAR term LLT_RPAR | |
1225 | { termNodeList x = termNodeList_new (); | |
1226 | termNodeList_addh (x, $3); | |
1227 | $$ = makeOpCallTermNode ($1, $2, x, $4); | |
1228 | } | |
1229 | | LLT_ISSUB LLT_LPAR term LLT_COMMA term LLT_RPAR | |
1230 | { termNodeList x = termNodeList_new (); | |
1231 | termNodeList_addh (x, $3); | |
1232 | termNodeList_addh (x, $5); | |
1233 | $$ = makeOpCallTermNode ($1, $2, x, $6); | |
1234 | } | |
1235 | | LLT_SIZEOF LLT_LPAR lclTypeSpec LLT_RPAR { $$ = makeSizeofTermNode ($1, $3); } | |
1236 | ||
1237 | /* removed 94-Mar-25: | |
1238 | ** | MODIFIES LLT_LPAR term LLT_RPAR | |
1239 | ** {termNodeList x = termNodeList_new (); | |
1240 | ** termNodeList_addh (x, $3); | |
1241 | ** $$ = makeOpCallTermNode ($1, $2, x, $4); } | |
1242 | */ | |
1243 | ||
1244 | cLiteral | |
1245 | : LLT_CINTEGER { $$ = makeLiteralTermNode ($1, sort_int); } | |
1246 | | LLT_LCSTRING { $$ = makeLiteralTermNode ($1, sort_cstring); } | |
1247 | | LLT_CCHAR { $$ = makeLiteralTermNode ($1, sort_char); } | |
1248 | | LLT_CFLOAT { $$ = makeLiteralTermNode ($1, sort_double); } | |
1249 | ||
1250 | quantifiers | |
1251 | : quantifier | |
1252 | { $$ = quantifierNodeList_add (quantifierNodeList_new (), $1); } | |
1253 | | quantifiers quantifier | |
1254 | { $$ = quantifierNodeList_add ($1, $2); } | |
1255 | ||
1256 | quantifier | |
1257 | : quantifierSym { scopeInfo si = (scopeInfo) dmalloc (sizeof (*si)); | |
1258 | si->kind = SPE_QUANT; | |
1259 | symtable_enterScope (g_symtab, si); } | |
1260 | quantifiedList | |
1261 | { $$ = makeQuantifierNode ($3, $1); } | |
1262 | ||
1263 | quantifiedList | |
1264 | : quantified { $$ = varNodeList_add (varNodeList_new (), $1); } | |
1265 | | quantifiedList LLT_COMMA quantified { $$ = varNodeList_add ($1, $3); } | |
1266 | ||
1267 | quantified | |
1268 | : varId LLT_COLON sortSpec { $$ = makeVarNode ($1, FALSE, $3); } | |
1269 | | varId LLT_COLON LLT_OBJ sortSpec { $$ = makeVarNode ($1, TRUE, $4); } | |
1270 | ||
1271 | simpleIdOrTypedefName | |
1272 | : simpleId | |
1273 | | LLT_TYPEDEF_NAME | |
1274 | ||
1275 | /* a different name space from varId/fcnId/typeId */ | |
1276 | fcnId : simpleId | |
1277 | varId : simpleId | |
1278 | tagId : simpleIdOrTypedefName | |
1279 | claimId : simpleIdOrTypedefName | |
1280 | sortId : simpleIdOrTypedefName | |
1281 | traitId : simpleIdOrTypedefName | |
1282 | opId : simpleIdOrTypedefName | |
1283 | ||
1284 | %% | |
1285 | ||
1286 | # include "bison.reset" | |
1287 | ||
1288 | /* | |
1289 | ** yytext is set in lex scanner | |
1290 | ** extern YYSTYPE yylval; | |
1291 | ** yylval is defined by code generated by bison | |
1292 | */ | |
1293 | ||
1294 | void ylerror (char *s) | |
1295 | { | |
1296 | /* | |
1297 | ** This resetting of the left context is very important when multiple | |
1298 | ** files are to be parsed. We do not want failures to propagate. | |
1299 | ** Lex/Yacc does not reset the flags when the parsing goes bad. | |
1300 | ** BEGIN 0; | |
1301 | **/ | |
1302 | ||
1303 | /*@-mustfree@*/ | |
1304 | lclfatalerror (yllval.ltok, | |
1305 | message ("%s: Token code: %s, Token String: %s", | |
1306 | cstring_fromChars (s), | |
1307 | ltoken_unparseCodeName (yllval.ltok), | |
1308 | ltoken_getRawString (yllval.ltok))); | |
1309 | /*@=mustfree@*/ | |
1310 | } | |
1311 | ||
1312 | static void yyprint (FILE *f, int t, YYSTYPE value) | |
1313 | { | |
1314 | fprintf (f, " type: %d (%s)", t, | |
1315 | cstring_toCharsSafe (ltoken_getRawString (value.ltok))); | |
1316 | } | |
1317 | ||
1318 | ||
1319 | ||
1320 | ||
1321 | ||
1322 | ||
1323 |