2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
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
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: 157 shift/reduce, 107 reduce/reduce conflicts
51 # include "splintMacros.nf"
53 # include "cscanner.h"
54 # include "cscannerHelp.h"
55 # include "exprChecks.h"
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.
78 %define api.prefix
{c_
}
80 ** %expect for LALR parsers means _NO_ r/r conflicts -- there are lots of them
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
;
136 extern
int c_lex
(void);
137 static void c_error
(const char *);
140 /* standard C tokens */
142 %token
<tok
> BADTOK SKIPTOK
143 %token
<tok
> CTOK_ELIPSIS CASE DEFAULT CIF CELSE SWITCH WHILE DO CFOR
144 %token
<tok
> GOTO CONTINUE BREAK RETURN
145 %token
<tok
> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN
146 %token
<tok
> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
147 %token
<tok
> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
148 %token
<tok
> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
149 %token
<tok
> INC_OP DEC_OP LEFT_OP RIGHT_OP
150 %token
<tok
> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
151 %token
<tok
> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
152 %token
<tok
> LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
153 %token
<tok
> CSTRUCT CUNION CENUM
154 %token
<tok
> VA_ARG VA_DCL
156 %token
<tok
> QGLOBALS
157 %token
<tok
> QMODIFIES
159 %token
<tok
> QCONSTANT
160 %token
<tok
> QFUNCTION
162 %token
<tok
> QDEFINES
164 %token
<tok
> QALLOCATES
166 %token
<tok
> QRELEASES
167 %token
<tok
> QPRECLAUSE
168 %token
<tok
> QPOSTCLAUSE
169 %token
<tok
> QINVARIANT
171 %token
<tok
> QUNDEF QKILLED
172 %token
<tok
> QENDMACRO
174 /* additional tokens introduced by splint pre-processor. */
175 %token
<tok
> LLMACRO LLMACROITER LLMACROEND TENDMACRO
177 /* For debugging purposes */
178 %token
<tok
> QDREVEALSTATE
180 /* break comments: */
181 %token
<tok
> QSWITCHBREAK QLOOPBREAK QINNERBREAK QSAFEBREAK
182 %token
<tok
> QINNERCONTINUE
184 /* case fall-through marker: */
185 %token
<tok
> QFALLTHROUGH
187 /* used in scanner only */
188 %token
<tok
> QLINTNOTREACHED
189 %token
<tok
> QLINTFALLTHROUGH
190 %token
<tok
> QLINTFALLTHRU
191 %token
<tok
> QARGSUSED
192 %token
<tok
> QPRINTFLIKE QLINTPRINTFLIKE QSCANFLIKE QMESSAGELIKE
194 /* not-reached marker: (used like a label) */
195 %token
<tok
> QNOTREACHED
197 /* type qualifiers: */
198 %token
<tok
> QCONST QRESTRICT QVOLATILE QINLINE QEXTENSION QEXTERN QSTATIC QAUTO QREGISTER
199 %token
<tok
> QOUT QIN QYIELD QONLY QTEMP QSHARED QREF QUNIQUE
200 %token
<tok
> QCHECKED QUNCHECKED QCHECKEDSTRICT QCHECKMOD
201 %token
<tok
> QKEEP QKEPT QPARTIAL QSPECIAL QOWNED QDEPENDENT
202 %token
<tok
> QRETURNED QEXPOSED QNULL QOBSERVER QISNULL
203 %token
<tok
> QEXITS QMAYEXIT QNEVEREXIT QTRUEEXIT QFALSEEXIT
204 %token
<tok
> QLONG QSIGNED QUNSIGNED QSHORT QUNUSED QSEF QNOTNULL QRELNULL
205 %token
<tok
> QABSTRACT QNUMABSTRACT QCONCRETE QMUTABLE QIMMUTABLE
206 %token
<tok
> QTRUENULL QFALSENULL QEXTERNAL
207 %token
<tok
> QREFCOUNTED QREFS QNEWREF QTEMPREF QKILLREF QRELDEF
208 %token
<ctyp
> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID
209 %token
<tok
> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
211 %token
<tok
> QNULLTERMINATED
212 %token
<tok
> QSETBUFFERSIZE
213 %token
<tok
> QSETSTRINGLENGTH
215 %token
<tok
> QMAXREAD
216 %token
<tok
> QTESTINRANGE
221 /* identifiers, literals */
222 %token
<entry
> IDENTIFIER
223 %token
<cname
> NEW_IDENTIFIER TYPE_NAME_OR_ID
224 %token
<annotation
> CANNOTATION
225 %token
<expr
> CCONSTANT
227 %type
<flagspec
> flagSpec
228 %type
<expr
> cconstantExpr
229 %token
<entry
> ITER_NAME ITER_ENDNAME
230 %type
<entry
> endIter
232 %type
<funcclauselist
> functionClauses functionClausesPlain
233 %type
<funcclause
> functionClause functionClausePlain
235 %type
<globsclause
> globalsClause globalsClausePlain
236 %type
<modsclause
> modifiesClause modifiesClausePlain nomodsClause
237 %type
<warnclause
> warnClause warnClausePlain optWarnClause
238 %type
<funcclause
> conditionClause conditionClausePlain
239 %type
<stateclause
> stateClause stateClausePlain
240 %type
<msconstraint
> metaStateConstraint
241 %type
<fcnconstraint
> functionConstraint
242 %type
<msspec
> metaStateSpecifier
243 %type
<msexpr
> metaStateExpression
245 %type
<sr
> globId globIdListExpr
246 %type
<globset
> globIdList
248 %token
<ctyp
> TYPE_NAME
249 %token
<msinfo
> METASTATE_NAME
250 %type
<msinfo
> metaStateName
251 %type
<cname
> enumerator newId
/*@-varuse@*/ /* yacc declares yytranslate here */
252 %type
<pointers
> pointers
/*@=varuse@*/
254 %type
<tok
> doHeader stateTag conditionTag startConditionClause
255 %type
<typequal
> exitsQualifier checkQualifier stateQualifier
256 paramQualifier returnQualifier visibilityQualifier
257 typedefQualifier refcountQualifier definedQualifier
259 /* type construction */
260 %type
<ctyp
> abstractDecl abstractDeclBase optAbstractDeclBase
261 %type
<ctyp
> suSpc enumSpc typeName typeSpecifier
263 %type
<ntyp
> namedDecl namedDeclBase optNamedDecl
264 %type
<ntyp
> plainNamedDecl plainNamedDeclBase
265 %type
<ntyp
> structNamedDecl
266 %type
<ntyp
> fcnDefHdrAux plainFcn
268 %type
<oentry
> paramDecl
271 %type
<ntyplist
> structNamedDeclList
273 %type
<entrylist
> genericParamList paramTypeList paramList idList paramIdList
274 %type
<exprlist
> argumentExprList iterArgList
275 %type
<exprlist
> initList namedInitializerList namedInitializerListAux namedInitializerTypeList namedInitializerTypeListAux
276 %type
<flist
> structDeclList structDecl
277 %type
<srset
> locModifies modList specClauseList optSpecClauseList
278 %type
<sr
> mExpr modListExpr specClauseListExpr
281 %type
<con
> BufConstraint
282 %type
<tok
> relationalOp
283 %type
<tok
> BufBinaryOp
284 %type
<tok
> bufferModifier
286 %type
<conE
> BufConstraintExpr
288 %type
<conE
> BufConstraintTerm
289 %type
<sr
> BufConstraintSrefExpr
291 %type
<conL
> BufConstraintList
293 %type
<conL
> optStructInvariant
295 %type
<tok
> BufUnaryOp
297 /*drl 1/6/2002 either /\ or && */
298 %type
<tok
> constraintSeperator
300 %type
<enumnamelist
> enumeratorList
301 %type
<cstringlist
> fieldDesignator
303 %type
<expr
> sizeofExpr sizeofExprAux offsetofExpr
304 %type
<expr
> openScope closeScope
305 %type
<expr
> instanceDecl namedInitializer optDeclarators namedInitializerType
306 %type
<expr
> primaryExpr postfixExpr primaryIterExpr postfixIterExpr
307 %type
<expr
> unaryExpr castExpr timesExpr plusExpr
308 %type
<expr
> unaryIterExpr castIterExpr timesIterExpr plusIterExpr
309 %type
<expr
> shiftExpr relationalExpr equalityExpr bitandExpr
310 %type
<expr
> xorExpr bitorExpr andExpr
311 %type
<expr
> orExpr conditionalExpr assignExpr
312 %type
<expr
> shiftIterExpr relationalIterExpr equalityIterExpr bitandIterExpr
313 %type
<expr
> xorIterExpr bitorIterExpr andIterExpr
314 %type
<expr
> orIterExpr conditionalIterExpr assignIterExpr iterArgExpr
315 %type
<expr
> expr optExpr constantExpr
316 %type
<expr
> init macroBody iterBody endBody partialIterStmt iterSelectionStmt
317 %type
<expr
> stmt stmtList fcnBody iterStmt iterDefStmt iterDefStmtList debugStmt
318 %type
<expr
> labeledStmt caseStmt defaultStmt
319 %type
<expr
> compoundStmt compoundStmtAux compoundStmtRest compoundStmtAuxErr
320 %type
<expr
> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt
321 %type
<expr
> stmtErr stmtListErr compoundStmtErr expressionStmtErr
322 %type
<expr
> iterationStmtErr initializerList typeInitializerList initializer
323 %type
<expr
> ifPred whilePred forPred iterWhilePred typeInitializer
325 %type
<expr
> designator designatorList designation
327 %type
<typequal
> storageSpecifier typeQualifier typeModifier globQual innerMods
328 %type
<tquallist
> optGlobQuals innerModsList
329 %type
<qtyp
> completeType completeTypeSpecifier optCompleteType
330 %type
<qtyp
> completeTypeSpecifierAux altType typeExpression
342 : externalDef
{ context_checkGlobalScope
(); }
343 | externalDefs externalDef
{ context_checkGlobalScope
(); }
347 : fcnDef optSemi
{ uentry_clearDecl
(); }
348 | constantDecl
{ uentry_clearDecl
(); }
349 | fcnDecl
{ uentry_clearDecl
(); }
350 | iterDecl
{ uentry_clearDecl
(); }
351 | macroDef
{ uentry_clearDecl
(); }
352 | initializer
{ uentry_checkDecl
(); exprNode_free
($1); }
353 | TSEMI
{ uentry_clearDecl
(); lltok_free
($1); /* evans 2002-02-08: okay to have a null statement */ }
354 |
error { uentry_clearDecl
(); }
358 : QCONSTANT completeTypeSpecifier NotType namedDecl NotType optSemi IsType QENDMACRO
359 { checkConstant
($2, $4); lltok_free2
($1, $8); }
360 | QCONSTANT completeTypeSpecifier NotType namedDecl NotType TASSIGN IsType init optDeclarators optSemi QENDMACRO
361 { checkValueConstant
($2, $4, $8); lltok_free3
($1, $6, $11); }
365 : QFUNCTION
{ context_enterFunctionHeader
(); } plainFcn optSemi QENDMACRO
367 declareStaticFunction
($3); context_quietExitFunction
();
368 context_exitFunctionHeader
();
369 lltok_free2
($1, $5); /*!*/
376 qtype qint
= qtype_create
(ctype_int
);
377 $$
= idDecl_fixBase
($1, qint
);
380 | completeTypeSpecifier NotType plainNamedDecl
381 { $$
= idDecl_fixBase
($3, $1); }
386 | pointers plainNamedDeclBase
387 { $$
= $2; qtype_adjustPointers
($1, idDecl_getTyp
($$
)); }
391 : newId
{ $$
= idDecl_create
($1, qtype_unknown
()); }
392 | IsType TLPAREN NotType namedDecl IsType TRPAREN
393 { $$
= idDecl_expectFunction
($4); lltok_free2
($2, $6); }
394 | namedDeclBase TLSQBR TRSQBR
395 { $$
= idDecl_replaceCtype
($1, ctype_makeInnerArray
(idDecl_getCtype
($1))); lltok_free2
($2, $3); }
396 | namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
398 exprNode_findValue
($4);
399 idDecl_notExpectingFunction
($1);
401 if
(exprNode_hasValue
($4))
403 $$
= idDecl_replaceCtype
($1, ctype_makeInnerFixedArray
(idDecl_getCtype
($1),
404 exprNode_getLongValue
($4)));
408 $$
= idDecl_replaceCtype
($1, ctype_makeInnerArray
(idDecl_getCtype
($1)));
411 lltok_free2
($2, $5);
413 | namedDeclBase PushType TLPAREN TRPAREN
414 { setCurrentParams
(uentryList_missingParams
); }
416 { /* need to support globals and modifies here! */
417 functionClauseList fcl
;
418 ctype ct
= ctype_makeFunction
(idDecl_getCtype
($1),
419 uentryList_makeMissingParams
());
421 $$
= idDecl_replaceCtype
($1, ct
);
423 /*drl 7/25/01 added*/
424 setImplicitfcnConstraints
();
426 DPRINTF
((message
("namedDeclBase PushType TLPAREN TRPAREN...:\n adding implict constraints to functionClause List: %s",
427 functionClauseList_unparse
($6)
431 fcl
= functionClauseList_setImplicitConstraints
($6);
433 idDecl_addClauses
($$
, fcl
);
435 DPRINTF
((message
("1 added fuctionClause List: %s to the Id",
436 functionClauseList_unparse
(fcl
)
442 lltok_free2
($3, $4);
444 | namedDeclBase PushType TLPAREN genericParamList TRPAREN
445 { setCurrentParams
($4); }
448 functionClauseList fcl
;
449 setImplicitfcnConstraints
();
450 clearCurrentParams
();
451 $$
= idDecl_replaceCtype
($1, ctype_makeFunction
(idDecl_getCtype
($1), $4));
453 DPRINTF
((message
("namedDeclBase PushType TLPAREN genericParamList TRPAREN...:\n adding implict constraints to functionClause List: %s",
454 functionClauseList_unparse
($7)
458 fcl
= functionClauseList_setImplicitConstraints
($7);
460 idDecl_addClauses
($$
, fcl
);
462 DPRINTF
((message
("added fuctionClause List: %s to the Id",
463 functionClauseList_unparse
(fcl
)
469 lltok_free2
($3, $5);
474 : newId
{ $$
= idDecl_create
($1, qtype_unknown
()); }
475 | IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
476 { $$
= idDecl_expectFunction
($4); lltok_free2
($2, $6); }
477 | plainNamedDeclBase TLSQBR TRSQBR
478 { $$
= idDecl_replaceCtype
($1, ctype_makeInnerArray
(idDecl_getCtype
($1)));
479 lltok_free2
($2, $3);
481 | plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
485 if
(exprNode_hasValue
($4)
486 && multiVal_isInt
(exprNode_getValue
($4)))
488 value
= (int) multiVal_forceInt
(exprNode_getValue
($4));
495 $$
= idDecl_replaceCtype
($1, ctype_makeInnerFixedArray
(idDecl_getCtype
($1), value
));
496 lltok_free2
($2, $5);
498 | plainNamedDeclBase PushType TLPAREN TRPAREN
499 { setCurrentParams
(uentryList_missingParams
); }
502 ctype ct
= ctype_makeFunction
(idDecl_getCtype
($1),
503 uentryList_makeMissingParams
());
505 $$
= idDecl_replaceCtype
($1, ct
);
506 idDecl_addClauses
($$
, $6);
508 lltok_free2
($3, $4);
510 | plainNamedDeclBase PushType TLPAREN genericParamList TRPAREN
511 { setCurrentParams
($4); }
514 clearCurrentParams
();
515 $$
= idDecl_replaceCtype
($1, ctype_makeFunction
(idDecl_getCtype
($1), $4));
516 idDecl_addClauses
($$
, $7);
519 /*!! lltok_free2 ($3, $5); */
524 : QITER newId TLPAREN genericParamList TRPAREN
525 { setCurrentParams
($4); } functionClausesPlain
526 { clearCurrentParams
(); } optSemi QENDMACRO
527 { declareCIter
($2, $4);
528 lltok_free3
($1, $3, $5);
533 : LLMACRO macroBody TENDMACRO
{ exprNode_checkMacroBody
($2); lltok_free2
($1, $3); }
534 | LLMACROITER iterBody TENDMACRO
{ exprNode_checkIterBody
($2); lltok_free2
($1, $3); }
535 | LLMACROEND endBody TENDMACRO
{ exprNode_checkIterEnd
($2); lltok_free2
($1, $3);}
536 | LLMACRO TENDMACRO
/* no stmt */ { exprChecks_checkEmptyMacroBody
(); lltok_free2
($1, $2); }
540 : fcnDefHdrAux
{ clabstract_declareFunction
($1); }
544 : metaStateSpecifier TASSIGN metaStateExpression
545 { $$
= metaStateConstraint_create
($1, $3); lltok_free
($2); }
549 : BufConstraintSrefExpr
{ cscannerHelp_expectingMetaStateName
(); } TCOLON metaStateName
550 { cscannerHelp_clearExpectingMetaStateName
();
551 $$
= metaStateSpecifier_create
($1, $4);
554 | CTOK_ELIPSIS
{ cscannerHelp_expectingMetaStateName
(); } TCOLON metaStateName
555 { cscannerHelp_clearExpectingMetaStateName
();
556 $$
= metaStateSpecifier_createElipsis
($4);
557 lltok_free2
($1, $3);
562 : metaStateSpecifier
{ $$
= metaStateExpression_create
($1); }
563 | metaStateSpecifier TBAR metaStateExpression
{ $$
= metaStateExpression_createMerge
($1, $3); lltok_free
($2); }
578 : BufConstraint constraintSeperator BufConstraintList
{ $$
= constraintList_add
($3, $1); }
579 | BufConstraint
{ $$
= constraintList_single
($1); }
583 : BufConstraintExpr relationalOp BufConstraintExpr
{
584 $$
= makeConstraintParse3
($1, $2, $3);
585 DPRINTF
(("Done BufConstraint1\n")); }
601 | BufUnaryOp TLPAREN BufConstraintExpr TRPAREN
{$$
= constraintExpr_parseMakeUnaryOp
($1, $3); DPRINTF
( ("Got BufConstraintExpr UNary Op ") ); }
602 | TLPAREN BufConstraintExpr BufBinaryOp BufConstraintExpr TRPAREN
{
603 DPRINTF
( ("Got BufConstraintExpr BINary Op ") );
604 $$
= constraintExpr_parseMakeBinaryOp
($2, $3, $4); }
608 : BufConstraintSrefExpr
{ $$
= constraintExpr_makeTermsRef
($1);}
609 | CCONSTANT
{ $$
= constraintExpr_makeIntLiteral
(exprNode_getLongValue
($1)); }
612 BufConstraintSrefExpr
614 { /*@-onlytrans@*/ $$
= checkbufferConstraintClausesId
($1); /*@=onlytrans@*/ /*@i523@*/ }
616 { $$
= fixStateClausesId
($1); }
617 | BufConstraintSrefExpr TLSQBR TRSQBR
618 { $$
= sRef_makeAnyArrayFetch
($1); }
619 | BufConstraintSrefExpr TLSQBR CCONSTANT TRSQBR
623 t = cstring_toCharsSafe (exprNode_unparse($3));
626 $$
= sRef_makeArrayFetchKnown
($1, exprNode_getLongValue
($3));
628 | TMULT BufConstraintSrefExpr
629 { $$
= sRef_constructPointer
($2); }
630 | TLPAREN BufConstraintSrefExpr TRPAREN
632 | BufConstraintSrefExpr TDOT newId
633 { cstring_markOwned
($3); $$
= sRef_buildField
($1, $3); }
634 | BufConstraintSrefExpr ARROW_OP newId
635 { cstring_markOwned
($3); $$
= sRef_makeArrow
($1, $3); }
638 | BufConstraintTerm TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
639 | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
640 | TLPAREN specClauseListExpr TRPAREN { $$ = $2; }
641 | specClauseListExpr TDOT newId { cstring_markOwned ($3);
642 $$ = sRef_buildField ($1, $3); }
659 ** Function clauses can appear in any order.
663 : %empty
{ $$
= functionClauseList_new
(); }
664 | functionClause functionClauses
665 { $$
= functionClauseList_prepend
($2, $1); }
669 ** Inside macro definitions, there are no end macros.
673 : %empty
{ $$
= functionClauseList_new
(); }
674 | functionClausePlain functionClausesPlain
675 { $$
= functionClauseList_prepend
($2, $1); }
679 : globalsClause
{ $$
= functionClause_createGlobals
($1); }
680 | modifiesClause
{ $$
= functionClause_createModifies
($1); }
681 | nomodsClause
{ $$
= functionClause_createModifies
($1); }
682 | stateClause
{ $$
= functionClause_createState
($1); }
683 | conditionClause
{ $$
= $1; }
684 | warnClause
{ $$
= functionClause_createWarn
($1); }
688 : globalsClausePlain
{ $$
= functionClause_createGlobals
($1); }
689 | modifiesClausePlain
{ $$
= functionClause_createModifies
($1); }
690 | nomodsClause
{ $$
= functionClause_createModifies
($1); }
691 | stateClausePlain
{ $$
= functionClause_createState
($1); }
692 | conditionClausePlain
{ $$
= $1; }
693 | warnClausePlain
{ $$
= functionClause_createWarn
($1); }
697 : globalsClausePlain QENDMACRO
{ $$
= $1; }
701 : QGLOBALS
{ setProcessingGlobalsList
(); }
704 unsetProcessingGlobals
();
705 $$
= globalsClause_create
($1, $3);
710 : QNOMODS
{ $$
= modifiesClause_createNoMods
($1); }
714 : modifiesClausePlain QENDMACRO
{ $$
= $1; }
720 context_setProtectVars
(); enterParamsTemp
();
721 sRef_setGlobalScopeSafe
();
726 sRef_clearGlobalScopeSafe
();
727 context_releaseVars
();
728 $$
= modifiesClause_create
($1, $3);
734 { $$
= flagSpec_createPlain
($1); }
735 | flagId TBAR flagSpec
736 { $$
= flagSpec_createOr
($1, $3); }
744 : %empty
{ $$
= warnClause_undefined
; }
749 : warnClausePlain QENDMACRO
{ $$
= $1; }
753 : QWARN flagSpec cconstantExpr
755 llassert
(exprNode_knownStringValue
($3));
756 $$
= warnClause_create
($1, $2, cstring_copy
(multiVal_forceString
(exprNode_getValue
($3))));
760 { $$
= warnClause_create
($1, $2, cstring_undefined
); }
764 : globIdListExpr
{ $$
= globSet_single
($1); }
765 | globIdList TCOMMA globIdListExpr
{ $$
= globSet_insert
($1, $3); }
769 : optGlobQuals globId
{ $$
= clabstract_createGlobal
($2, $1); }
773 : %empty
{ $$
= qualList_undefined
; }
774 | globQual optGlobQuals
{ $$
= qualList_add
($2, $1); }
778 : id
{ $$
= uentry_getSref
($1); }
779 | NEW_IDENTIFIER
{ $$
= clabstract_unrecognizedGlobal
($1); }
780 | initializer
{ $$
= clabstract_checkGlobal
($1); }
784 : QUNDEF
{ $$
= qual_createUndef
(); }
785 | QKILLED
{ $$
= qual_createKilled
(); }
786 | QOUT
{ $$
= qual_createOut
(); }
787 | QIN
{ $$
= qual_createIn
(); }
788 | QPARTIAL
{ $$
= qual_createPartial
(); }
807 /**!!! deal with fred; fred (int); declarations! **/
808 qtype qint
= qtype_create
(ctype_int
);
809 $$
= idDecl_fixBase
($1, qint
);
812 | completeTypeSpecifier NotType namedDecl
813 { $$
= idDecl_fixBase
($3, $1); }
817 : TLBRACE
{ checkDoneParams
(); context_enterInnerContext
(); }
820 exprNode_checkFunctionBody
($3); $$
= $3;
821 context_exitInner
($3);
823 |
{ context_enterOldStyleScope
(); } initializerList
824 { oldStyleDoneParams
(); context_enterInnerContext
(); }
827 exprNode_checkFunctionBody
($4);
828 $$
= $4; /* oldstyle */
829 context_exitInner
($4);
836 context_setFunctionDefined
(exprNode_loc
($2));
837 exprNode_checkFunction
(context_getHeader
(), $2);
840 context_exitFunction
();
845 : modList optSemi
{ $$
= $1; }
846 | optSemi
{ $$
= sRefSet_new
(); }
850 : id
{ $$
= uentry_getSref
($1); checkModifiesId
($1); }
851 | NEW_IDENTIFIER
{ $$
= fixModifiesId
($1); }
852 | TYPE_NAME_OR_ID
{ $$
= fixModifiesId
($1); }
853 | modListExpr TLSQBR TRSQBR
{ $$
= modListArrayFetch
($1, sRef_undefined
); }
854 | modListExpr TLSQBR mExpr TRSQBR
{ $$
= modListArrayFetch
($1, $3); }
855 | TMULT modListExpr
{ $$
= modListPointer
($2); }
856 | TLPAREN modListExpr TRPAREN
{ $$
= $2; }
857 | modListExpr TDOT newId
{ $$
= modListFieldAccess
($1, $3); }
858 | modListExpr ARROW_OP newId
{ $$
= modListArrowAccess
($1, $3); }
862 : modListExpr
{ $$
= $1; }
863 | cconstantExpr
{ $$
= sRef_makeUnknown
(); /* sRef_makeConstant ($1); ? */ }
868 : modListExpr
{ $$
= sRefSet_single
($1); }
869 | modList TCOMMA modListExpr
{ $$
= sRefSet_insert
($1, $3); }
874 { $$
= checkStateClausesId
($1); }
876 { $$
= fixStateClausesId
($1); }
877 | specClauseListExpr TLSQBR TRSQBR
{ $$
= sRef_makeAnyArrayFetch
($1); }
878 | specClauseListExpr TLSQBR mExpr TRSQBR
{ $$
= sRef_makeAnyArrayFetch
($1); }
879 | TMULT specClauseListExpr
{ $$
= sRef_constructPointer
($2); }
880 | TLPAREN specClauseListExpr TRPAREN
{ $$
= $2; }
881 | specClauseListExpr TDOT newId
{ cstring_markOwned
($3);
882 $$
= sRef_buildField
($1, $3); }
883 | specClauseListExpr ARROW_OP newId
{ cstring_markOwned
($3);
884 $$
= sRef_makeArrow
($1, $3); }
888 : %empty
{ DPRINTF
((message
("Empty optSpecClauseList") )); $$
= sRefSet_undefined
; }
894 { if
(sRef_isValid
($1)) { $$
= sRefSet_single
($1); }
896 DPRINTF
((message
("returning sRefSEt_undefined ") ));
897 $$
= sRefSet_undefined
; }
899 | specClauseList TCOMMA specClauseListExpr
900 { if
(sRef_isValid
($3))
902 $$
= sRefSet_insert
($1, $3);
912 : id
{ $$
= exprNode_fromIdentifier
($1); }
913 | NEW_IDENTIFIER
{ $$
= exprNode_fromUIO
($1); }
915 | TLPAREN expr TRPAREN
{ $$
= exprNode_addParens
($1, $2); }
916 | TYPE_NAME_OR_ID
{ $$
= exprNode_fromIdentifier
(cscannerHelp_coerceId
($1)); }
917 | QEXTENSION
{ $$
= exprNode_makeError
(); }
918 | TLPAREN
{ exprChecks_inCompoundStatementExpression
(); }
920 { exprChecks_leaveCompoundStatementExpression
(); $$
= exprNode_compoundStatementExpression
($1, $3); }
925 | postfixExpr TLSQBR expr TRSQBR
{ $$
= exprNode_arrayFetch
($1, $3); }
926 | postfixExpr TLPAREN TRPAREN
{ $$
= exprNode_functionCall
($1, exprNodeList_new
()); }
927 | postfixExpr TLPAREN argumentExprList TRPAREN
{ $$
= exprNode_functionCall
($1, $3); }
928 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN
{ $$
= exprNode_vaArg
($1, $3, $5); }
929 | postfixExpr NotType TDOT newId IsType
{ $$
= exprNode_fieldAccess
($1, $3, $4); }
930 | postfixExpr NotType ARROW_OP newId IsType
{ $$
= exprNode_arrowAccess
($1, $3, $4); }
931 | postfixExpr INC_OP
{ $$
= exprNode_postOp
($1, $2); }
932 | postfixExpr DEC_OP
{ $$
= exprNode_postOp
($1, $2); }
933 | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE
934 { /* added for C99 */ $$
= exprNode_undefined
; /*@i87 no checking */ }
938 : assignExpr
{ $$
= exprNodeList_singleton
($1); }
939 | argumentExprList TCOMMA assignExpr
{ $$
= exprNodeList_push
($1, $3); }
944 | INC_OP unaryExpr
{ $$
= exprNode_preOp
($2, $1); }
945 | DEC_OP unaryExpr
{ $$
= exprNode_preOp
($2, $1); }
946 | TAMPERSAND castExpr
{ $$
= exprNode_preOp
($2, $1); }
947 | TMULT castExpr
{ $$
= exprNode_preOp
($2, $1); }
948 | TPLUS castExpr
{ $$
= exprNode_preOp
($2, $1); }
949 | TMINUS castExpr
{ $$
= exprNode_preOp
($2, $1); }
950 | TTILDE castExpr
{ $$
= exprNode_preOp
($2, $1); }
951 | TEXCL castExpr
{ $$
= exprNode_preOp
($2, $1); }
952 | processSizeof sizeofExpr endprocessSizeof
{ $$
= $2; }
953 | offsetofExpr
{ $$
= $1; }
957 : fieldDesignator TDOT newId
{ $$
= cstringList_add
($1, $3); lltok_free
($2); }
958 | fieldDesignator TLSQBR expr TRSQBR
{ $$
= $1; lltok_free2
($2, $4); }
959 /* evans 2002-07-02: offsetof designators can use array indexes */
960 | newId
{ $$
= cstringList_single
($1); }
964 : COFFSETOF IsType TLPAREN typeExpression NotType TCOMMA fieldDesignator TRPAREN IsType
965 { $$
= exprNode_offsetof
($4, $7);
966 lltok_free3
($1, $3, $6); lltok_free
($8); }
970 : IsType
{ context_setProtectVars
(); }
971 sizeofExprAux
{ context_sizeofReleaseVars
(); $$
= $3; }
975 : %empty
{context_enterSizeof
();}
979 : %empty
{context_leaveSizeof
();}
983 : CSIZEOF TLPAREN typeExpression TRPAREN
{ $$
= exprNode_sizeofType
($3); lltok_free3
($1, $2, $4); }
984 | CSIZEOF unaryExpr
{ $$
= exprNode_sizeofExpr
($2); lltok_free
($1); }
985 | CALIGNOF TLPAREN typeExpression TRPAREN
{ $$
= exprNode_alignofType
($3); lltok_free3
($1, $2, $4); }
986 | CALIGNOF unaryExpr
{ $$
= exprNode_alignofExpr
($2); lltok_free
($1); }
993 | TLPAREN typeExpression TRPAREN castExpr
994 { $$
= exprNode_cast
($1, $4, $2); lltok_free
($3); }
999 | timesExpr TMULT castExpr
{ $$
= exprNode_op
($1, $3, $2); }
1000 | timesExpr TDIV castExpr
{ $$
= exprNode_op
($1, $3, $2); }
1001 | timesExpr TPERCENT castExpr
{ $$
= exprNode_op
($1, $3, $2); }
1006 | plusExpr TPLUS timesExpr
{ $$
= exprNode_op
($1, $3, $2); }
1007 | plusExpr TMINUS timesExpr
{ $$
= exprNode_op
($1, $3, $2); }
1012 | shiftExpr LEFT_OP plusExpr
{ $$
= exprNode_op
($1, $3, $2); }
1013 | shiftExpr RIGHT_OP plusExpr
{ $$
= exprNode_op
($1, $3, $2); }
1018 | relationalExpr TLT shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
1019 | relationalExpr TGT shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
1020 | relationalExpr LE_OP shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
1021 | relationalExpr GE_OP shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
1026 | equalityExpr EQ_OP relationalExpr
{ $$
= exprNode_op
($1, $3, $2); }
1027 | equalityExpr NE_OP relationalExpr
{ $$
= exprNode_op
($1, $3, $2); }
1032 | bitandExpr TAMPERSAND equalityExpr
{ $$
= exprNode_op
($1, $3, $2); }
1037 | xorExpr TCIRC bitandExpr
{ $$
= exprNode_op
($1, $3, $2); }
1042 | bitorExpr TBAR xorExpr
{ $$
= exprNode_op
($1, $3, $2); }
1048 { exprNode_produceGuards
($1);
1049 context_enterAndClause
($1);
1053 $$
= exprNode_op
($1, $4, $2);
1054 context_exitAndClause
($$
, $4);
1062 exprNode_produceGuards
($1);
1063 context_enterOrClause
($1);
1067 $$
= exprNode_op
($1, $4, $2);
1068 context_exitOrClause
($$
, $4);
1075 { /* GCC extension: conditional with empty if */
1076 exprNode_produceGuards
($1); context_enterTrueClause
($1); } TCOLON
1077 { context_enterFalseClause
($1); } conditionalExpr
1078 { $$
= exprNode_condIfOmit
($1, $6); context_exitClause
($1, exprNode_undefined
, $6); }
1079 | orExpr TQUEST
{ exprNode_produceGuards
($1); context_enterTrueClause
($1); } expr TCOLON
1080 { context_enterFalseClause
($1); } conditionalExpr
1081 { $$
= exprNode_cond
($1, $4, $7); context_exitClause
($1, $4, $7); }
1086 | unaryExpr TASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1087 | unaryExpr MUL_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1088 | unaryExpr DIV_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1089 | unaryExpr MOD_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1090 | unaryExpr ADD_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1091 | unaryExpr SUB_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1092 | unaryExpr LEFT_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1093 | unaryExpr RIGHT_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1094 | unaryExpr AND_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1095 | unaryExpr XOR_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1096 | unaryExpr OR_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
1101 | expr TCOMMA assignExpr
{ $$
= exprNode_comma
($1, $3); }
1105 : %empty
{ $$
= exprNode_undefined
; }
1113 /* instance_orTypeDecl_and_possible_initialization */
1116 : instanceDecl
{ $$
= $1; }
1117 | VA_DCL
{ doVaDcl
(); $$
= exprNode_makeError
(); }
1118 | typeDecl
{ $$
= exprNode_makeError
(); }
1122 : completeTypeSpecifier IsType TSEMI
1123 { $$
= exprNode_makeError
(); }
1125 ** This causes r/r conflicts with function definitions.
1126 ** Instead we need to snarf one first. (gack)
1128 ** | completeTypeSpecifier { setProcessingVars ($1); }
1130 ** namedInitializerList IsType TSEMI
1131 ** { unsetProcessingVars (); }
1134 ** the solution is pretty ugly:
1136 | completeTypeSpecifier NotType namedDecl NotType
1138 setProcessingVars
($1);
1139 processNamedDecl
($3);
1141 IsType optDeclarators TSEMI IsType
1143 unsetProcessingVars
();
1144 $$
= exprNode_makeEmptyInitialization
($3);
1145 DPRINTF
(("Empty initialization: %s", exprNode_unparse
($$
)));
1147 | completeTypeSpecifier NotType namedDecl NotType TASSIGN
1148 { setProcessingVars
($1); processNamedDecl
($3); }
1149 IsType init optDeclarators TSEMI IsType
1150 { $$
= exprNode_concat
($9, exprNode_makeInitialization
($3, $8));
1151 unsetProcessingVars
();
1155 namedInitializerType
1156 : namedInitializer
{ $$
= $1; }
1157 | TYPE_NAME
{ $$
= exprNode_fromIdentifier
(usymtab_getTypeEntry
(ctype_typeId
($1))); }
1163 processNamedDecl
($1);
1164 $$
= exprNode_makeEmptyInitialization
($1);
1166 | namedDecl NotType TASSIGN
{ processNamedDecl
($1); } IsType init
1167 { $$
= exprNode_makeInitialization
($1, $6); }
1171 : CTYPEDEF completeTypeSpecifier
{ setProcessingTypedef
($2); }
1172 NotType namedInitializerTypeList IsType optWarnClause TSEMI
1173 { clabstract_declareType
($5, $7); }
1174 | CTYPEDEF completeTypeSpecifier IsType TSEMI
{ /* in the ANSI grammar, semantics unclear */ }
1175 | CTYPEDEF namedInitializerList IsType TSEMI
{ /* in the ANSI grammar, semantics unclear */ }
1179 : %empty
{ cscannerHelp_setExpectingTypeName
(); }
1183 : %empty
{ cscannerHelp_setExpectingTypeName
(); context_pushLoc
(); }
1186 namedInitializerList
1187 : namedInitializerListAux IsType
{ $$
= $1; }
1190 namedInitializerListAux
1191 : namedInitializer
{ $$
= exprNodeList_singleton
($1); }
1192 | namedInitializerList TCOMMA NotType namedInitializer
{ $$
= exprNodeList_push
($1, $4); }
1195 namedInitializerTypeList
1196 : namedInitializerTypeListAux IsType
{ $$
= $1; }
1199 namedInitializerTypeListAux
1200 : namedInitializerType
{ $$
= exprNodeList_singleton
($1); }
1201 | namedInitializerTypeList TCOMMA NotType namedInitializerType
{ $$
= exprNodeList_push
($1, $4); }
1205 : %empty
{ $$
= exprNode_makeError
(); }
1206 | optDeclarators TCOMMA NotType namedInitializer
{ $$
= exprNode_concat
($1, $4); }
1211 | TLBRACE initList TRBRACE
{ $$
= exprNode_makeInitBlock
($1, $2); lltok_free
($3); }
1212 | TLBRACE initList TCOMMA TRBRACE
{ $$
= exprNode_makeInitBlock
($1, $2); lltok_free2
($3, $4); }
1213 | designation init
{ $$
= exprNode_undefined
; }
1217 ** Splint parses these (added in ISO C99), but no checking yet...
1221 : designatorList TASSIGN
{ $$
= $1; }
1222 | newId TCOLON
{ $$
= exprNode_undefined
;
1223 /* gcc extension, obsolete since 2.5 */ }
1227 : designator
{ $$
= exprNode_undefined
; }
1228 | designatorList designator
{ $$
= exprNode_undefined
; }
1232 : TLSQBR constantExpr TRSQBR
{ $$
= exprNode_undefined
; }
1233 | TDOT newId
{ $$
= exprNode_undefined
; }
1238 { $$
= exprNodeList_singleton
($1); }
1239 | initList TCOMMA init
1240 { $$
= exprNodeList_push
($1, $3); }
1244 ** need to do the storage class global hack so tags are
1245 ** declared with the right storage class.
1249 : QEXTERN
{ setStorageClass
(SCEXTERN
); $$
= qual_createExtern
(); }
1250 | QINLINE
{ $$
= qual_createInline
(); }
1251 | QSTATIC
{ setStorageClass
(SCSTATIC
); $$
= qual_createStatic
(); }
1252 | QAUTO
{ $$
= qual_createAuto
(); }
1253 | QREGISTER
{ $$
= qual_createRegister
(); }
1257 : stateClausePlain QENDMACRO
{ $$
= $1; }
1263 context_setProtectVars
();
1265 sRef_setGlobalScopeSafe
();
1267 specClauseList optSemi IsType
1270 sRef_clearGlobalScopeSafe
();
1271 context_releaseVars
();
1272 $$
= stateClause_createPlain
($1, $4);
1277 : conditionClausePlain QENDMACRO
{ $$
= $1; }
1280 startConditionClause
1281 : conditionTag NotType
{ $$
= $1; context_enterFunctionHeader
(); }
1284 conditionClausePlain
1285 : startConditionClause stateQualifier
1287 context_exitFunctionHeader
();
1288 context_setProtectVars
();
1290 sRef_setGlobalScopeSafe
();
1292 optSpecClauseList optSemi IsType
1295 sRef_clearGlobalScopeSafe
();
1296 context_releaseVars
();
1297 $$
= functionClause_createState
(stateClause_create
($1, $2, $4));
1299 | startConditionClause
1301 context_setProtectVars
();
1303 sRef_setGlobalScopeSafe
();
1305 functionConstraint optSemi IsType
1307 context_exitFunctionHeader
();
1309 sRef_clearGlobalScopeSafe
();
1310 context_releaseVars
();
1311 DPRINTF
(("done optGlobBufConstraintsAux\n"));
1313 if
(lltok_isEnsures
($1))
1315 $$
= functionClause_createEnsures
($3);
1317 else if
(lltok_isRequires
($1))
1319 $$
= functionClause_createRequires
($3);
1326 DPRINTF
(("FunctionclauseS: %s", functionClause_unparse
($$
)));
1331 : BufConstraintList
{ $$
= functionConstraint_createBufferConstraint
($1); }
1332 | metaStateConstraint
{ $$
= functionConstraint_createMetaStateConstraint
($1); DPRINTF
(("Made constraint: %s", functionConstraint_unparse
($$
))); }
1336 : QEXITS
{ $$
= qual_createExits
(); }
1337 | QMAYEXIT
{ $$
= qual_createMayExit
(); }
1338 | QTRUEEXIT
{ $$
= qual_createTrueExit
(); }
1339 | QFALSEEXIT
{ $$
= qual_createFalseExit
(); }
1340 | QNEVEREXIT
{ $$
= qual_createNeverExit
(); }
1344 : QCHECKED
{ $$
= qual_createChecked
(); }
1345 | QCHECKMOD
{ $$
= qual_createCheckMod
(); }
1346 | QUNCHECKED
{ $$
= qual_createUnchecked
(); }
1347 | QCHECKEDSTRICT
{ $$
= qual_createCheckedStrict
(); }
1351 : QOWNED
{ $$
= qual_createOwned
(); }
1352 | QDEPENDENT
{ $$
= qual_createDependent
(); }
1353 | QYIELD
{ $$
= qual_createYield
(); }
1354 | QTEMP
{ $$
= qual_createTemp
(); }
1355 | QONLY
{ $$
= qual_createOnly
(); }
1356 | QKEEP
{ $$
= qual_createKeep
(); }
1357 | QKEPT
{ $$
= qual_createKept
(); }
1358 | QSHARED
{ $$
= qual_createShared
(); }
1359 | QUNIQUE
{ $$
= qual_createUnique
(); }
1360 | QNULL
{ $$
= qual_createNull
(); }
1361 | QISNULL
{ $$
= qual_createIsNull
(); }
1362 | QRELNULL
{ $$
= qual_createRelNull
(); }
1363 | QNOTNULL
{ $$
= qual_createNotNull
(); }
1364 | QEXPOSED
{ $$
= qual_createExposed
(); }
1365 | QOBSERVER
{ $$
= qual_createObserver
(); }
1366 | QNULLTERMINATED
{ $$
= qual_createNullTerminated
(); }
1367 | CANNOTATION
{ $$
= qual_createMetaState
($1); }
1371 : QRETURNED
{ $$
= qual_createReturned
(); }
1372 | QSEF
{ $$
= qual_createSef
(); }
1376 : QUNUSED
{ $$
= qual_createUnused
(); }
1377 | QEXTERNAL
{ $$
= qual_createExternal
(); }
1381 : QTRUENULL
{ $$
= qual_createTrueNull
(); }
1382 | QFALSENULL
{ $$
= qual_createFalseNull
(); }
1386 : QABSTRACT
{ $$
= qual_createAbstract
(); }
1387 | QNUMABSTRACT
{ $$
= qual_createNumAbstract
(); }
1388 | QCONCRETE
{ $$
= qual_createConcrete
(); }
1389 | QMUTABLE
{ $$
= qual_createMutable
(); }
1390 | QIMMUTABLE
{ $$
= qual_createImmutable
(); }
1394 : QREFCOUNTED
{ $$
= qual_createRefCounted
(); }
1395 | QREFS
{ $$
= qual_createRefs
(); }
1396 | QKILLREF
{ $$
= qual_createKillRef
(); }
1397 | QRELDEF
{ $$
= qual_createRelDef
(); }
1398 | QNEWREF
{ $$
= qual_createNewRef
(); }
1399 | QTEMPREF
{ $$
= qual_createTempRef
(); }
1403 : QSHORT
{ $$
= qual_createShort
(); }
1404 | QLONG
{ $$
= qual_createLong
(); }
1405 | QSIGNED
{ $$
= qual_createSigned
(); }
1406 | QUNSIGNED
{ $$
= qual_createUnsigned
(); }
1410 : QOUT
{ $$
= qual_createOut
(); }
1411 | QIN
{ $$
= qual_createIn
(); }
1412 | QPARTIAL
{ $$
= qual_createPartial
(); }
1413 | QSPECIAL
{ $$
= qual_createSpecial
(); }
1417 : QCONST IsType
{ $$
= qual_createConst
(); }
1418 | QVOLATILE IsType
{ $$
= qual_createVolatile
(); }
1419 | QRESTRICT IsType
{ $$
= qual_createRestrict
(); }
1420 | definedQualifier IsType
{ $$
= $1; }
1421 | stateQualifier IsType
{ $$
= $1; }
1422 | exitsQualifier IsType
{ $$
= $1; }
1423 | paramQualifier IsType
{ $$
= $1; }
1424 | checkQualifier IsType
{ $$
= $1; }
1425 | returnQualifier IsType
{ $$
= $1; }
1426 | visibilityQualifier IsType
{ $$
= $1; }
1427 | typedefQualifier IsType
{ $$
= $1; }
1428 | refcountQualifier IsType
{ $$
= $1; }
1432 ** This is copied into the mtgrammar!
1442 | QANYTYPE NotType
{ $$
= ctype_makeAnytype
(); }
1443 | QINTEGRALTYPE NotType
{ $$
= ctype_anyintegral
; }
1444 | QUNSIGNEDINTEGRALTYPE NotType
{ $$
= ctype_unsignedintegral
; }
1445 | QSIGNEDINTEGRALTYPE NotType
{ $$
= ctype_signedintegral
; }
1449 | typeModifier NotType
{ $$
= ctype_fromQual
($1); }
1453 : IsType completeTypeSpecifier IsType
1454 { $$
= qtype_resolve
($2); }
1457 completeTypeSpecifier
1458 : completeTypeSpecifierAux
{ $$
= $1; }
1459 | completeTypeSpecifierAux QALT altType QENDMACRO
1460 { $$
= qtype_mergeAlt
($1, $3); }
1465 | typeExpression TCOMMA altType
1466 { $$
= qtype_mergeAlt
($1, $3); }
1469 completeTypeSpecifierAux
1470 : storageSpecifier optCompleteType
{ $$
= qtype_addQual
($2, $1); }
1471 | typeQualifier optCompleteType
{ $$
= qtype_addQual
($2, $1); }
1472 | typeSpecifier optCompleteType
{ $$
= qtype_combine
($2, $1); }
1476 : %empty
{ $$
= qtype_unknown
(); }
1477 | completeTypeSpecifier
{ $$
= $1; }
1481 : %empty
{ $$
= constraintList_undefined
; }
1482 /* drl commenting before a CVS commit
1483 | QINVARIANT BufConstraintList QENDMACRO { $$ = $2 }
1488 : NotType CSTRUCT newId IsType TLBRACE
{ sRef_setGlobalScopeSafe
(); }
1489 CreateStructInnerScope
1490 structDeclList DeleteStructInnerScope
{ sRef_clearGlobalScopeSafe
(); }
1493 { ctype ct
; ct
= declareStruct
($3, $8); /* context_setGlobalStructInfo(ct, $12); */ $$
= ct
; }
1494 | NotType CUNION newId IsType TLBRACE
{ sRef_setGlobalScopeSafe
(); }
1495 CreateStructInnerScope
1496 structDeclList DeleteStructInnerScope
{ sRef_clearGlobalScopeSafe
(); }
1498 { $$
= declareUnion
($3, $8); }
1499 | NotType CSTRUCT newId IsType TLBRACE TRBRACE
1500 { $$
= declareStruct
($3, uentryList_new
()); }
1501 | NotType CUNION newId IsType TLBRACE TRBRACE
1502 { $$
= declareUnion
($3, uentryList_new
()); }
1503 | NotType CSTRUCT IsType TLBRACE
{ sRef_setGlobalScopeSafe
(); }
1504 CreateStructInnerScope
1505 structDeclList DeleteStructInnerScope
{ sRef_clearGlobalScopeSafe
(); }
1507 { $$
= declareUnnamedStruct
($7); }
1508 | NotType CUNION IsType TLBRACE
{ sRef_setGlobalScopeSafe
(); }
1509 CreateStructInnerScope structDeclList DeleteStructInnerScope
1510 { sRef_clearGlobalScopeSafe
(); }
1512 { $$
= declareUnnamedUnion
($7); }
1513 | NotType CSTRUCT IsType TLBRACE TRBRACE
1514 { $$
= ctype_createUnnamedStruct
(uentryList_new
()); }
1515 | NotType CUNION IsType TLBRACE TRBRACE
1516 { $$
= ctype_createUnnamedUnion
(uentryList_new
()); }
1517 | NotType CSTRUCT newId NotType
{ $$
= handleStruct
($3); }
1518 | NotType CUNION newId NotType
{ $$
= handleUnion
($3); }
1522 : %empty
{ cscannerHelp_clearExpectingTypeName
(); }
1527 | macroDef
{ $$
= uentryList_undefined
; /* bogus! */ }
1528 | structDeclList structDecl
{ $$
= uentryList_mergeFields
($1, $2); }
1532 : completeTypeSpecifier NotType structNamedDeclList IsType TSEMI
1533 { $$
= fixUentryList
($3, $1); }
1534 | completeTypeSpecifier IsType TSEMI
1535 { $$
= fixUnnamedDecl
($1); }
1539 : structNamedDecl NotType
1540 { $$
= idDeclList_singleton
($1); }
1541 | structNamedDeclList TCOMMA structNamedDecl NotType
1542 { $$
= idDeclList_add
($1, $3); }
1545 structNamedDecl
/* hack to get around namespace problems */
1546 : namedDecl
{ $$
= $1; }
1547 | TCOLON IsType constantExpr
{ $$
= idDecl_undefined
; }
1548 | namedDecl TCOLON IsType constantExpr
{ $$
= $1; }
1549 /* Need the IsType in case there is a cast in the constant expression. */
1553 : NotType CENUM TLBRACE enumeratorList TRBRACE IsType
1554 { $$
= declareUnnamedEnum
($4); }
1555 | NotType CENUM newId TLBRACE
{ context_pushLoc
(); } enumeratorList TRBRACE IsType
1556 { context_popLoc
(); $$
= declareEnum
($3, $6); }
1557 | NotType CENUM newId IsType
{ $$
= handleEnum
($3); }
1562 { $$
= enumNameList_single
($1); }
1563 | enumeratorList TCOMMA enumerator
1564 { $$
= enumNameList_push
($1, $3); }
1565 | enumeratorList TCOMMA
1570 { uentry ue
= uentry_makeEnumConstant
($1, ctype_unknown
);
1571 usymtab_supGlobalEntry
(ue
);
1574 | newId TASSIGN IsType constantExpr
1575 { uentry ue
= uentry_makeEnumInitializedConstant
($1, ctype_unknown
, $4);
1576 usymtab_supGlobalEntry
(ue
);
1583 | optAbstractDeclBase
{ $$
= idDecl_create
(cstring_undefined
, qtype_create
($1)); }
1584 | pointers TYPE_NAME
1586 qtype qt
= qtype_unknown
();
1587 qtype_adjustPointers
($1, qt
);
1588 $$
= idDecl_create
(cstring_copy
(cscannerHelp_observeLastIdentifier
()), qt
);
1590 | pointers optNamedDecl
1591 { $$
= $2; qtype_adjustPointers
($1, idDecl_getTyp
($$
)); }
1596 | pointers namedDeclBase
1597 { $$
= $2; qtype_adjustPointers
($1, idDecl_getTyp
($$
)); }
1601 : paramTypeList
{ $$
= handleParamTypeList
($1); }
1602 | NotType paramIdList
{ $$
= handleParamIdList
($2); }
1606 : QCONST
{ $$
= qual_createConst
(); }
1607 | QRESTRICT
{ $$
= qual_createRestrict
(); }
1608 | QVOLATILE
{ $$
= qual_createVolatile
(); }
1612 : innerMods
{ $$
= qualList_single
($1); }
1613 | innerModsList innerMods
{ $$
= qualList_add
($1, $2); }
1617 : TMULT
{ $$
= pointers_create
($1); }
1618 | TMULT innerModsList
{ $$
= pointers_createMods
($1, $2); }
1619 | TMULT pointers
{ $$
= pointers_extend
(pointers_create
($1), $2); }
1620 | TMULT innerModsList pointers
{ $$
= pointers_extend
(pointers_createMods
($1, $2), $3); }
1625 | idList TCOMMA CTOK_ELIPSIS
{ $$
= uentryList_add
($1, uentry_makeElipsisMarker
()); }
1629 : newId
{ $$
= uentryList_single
(uentry_makeVariableLoc
($1, ctype_int
)); }
1630 | idList TCOMMA newId
{ $$
= uentryList_add
($1, uentry_makeVariableLoc
($3, ctype_int
)); }
1631 | idList TCOMMA paramDecl
1633 $$
= uentryList_add
($1, $3);
1635 if
(!isParamDeclStyleMixed
())
1637 setParamDeclStyleMixed
();
1638 llparseerror
(cstring_makeLiteral
("Inconsistent function parameter syntax (mixing old and new style declaration)"));
1644 : CTOK_ELIPSIS
{ $$
= uentryList_single
(uentry_makeElipsisMarker
()); }
1646 | paramList TCOMMA CTOK_ELIPSIS
{ $$
= uentryList_add
($1, uentry_makeElipsisMarker
()); }
1650 : paramDecl
{ $$
= uentryList_single
($1); }
1651 | paramList TCOMMA paramDecl
{ $$
= uentryList_add
($1, $3); }
1652 | paramList TCOMMA newId
1654 idDecl tparam
= idDecl_create
($3, qtype_unknown
());
1655 $$
= uentryList_add
($1, makeCurrentParam
(tparam
));
1656 idDecl_free
(tparam
);
1658 if
(!isParamDeclStyleMixed
())
1660 setParamDeclStyleMixed
();
1661 llparseerror
(cstring_makeLiteral
("Inconsistent function parameter syntax (mixing new and old style declaration)"));
1667 : IsType completeTypeSpecifier optNamedDecl IsType
1668 { $$
= makeCurrentParam
(idDecl_fixParamBase
($3, $2)); }
1673 | completeType abstractDecl
{ $$
= qtype_newBase
($1, $2); }
1677 : pointers
{ $$
= ctype_adjustPointers
($1, ctype_unknown
); }
1679 | pointers abstractDeclBase
{ $$
= ctype_adjustPointers
($1, $2); }
1683 : %empty
{ $$
= ctype_unknown
; }
1688 : IsType TLPAREN NotType abstractDecl TRPAREN
1689 { $$
= ctype_expectFunction
($4); }
1690 | TLSQBR TRSQBR
{ $$
= ctype_makeArray
(ctype_unknown
); }
1691 | TLSQBR constantExpr TRSQBR
1692 { $$
= ctype_makeFixedArray
(ctype_unknown
, exprNode_getLongValue
($2)); }
1693 | abstractDeclBase TLSQBR TRSQBR
{ $$
= ctype_makeInnerArray
($1); }
1694 | abstractDeclBase TLSQBR constantExpr TRSQBR
1695 { $$
= ctype_makeInnerFixedArray
($1, exprNode_getLongValue
($3)); }
1696 | IsType TLPAREN TRPAREN
1697 { $$
= ctype_makeFunction
(ctype_unknown
, uentryList_makeMissingParams
()); }
1698 | IsType TLPAREN paramTypeList TRPAREN
1699 { $$
= ctype_makeParamsFunction
(ctype_unknown
, $3); }
1700 | abstractDeclBase IsType TLPAREN TRPAREN
1701 { $$
= ctype_makeFunction
($1, uentryList_makeMissingParams
()); }
1702 | abstractDeclBase IsType TLPAREN paramTypeList TRPAREN
1703 { $$
= ctype_makeParamsFunction
($1, $4); }
1722 : QDREVEALSTATE TLPAREN expr TRPAREN
{ exprNode_revealState
($3); $$
= exprNode_undefined
; }
1726 : iterDefStmtList
{ $$
= $1; }
1735 | iterDefStmtList iterDefStmt
1736 { $$
= exprNode_concat
($1, $2); }
1739 iterDefIterationStmt
1740 : iterWhilePred iterDefStmtList
1741 { $$
= exprNode_while
($1, $2); }
1742 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
1743 { $$
= exprNode_doWhile
($2, $5); }
1744 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
1745 { $$
= exprNode_doWhile
($2, $5); }
1746 | forPred iterDefStmt
1747 { $$
= exprNode_for
($1, $2); }
1751 : CFOR TLPAREN optExpr TSEMI optExpr TSEMI
1752 { context_setProtectVars
(); } optExpr
{ context_sizeofReleaseVars
(); }
1754 { $$
= exprNode_forPred
($3, $5, $8);
1755 context_enterForClause
($5); }
1759 : ITER_NAME CreateInnerScope TLPAREN
1760 { setProcessingIterVars
($1); }
1762 { $$
= exprNode_iterStart
($1, $5); }
1763 | ITER_ENDNAME
{ $$
= exprNode_createId
($1); }
1770 | openScope initializerList
{ $$
= $1; DPRINTF
(("def stmt: %s", exprNode_unparse
($$
))); }
1775 | iterDefIterationStmt
1778 | TLPAREN iterDefStmt TRPAREN
{ $$
= $2; }
1779 |
error { $$
= exprNode_makeError
(); }
1783 : ifPred
{ exprNode_checkIfPred
($1); } iterDefStmt
1784 { /* don't: context_exitTrueClause ($1, $2); */
1785 $$
= exprNode_if
($1, $3);
1790 : CreateInnerScope TLBRACE
{ $$
= exprNode_createTok
($2); }
1794 : DeleteInnerScopeSafe TRBRACE
{ $$
= exprNode_createTok
($2); }
1811 | TLPAREN stmtErr TRPAREN
{ $$
= exprNode_addParens
($1, $2); }
1814 |
error { $$
= exprNode_makeError
(); }
1818 : newId TCOLON
{ $$
= exprNode_labelMarker
($1); }
1819 | QNOTREACHED stmt
{ $$
= exprNode_notReached
($2); }
1823 ** We allow more than one QFALLTHROUGH token to support mixed lint/splint markers.
1826 optExtraFallThroughs
1828 | QFALLTHROUGH optExtraFallThroughs
{ ; }
1831 /* Note that we can semantically check that the object to the case is
1832 indeed constant. In this case, we may not want to go through this effort */
1835 : CASE constantExpr
{ context_enterCaseClause
($2); }
1836 TCOLON
{ $$
= exprNode_caseMarker
($2, FALSE
); }
1837 | QFALLTHROUGH optExtraFallThroughs CASE constantExpr
{ context_enterCaseClause
($4); }
1838 TCOLON
{ $$
= exprNode_caseMarker
($4, TRUE
); }
1842 : DEFAULT
{ context_enterCaseClause
(exprNode_undefined
); }
1843 TCOLON
{ $$
= exprNode_defaultMarker
($1, FALSE
); }
1844 | QFALLTHROUGH optExtraFallThroughs DEFAULT
{ context_enterCaseClause
(exprNode_undefined
); }
1845 TCOLON
{ $$
= exprNode_defaultMarker
($3, TRUE
); }
1849 : TLPAREN compoundStmt TRPAREN
{ $$
= $2; }
1850 | CreateInnerScope compoundStmtAux
1851 { $$
= $2; context_exitInner
($2); }
1855 : CreateInnerScope compoundStmtAuxErr DeleteInnerScope
{ $$
= $2; }
1859 : %empty
{ context_enterInnerContext
(); }
1863 : %empty
{ context_exitInnerPlain
(); }
1866 CreateStructInnerScope
1867 : %empty
{ context_enterStructInnerContext
(); }
1870 DeleteStructInnerScope
1871 : %empty
{ context_exitStructInnerContext
(); }
1874 DeleteInnerScopeSafe
1875 : %empty
{ context_exitInnerSafe
(); }
1879 : TRBRACE
{ $$
= exprNode_createTok
($1); }
1880 | QNOTREACHED TRBRACE
{ $$
= exprNode_notReached
(exprNode_createTok
($2)); }
1881 | stmtList TRBRACE
{ $$
= exprNode_updateLocation
($1, lltok_getLoc
($2)); }
1882 | stmtList QNOTREACHED TRBRACE
1883 { $$
= exprNode_notReached
(exprNode_updateLocation
($1, lltok_getLoc
($3))); }
1884 | initializerList TRBRACE
{ $$
= exprNode_updateLocation
($1, lltok_getLoc
($2)); }
1885 | initializerList QNOTREACHED TRBRACE
1886 { $$
= exprNode_notReached
(exprNode_updateLocation
($1, lltok_getLoc
($3))); }
1887 | initializerList stmtList TRBRACE
1888 { $$
= exprNode_updateLocation
(exprNode_concat
($1, $2), lltok_getLoc
($3)); }
1889 | initializerList stmtList QNOTREACHED TRBRACE
1890 { $$
= exprNode_notReached
(exprNode_updateLocation
(exprNode_concat
($1, $2),
1891 lltok_getLoc
($3)));
1896 : TLBRACE compoundStmtRest
1897 { $$
= exprNode_makeBlock
($2); }
1902 { $$
= exprNode_createTok
($2); }
1903 | TLBRACE stmtListErr TRBRACE
1904 { $$
= exprNode_updateLocation
($2, lltok_getLoc
($3)); }
1905 | TLBRACE initializerList TRBRACE
1906 { $$
= exprNode_updateLocation
($2, lltok_getLoc
($3)); }
1907 | TLBRACE initializerList stmtList TRBRACE
1908 { $$
= exprNode_updateLocation
(exprNode_concat
($2, $3), lltok_getLoc
($4)); }
1913 | stmtListErr stmtErr
{ $$
= exprNode_concat
($1, $2); }
1917 : initializer
{ $$
= $1; }
1918 | initializerList initializer
{ $$
= exprNode_concat
($1, $2); }
1922 : typeInitializer
{ $$
= $1; }
1923 | typeInitializerList TCOMMA typeInitializer
{ $$
= exprNode_concat
($1, $3); }
1927 : assignExpr
{ $$
= $1; }
1928 | TLBRACE typeInitializerList optComma TRBRACE
{ $$
= $2; }
1933 | stmtList stmt
{ $$
= exprNode_concat
($1, $2); }
1937 : TSEMI
{ $$
= exprNode_createTok
($1); }
1938 | expr TSEMI
{ $$
= exprNode_statement
($1, $2); }
1942 : TSEMI
{ $$
= exprNode_createTok
($1); }
1943 | expr TSEMI
{ $$
= exprNode_statement
($1, $2); }
1944 | expr
{ $$
= exprNode_checkExpr
($1); }
1948 : CIF TLPAREN expr TRPAREN
1950 exprNode_produceGuards
($3); context_enterTrueClause
($3);
1951 exprNode_checkIfPred
($3);
1956 ** not ANSI: | CIF TLPAREN compoundStmt TRPAREN
1957 ** { $$ = $3; context_enterTrueClause (); }
1964 context_exitTrueClause
($1, $2);
1965 $$
= exprNode_if
($1, $2);
1967 | ifPred stmt CELSE
{ context_enterFalseClause
($1); } stmt
1969 context_exitClause
($1, $2, $5);
1970 $$
= exprNode_ifelse
($1, $2, $5);
1972 | SWITCH TLPAREN expr
{ context_enterSwitch
($3); }
1973 TRPAREN stmt
{ $$
= exprNode_switch
($3, $6); }
1977 : WHILE TLPAREN expr TRPAREN
1978 { $$
= exprNode_whilePred
($3); context_enterWhileClause
($3); }
1979 /* not ANSI: | WHILE TLPAREN compoundStmt TRPAREN stmt { $$ = exprNode_while ($3, $5); } */
1983 : WHILE TLPAREN expr TRPAREN
{ $$
= exprNode_whilePred
($3); }
1987 : ITER_NAME
{ context_enterIterClause
(); }
1988 CreateInnerScope TLPAREN
{ setProcessingIterVars
($1); }
1990 compoundStmt endIter DeleteInnerScope
1992 $$
= exprNode_iter
($1, $6, $8, $9);
1998 : iterArgExpr
{ $$
= exprNodeList_singleton
($1); }
1999 | iterArgList
{ nextIterParam
(); } TCOMMA iterArgExpr
2000 { $$
= exprNodeList_push
($1, $4); }
2004 : assignIterExpr
{ $$
= exprNode_iterExpr
($1); }
2005 | id
{ $$
= exprNode_iterId
($1); }
2006 | TYPE_NAME_OR_ID
{ uentry ue
= cscannerHelp_coerceIterId
($1);
2008 if
(uentry_isValid
(ue
))
2010 $$
= exprNode_iterId
(ue
);
2014 $$
= exprNode_iterNewId
(cstring_copy
(cscannerHelp_observeLastIdentifier
()));
2017 | NEW_IDENTIFIER
{ $$
= exprNode_iterNewId
($1); }
2021 ** everything is the same, EXCEPT it cannot be a NEW_IDENTIFIER
2026 | cconstantExpr CCONSTANT
{ $$
= exprNode_combineLiterals
($1, $2); }
2031 | TLPAREN expr TRPAREN
{ $$
= exprNode_addParens
($1, $2); }
2036 | postfixExpr TLSQBR expr TRSQBR
{ $$
= exprNode_arrayFetch
($1, $3); }
2037 | postfixExpr TLPAREN TRPAREN
{ $$
= exprNode_functionCall
($1, exprNodeList_new
()); }
2038 | postfixExpr TLPAREN argumentExprList TRPAREN
{ $$
= exprNode_functionCall
($1, $3); }
2039 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN
2040 { $$
= exprNode_vaArg
($1, $3, $5); }
2041 | postfixExpr NotType TDOT newId IsType
{ $$
= exprNode_fieldAccess
($1, $3, $4); }
2042 | postfixExpr NotType ARROW_OP newId IsType
{ $$
= exprNode_arrowAccess
($1, $3, $4); }
2043 | postfixExpr INC_OP
{ $$
= exprNode_postOp
($1, $2); }
2044 | postfixExpr DEC_OP
{ $$
= exprNode_postOp
($1, $2); }
2049 | INC_OP unaryExpr
{ $$
= exprNode_preOp
($2, $1); }
2050 | DEC_OP unaryExpr
{ $$
= exprNode_preOp
($2, $1); }
2051 | TAMPERSAND castExpr
{ $$
= exprNode_preOp
($2, $1); }
2052 | TMULT castExpr
{ $$
= exprNode_preOp
($2, $1); }
2053 | TPLUS castExpr
{ $$
= exprNode_preOp
($2, $1); }
2054 | TMINUS castExpr
{ $$
= exprNode_preOp
($2, $1); }
2055 | TTILDE castExpr
{ $$
= exprNode_preOp
($2, $1); }
2056 | TEXCL castExpr
{ $$
= exprNode_preOp
($2, $1); }
2057 | sizeofExpr
{ $$
= $1; }
2062 | TLPAREN typeExpression TRPAREN castExpr
{ $$
= exprNode_cast
($1, $4, $2); }
2067 | timesExpr TMULT castExpr
{ $$
= exprNode_op
($1, $3, $2); }
2068 | timesExpr TDIV castExpr
{ $$
= exprNode_op
($1, $3, $2); }
2069 | timesExpr TPERCENT castExpr
{ $$
= exprNode_op
($1, $3, $2); }
2074 | plusExpr TPLUS timesExpr
{ $$
= exprNode_op
($1, $3, $2); }
2075 | plusExpr TMINUS timesExpr
{ $$
= exprNode_op
($1, $3, $2); }
2080 | shiftExpr LEFT_OP plusExpr
{ $$
= exprNode_op
($1, $3, $2); }
2081 | shiftExpr RIGHT_OP plusExpr
{ $$
= exprNode_op
($1, $3, $2); }
2086 | relationalExpr TLT shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
2087 | relationalExpr TGT shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
2088 | relationalExpr LE_OP shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
2089 | relationalExpr GE_OP shiftExpr
{ $$
= exprNode_op
($1, $3, $2); }
2093 : relationalIterExpr
2094 | equalityExpr EQ_OP relationalExpr
{ $$
= exprNode_op
($1, $3, $2); }
2095 | equalityExpr NE_OP relationalExpr
{ $$
= exprNode_op
($1, $3, $2); }
2100 | bitandExpr TAMPERSAND equalityExpr
{ $$
= exprNode_op
($1, $3, $2); }
2105 | xorExpr TCIRC bitandExpr
{ $$
= exprNode_op
($1, $3, $2); }
2110 | bitorExpr TBAR xorExpr
{ $$
= exprNode_op
($1, $3, $2); }
2115 | andExpr AND_OP bitorExpr
{ $$
= exprNode_op
($1, $3, $2); }
2120 | orExpr OR_OP andExpr
{ $$
= exprNode_op
($1, $3, $2); }
2125 | orExpr TQUEST
{ context_enterTrueClause
($1); }
2126 TCOLON
{ context_enterFalseClause
($1); } conditionalExpr
2127 { $$
= exprNode_condIfOmit
($1, $6); }
2128 | orExpr TQUEST
{ context_enterTrueClause
($1); }
2129 expr TCOLON
{ context_enterFalseClause
($1); } conditionalExpr
2130 { $$
= exprNode_cond
($1, $4, $7); }
2134 : conditionalIterExpr
2135 | unaryExpr TASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2136 | unaryExpr MUL_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2137 | unaryExpr DIV_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2138 | unaryExpr MOD_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2139 | unaryExpr ADD_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2140 | unaryExpr SUB_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2141 | unaryExpr LEFT_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2142 | unaryExpr RIGHT_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2143 | unaryExpr AND_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2144 | unaryExpr XOR_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2145 | unaryExpr OR_ASSIGN assignExpr
{ $$
= exprNode_assign
($1, $3, $2); }
2149 : %empty
{ $$
= uentry_undefined
; }
2150 | ITER_ENDNAME
{ $$
= $1; }
2154 : DO
{ context_enterDoWhileClause
(); $$
= $1; }
2159 { $$
= exprNode_while
($1, $2); context_exitWhileClause
($1, $2); }
2160 | doHeader stmt WHILE TLPAREN expr TRPAREN TSEMI
2161 { $$
= exprNode_statement
(exprNode_doWhile
($2, $5), $7); }
2163 { $$
= exprNode_for
($1, $2); context_exitForClause
($1, $2); }
2167 : whilePred stmtErr
{ $$
= exprNode_while
($1, $2); context_exitWhileClause
($1, $2); }
2168 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
2169 { $$
= exprNode_statement
(exprNode_doWhile
($2, $5), $7); }
2170 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
2171 { $$
= exprNode_doWhile
($2, $5); }
2172 | forPred stmtErr
{ $$
= exprNode_for
($1, $2); context_exitForClause
($1, $2); }
2176 : GOTO newId TSEMI
{ $$
= exprNode_goto
($2); }
2177 | CONTINUE TSEMI
{ $$
= exprNode_continue
($1, BADTOK
); }
2178 | QINNERCONTINUE CONTINUE TSEMI
2179 { $$
= exprNode_continue
($1, QINNERCONTINUE
); }
2180 | BREAK TSEMI
{ $$
= exprNode_break
($1, BADTOK
); }
2181 | QSWITCHBREAK BREAK TSEMI
{ $$
= exprNode_break
($2, QSWITCHBREAK
); }
2182 | QLOOPBREAK BREAK TSEMI
{ $$
= exprNode_break
($2, QLOOPBREAK
); }
2183 | QINNERBREAK BREAK TSEMI
{ $$
= exprNode_break
($2, QINNERBREAK
); }
2184 | QSAFEBREAK BREAK TSEMI
{ $$
= exprNode_break
($2, QSAFEBREAK
); }
2185 | RETURN TSEMI
{ $$
= exprNode_nullReturn
($1); }
2186 | RETURN expr TSEMI
{ $$
= exprNode_return
($2); }
2205 | ITER_NAME
{ $$
= uentry_getName
($1); }
2206 | ITER_ENDNAME
{ $$
= uentry_getName
($1); }
2207 | id
{ $$
= uentry_getName
($1); }
2208 | TYPE_NAME_OR_ID
{ $$
= $1; }
2213 | TYPE_NAME_OR_ID
{ $$
= ctype_unknown
; }
2214 | CTYPEOF TLPAREN expr TRPAREN
{ $$
= exprNode_getType
($3); exprNode_free
($3); }
2215 | CTYPEOF TLPAREN typeExpression TRPAREN
{ $$
= qtype_getType
($3); }
2220 # include "bison.reset"
2223 c_error
(const /*@unused@*/ char *s
)
2225 static bool givehint
= FALSE
;
2227 if
(context_inIterDef
())
2229 llerror
(FLG_SYNTAX
, message
("Iter syntax not parseable: %s",
2230 context_inFunctionName
()));
2232 else if
(context_inIterEnd
())
2234 llerror
(FLG_SYNTAX
, message
("Iter finalizer syntax not parseable: %s",
2235 context_inFunctionName
()));
2237 else if
(context_inMacro
())
2239 llerror
(FLG_SYNTAX
, message
("Macro syntax not parseable: %s",
2240 context_inFunctionName
()));
2242 if
(context_inUnknownMacro
())
2246 llhint
(cstring_makeLiteral
2247 ("Precede macro definition with /*@notfunction@*/ "
2248 "to suppress checking and force expansion"));
2253 cscannerHelp_swallowMacro
();
2254 context_exitAllClausesQuiet
();
2258 llparseerror
(cstring_undefined
);