Some consistency changes to library & headers flags.
[splint-patched.git] / src / cgrammar.y
blob2d1c5d01cd326d1a80f076141e4a97b6f4e3d96d
1 /*;-*-C-*-;
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 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.
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.
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.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
27 ** cgrammar.y
29 ** Yacc/Bison grammar for extended ANSI C used by Splint.
31 ** original grammar by Nate Osgood ---
32 ** hacrat@catfish.lcs.mit.edu Mon Jun 14 13:06:32 1993
34 ** changes for Splint --- handle typedef names correctly
35 ** fix struct/union parsing bug (empty struct is accepted)
36 ** add productions to handle macros --- require
37 ** error correction --- main source of conflicts in grammar.
38 ** need to process initializations sequentially, L->R
40 ** production names are cryptic, so more productions fit on one line
42 ** conflicts: 87 shift/reduce, 18 reduce/reduce
43 ** most of these are due to handling macros
44 ** a few are due to handling type expressions
46 ** UPDATE: 138 shift/reduce, 17 reduce/reduce conflicts
49 /*@=allmacros@*/
51 # include "splintMacros.nf"
52 # include "basic.h"
53 # include "cscanner.h"
54 # include "cscannerHelp.h"
55 # include "exprChecks.h"
57 /*@-allmacros@*/
58 /*@-matchfields@*/
60 # define YYDEBUG 1
63 ** This is necessary, or else when the bison-generated code #include's malloc.h,
64 ** there will be a parse error.
66 ** Unfortunately, it means the error checking on malloc, etc. is lost for allocations
67 ** in bison-generated files under Win32.
70 # ifdef WIN32
71 # undef malloc
72 # undef calloc
73 # undef realloc
74 # endif
78 %define api.prefix {c_}
80 ** %expect for LALR parsers means _NO_ r/r conflicts -- there are lots of them
82 ** %expect 138
83 ** %expect-rr 17
86 %union
88 lltok tok;
89 int count;
90 qual typequal;
91 qualList tquallist;
92 ctype ctyp;
93 /*@dependent@*/ sRef sr;
95 /*@only@*/ functionClauseList funcclauselist;
96 /*@only@*/ functionClause funcclause;
97 /*@only@*/ flagSpec flagspec;
98 /*@only@*/ globalsClause globsclause;
99 /*@only@*/ modifiesClause modsclause;
100 /*@only@*/ warnClause warnclause;
101 /*@only@*/ stateClause stateclause;
102 /*@only@*/ pointers pointers;
103 /*@only@*/ functionConstraint fcnconstraint;
105 /*@only@*/ metaStateConstraint msconstraint;
106 /*@only@*/ metaStateSpecifier msspec;
107 /*@only@*/ metaStateExpression msexpr;
108 /*@observer@*/ metaStateInfo msinfo;
110 /*@only@*/ globSet globset;
111 /*@only@*/ qtype qtyp;
112 /*@only@*/ cstring cname;
113 /*@observer@*/ annotationInfo annotation;
114 /*@only@*/ idDecl ntyp;
115 /*@only@*/ idDeclList ntyplist;
116 /*@only@*/ uentryList flist;
117 /*@owned@*/ uentryList entrylist;
118 /*@observer@*/ /*@dependent@*/ uentry entry;
119 /*@only@*/ uentry oentry;
120 /*@only@*/ exprNode expr;
121 /*@only@*/ enumNameList enumnamelist;
122 /*@only@*/ exprNodeList exprlist;
123 /*@only@*/ sRefSet srset;
124 /*@only@*/ cstringList cstringlist;
126 constraint con;
127 constraintList conL;
128 constraintExpr conE;
132 extern int c_lex (void);
133 static void c_error (const char *);
136 /* standard C tokens */
138 %token <tok> BADTOK SKIPTOK
139 %token <tok> CTOK_ELIPSIS CASE DEFAULT CIF CELSE SWITCH WHILE DO CFOR
140 %token <tok> GOTO CONTINUE BREAK RETURN
141 %token <tok> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN
142 %token <tok> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
143 %token <tok> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
144 %token <tok> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
145 %token <tok> INC_OP DEC_OP LEFT_OP RIGHT_OP
146 %token <tok> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
147 %token <tok> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
148 %token <tok> LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
149 %token <tok> CSTRUCT CUNION CENUM
150 %token <tok> VA_ARG VA_DCL
151 %token <tok> QWARN
152 %token <tok> QGLOBALS
153 %token <tok> QMODIFIES
154 %token <tok> QNOMODS
155 %token <tok> QCONSTANT
156 %token <tok> QFUNCTION
157 %token <tok> QITER
158 %token <tok> QDEFINES
159 %token <tok> QUSES
160 %token <tok> QALLOCATES
161 %token <tok> QSETS
162 %token <tok> QRELEASES
163 %token <tok> QPRECLAUSE
164 %token <tok> QPOSTCLAUSE
165 %token <tok> QALT
166 %token <tok> QUNDEF QKILLED
167 %token <tok> QENDMACRO
169 /* additional tokens introduced by splint pre-processor. */
170 %token <tok> LLMACRO LLMACROITER LLMACROEND TENDMACRO
172 /* For debugging purposes */
173 %token <tok> QDREVEALSTATE
175 /* break comments: */
176 %token <tok> QSWITCHBREAK QLOOPBREAK QINNERBREAK QSAFEBREAK
177 %token <tok> QINNERCONTINUE
179 /* case fall-through marker: */
180 %token <tok> QFALLTHROUGH
182 /* used in scanner only */
183 %token <tok> QLINTNOTREACHED
184 %token <tok> QLINTFALLTHROUGH
185 %token <tok> QLINTFALLTHRU
186 %token <tok> QARGSUSED
187 %token <tok> QPRINTFLIKE QLINTPRINTFLIKE QSCANFLIKE QMESSAGELIKE
189 /* not-reached marker: (used like a label) */
190 %token <tok> QNOTREACHED
192 /* type qualifiers: */
193 %token <tok> QCONST QRESTRICT QVOLATILE QINLINE QEXTENSION QEXTERN QSTATIC QAUTO QREGISTER
194 %token <tok> QOUT QIN QYIELD QONLY QTEMP QSHARED QREF QUNIQUE
195 %token <tok> QCHECKED QUNCHECKED QCHECKEDSTRICT QCHECKMOD
196 %token <tok> QKEEP QKEPT QPARTIAL QSPECIAL QOWNED QDEPENDENT
197 %token <tok> QRETURNED QEXPOSED QNULL QOBSERVER QISNULL
198 %token <tok> QEXITS QMAYEXIT QNEVEREXIT QTRUEEXIT QFALSEEXIT
199 %token <tok> QLONG QSIGNED QUNSIGNED QSHORT QUNUSED QSEF QNOTNULL QRELNULL
200 %token <tok> QABSTRACT QNUMABSTRACT QCONCRETE QMUTABLE QIMMUTABLE
201 %token <tok> QTRUENULL QFALSENULL QEXTERNAL
202 %token <tok> QREFCOUNTED QREFS QNEWREF QTEMPREF QKILLREF QRELDEF
203 %token <ctyp> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID
204 %token <tok> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
206 %token <tok> QNULLTERMINATED
207 %token <tok> QMAXSET
208 %token <tok> QMAXREAD
210 %token <tok> TCAND
213 /* identifiers, literals */
214 %token <entry> IDENTIFIER
215 %token <cname> NEW_IDENTIFIER
216 %token <annotation> CANNOTATION
217 %token <expr> CCONSTANT
218 %type <cname> flagId
219 %type <flagspec> flagSpec
220 %type <expr> cconstantExpr
221 %token <entry> ITER_NAME ITER_ENDNAME
222 %type <entry> endIter
224 %type <funcclauselist> functionClauses functionClausesPlain
225 %type <funcclause> functionClause functionClausePlain
227 %type <globsclause> globalsClause globalsClausePlain
228 %type <modsclause> modifiesClause modifiesClausePlain nomodsClause
229 %type <warnclause> warnClause warnClausePlain optWarnClause
230 %type <funcclause> conditionClause conditionClausePlain
231 %type <stateclause> stateClause stateClausePlain
232 %type <msconstraint> metaStateConstraint
233 %type <fcnconstraint> functionConstraint
234 %type <msspec> metaStateSpecifier
235 %type <msexpr> metaStateExpression
237 %type <sr> globId globIdListExpr
238 %type <globset> globIdList
240 %token <ctyp> TYPE_NAME
241 %token <msinfo> METASTATE_NAME
242 %type <cname> enumerator newId
243 %type <pointers> pointers
245 %type <tok> doHeader stateTag conditionTag startConditionClause
246 %type <typequal> exitsQualifier checkQualifier stateQualifier
247 paramQualifier returnQualifier visibilityQualifier
248 typedefQualifier refcountQualifier definedQualifier
250 /* type construction */
251 %type <ctyp> abstractDecl abstractDeclBase optAbstractDeclBase
252 %type <ctyp> suSpc enumSpc typeName typeSpecifier
254 %type <ntyp> namedDecl namedDeclBase optNamedDecl
255 %type <ntyp> plainNamedDecl plainNamedDeclBase
256 %type <ntyp> structNamedDecl
257 %type <ntyp> plainFcn
259 %type <oentry> paramDecl
260 %type <entry> id
262 %type <ntyplist> structNamedDeclList
264 %type <entrylist> genericParamList paramTypeList paramList idList paramIdList
265 %type <exprlist> argumentExprList iterArgList
266 %type <exprlist> initList namedInitializerList namedInitializerListAux namedInitializerTypeList namedInitializerTypeListAux
267 %type <flist> structDeclList structDecl
268 %type <srset> locModifies modList specClauseList optSpecClauseList
269 %type <sr> mExpr modListExpr specClauseListExpr
271 %type <tok> BufUnaryOp BufBinaryOp BufRelationalOp BufConstraintSeparator
272 %type <con> BufConstraint
273 %type <conL> BufConstraintList
274 %type <conE> BufConstraintExpr
275 %type <sr> BufConstraintSrefExpr
277 %type <enumnamelist> enumeratorList
278 %type <cstringlist> fieldDesignator
280 %type <expr> sizeofExpr sizeofExprAux offsetofExpr
281 %type <expr> openScope closeScope
282 %type <expr> instanceDeclAux instanceDecl namedInitializer declarators namedInitializerType
283 %type <expr> primaryExpr postfixExpr primaryIterExpr postfixIterExpr
284 %type <expr> unaryExpr castExpr timesExpr plusExpr
285 %type <expr> unaryIterExpr castIterExpr timesIterExpr plusIterExpr
286 %type <expr> shiftExpr relationalExpr equalityExpr bitandExpr
287 %type <expr> xorExpr bitorExpr andExpr
288 %type <expr> orExpr conditionalExpr assignExpr
289 %type <expr> shiftIterExpr relationalIterExpr equalityIterExpr bitandIterExpr
290 %type <expr> xorIterExpr bitorIterExpr andIterExpr
291 %type <expr> orIterExpr conditionalIterExpr assignIterExpr iterArgExpr
292 %type <expr> expr optExpr optInitExpr constantExpr
293 %type <expr> init macroBody iterBody endBody partialIterStmt iterSelectionStmt
294 %type <expr> stmt fcnBody iterStmt iterDefStmt iterDefStmtList debugStmt
295 %type <expr> labeledStmt caseStmt defaultStmt
296 %type <expr> compoundStmt compoundStmtAux compoundStmtAuxErr initStmtList initStmtListErr
297 %type <expr> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt
298 %type <expr> stmtErr compoundStmtErr expressionStmtErr
299 %type <expr> iterationStmtErr initializerList typeInitializerList initializer
300 %type <expr> ifPred whilePred forPred iterWhilePred typeInitializer
302 %type <expr> designator designatorList designation
304 %type <typequal> storageSpecifier typeQualifier typeModifier globQual innerMods
305 %type <tquallist> optGlobQuals innerModsList
306 %type <qtyp> completeType completeTypeSpecifier optCompleteType
307 %type <qtyp> completeTypeSpecifierAux altType typeExpression
309 %start file
313 file
314 : %empty
315 | externalDefs
318 externalDefs
319 : externalDef { context_checkGlobalScope (); }
320 | externalDefs externalDef { context_checkGlobalScope (); }
323 externalDef
324 : fcnDef optSemi { uentry_clearDecl (); }
325 | constantDecl { uentry_clearDecl (); }
326 | fcnDecl { uentry_clearDecl (); }
327 | iterDecl { uentry_clearDecl (); }
328 | macroDef { uentry_clearDecl (); }
329 | initializer { uentry_checkDecl (); exprNode_free ($1); }
330 | typeDecl { uentry_checkDecl (); }
331 | TSEMI { uentry_clearDecl (); lltok_free ($1); /* okay to have a null statement */ }
332 | error { uentry_clearDecl (); }
335 constantDecl
336 : QCONSTANT completeTypeSpecifier NotType namedDecl NotType optSemi IsType QENDMACRO
337 { checkConstant ($2, $4); lltok_free2 ($1, $8); }
338 | QCONSTANT completeTypeSpecifier NotType namedDecl NotType TASSIGN IsType init optSemi QENDMACRO
339 { checkValueConstant ($2, $4, $8); lltok_free3 ($1, $6, $10); }
342 fcnDecl
343 : QFUNCTION { context_enterFunctionHeader (); } plainFcn optSemi QENDMACRO
345 declareStaticFunction ($3); context_quietExitFunction ();
346 context_exitFunctionHeader ();
347 lltok_free2 ($1, $5); /*!*/
351 plainFcn
352 : plainNamedDecl
354 qtype qint = qtype_create (ctype_int);
355 $$ = idDecl_fixBase ($1, qint);
356 qtype_free (qint);
358 | completeTypeSpecifier NotType plainNamedDecl
359 { $$ = idDecl_fixBase ($3, $1); }
362 plainNamedDecl
363 : plainNamedDeclBase
364 | pointers plainNamedDeclBase
365 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
368 namedDeclBase
369 : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
370 | IsType TLPAREN NotType namedDecl IsType TRPAREN
371 { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
372 | namedDeclBase TLSQBR TRSQBR
373 { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); lltok_free2 ($2, $3); }
374 | namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
376 exprNode_findValue ($4);
377 idDecl_notExpectingFunction ($1);
379 if (exprNode_hasValue ($4))
381 $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1),
382 exprNode_getLongValue ($4)));
384 else
386 $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
389 lltok_free2 ($2, $5);
391 | namedDeclBase PushType TLPAREN TRPAREN
392 { setCurrentParams (uentryList_missingParams); }
393 functionClauses
394 { /* need to support globals and modifies here! */
395 functionClauseList fcl;
396 ctype ct = ctype_makeFunction (idDecl_getCtype ($1),
397 uentryList_makeMissingParams ());
398 $$ = idDecl_replaceCtype ($1, ct);
399 setImplicitfcnConstraints();
400 fcl = functionClauseList_setImplicitConstraints($6);
401 idDecl_addClauses ($$, fcl);
402 context_popLoc ();
403 lltok_free2 ($3, $4);
405 | namedDeclBase PushType TLPAREN genericParamList TRPAREN
406 { setCurrentParams ($4); }
407 functionClauses
409 functionClauseList fcl;
410 setImplicitfcnConstraints ();
411 clearCurrentParams ();
412 $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
413 fcl = functionClauseList_setImplicitConstraints($7);
414 idDecl_addClauses ($$, fcl);
415 context_popLoc ();
416 lltok_free2 ($3, $5);
420 plainNamedDeclBase
421 : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
422 | IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
423 { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
424 | plainNamedDeclBase TLSQBR TRSQBR
425 { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
426 lltok_free2 ($2, $3);
428 | plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
430 $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
431 lltok_free2 ($2, $5);
433 | plainNamedDeclBase PushType TLPAREN TRPAREN
434 { setCurrentParams (uentryList_missingParams); }
435 functionClausesPlain
437 ctype ct = ctype_makeFunction (idDecl_getCtype ($1),
438 uentryList_makeMissingParams ());
440 $$ = idDecl_replaceCtype ($1, ct);
441 idDecl_addClauses ($$, $6);
442 context_popLoc ();
443 lltok_free2 ($3, $4);
445 | plainNamedDeclBase PushType TLPAREN genericParamList TRPAREN
446 { setCurrentParams ($4); }
447 functionClausesPlain
449 clearCurrentParams ();
450 $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
451 idDecl_addClauses ($$, $7);
452 context_popLoc ();
453 lltok_free ($3);
454 /*!! lltok_free2 ($3, $5); */
458 iterDecl
459 : QITER newId TLPAREN genericParamList TRPAREN
460 { setCurrentParams ($4); } functionClausesPlain
461 { clearCurrentParams (); } optSemi QENDMACRO
462 { declareCIter ($2, $4);
463 lltok_free3 ($1, $3, $5);
467 macroDef
468 : LLMACRO macroBody TENDMACRO { exprNode_checkMacroBody ($2); lltok_free2 ($1, $3); }
469 | LLMACROITER iterBody TENDMACRO { exprNode_checkIterBody ($2); lltok_free2 ($1, $3); }
470 | LLMACROEND endBody TENDMACRO { exprNode_checkIterEnd ($2); lltok_free2 ($1, $3); }
471 | LLMACRO TENDMACRO /* no stmt */ { exprChecks_checkEmptyMacroBody (); lltok_free2 ($1, $2); }
474 metaStateConstraint
475 : metaStateSpecifier TASSIGN metaStateExpression
476 { $$ = metaStateConstraint_create ($1, $3); lltok_free ($2); }
479 metaStateSpecifier
480 : BufConstraintSrefExpr { cscannerHelp_expectingMetaStateName (); } TCOLON METASTATE_NAME
481 { cscannerHelp_clearExpectingMetaStateName ();
482 $$ = metaStateSpecifier_create ($1, $4);
483 lltok_free ($3);
485 | CTOK_ELIPSIS { cscannerHelp_expectingMetaStateName (); } TCOLON METASTATE_NAME
486 { cscannerHelp_clearExpectingMetaStateName ();
487 $$ = metaStateSpecifier_createElipsis ($4);
488 lltok_free2 ($1, $3);
492 metaStateExpression
493 : metaStateSpecifier { $$ = metaStateExpression_create ($1); }
494 | metaStateSpecifier TBAR metaStateExpression { $$ = metaStateExpression_createMerge ($1, $3); lltok_free ($2); }
497 BufConstraintList
498 : BufConstraint { $$ = constraintList_single ($1); }
499 | BufConstraint BufConstraintSeparator BufConstraintList { $$ = constraintList_add ($3, $1); }
502 BufConstraint
503 : BufConstraintExpr BufRelationalOp BufConstraintExpr { $$ = makeConstraintParse3 ($1, $2, $3); }
506 BufConstraintExpr
507 : CCONSTANT
508 { $$ = constraintExpr_makeIntLiteral (exprNode_getLongValue ($1)); }
509 | BufConstraintSrefExpr
510 { $$ = constraintExpr_makeTermsRef ($1); }
511 | BufUnaryOp TLPAREN BufConstraintSrefExpr TRPAREN
512 { $$ = constraintExpr_parseMakeUnaryOp ($1, constraintExpr_makeTermsRef ($3)); }
513 | TLPAREN BufConstraintExpr BufBinaryOp BufConstraintExpr TRPAREN
514 { $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
517 BufConstraintSrefExpr
518 : id
519 { /*@-onlytrans@*/ $$ = checkbufferConstraintClausesId ($1); /*@=onlytrans@*/ /*@i523@*/ }
520 | NEW_IDENTIFIER
521 { $$ = fixStateClausesId ($1); }
522 | BufConstraintSrefExpr TLSQBR TRSQBR
523 { $$ = sRef_makeAnyArrayFetch ($1); }
524 | BufConstraintSrefExpr TLSQBR CCONSTANT TRSQBR
525 { $$ = sRef_makeArrayFetchKnown ($1, exprNode_getLongValue ($3)); }
526 | TMULT BufConstraintSrefExpr
527 { $$ = sRef_constructPointer ($2); }
528 | TLPAREN BufConstraintSrefExpr TRPAREN
529 { $$ = $2; }
530 | BufConstraintSrefExpr TDOT newId
531 { cstring_markOwned ($3); $$ = sRef_buildField ($1, $3); }
532 | BufConstraintSrefExpr ARROW_OP newId
533 { cstring_markOwned ($3); $$ = sRef_makeArrow ($1, $3); }
536 BufUnaryOp
537 : QMAXSET
538 | QMAXREAD
541 BufBinaryOp
542 : TPLUS
543 | TMINUS
546 BufRelationalOp
547 : GE_OP
548 | LE_OP
549 | EQ_OP
552 BufConstraintSeparator
553 : TCAND
554 | AND_OP
558 ** Function clauses can appear in any order.
561 functionClauses
562 : %empty { $$ = functionClauseList_new (); }
563 | functionClause functionClauses
564 { $$ = functionClauseList_prepend ($2, $1); }
568 ** Inside macro definitions, there are no end macros.
571 functionClausesPlain
572 : %empty { $$ = functionClauseList_new (); }
573 | functionClausePlain functionClausesPlain
574 { $$ = functionClauseList_prepend ($2, $1); }
577 functionClause
578 : globalsClause { $$ = functionClause_createGlobals ($1); }
579 | modifiesClause { $$ = functionClause_createModifies ($1); }
580 | nomodsClause { $$ = functionClause_createModifies ($1); }
581 | stateClause { $$ = functionClause_createState ($1); }
582 | conditionClause { $$ = $1; }
583 | warnClause { $$ = functionClause_createWarn ($1); }
586 functionClausePlain
587 : globalsClausePlain { $$ = functionClause_createGlobals ($1); }
588 | modifiesClausePlain { $$ = functionClause_createModifies ($1); }
589 | nomodsClause { $$ = functionClause_createModifies ($1); }
590 | stateClausePlain { $$ = functionClause_createState ($1); }
591 | conditionClausePlain { $$ = $1; }
592 | warnClausePlain { $$ = functionClause_createWarn ($1); }
595 globalsClause
596 : globalsClausePlain QENDMACRO { $$ = $1; }
599 globalsClausePlain
600 : QGLOBALS { setProcessingGlobalsList (); }
601 globIdList optSemi
603 unsetProcessingGlobals ();
604 $$ = globalsClause_create ($1, $3);
608 nomodsClause
609 : QNOMODS { $$ = modifiesClause_createNoMods ($1); }
612 modifiesClause
613 : modifiesClausePlain QENDMACRO { $$ = $1; }
616 modifiesClausePlain
617 : QMODIFIES
619 context_setProtectVars (); enterParamsTemp ();
620 sRef_setGlobalScopeSafe ();
622 locModifies
624 exitParamsTemp ();
625 sRef_clearGlobalScopeSafe ();
626 context_releaseVars ();
627 $$ = modifiesClause_create ($1, $3);
631 flagSpec
632 : flagId
633 { $$ = flagSpec_createPlain ($1); }
634 | flagId TBAR flagSpec
635 { $$ = flagSpec_createOr ($1, $3); }
638 flagId
639 : NEW_IDENTIFIER
642 optWarnClause
643 : %empty { $$ = warnClause_undefined; }
644 | warnClause
647 warnClause
648 : warnClausePlain QENDMACRO { $$ = $1; }
651 warnClausePlain
652 : QWARN flagSpec cconstantExpr
654 llassert (exprNode_knownStringValue ($3));
655 $$ = warnClause_create ($1, $2, cstring_copy (multiVal_forceString (exprNode_getValue ($3))));
656 exprNode_free ($3);
658 | QWARN flagSpec
659 { $$ = warnClause_create ($1, $2, cstring_undefined); }
662 globIdList
663 : globIdListExpr { $$ = globSet_single ($1); }
664 | globIdList TCOMMA globIdListExpr { $$ = globSet_insert ($1, $3); }
667 globIdListExpr
668 : optGlobQuals globId { $$ = clabstract_createGlobal ($2, $1); }
671 optGlobQuals
672 : %empty { $$ = qualList_undefined; }
673 | globQual optGlobQuals { $$ = qualList_add ($2, $1); }
676 globId
677 : id { $$ = uentry_getSref ($1); }
678 | NEW_IDENTIFIER { $$ = clabstract_unrecognizedGlobal ($1); }
679 | initializer { $$ = clabstract_checkGlobal ($1); }
682 globQual
683 : QUNDEF { $$ = qual_createUndef (); }
684 | QKILLED { $$ = qual_createKilled (); }
685 | QOUT { $$ = qual_createOut (); }
686 | QIN { $$ = qual_createIn (); }
687 | QPARTIAL { $$ = qual_createPartial (); }
690 stateTag
691 : QDEFINES
692 | QUSES
693 | QALLOCATES
694 | QSETS
695 | QRELEASES
698 conditionTag
699 : QPRECLAUSE
700 | QPOSTCLAUSE
703 fcnHdr
704 : namedDecl
706 qtype qint = qtype_create (ctype_int);
707 clabstract_declareFunction (idDecl_fixBase ($1, qint));
708 qtype_free (qint);
710 | completeTypeSpecifier NotType namedDecl
712 clabstract_declareFunction (idDecl_fixBase ($3, $1));
716 optInitializerList
717 : %empty
718 { checkDoneParams (); }
719 | { context_enterOldStyleScope (); } initializerList
720 { oldStyleDoneParams (); }
721 | { context_enterOldStyleScope (); } VA_DCL
722 { doVaDcl (); oldStyleDoneParams (); }
725 fcnBody
726 : { context_enterInnerContext (); } compoundStmtAux
728 exprNode_checkFunctionBody ($2);
729 context_exitInner ($2);
730 $$ = $2;
734 fcnDef
735 : fcnHdr optInitializerList fcnBody
737 context_setFunctionDefined (exprNode_loc ($3));
738 exprNode_checkFunction (context_getHeader (), $3);
739 context_exitFunction ();
743 locModifies
744 : modList optSemi { $$ = $1; }
745 | optSemi { $$ = sRefSet_new (); }
748 modListExpr
749 : id { $$ = uentry_getSref ($1); checkModifiesId ($1); }
750 | NEW_IDENTIFIER { $$ = fixModifiesId ($1); }
751 | modListExpr TLSQBR TRSQBR { $$ = modListArrayFetch ($1, sRef_undefined); }
752 | modListExpr TLSQBR mExpr TRSQBR { $$ = modListArrayFetch ($1, $3); }
753 | TMULT modListExpr { $$ = modListPointer ($2); }
754 | TLPAREN modListExpr TRPAREN { $$ = $2; }
755 | modListExpr TDOT newId { $$ = modListFieldAccess ($1, $3); }
756 | modListExpr ARROW_OP newId { $$ = modListArrowAccess ($1, $3); }
759 mExpr
760 : modListExpr { $$ = $1; }
761 | cconstantExpr { $$ = sRef_makeUnknown (); /* sRef_makeConstant ($1); ? */ }
762 /* arithmetic? */
765 modList
766 : modListExpr { $$ = sRefSet_single ($1); }
767 | modList TCOMMA modListExpr { $$ = sRefSet_insert ($1, $3); }
770 specClauseListExpr
771 : id
772 { $$ = checkStateClausesId ($1); }
773 | NEW_IDENTIFIER
774 { $$ = fixStateClausesId ($1); }
775 | specClauseListExpr TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
776 | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
777 | TMULT specClauseListExpr { $$ = sRef_constructPointer ($2); }
778 | TLPAREN specClauseListExpr TRPAREN { $$ = $2; }
779 | specClauseListExpr TDOT newId { cstring_markOwned ($3);
780 $$ = sRef_buildField ($1, $3); }
781 | specClauseListExpr ARROW_OP newId { cstring_markOwned ($3);
782 $$ = sRef_makeArrow ($1, $3); }
785 optSpecClauseList
786 : %empty { $$ = sRefSet_undefined; }
787 | specClauseList
790 specClauseList
791 : specClauseListExpr
792 { $$ = sRef_isValid ($1) ? sRefSet_single ($1) : sRefSet_undefined; }
793 | specClauseList TCOMMA specClauseListExpr
794 { $$ = sRef_isValid ($3) ? sRefSet_insert ($1, $3) : $1; }
797 primaryExpr
798 : id { $$ = exprNode_fromIdentifier ($1); }
799 | NEW_IDENTIFIER { $$ = exprNode_fromUIO ($1); }
800 | cconstantExpr
801 | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
802 | QEXTENSION { $$ = exprNode_makeError (); }
803 | TLPAREN { exprChecks_inCompoundStatementExpression (); }
804 compoundStmt TRPAREN
805 { exprChecks_leaveCompoundStatementExpression (); $$ = exprNode_compoundStatementExpression ($1, $3); }
808 postfixExpr
809 : primaryExpr
810 | postfixExpr TLSQBR expr TRSQBR { $$ = exprNode_arrayFetch ($1, $3); }
811 | postfixExpr TLPAREN TRPAREN { $$ = exprNode_functionCall ($1, exprNodeList_new ()); }
812 | postfixExpr TLPAREN argumentExprList TRPAREN { $$ = exprNode_functionCall ($1, $3); }
813 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN { $$ = exprNode_vaArg ($1, $3, $5); }
814 | postfixExpr NotType TDOT newId IsType { $$ = exprNode_fieldAccess ($1, $3, $4); }
815 | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
816 | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
817 | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
818 | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE
819 { /* added for C99 */ $$ = exprNode_undefined; /*@i87 no checking */ }
822 argumentExprList
823 : assignExpr { $$ = exprNodeList_singleton ($1); }
824 | argumentExprList TCOMMA assignExpr { $$ = exprNodeList_push ($1, $3); }
827 unaryExpr
828 : postfixExpr
829 | INC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
830 | DEC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
831 | TAMPERSAND castExpr { $$ = exprNode_preOp ($2, $1); }
832 | TMULT castExpr { $$ = exprNode_preOp ($2, $1); }
833 | TPLUS castExpr { $$ = exprNode_preOp ($2, $1); }
834 | TMINUS castExpr { $$ = exprNode_preOp ($2, $1); }
835 | TTILDE castExpr { $$ = exprNode_preOp ($2, $1); }
836 | TEXCL castExpr { $$ = exprNode_preOp ($2, $1); }
837 | processSizeof sizeofExpr endprocessSizeof { $$ = $2; }
838 | offsetofExpr { $$ = $1; }
841 fieldDesignator
842 : fieldDesignator TDOT newId { $$ = cstringList_add ($1, $3); lltok_free ($2); }
843 | fieldDesignator TLSQBR expr TRSQBR { $$ = $1; lltok_free2 ($2, $4); }
844 /* offsetof designators can use array indexes */
845 | newId { $$ = cstringList_single ($1); }
848 offsetofExpr
849 : COFFSETOF IsType TLPAREN typeExpression NotType TCOMMA fieldDesignator TRPAREN IsType
850 { $$ = exprNode_offsetof ($4, $7);
851 lltok_free3 ($1, $3, $6); lltok_free ($8); }
854 sizeofExpr
855 : IsType { context_setProtectVars (); }
856 sizeofExprAux { context_sizeofReleaseVars (); $$ = $3; }
859 processSizeof
860 : %empty { context_enterSizeof(); }
863 endprocessSizeof
864 : %empty { context_leaveSizeof(); }
867 sizeofExprAux
868 : CSIZEOF TLPAREN typeExpression TRPAREN { $$ = exprNode_sizeofType ($3); lltok_free3 ($1, $2, $4); }
869 | CSIZEOF unaryExpr { $$ = exprNode_sizeofExpr ($2); lltok_free ($1); }
870 | CALIGNOF TLPAREN typeExpression TRPAREN { $$ = exprNode_alignofType ($3); lltok_free3 ($1, $2, $4); }
871 | CALIGNOF unaryExpr { $$ = exprNode_alignofExpr ($2); lltok_free ($1); }
875 castExpr
876 : unaryExpr
877 | TLPAREN typeExpression TRPAREN castExpr
878 { $$ = exprNode_cast ($1, $4, $2); lltok_free ($3); }
881 timesExpr
882 : castExpr
883 | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
884 | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
885 | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
888 plusExpr
889 : timesExpr
890 | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
891 | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
894 shiftExpr
895 : plusExpr
896 | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
897 | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
900 relationalExpr
901 : shiftExpr
902 | relationalExpr TLT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
903 | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
904 | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
905 | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
908 equalityExpr
909 : relationalExpr
910 | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
911 | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
914 bitandExpr
915 : equalityExpr
916 | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
919 xorExpr
920 : bitandExpr
921 | xorExpr TCIRC bitandExpr { $$ = exprNode_op ($1, $3, $2); }
924 bitorExpr
925 : xorExpr
926 | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
929 andExpr
930 : bitorExpr
931 | andExpr AND_OP
932 { exprNode_produceGuards ($1);
933 context_enterAndClause ($1);
935 bitorExpr
937 $$ = exprNode_op ($1, $4, $2);
938 context_exitAndClause ($$, $4);
942 orExpr
943 : andExpr
944 | orExpr OR_OP
946 exprNode_produceGuards ($1);
947 context_enterOrClause ($1);
949 andExpr
951 $$ = exprNode_op ($1, $4, $2);
952 context_exitOrClause ($$, $4);
956 conditionalExpr
957 : orExpr
958 | orExpr TQUEST
959 { /* GCC extension: conditional with empty if */
960 exprNode_produceGuards ($1); context_enterTrueClause ($1); } TCOLON
961 { context_enterFalseClause ($1); } conditionalExpr
962 { $$ = exprNode_condIfOmit ($1, $6); context_exitConditionalClause ($1, exprNode_undefined, $6); }
963 | orExpr TQUEST { exprNode_produceGuards ($1); context_enterTrueClause ($1); } expr TCOLON
964 { context_enterFalseClause ($1); } conditionalExpr
965 { $$ = exprNode_cond ($1, $4, $7); context_exitConditionalClause ($1, $4, $7); }
968 assignExpr
969 : conditionalExpr
970 | unaryExpr TASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
971 | unaryExpr MUL_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
972 | unaryExpr DIV_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
973 | unaryExpr MOD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
974 | unaryExpr ADD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
975 | unaryExpr SUB_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
976 | unaryExpr LEFT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
977 | unaryExpr RIGHT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
978 | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
979 | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
980 | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
983 expr
984 : assignExpr
985 | expr TCOMMA assignExpr { $$ = exprNode_comma ($1, $3); }
988 optExpr
989 : %empty { $$ = exprNode_undefined; }
990 | expr
993 optInitExpr
994 : optExpr
995 | instanceDecl
998 constantExpr
999 : conditionalExpr
1002 initializer
1003 : instanceDecl TSEMI IsType { $$ = $1; }
1006 instanceDeclAux
1007 : completeTypeSpecifier NotType namedDecl NotType
1008 { setProcessingVars ($1); processNamedDecl ($3); } IsType
1009 { $$ = exprNode_makeEmptyInitialization ($3); }
1010 | completeTypeSpecifier NotType namedDecl NotType
1011 { setProcessingVars ($1); processNamedDecl ($3); } IsType TASSIGN init
1012 { $$ = exprNode_makeInitialization ($3, $8); }
1015 instanceDecl
1017 ** : completeTypeSpecifier { setProcessingVars ($1); } NotType namedInitializerList { unsetProcessingVars (); }
1019 ** This causes r/r conflicts with function definitions.
1020 ** Instead we need to snarf one first. (gack)
1021 ** The solution is pretty ugly:
1023 : instanceDeclAux { unsetProcessingVars (); $$ = $1; }
1024 | instanceDeclAux declarators { unsetProcessingVars (); $$ = exprNode_concat ($1, $2); }
1027 namedInitializerType
1028 : namedInitializer { $$ = $1; }
1029 | TYPE_NAME { $$ = exprNode_fromIdentifier (usymtab_getTypeEntry (ctype_typeId ($1))); }
1032 namedInitializer
1033 : namedDecl NotType
1035 processNamedDecl ($1);
1036 $$ = exprNode_makeEmptyInitialization ($1);
1038 | namedDecl NotType TASSIGN { processNamedDecl ($1); } IsType init
1039 { $$ = exprNode_makeInitialization ($1, $6); }
1042 typeDecl
1043 : CTYPEDEF completeTypeSpecifier { setProcessingTypedef ($2); }
1044 NotType namedInitializerTypeList optWarnClause TSEMI IsType
1045 { clabstract_declareType ($5, $6); }
1046 | CTYPEDEF completeTypeSpecifier TSEMI IsType { /* in the ANSI grammar, semantics unclear */ }
1047 | CTYPEDEF namedInitializerList TSEMI IsType { /* in the ANSI grammar, semantics unclear */ }
1048 | completeTypeSpecifier TSEMI IsType
1051 IsType
1052 : %empty { cscannerHelp_setExpectingTypeName (); }
1055 PushType
1056 : %empty { cscannerHelp_setExpectingTypeName (); context_pushLoc (); }
1059 namedInitializerList
1060 : namedInitializerListAux IsType { $$ = $1; }
1063 namedInitializerListAux
1064 : namedInitializer { $$ = exprNodeList_singleton ($1); }
1065 | namedInitializerList TCOMMA NotType namedInitializer { $$ = exprNodeList_push ($1, $4); }
1068 namedInitializerTypeList
1069 : namedInitializerTypeListAux IsType { $$ = $1; }
1072 namedInitializerTypeListAux
1073 : namedInitializerType { $$ = exprNodeList_singleton ($1); }
1074 | namedInitializerTypeList TCOMMA NotType namedInitializerType { $$ = exprNodeList_push ($1, $4); }
1077 declarators
1078 : TCOMMA NotType namedInitializer { $$ = $3; }
1079 | declarators TCOMMA NotType namedInitializer { $$ = exprNode_concat ($1, $4); }
1082 init
1083 : assignExpr
1084 | TLBRACE initList TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); lltok_free ($3); }
1085 | TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); lltok_free2 ($3, $4); }
1086 | designation init { $$ = exprNode_undefined; }
1090 ** Splint parses these (added in ISO C99), but no checking yet...
1093 designation
1094 : designatorList TASSIGN { $$ = $1; }
1095 | newId TCOLON { $$ = exprNode_undefined;
1096 /* gcc extension, obsolete since 2.5 */ }
1099 designatorList
1100 : designator { $$ = exprNode_undefined; }
1101 | designatorList designator { $$ = exprNode_undefined; }
1104 designator
1105 : TLSQBR constantExpr TRSQBR { $$ = exprNode_undefined; }
1106 | TDOT newId { $$ = exprNode_undefined; }
1109 initList
1110 : init
1111 { $$ = exprNodeList_singleton ($1); }
1112 | initList TCOMMA init
1113 { $$ = exprNodeList_push ($1, $3); }
1117 ** need to do the storage class global hack so tags are
1118 ** declared with the right storage class.
1121 storageSpecifier
1122 : QEXTERN { setStorageClass (SCEXTERN); $$ = qual_createExtern (); }
1123 | QINLINE { $$ = qual_createInline (); }
1124 | QSTATIC { setStorageClass (SCSTATIC); $$ = qual_createStatic (); }
1125 | QAUTO { $$ = qual_createAuto (); }
1126 | QREGISTER { $$ = qual_createRegister (); }
1129 stateClause
1130 : stateClausePlain QENDMACRO { $$ = $1; }
1133 stateClausePlain
1134 : stateTag NotType
1136 context_setProtectVars ();
1137 enterParamsTemp ();
1138 sRef_setGlobalScopeSafe ();
1140 specClauseList optSemi IsType
1142 exitParamsTemp ();
1143 sRef_clearGlobalScopeSafe ();
1144 context_releaseVars ();
1145 $$ = stateClause_createPlain ($1, $4);
1149 conditionClause
1150 : conditionClausePlain QENDMACRO { $$ = $1; }
1153 startConditionClause
1154 : conditionTag NotType { $$ = $1; context_enterFunctionHeader (); }
1157 conditionClausePlain
1158 : startConditionClause stateQualifier
1160 context_exitFunctionHeader ();
1161 context_setProtectVars ();
1162 enterParamsTemp ();
1163 sRef_setGlobalScopeSafe ();
1165 optSpecClauseList optSemi IsType
1167 exitParamsTemp ();
1168 sRef_clearGlobalScopeSafe ();
1169 context_releaseVars ();
1170 $$ = functionClause_createState (stateClause_create ($1, $2, $4));
1172 | startConditionClause
1174 context_setProtectVars ();
1175 enterParamsTemp ();
1176 sRef_setGlobalScopeSafe ();
1178 functionConstraint optSemi IsType
1180 context_exitFunctionHeader ();
1181 exitParamsTemp ();
1182 sRef_clearGlobalScopeSafe ();
1183 context_releaseVars ();
1185 if (lltok_isEnsures ($1))
1187 $$ = functionClause_createEnsures ($3);
1189 else if (lltok_isRequires ($1))
1191 $$ = functionClause_createRequires ($3);
1193 else
1195 BADBRANCH;
1200 functionConstraint
1201 : BufConstraintList { $$ = functionConstraint_createBufferConstraint ($1); }
1202 | metaStateConstraint { $$ = functionConstraint_createMetaStateConstraint ($1); }
1205 exitsQualifier
1206 : QEXITS { $$ = qual_createExits (); }
1207 | QMAYEXIT { $$ = qual_createMayExit (); }
1208 | QTRUEEXIT { $$ = qual_createTrueExit (); }
1209 | QFALSEEXIT { $$ = qual_createFalseExit (); }
1210 | QNEVEREXIT { $$ = qual_createNeverExit (); }
1213 checkQualifier
1214 : QCHECKED { $$ = qual_createChecked (); }
1215 | QCHECKMOD { $$ = qual_createCheckMod (); }
1216 | QUNCHECKED { $$ = qual_createUnchecked (); }
1217 | QCHECKEDSTRICT { $$ = qual_createCheckedStrict (); }
1220 stateQualifier
1221 : QOWNED { $$ = qual_createOwned (); }
1222 | QDEPENDENT { $$ = qual_createDependent (); }
1223 | QYIELD { $$ = qual_createYield (); }
1224 | QTEMP { $$ = qual_createTemp (); }
1225 | QONLY { $$ = qual_createOnly (); }
1226 | QKEEP { $$ = qual_createKeep (); }
1227 | QKEPT { $$ = qual_createKept (); }
1228 | QSHARED { $$ = qual_createShared (); }
1229 | QUNIQUE { $$ = qual_createUnique (); }
1230 | QNULL { $$ = qual_createNull (); }
1231 | QISNULL { $$ = qual_createIsNull (); }
1232 | QRELNULL { $$ = qual_createRelNull (); }
1233 | QNOTNULL { $$ = qual_createNotNull (); }
1234 | QEXPOSED { $$ = qual_createExposed (); }
1235 | QOBSERVER { $$ = qual_createObserver (); }
1236 | QNULLTERMINATED { $$ = qual_createNullTerminated (); }
1237 | CANNOTATION { $$ = qual_createMetaState ($1); }
1240 paramQualifier
1241 : QRETURNED { $$ = qual_createReturned (); }
1242 | QSEF { $$ = qual_createSef (); }
1245 visibilityQualifier
1246 : QUNUSED { $$ = qual_createUnused (); }
1247 | QEXTERNAL { $$ = qual_createExternal (); }
1250 returnQualifier
1251 : QTRUENULL { $$ = qual_createTrueNull (); }
1252 | QFALSENULL { $$ = qual_createFalseNull (); }
1255 typedefQualifier
1256 : QABSTRACT { $$ = qual_createAbstract (); }
1257 | QNUMABSTRACT { $$ = qual_createNumAbstract (); }
1258 | QCONCRETE { $$ = qual_createConcrete (); }
1259 | QMUTABLE { $$ = qual_createMutable (); }
1260 | QIMMUTABLE { $$ = qual_createImmutable (); }
1263 refcountQualifier
1264 : QREFCOUNTED { $$ = qual_createRefCounted (); }
1265 | QREFS { $$ = qual_createRefs (); }
1266 | QKILLREF { $$ = qual_createKillRef (); }
1267 | QRELDEF { $$ = qual_createRelDef (); }
1268 | QNEWREF { $$ = qual_createNewRef (); }
1269 | QTEMPREF { $$ = qual_createTempRef (); }
1272 typeModifier
1273 : QSHORT { $$ = qual_createShort (); }
1274 | QLONG { $$ = qual_createLong (); }
1275 | QSIGNED { $$ = qual_createSigned (); }
1276 | QUNSIGNED { $$ = qual_createUnsigned (); }
1279 definedQualifier
1280 : QOUT { $$ = qual_createOut (); }
1281 | QIN { $$ = qual_createIn (); }
1282 | QPARTIAL { $$ = qual_createPartial (); }
1283 | QSPECIAL { $$ = qual_createSpecial (); }
1286 typeQualifier
1287 : QCONST IsType { $$ = qual_createConst (); }
1288 | QVOLATILE IsType { $$ = qual_createVolatile (); }
1289 | QRESTRICT IsType { $$ = qual_createRestrict (); }
1290 | definedQualifier IsType { $$ = $1; }
1291 | stateQualifier IsType { $$ = $1; }
1292 | exitsQualifier IsType { $$ = $1; }
1293 | paramQualifier IsType { $$ = $1; }
1294 | checkQualifier IsType { $$ = $1; }
1295 | returnQualifier IsType { $$ = $1; }
1296 | visibilityQualifier IsType { $$ = $1; }
1297 | typedefQualifier IsType { $$ = $1; }
1298 | refcountQualifier IsType { $$ = $1; }
1302 ** This is copied into the mtgrammar!
1305 typeSpecifier
1306 : CGCHAR NotType
1307 | CINT NotType
1308 | CBOOL NotType
1309 | CGFLOAT NotType
1310 | CDOUBLE NotType
1311 | CVOID NotType
1312 | QANYTYPE NotType { $$ = ctype_makeAnytype (); }
1313 | QINTEGRALTYPE NotType { $$ = ctype_anyintegral; }
1314 | QUNSIGNEDINTEGRALTYPE NotType { $$ = ctype_unsignedintegral; }
1315 | QSIGNEDINTEGRALTYPE NotType { $$ = ctype_signedintegral; }
1316 | typeName NotType
1317 | suSpc NotType
1318 | enumSpc NotType
1319 | typeModifier NotType { $$ = ctype_fromQual ($1); }
1322 completeType
1323 : IsType completeTypeSpecifier IsType
1324 { $$ = qtype_resolve ($2); }
1327 completeTypeSpecifier
1328 : completeTypeSpecifierAux { $$ = $1; }
1329 | completeTypeSpecifierAux QALT altType QENDMACRO
1330 { $$ = qtype_mergeAlt ($1, $3); }
1333 altType
1334 : typeExpression
1335 | typeExpression TCOMMA altType
1336 { $$ = qtype_mergeAlt ($1, $3); }
1339 completeTypeSpecifierAux
1340 : storageSpecifier optCompleteType { $$ = qtype_addQual ($2, $1); }
1341 | typeQualifier optCompleteType { $$ = qtype_addQual ($2, $1); }
1342 | typeSpecifier optCompleteType { $$ = qtype_combine ($2, $1); }
1345 optCompleteType
1346 : %empty { $$ = qtype_unknown (); }
1347 | completeTypeSpecifier { $$ = $1; }
1350 suSpc
1351 : NotType CSTRUCT newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1352 CreateStructInnerScope
1353 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
1354 TRBRACE
1355 { $$ = declareStruct ($3, $8); }
1356 | NotType CUNION newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1357 CreateStructInnerScope
1358 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
1359 TRBRACE
1360 { $$ = declareUnion ($3, $8); }
1361 | NotType CSTRUCT newId IsType TLBRACE TRBRACE
1362 { $$ = declareStruct ($3, uentryList_new ()); }
1363 | NotType CUNION newId IsType TLBRACE TRBRACE
1364 { $$ = declareUnion ($3, uentryList_new ()); }
1365 | NotType CSTRUCT IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1366 CreateStructInnerScope
1367 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
1368 TRBRACE
1369 { $$ = declareUnnamedStruct ($7); }
1370 | NotType CUNION IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1371 CreateStructInnerScope structDeclList DeleteStructInnerScope
1372 { sRef_clearGlobalScopeSafe (); }
1373 TRBRACE
1374 { $$ = declareUnnamedUnion ($7); }
1375 | NotType CSTRUCT IsType TLBRACE TRBRACE
1376 { $$ = ctype_createUnnamedStruct (uentryList_new ()); }
1377 | NotType CUNION IsType TLBRACE TRBRACE
1378 { $$ = ctype_createUnnamedUnion (uentryList_new ()); }
1379 | NotType CSTRUCT newId NotType { $$ = handleStruct ($3); }
1380 | NotType CUNION newId NotType { $$ = handleUnion ($3); }
1383 NotType
1384 : %empty { cscannerHelp_clearExpectingTypeName (); }
1387 structDeclList
1388 : structDecl
1389 | macroDef { $$ = uentryList_undefined; /* bogus! */ }
1390 | structDeclList structDecl { $$ = uentryList_mergeFields ($1, $2); }
1393 structDecl
1394 : completeTypeSpecifier NotType structNamedDeclList IsType TSEMI
1395 { $$ = fixUentryList ($3, $1); }
1396 | completeTypeSpecifier IsType TSEMI
1397 { $$ = fixUnnamedDecl ($1); }
1400 structNamedDeclList
1401 : structNamedDecl NotType
1402 { $$ = idDeclList_singleton ($1); }
1403 | structNamedDeclList TCOMMA structNamedDecl NotType
1404 { $$ = idDeclList_add ($1, $3); }
1407 structNamedDecl /* hack to get around namespace problems */
1408 : namedDecl { $$ = $1; }
1409 | TCOLON IsType constantExpr { $$ = idDecl_undefined; }
1410 | namedDecl TCOLON IsType constantExpr { $$ = $1; }
1411 /* Need the IsType in case there is a cast in the constant expression. */
1414 enumSpc
1415 : NotType CENUM TLBRACE enumeratorList TRBRACE IsType
1416 { $$ = declareUnnamedEnum ($4); }
1417 | NotType CENUM newId TLBRACE { context_pushLoc (); } enumeratorList TRBRACE IsType
1418 { context_popLoc (); $$ = declareEnum ($3, $6); }
1419 | NotType CENUM newId IsType { $$ = handleEnum ($3); }
1422 enumeratorList
1423 : enumerator
1424 { $$ = enumNameList_single ($1); }
1425 | enumeratorList TCOMMA enumerator
1426 { $$ = enumNameList_push ($1, $3); }
1427 | enumeratorList TCOMMA
1430 enumerator
1431 : newId
1432 { uentry ue = uentry_makeEnumConstant ($1, ctype_unknown);
1433 usymtab_supGlobalEntry (ue);
1434 $$ = $1;
1436 | newId TASSIGN IsType constantExpr NotType
1437 { uentry ue = uentry_makeEnumInitializedConstant ($1, ctype_unknown, $4);
1438 usymtab_supGlobalEntry (ue);
1439 $$ = $1;
1443 optNamedDecl
1444 : namedDeclBase
1445 | optAbstractDeclBase { $$ = idDecl_create (cstring_undefined, qtype_create ($1)); }
1446 | pointers TYPE_NAME
1448 qtype qt = qtype_unknown ();
1449 qtype_adjustPointers ($1, qt);
1450 $$ = idDecl_create (cstring_copy (cscannerHelp_observeLastIdentifier ()), qt);
1452 | pointers optNamedDecl
1453 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
1456 namedDecl
1457 : namedDeclBase
1458 | pointers namedDeclBase
1459 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
1462 genericParamList
1463 : paramTypeList { $$ = handleParamTypeList ($1); }
1464 | NotType paramIdList { $$ = handleParamIdList ($2); }
1467 innerMods
1468 : QCONST { $$ = qual_createConst (); }
1469 | QRESTRICT { $$ = qual_createRestrict (); }
1470 | QVOLATILE { $$ = qual_createVolatile (); }
1473 innerModsList
1474 : innerMods { $$ = qualList_single ($1); }
1475 | innerModsList innerMods { $$ = qualList_add ($1, $2); }
1478 pointers
1479 : TMULT { $$ = pointers_create ($1); }
1480 | TMULT innerModsList { $$ = pointers_createMods ($1, $2); }
1481 | TMULT pointers { $$ = pointers_extend (pointers_create ($1), $2); }
1482 | TMULT innerModsList pointers { $$ = pointers_extend (pointers_createMods ($1, $2), $3); }
1485 paramIdList
1486 : idList
1487 | idList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
1490 idList
1491 : newId { $$ = uentryList_single (uentry_makeVariableLoc ($1, ctype_int)); }
1492 | idList TCOMMA newId { $$ = uentryList_add ($1, uentry_makeVariableLoc ($3, ctype_int)); }
1493 | idList TCOMMA paramDecl
1495 $$ = uentryList_add ($1, $3);
1497 if (!isParamDeclStyleMixed())
1499 setParamDeclStyleMixed ();
1500 llparseerror (cstring_makeLiteral ("Inconsistent function parameter"
1501 " syntax (mixing old and new style declaration)"));
1506 paramTypeList
1507 : CTOK_ELIPSIS { $$ = uentryList_single (uentry_makeElipsisMarker ()); }
1508 | paramList
1509 | paramList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
1512 paramList
1513 : paramDecl { $$ = uentryList_single ($1); }
1514 | paramList TCOMMA paramDecl { $$ = uentryList_add ($1, $3); }
1515 | paramList TCOMMA newId
1517 idDecl tparam = idDecl_create ($3, qtype_unknown ());
1518 $$ = uentryList_add ($1, makeCurrentParam (tparam));
1519 idDecl_free (tparam);
1521 if (!isParamDeclStyleMixed())
1523 setParamDeclStyleMixed ();
1524 llparseerror (cstring_makeLiteral ("Inconsistent function parameter"
1525 " syntax (mixing new and old style declaration)"));
1530 paramDecl
1531 : IsType completeTypeSpecifier optNamedDecl IsType
1532 { $$ = makeCurrentParam (idDecl_fixParamBase ($3, $2)); }
1535 typeExpression
1536 : completeType
1537 | completeType abstractDecl { $$ = qtype_newBase ($1, $2); }
1540 abstractDecl
1541 : pointers { $$ = ctype_adjustPointers ($1, ctype_unknown); }
1542 | abstractDeclBase
1543 | pointers abstractDeclBase { $$ = ctype_adjustPointers ($1, $2); }
1546 optAbstractDeclBase
1547 : %empty { $$ = ctype_unknown; }
1548 | abstractDeclBase
1551 abstractDeclBase
1552 : IsType TLPAREN NotType abstractDecl TRPAREN
1553 { $$ = ctype_expectFunction ($4); }
1554 | TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
1555 | TLSQBR constantExpr TRSQBR
1556 { $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
1557 | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeInnerArray ($1); }
1558 | abstractDeclBase TLSQBR constantExpr TRSQBR
1559 { $$ = ctype_makeInnerFixedArray ($1, exprNode_getLongValue ($3)); }
1560 | IsType TLPAREN TRPAREN
1561 { $$ = ctype_makeFunction (ctype_unknown, uentryList_makeMissingParams ()); }
1562 | IsType TLPAREN paramTypeList TRPAREN
1563 { $$ = ctype_makeParamsFunction (ctype_unknown, $3); }
1564 | abstractDeclBase IsType TLPAREN TRPAREN
1565 { $$ = ctype_makeFunction ($1, uentryList_makeMissingParams ()); }
1566 | abstractDeclBase IsType TLPAREN paramTypeList TRPAREN
1567 { $$ = ctype_makeParamsFunction ($1, $4); }
1570 /* statement */
1572 stmt
1573 : labeledStmt
1574 | caseStmt
1575 | defaultStmt
1576 | compoundStmt
1577 | expressionStmt
1578 | selectionStmt
1579 | iterationStmt
1580 | iterStmt
1581 | jumpStmt
1582 | debugStmt
1585 debugStmt
1586 : QDREVEALSTATE TLPAREN expr TRPAREN { exprNode_revealState ($3); $$ = exprNode_undefined; }
1589 iterBody
1590 : iterDefStmtList
1593 endBody
1594 : iterBody
1597 iterDefStmtList
1598 : iterDefStmt
1599 | iterDefStmtList iterDefStmt
1600 { $$ = exprNode_concat ($1, $2); }
1603 iterDefIterationStmt
1604 : iterWhilePred iterDefStmtList
1605 { $$ = exprNode_while ($1, $2); }
1606 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
1607 { $$ = exprNode_doWhile ($2, $5); }
1608 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
1609 { $$ = exprNode_doWhile ($2, $5); }
1610 | forPred iterDefStmt
1611 { $$ = exprNode_for ($1, $2); }
1614 forPred
1615 : CFOR TLPAREN optInitExpr TSEMI optExpr TSEMI
1616 { context_setProtectVars (); } optExpr { context_sizeofReleaseVars (); }
1617 TRPAREN
1618 { $$ = exprNode_forPred ($3, $5, $8);
1619 context_enterForClause ($5); }
1622 partialIterStmt
1623 : ITER_NAME CreateInnerScope TLPAREN
1624 { setProcessingIterVars ($1); }
1625 iterArgList TRPAREN
1626 { $$ = exprNode_iterStart ($1, $5); }
1627 | ITER_ENDNAME { $$ = exprNode_createId ($1); }
1630 iterDefStmt
1631 : labeledStmt
1632 | caseStmt
1633 | defaultStmt
1634 | openScope initializerList { $$ = $1; }
1635 | openScope
1636 | closeScope
1637 | expressionStmt
1638 | iterSelectionStmt
1639 | iterDefIterationStmt
1640 | partialIterStmt
1641 | jumpStmt
1642 | TLPAREN iterDefStmt TRPAREN { $$ = $2; }
1643 | error { $$ = exprNode_makeError (); }
1646 iterSelectionStmt
1647 : ifPred { exprNode_checkIfPred ($1); } iterDefStmt
1648 { /* don't: context_exitConditionalClause ($1, $2, exprNode_undefined); */
1649 $$ = exprNode_if ($1, $3);
1653 openScope
1654 : CreateInnerScope TLBRACE { $$ = exprNode_createTok ($2); }
1657 closeScope
1658 : DeleteInnerScopeSafe TRBRACE { $$ = exprNode_createTok ($2); }
1661 macroBody
1662 : initStmtListErr
1665 stmtErr
1666 : labeledStmt
1667 | caseStmt
1668 | defaultStmt
1669 | compoundStmtErr
1670 | expressionStmtErr
1671 | selectionStmt
1672 | iterStmt
1673 | iterationStmtErr
1674 | TLPAREN stmtErr TRPAREN { $$ = exprNode_addParens ($1, $2); }
1675 | jumpStmt
1676 | debugStmt
1677 | error { $$ = exprNode_makeError (); }
1680 labeledStmt
1681 : newId TCOLON { $$ = exprNode_labelMarker ($1); }
1682 | QNOTREACHED stmt { $$ = exprNode_notReached ($2); }
1686 ** We allow more than one QFALLTHROUGH token to support mixed lint/splint markers.
1689 fallThroughList
1690 : QFALLTHROUGH
1691 | fallThroughList QFALLTHROUGH
1694 /* Note that we can semantically check that the object to the case is
1695 indeed constant. In this case, we may not want to go through this effort */
1697 caseStmt
1698 : CASE constantExpr { context_enterCaseClause ($2); }
1699 TCOLON { $$ = exprNode_caseMarker ($2, FALSE); }
1700 | fallThroughList CASE constantExpr { context_enterCaseClause ($3); }
1701 TCOLON { $$ = exprNode_caseMarker ($3, TRUE); }
1704 defaultStmt
1705 : DEFAULT { context_enterCaseClause (exprNode_undefined); }
1706 TCOLON { $$ = exprNode_defaultMarker ($1, FALSE); }
1707 | fallThroughList DEFAULT { context_enterCaseClause (exprNode_undefined); }
1708 TCOLON { $$ = exprNode_defaultMarker ($2, TRUE); }
1711 compoundStmt
1712 : TLPAREN compoundStmt TRPAREN { $$ = $2; }
1713 | CreateInnerScope compoundStmtAux
1714 { $$ = $2; context_exitInner ($2); }
1717 compoundStmtErr
1718 : CreateInnerScope compoundStmtAuxErr DeleteInnerScope { $$ = $2; }
1721 CreateInnerScope
1722 : %empty { context_enterInnerContext (); }
1725 DeleteInnerScope
1726 : %empty { context_exitInnerPlain (); }
1729 CreateStructInnerScope
1730 : %empty { context_enterStructInnerContext (); }
1733 DeleteStructInnerScope
1734 : %empty { context_exitStructInnerContext (); }
1737 DeleteInnerScopeSafe
1738 : %empty { context_exitInnerSafe (); }
1741 initStmtList
1742 : initializer
1743 | stmt
1744 | typeDecl { $$ = exprNode_undefined; }
1745 | initStmtList initializer { $$ = exprNode_isDefined ($1) ? exprNode_concat ($1, $2) : $2; }
1746 | initStmtList typeDecl { $$ = $1; }
1747 | initStmtList stmt { $$ = exprNode_isDefined ($1) ? exprNode_concat ($1, $2) : $2; }
1750 compoundStmtAux
1751 : TLBRACE TRBRACE
1752 { $$ = exprNode_makeBlock (exprNode_createTok ($2)); }
1753 | TLBRACE initStmtList TRBRACE
1754 { $$ = exprNode_makeBlock (exprNode_updateLocation ($2, lltok_getLoc ($3))); }
1757 initStmtListErr
1758 : initializer
1759 | stmtErr
1760 | typeDecl { $$ = exprNode_undefined; }
1761 | initStmtListErr initializer { $$ = exprNode_isDefined ($1) ? exprNode_concat ($1, $2) : $2; }
1762 | initStmtListErr typeDecl { $$ = $1; }
1763 | initStmtListErr stmtErr { $$ = exprNode_isDefined ($1) ? exprNode_concat ($1, $2) : $2; }
1766 compoundStmtAuxErr
1767 : TLBRACE TRBRACE
1768 { $$ = exprNode_makeBlock (exprNode_createTok ($2)); }
1769 | TLBRACE initStmtListErr TRBRACE
1770 { $$ = exprNode_makeBlock (exprNode_updateLocation ($2, lltok_getLoc ($3))); }
1773 initializerList
1774 : initializer
1775 | initializerList initializer { $$ = exprNode_concat ($1, $2); }
1778 typeInitializerList
1779 : typeInitializer { $$ = $1; }
1780 | typeInitializerList TCOMMA typeInitializer { $$ = exprNode_concat ($1, $3); }
1783 typeInitializer
1784 : assignExpr { $$ = $1; }
1785 | TLBRACE typeInitializerList optComma TRBRACE { $$ = $2; }
1788 expressionStmt
1789 : TSEMI { $$ = exprNode_createTok ($1); }
1790 | expr TSEMI { $$ = exprNode_statement ($1, $2); }
1793 expressionStmtErr
1794 : TSEMI { $$ = exprNode_createTok ($1); }
1795 | expr TSEMI { $$ = exprNode_statement ($1, $2); }
1796 | expr { $$ = exprNode_checkExpr ($1); }
1799 ifPred
1800 : CIF TLPAREN expr TRPAREN
1802 exprNode_produceGuards ($3); context_enterTrueClause ($3);
1803 exprNode_checkIfPred ($3);
1804 $$ = $3;
1806 /* not ANSI: | CIF TLPAREN compoundStmt TRPAREN { $$ = $3; context_enterTrueClause (); } */
1809 selectionStmt
1810 : ifPred stmt
1812 context_exitConditionalClause ($1, $2, exprNode_undefined);
1813 $$ = exprNode_if ($1, $2);
1815 | ifPred stmt CELSE { context_enterFalseClause ($1); } stmt
1817 context_exitConditionalClause ($1, $2, $5);
1818 $$ = exprNode_ifelse ($1, $2, $5);
1820 | SWITCH TLPAREN expr { context_enterSwitch ($3); }
1821 TRPAREN stmt { $$ = exprNode_switch ($3, $6); }
1824 whilePred
1825 : WHILE TLPAREN expr TRPAREN
1826 { $$ = exprNode_whilePred ($3); context_enterWhileClause ($3); }
1827 /* not ANSI: | WHILE TLPAREN compoundStmt TRPAREN stmt { $$ = exprNode_while ($3, $5); } */
1830 iterWhilePred
1831 : WHILE TLPAREN expr TRPAREN { $$ = exprNode_whilePred($3); }
1834 iterStmt
1835 : ITER_NAME { context_enterIterClause (); }
1836 CreateInnerScope TLPAREN { setProcessingIterVars ($1); }
1837 iterArgList TRPAREN
1838 compoundStmt endIter DeleteInnerScope
1839 { $$ = exprNode_iter ($1, $6, $8, $9); }
1842 iterArgList
1843 : iterArgExpr { $$ = exprNodeList_singleton ($1); }
1844 | iterArgList { nextIterParam (); } TCOMMA iterArgExpr
1845 { $$ = exprNodeList_push ($1, $4); }
1848 iterArgExpr
1849 : assignIterExpr { $$ = exprNode_iterExpr ($1); }
1850 | id { $$ = exprNode_iterId ($1); }
1851 | NEW_IDENTIFIER { $$ = exprNode_iterNewId ($1); }
1855 ** everything is the same, EXCEPT it cannot be a NEW_IDENTIFIER
1858 cconstantExpr
1859 : CCONSTANT
1860 | cconstantExpr CCONSTANT { $$ = exprNode_combineLiterals ($1, $2); }
1863 primaryIterExpr
1864 : cconstantExpr
1865 | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
1868 postfixIterExpr
1869 : primaryIterExpr
1870 | postfixExpr TLSQBR expr TRSQBR { $$ = exprNode_arrayFetch ($1, $3); }
1871 | postfixExpr TLPAREN TRPAREN { $$ = exprNode_functionCall ($1, exprNodeList_new ()); }
1872 | postfixExpr TLPAREN argumentExprList TRPAREN { $$ = exprNode_functionCall ($1, $3); }
1873 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN
1874 { $$ = exprNode_vaArg ($1, $3, $5); }
1875 | postfixExpr NotType TDOT newId IsType { $$ = exprNode_fieldAccess ($1, $3, $4); }
1876 | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
1877 | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
1878 | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
1881 unaryIterExpr
1882 : postfixIterExpr
1883 | INC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
1884 | DEC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
1885 | TAMPERSAND castExpr { $$ = exprNode_preOp ($2, $1); }
1886 | TMULT castExpr { $$ = exprNode_preOp ($2, $1); }
1887 | TPLUS castExpr { $$ = exprNode_preOp ($2, $1); }
1888 | TMINUS castExpr { $$ = exprNode_preOp ($2, $1); }
1889 | TTILDE castExpr { $$ = exprNode_preOp ($2, $1); }
1890 | TEXCL castExpr { $$ = exprNode_preOp ($2, $1); }
1891 | sizeofExpr { $$ = $1; }
1894 castIterExpr
1895 : unaryIterExpr
1896 | TLPAREN typeExpression TRPAREN castExpr { $$ = exprNode_cast ($1, $4, $2); }
1899 timesIterExpr
1900 : castIterExpr
1901 | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
1902 | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
1903 | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
1906 plusIterExpr
1907 : timesIterExpr
1908 | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
1909 | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
1912 shiftIterExpr
1913 : plusIterExpr
1914 | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
1915 | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
1918 relationalIterExpr
1919 : shiftIterExpr
1920 | relationalExpr TLT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
1921 | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
1922 | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
1923 | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
1926 equalityIterExpr
1927 : relationalIterExpr
1928 | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
1929 | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
1932 bitandIterExpr
1933 : equalityIterExpr
1934 | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
1937 xorIterExpr
1938 : bitandIterExpr
1939 | xorExpr TCIRC bitandExpr { $$ = exprNode_op ($1, $3, $2); }
1942 bitorIterExpr
1943 : xorIterExpr
1944 | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
1947 andIterExpr
1948 : bitorIterExpr
1949 | andExpr AND_OP bitorExpr { $$ = exprNode_op ($1, $3, $2); }
1952 orIterExpr
1953 : andIterExpr
1954 | orExpr OR_OP andExpr { $$ = exprNode_op ($1, $3, $2); }
1957 conditionalIterExpr
1958 : orIterExpr
1959 | orExpr TQUEST { context_enterTrueClause ($1); }
1960 TCOLON { context_enterFalseClause ($1); } conditionalExpr
1961 { $$ = exprNode_condIfOmit ($1, $6); }
1962 | orExpr TQUEST { context_enterTrueClause ($1); }
1963 expr TCOLON { context_enterFalseClause ($1); } conditionalExpr
1964 { $$ = exprNode_cond ($1, $4, $7); }
1967 assignIterExpr
1968 : conditionalIterExpr
1969 | unaryExpr TASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1970 | unaryExpr MUL_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1971 | unaryExpr DIV_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1972 | unaryExpr MOD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1973 | unaryExpr ADD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1974 | unaryExpr SUB_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1975 | unaryExpr LEFT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1976 | unaryExpr RIGHT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1977 | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1978 | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1979 | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1982 endIter
1983 : %empty { $$ = uentry_undefined; }
1984 | ITER_ENDNAME { $$ = $1; }
1987 doHeader
1988 : DO { context_enterDoWhileClause (); $$ = $1; }
1991 iterationStmt
1992 : whilePred stmt
1993 { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
1994 | doHeader stmt WHILE TLPAREN expr TRPAREN TSEMI
1995 { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
1996 | { context_enterInnerContext (); } forPred stmt
1997 { $$ = exprNode_for ($2, $3); context_exitForClause ($2, $3); context_exitInnerPlain(); }
2000 iterationStmtErr
2001 : whilePred stmtErr { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
2002 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
2003 { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
2004 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
2005 { $$ = exprNode_doWhile ($2, $5); }
2006 | { context_enterInnerContext (); } forPred stmtErr
2007 { $$ = exprNode_for ($2, $3); context_exitForClause ($2, $3); context_exitInnerPlain(); }
2010 jumpStmt
2011 : GOTO newId TSEMI { $$ = exprNode_goto ($2); }
2012 | CONTINUE TSEMI { $$ = exprNode_continue ($1, BADTOK); }
2013 | QINNERCONTINUE CONTINUE TSEMI
2014 { $$ = exprNode_continue ($1, QINNERCONTINUE); }
2015 | BREAK TSEMI { $$ = exprNode_break ($1, BADTOK); }
2016 | QSWITCHBREAK BREAK TSEMI { $$ = exprNode_break ($2, QSWITCHBREAK); }
2017 | QLOOPBREAK BREAK TSEMI { $$ = exprNode_break ($2, QLOOPBREAK); }
2018 | QINNERBREAK BREAK TSEMI { $$ = exprNode_break ($2, QINNERBREAK); }
2019 | QSAFEBREAK BREAK TSEMI { $$ = exprNode_break ($2, QSAFEBREAK); }
2020 | RETURN TSEMI { $$ = exprNode_nullReturn ($1); }
2021 | RETURN expr TSEMI { $$ = exprNode_return ($2); }
2024 optSemi
2025 : %empty
2026 | TSEMI
2029 optComma
2030 : %empty
2031 | TCOMMA
2035 : IDENTIFIER
2038 newId
2039 : NEW_IDENTIFIER
2040 | ITER_NAME { $$ = uentry_getName ($1); }
2041 | ITER_ENDNAME { $$ = uentry_getName ($1); }
2042 | id { $$ = uentry_getName ($1); }
2045 typeName
2046 : TYPE_NAME
2047 | CTYPEOF TLPAREN expr TRPAREN { $$ = exprNode_getType ($3); exprNode_free ($3); }
2048 | CTYPEOF TLPAREN typeExpression TRPAREN { $$ = qtype_getType ($3); }
2053 # include "bison.reset"
2055 static void
2056 c_error (const /*@unused@*/ char *s)
2058 static bool givehint = FALSE;
2060 if (context_inIterDef ())
2062 llerror (FLG_SYNTAX, message ("Iter syntax not parseable: %s",
2063 context_inFunctionName ()));
2065 else if (context_inIterEnd ())
2067 llerror (FLG_SYNTAX, message ("Iter finalizer syntax not parseable: %s",
2068 context_inFunctionName ()));
2070 else if (context_inMacro ())
2072 llerror (FLG_SYNTAX, message ("Macro syntax not parseable: %s",
2073 context_inFunctionName ()));
2075 if (context_inUnknownMacro ())
2077 if (!givehint)
2079 llhint (cstring_makeLiteral
2080 ("Precede macro definition with /*@notfunction@*/ "
2081 "to suppress checking and force expansion"));
2082 givehint = TRUE;
2086 cscannerHelp_swallowMacro ();
2087 context_exitAllClausesQuiet ();
2089 else
2091 llparseerror (cstring_undefined);