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