]> andersk Git - splint.git/blame - src/cgrammar.y
Fixed data on readme.
[splint.git] / src / cgrammar.y
CommitLineData
885824d3 1/*;-*-C-*-;
11db3170 2** Splint - annotation-assisted static program checker
1b8ae690 3** Copyright (C) 1994-2002 University of Virginia,
11db3170 4** Massachusetts Institute of Technology
5**
6** This program is free software; you can redistribute it and/or modify it
7** under the terms of the GNU General Public License as published by the
8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version.
10**
11** This program is distributed in the hope that it will be useful, but
12** WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** General Public License for more details.
15**
16** The GNU General Public License is available from http://www.gnu.org/ or
17** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18** MA 02111-1307, USA.
19**
155af98d 20** For information on splint: info@splint.org
21** To report a bug: splint-bug@splint.org
11db3170 22** For more information: http://www.splint.org
885824d3 23*/
24%{
25/*
26**
27** cgrammar.y
28**
1b8ae690 29** Yacc/Bison grammar for extended ANSI C used by Splint.
885824d3 30**
31** original grammar by Nate Osgood ---
32** hacrat@catfish.lcs.mit.edu Mon Jun 14 13:06:32 1993
33**
1b8ae690 34** changes for Splint --- handle typedef names correctly
885824d3 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
39**
40** production names are cryptic, so more productions fit on one line
41**
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
45*/
46
47/*@=allmacros@*/
48
49extern int yylex ();
b37cf05e 50extern void yyerror (char *);
885824d3 51
1b8ae690 52# include "splintMacros.nf"
885824d3 53# include "basic.h"
08eb3d0e 54# include "cscanner.h"
16c024b5 55# include "cscannerHelp.h"
885824d3 56# include "cgrammar.h"
57# include "exprChecks.h"
58
59/*@-allmacros@*/
60/*@-matchfields@*/
61
62# define SHOWCSYM FALSE
885824d3 63
64/*
65** This is necessary, or else when the bison-generated code #include's malloc.h,
66** there will be a parse error.
67**
68** Unfortunately, it means the error checking on malloc, etc. is lost for allocations
69** in bison-generated files under Win32.
70*/
71
72# ifdef WIN32
73# undef malloc
74# undef calloc
75# undef realloc
76# endif
77
78%}
79
80%union
81{
28bf4b0b 82 lltok tok;
83 int count;
84 qual typequal;
85 qualList tquallist;
86 ctype ctyp;
990ec868 87 /*@dependent@*/ sRef sr;
b37cf05e 88 /*@only@*/ sRef osr;
28bf4b0b 89
90 /*@only@*/ functionClauseList funcclauselist;
91 /*@only@*/ functionClause funcclause;
92 /*@only@*/ flagSpec flagspec;
93 /*@only@*/ globalsClause globsclause;
94 /*@only@*/ modifiesClause modsclause;
95 /*@only@*/ warnClause warnclause;
96 /*@only@*/ stateClause stateclause;
f9264521 97 /*@only@*/ pointers pointers;
3814599d 98 /*@only@*/ functionConstraint fcnconstraint;
99
08eb3d0e 100 /*@only@*/ metaStateConstraint msconstraint;
101 /*@only@*/ metaStateSpecifier msspec;
102 /*@only@*/ metaStateExpression msexpr;
103 /*@observer@*/ metaStateInfo msinfo;
104
28bf4b0b 105 /*@only@*/ sRefList srlist;
106 /*@only@*/ globSet globset;
107 /*@only@*/ qtype qtyp;
108 /*@only@*/ cstring cname;
109 /*@observer@*/ annotationInfo annotation;
110 /*@only@*/ idDecl ntyp;
111 /*@only@*/ idDeclList ntyplist;
112 /*@only@*/ uentryList flist;
113 /*@owned@*/ uentryList entrylist;
114 /*@observer@*/ /*@dependent@*/ uentry entry;
115 /*@only@*/ uentry oentry;
116 /*@only@*/ exprNode expr;
117 /*@only@*/ enumNameList enumnamelist;
e83c79ec 118 /*@only@*/ exprNodeList exprlist;
28bf4b0b 119 /*@only@*/ sRefSet srset;
120 /*@only@*/ cstringList cstringlist;
08eb3d0e 121
103db890 122 /*drl
123 added 1/19/2001
124 */
125 constraint con;
126 constraintList conL;
127 constraintExpr conE;
28bf4b0b 128 /* drl */
885824d3 129}
130
131/* standard C tokens */
132
133%token <tok> BADTOK SKIPTOK
134%token <tok> CTOK_ELIPSIS CASE DEFAULT CIF CELSE SWITCH WHILE DO CFOR
135%token <tok> GOTO CONTINUE BREAK RETURN
136%token <tok> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN
137%token <tok> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
138%token <tok> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
abd7f895 139%token <tok> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
885824d3 140%token <tok> INC_OP DEC_OP LEFT_OP RIGHT_OP
141%token <tok> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
142%token <tok> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
143%token <tok> LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
144%token <tok> CSTRUCT CUNION CENUM
145%token <tok> VA_ARG VA_DCL
28bf4b0b 146%token <tok> QWARN
885824d3 147%token <tok> QGLOBALS
148%token <tok> QMODIFIES
149%token <tok> QNOMODS
150%token <tok> QCONSTANT
151%token <tok> QFUNCTION
152%token <tok> QITER
153%token <tok> QDEFINES
154%token <tok> QUSES
155%token <tok> QALLOCATES
156%token <tok> QSETS
157%token <tok> QRELEASES
158%token <tok> QPRECLAUSE
86d93ed3 159%token <tok> QPOSTCLAUSE
160%token <tok> QINVARIANT
885824d3 161%token <tok> QALT
162%token <tok> QUNDEF QKILLED
163%token <tok> QENDMACRO
164
1b8ae690 165/* additional tokens introduced by splint pre-processor. */
885824d3 166%token <tok> LLMACRO LLMACROITER LLMACROEND TENDMACRO
167
168/* break comments: */
169%token <tok> QSWITCHBREAK QLOOPBREAK QINNERBREAK QSAFEBREAK
170%token <tok> QINNERCONTINUE
171
172/* case fall-through marker: */
173%token <tok> QFALLTHROUGH
174
175/* used in scanner only */
176%token <tok> QLINTNOTREACHED
177%token <tok> QLINTFALLTHROUGH
178%token <tok> QLINTFALLTHRU
179%token <tok> QARGSUSED
180%token <tok> QPRINTFLIKE QLINTPRINTFLIKE QSCANFLIKE QMESSAGELIKE
181
182/* not-reached marker: (used like a label) */
183%token <tok> QNOTREACHED
184
185/* type qualifiers: */
f9264521 186%token <tok> QCONST QRESTRICT QVOLATILE QINLINE QEXTENSION QEXTERN QSTATIC QAUTO QREGISTER
885824d3 187%token <tok> QOUT QIN QYIELD QONLY QTEMP QSHARED QREF QUNIQUE
188%token <tok> QCHECKED QUNCHECKED QCHECKEDSTRICT QCHECKMOD
189%token <tok> QKEEP QKEPT QPARTIAL QSPECIAL QOWNED QDEPENDENT
190%token <tok> QRETURNED QEXPOSED QNULL QOBSERVER QISNULL
191%token <tok> QEXITS QMAYEXIT QNEVEREXIT QTRUEEXIT QFALSEEXIT
192%token <tok> QLONG QSIGNED QUNSIGNED QSHORT QUNUSED QSEF QNOTNULL QRELNULL
e5081f8c 193%token <tok> QABSTRACT QNUMABSTRACT QCONCRETE QMUTABLE QIMMUTABLE
885824d3 194%token <tok> QTRUENULL QFALSENULL QEXTERNAL
195%token <tok> QREFCOUNTED QREFS QNEWREF QTEMPREF QKILLREF QRELDEF
196%token <ctyp> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID
197%token <tok> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
198
93307a76 199%token <tok> QNULLTERMINATED
11ed4f45 200%token <tok> QSETBUFFERSIZE
201%token <tok> QSETSTRINGLENGTH
93307a76 202%token <tok> QMAXSET
203%token <tok> QMAXREAD
a0a162cd 204%token <tok> QTESTINRANGE
11ed4f45 205
dcaf75ea 206%token <tok> TCAND
93307a76 207
208
885824d3 209/* identifiers, literals */
210%token <entry> IDENTIFIER
211%token <cname> NEW_IDENTIFIER TYPE_NAME_OR_ID
28bf4b0b 212%token <annotation> CANNOTATION
213%token <expr> CCONSTANT
214%type <cname> flagId
215%type <flagspec> flagSpec
216%type <expr> cconstantExpr
885824d3 217%token <entry> ITER_NAME ITER_ENDNAME
218%type <entry> endIter
28bf4b0b 219
220%type <funcclauselist> functionClauses functionClausesPlain
221%type <funcclause> functionClause functionClause functionClausePlain
222
223%type <globsclause> globalsClause globalsClausePlain
224%type <modsclause> modifiesClause modifiesClausePlain nomodsClause
e83c79ec 225%type <warnclause> warnClause warnClausePlain optWarnClause
d9a28762 226%type <funcclause> conditionClause conditionClausePlain
28bf4b0b 227%type <stateclause> stateClause stateClausePlain
08eb3d0e 228%type <msconstraint> metaStateConstraint
3814599d 229%type <fcnconstraint> functionConstraint
08eb3d0e 230%type <msspec> metaStateSpecifier
231%type <msexpr> metaStateExpression
28bf4b0b 232
233%type <sr> globId globIdListExpr
234%type <globset> globIdList
235
885824d3 236%token <ctyp> TYPE_NAME
08eb3d0e 237%token <msinfo> METASTATE_NAME
238%type <msinfo> metaStateName
885824d3 239%type <cname> enumerator newId /*@-varuse@*/ /* yacc declares yytranslate here */
f9264521 240%type <pointers> pointers /*@=varuse@*/
885824d3 241
d9a28762 242%type <tok> doHeader stateTag conditionTag startConditionClause
28bf4b0b 243%type <typequal> exitsQualifier checkQualifier stateQualifier
244 paramQualifier returnQualifier visibilityQualifier
245 typedefQualifier refcountQualifier definedQualifier
885824d3 246
247/* type construction */
248%type <ctyp> abstractDecl abstractDeclBase optAbstractDeclBase
249%type <ctyp> suSpc enumSpc typeName typeSpecifier
250
251%type <ntyp> namedDecl namedDeclBase optNamedDecl
252%type <ntyp> plainNamedDecl plainNamedDeclBase
253%type <ntyp> structNamedDecl
254%type <ntyp> fcnDefHdrAux plainFcn
255
256%type <oentry> paramDecl
257%type <entry> id
258
259%type <ntyplist> structNamedDeclList
260
261%type <entrylist> genericParamList paramTypeList paramList idList paramIdList
e83c79ec 262%type <exprlist> argumentExprList iterArgList
3dabb077 263%type <exprlist> initList namedInitializerList namedInitializerListAux namedInitializerTypeList namedInitializerTypeListAux
885824d3 264%type <flist> structDeclList structDecl
28bf4b0b 265%type <srset> locModifies modList specClauseList optSpecClauseList
885824d3 266%type <sr> mExpr modListExpr specClauseListExpr
93307a76 267
268/*drl*/
08eb3d0e 269%type <con> BufConstraint
93307a76 270%type <tok> relationalOp
271%type <tok> BufBinaryOp
272%type <tok> bufferModifier
273
103db890 274%type <conE> BufConstraintExpr
93307a76 275
103db890 276%type <conE> BufConstraintTerm
277%type <sr> BufConstraintSrefExpr
93307a76 278
3814599d 279%type <conL> BufConstraintList
93307a76 280
86d93ed3 281%type <conL> optStructInvariant
282
93307a76 283%type <tok> BufUnaryOp
284
86d93ed3 285/*drl 1/6/2002 either /\ or && */
286%type <tok> constraintSeperator
287
885824d3 288%type <enumnamelist> enumeratorList
289%type <cstringlist> fieldDesignator
290
291%type <expr> sizeofExpr sizeofExprAux offsetofExpr
292%type <expr> openScope closeScope
3dabb077 293%type <expr> instanceDecl namedInitializer optDeclarators namedInitializerType
885824d3 294%type <expr> primaryExpr postfixExpr primaryIterExpr postfixIterExpr
295%type <expr> unaryExpr castExpr timesExpr plusExpr
296%type <expr> unaryIterExpr castIterExpr timesIterExpr plusIterExpr
297%type <expr> shiftExpr relationalExpr equalityExpr bitandExpr
298%type <expr> xorExpr bitorExpr andExpr
299%type <expr> orExpr conditionalExpr assignExpr
300%type <expr> shiftIterExpr relationalIterExpr equalityIterExpr bitandIterExpr
301%type <expr> xorIterExpr bitorIterExpr andIterExpr
302%type <expr> orIterExpr conditionalIterExpr assignIterExpr iterArgExpr
303%type <expr> expr optExpr constantExpr
304%type <expr> init macroBody iterBody endBody partialIterStmt iterSelectionStmt
305%type <expr> stmt stmtList fcnBody iterStmt iterDefStmt iterDefStmtList
306%type <expr> labeledStmt caseStmt defaultStmt
307%type <expr> compoundStmt compoundStmtAux compoundStmtRest compoundStmtAuxErr
308%type <expr> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt
309%type <expr> stmtErr stmtListErr compoundStmtErr expressionStmtErr
abd7f895 310%type <expr> iterationStmtErr initializerList typeInitializerList initializer
311%type <expr> ifPred whilePred forPred iterWhilePred typeInitializer
885824d3 312
1214340e 313%type <expr> designator designatorList designation
314
f9264521 315%type <typequal> storageSpecifier typeQualifier typeModifier globQual innerMods
316%type <tquallist> optGlobQuals innerModsList
885824d3 317%type <qtyp> completeType completeTypeSpecifier optCompleteType
318%type <qtyp> completeTypeSpecifierAux altType typeExpression
319
320%start file
321
322%%
323
324file
325 :
326 | externalDefs
2f2892c2 327 ;
885824d3 328
329externalDefs
b7e84605 330 : externalDef { context_checkGlobalScope (); }
331 | externalDefs externalDef { context_checkGlobalScope (); }
2f2892c2 332 ;
885824d3 333
334externalDef
335 : fcnDef optSemi { uentry_clearDecl (); }
336 | constantDecl { uentry_clearDecl (); }
337 | fcnDecl { uentry_clearDecl (); }
338 | iterDecl { uentry_clearDecl (); }
339 | macroDef { uentry_clearDecl (); }
340 | initializer { uentry_checkDecl (); exprNode_free ($1); }
6fcd0b1e 341 | TSEMI { uentry_clearDecl (); lltok_free ($1); /* evans 2002-02-08: okay to have a null statement */ }
885824d3 342 | error { uentry_clearDecl (); }
2f2892c2 343 ;
885824d3 344
345constantDecl
346 : QCONSTANT completeTypeSpecifier NotType namedDecl NotType optSemi IsType QENDMACRO
6fcd0b1e 347 { checkConstant ($2, $4); lltok_free2 ($1, $8); }
885824d3 348 | QCONSTANT completeTypeSpecifier NotType namedDecl NotType TASSIGN IsType init optDeclarators optSemi QENDMACRO
6fcd0b1e 349 { checkValueConstant ($2, $4, $8); lltok_free3 ($1, $6, $11); }
2f2892c2 350;
885824d3 351
352fcnDecl
28bf4b0b 353 : QFUNCTION { context_enterFunctionHeader (); } plainFcn optSemi QENDMACRO
354 {
355 declareStaticFunction ($3); context_quietExitFunction ();
356 context_exitFunctionHeader ();
6fcd0b1e 357 lltok_free2 ($1, $5); /*!*/
28bf4b0b 358 }
2f2892c2 359;
885824d3 360
361plainFcn
362 : plainNamedDecl
363 {
364 qtype qint = qtype_create (ctype_int);
365 $$ = idDecl_fixBase ($1, qint);
366 qtype_free (qint);
367 }
368 | completeTypeSpecifier NotType plainNamedDecl
369 { $$ = idDecl_fixBase ($3, $1); }
2f2892c2 370;
885824d3 371
372plainNamedDecl
373 : plainNamedDeclBase
374 | pointers plainNamedDeclBase
375 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
2f2892c2 376;
885824d3 377
378namedDeclBase
379 : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
380 | IsType TLPAREN NotType namedDecl IsType TRPAREN
6fcd0b1e 381 { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
885824d3 382 | namedDeclBase TLSQBR TRSQBR
6fcd0b1e 383 { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); lltok_free2 ($2, $3); }
885824d3 384 | namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
e5f31c00 385 {
e8b84478 386 exprNode_findValue ($4);
387 idDecl_notExpectingFunction ($1);
388
7534721d 389 if (exprNode_hasValue ($4))
390 {
077d4458 391 $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1),
392 exprNode_getLongValue ($4)));
7534721d 393 }
394 else
395 {
393e573f 396 $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
7534721d 397 }
6fcd0b1e 398
399 lltok_free2 ($2, $5);
885824d3 400 }
401 | namedDeclBase PushType TLPAREN TRPAREN
28bf4b0b 402 { setCurrentParams (uentryList_missingParams); }
403 functionClauses
885824d3 404 { /* need to support globals and modifies here! */
4287634e 405 functionClauseList fcl;
885824d3 406 ctype ct = ctype_makeFunction (idDecl_getCtype ($1),
407 uentryList_makeMissingParams ());
28bf4b0b 408
885824d3 409 $$ = idDecl_replaceCtype ($1, ct);
312c9815 410
d30bc0c7 411 /*drl 7/25/01 added*/
412 setImplictfcnConstraints();
312c9815 413
4287634e 414 DPRINTF((message("namedDeclBase PushType TLPAREN TRPAREN...:\n adding implict constraints to functionClause List: %s",
415 functionClauseList_unparse($6)
416 )
417 ));
418
419 fcl = functionClauseList_setImplictConstraints($6);
420
421 idDecl_addClauses ($$, fcl);
422
423 DPRINTF((message("1 added fuctionClause List: %s to the Id",
424 functionClauseList_unparse(fcl)
425 )
426 ));
312c9815 427
4287634e 428
312c9815 429 context_popLoc ();
6fcd0b1e 430 lltok_free2 ($3, $4);
885824d3 431 }
432 | namedDeclBase PushType TLPAREN genericParamList TRPAREN
28bf4b0b 433 { setCurrentParams ($4); }
434 functionClauses
312c9815 435 {
4287634e 436 functionClauseList fcl;
312c9815 437 setImplictfcnConstraints ();
470b7798 438 clearCurrentParams ();
885824d3 439 $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
4287634e 440
441 DPRINTF((message("namedDeclBase PushType TLPAREN genericParamList TRPAREN...:\n adding implict constraints to functionClause List: %s",
442 functionClauseList_unparse($7)
443 )
444 )) ;
445
446 fcl = functionClauseList_setImplictConstraints($7);
447
448 idDecl_addClauses ($$, fcl);
449
450 DPRINTF((message("added fuctionClause List: %s to the Id",
451 functionClauseList_unparse(fcl)
452 )
453 ));
454
455
4ab867d6 456 context_popLoc ();
6fcd0b1e 457 lltok_free2 ($3, $5);
885824d3 458 }
2f2892c2 459;
885824d3 460
461plainNamedDeclBase
462 : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
463 | IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
6fcd0b1e 464 { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
885824d3 465 | plainNamedDeclBase TLSQBR TRSQBR
6fcd0b1e 466 { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
467 lltok_free2 ($2, $3);
468 }
885824d3 469 | plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
470 {
471 int value;
472
473 if (exprNode_hasValue ($4)
474 && multiVal_isInt (exprNode_getValue ($4)))
475 {
476 value = (int) multiVal_forceInt (exprNode_getValue ($4));
477 }
478 else
479 {
480 value = 0;
481 }
482
393e573f 483 $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), value));
6fcd0b1e 484 lltok_free2 ($2, $5);
885824d3 485 }
486 | plainNamedDeclBase PushType TLPAREN TRPAREN
28bf4b0b 487 { setCurrentParams (uentryList_missingParams); }
488 functionClausesPlain
489 {
885824d3 490 ctype ct = ctype_makeFunction (idDecl_getCtype ($1),
491 uentryList_makeMissingParams ());
28bf4b0b 492
885824d3 493 $$ = idDecl_replaceCtype ($1, ct);
28bf4b0b 494 idDecl_addClauses ($$, $6);
885824d3 495 context_popLoc ();
6fcd0b1e 496 lltok_free2 ($3, $4);
885824d3 497 }
498 | plainNamedDeclBase PushType TLPAREN genericParamList TRPAREN
28bf4b0b 499 { setCurrentParams ($4); }
500 functionClausesPlain
501 {
502 clearCurrentParams ();
885824d3 503 $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
28bf4b0b 504 idDecl_addClauses ($$, $7);
885824d3 505 context_popLoc ();
6fcd0b1e 506 lltok_free ($3);
507 /*!! lltok_free2 ($3, $5); */
885824d3 508 }
2f2892c2 509;
885824d3 510
511iterDecl
512 : QITER newId TLPAREN genericParamList TRPAREN
28bf4b0b 513 { setCurrentParams ($4); } functionClausesPlain
885824d3 514 { clearCurrentParams (); } optSemi QENDMACRO
6fcd0b1e 515 { declareCIter ($2, $4);
516 lltok_free3 ($1, $3, $5);
517 }
2f2892c2 518;
885824d3 519
520macroDef
6fcd0b1e 521 : LLMACRO macroBody TENDMACRO { exprNode_checkMacroBody ($2); lltok_free2 ($1, $3); }
522 | LLMACROITER iterBody TENDMACRO { exprNode_checkIterBody ($2); lltok_free2 ($1, $3); }
523 | LLMACROEND endBody TENDMACRO { exprNode_checkIterEnd ($2); lltok_free2 ($1, $3);}
524 | LLMACRO TENDMACRO /* no stmt */ { exprChecks_checkEmptyMacroBody (); lltok_free2 ($1, $2); }
2f2892c2 525;
885824d3 526
527fcnDefHdr
08eb3d0e 528 : fcnDefHdrAux { clabstract_declareFunction ($1); }
2f2892c2 529;
08eb3d0e 530
531metaStateConstraint
532 : metaStateSpecifier TASSIGN metaStateExpression
6fcd0b1e 533 { $$ = metaStateConstraint_create ($1, $3); lltok_free ($2); }
2f2892c2 534;
08eb3d0e 535
536metaStateSpecifier
16c024b5 537 : BufConstraintSrefExpr { cscannerHelp_expectingMetaStateName (); } TCOLON metaStateName
538 { cscannerHelp_clearExpectingMetaStateName ();
6fcd0b1e 539 $$ = metaStateSpecifier_create ($1, $4);
540 lltok_free ($3);
541 }
16c024b5 542 | CTOK_ELIPSIS { cscannerHelp_expectingMetaStateName (); } TCOLON metaStateName
543 { cscannerHelp_clearExpectingMetaStateName ();
6fcd0b1e 544 $$ = metaStateSpecifier_createElipsis ($4);
545 lltok_free2 ($1, $3);
546 }
2f2892c2 547;
08eb3d0e 548
549metaStateExpression
550: metaStateSpecifier { $$ = metaStateExpression_create ($1); }
6fcd0b1e 551| metaStateSpecifier TBAR metaStateExpression { $$ = metaStateExpression_createMerge ($1, $3); lltok_free ($2); }
2f2892c2 552;
08eb3d0e 553
554metaStateName
555: METASTATE_NAME
2f2892c2 556;
93307a76 557
558/*drl*/
559
86d93ed3 560constraintSeperator
561: TCAND
562| AND_OP
2f2892c2 563;
86d93ed3 564
93307a76 565BufConstraintList
86d93ed3 566: BufConstraint constraintSeperator BufConstraintList { $$ = constraintList_add ($3, $1); }
3814599d 567| BufConstraint { $$ = constraintList_single ($1); }
2f2892c2 568;
93307a76 569
570BufConstraint
dcaf75ea 571: BufConstraintExpr relationalOp BufConstraintExpr {
93307a76 572 $$ = makeConstraintParse3 ($1, $2, $3);
ef2aa32a 573 DPRINTF(("Done BufConstraint1\n")); }
2f2892c2 574;
93307a76 575
576bufferModifier
577 : QMAXSET
d9a28762 578 | QMAXREAD
2f2892c2 579;
93307a76 580
581relationalOp
582 : GE_OP
583 | LE_OP
584 | EQ_OP
2f2892c2 585;
93307a76 586
587BufConstraintExpr
588 : BufConstraintTerm
34f0c5e7 589 | BufUnaryOp TLPAREN BufConstraintExpr TRPAREN {$$ = constraintExpr_parseMakeUnaryOp ($1, $3); DPRINTF( ("Got BufConstraintExpr UNary Op ") ); }
93307a76 590 | TLPAREN BufConstraintExpr BufBinaryOp BufConstraintExpr TRPAREN {
34f0c5e7 591 DPRINTF( ("Got BufConstraintExpr BINary Op ") );
93307a76 592 $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
2f2892c2 593;
93307a76 594
595BufConstraintTerm
b9904f57 596 : BufConstraintSrefExpr { $$ = constraintExpr_makeTermsRef ($1);}
597 | CCONSTANT { $$ = constraintExpr_makeIntLiteral (exprNode_getLongValue ($1)); }
2f2892c2 598;
103db890 599
600BufConstraintSrefExpr
08eb3d0e 601: id
602 { /*@-onlytrans@*/ $$ = checkbufferConstraintClausesId ($1); /*@=onlytrans@*/ /*@i523@*/ }
603| NEW_IDENTIFIER
604 { $$ = fixStateClausesId ($1); }
605| BufConstraintSrefExpr TLSQBR TRSQBR
606 { $$ = sRef_makeAnyArrayFetch ($1); }
607| BufConstraintSrefExpr TLSQBR CCONSTANT TRSQBR
608 {
609 /*
610 char *t; int c;
611 t = cstring_toCharsSafe (exprNode_unparse($3));
612 c = atoi( t );
613 */
614 $$ = sRef_makeArrayFetchKnown ($1, exprNode_getLongValue ($3));
615 }
616| TMULT BufConstraintSrefExpr
617 { $$ = sRef_constructPointer ($2); }
618| TLPAREN BufConstraintSrefExpr TRPAREN
619 { $$ = $2; }
620| BufConstraintSrefExpr TDOT newId
621 { cstring_markOwned ($3); $$ = sRef_buildField ($1, $3); }
622| BufConstraintSrefExpr ARROW_OP newId
623 { cstring_markOwned ($3); $$ = sRef_makeArrow ($1, $3); }
103db890 624
625/*
626| BufConstraintTerm TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
627 | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
628 | TLPAREN specClauseListExpr TRPAREN { $$ = $2; }
629 | specClauseListExpr TDOT newId { cstring_markOwned ($3);
630 $$ = sRef_buildField ($1, $3); }
631*/
2f2892c2 632;
103db890 633
93307a76 634/*BufConstraintExpr
635: BufConstraintTerm
636*/
637
638BufUnaryOp
639: bufferModifier
640;
641
642BufBinaryOp
643 : TPLUS
644| TMINUS
645;
28bf4b0b 646/*
647** Function clauses can appear in any order.
648*/
93307a76 649
28bf4b0b 650functionClauses
651 : { $$ = functionClauseList_new (); }
652 | functionClause functionClauses
653 { $$ = functionClauseList_prepend ($2, $1); }
2f2892c2 654;
93307a76 655
28bf4b0b 656/*
657** Inside macro definitions, there are no end macros.
658*/
93307a76 659
28bf4b0b 660functionClausesPlain
661 :
662 { $$ = functionClauseList_new (); }
663 | functionClausePlain functionClausesPlain
664 { $$ = functionClauseList_prepend ($2, $1); }
2f2892c2 665;
28bf4b0b 666
667functionClause
668 : globalsClause { $$ = functionClause_createGlobals ($1); }
669 | modifiesClause { $$ = functionClause_createModifies ($1); }
670 | nomodsClause { $$ = functionClause_createModifies ($1); }
671 | stateClause { $$ = functionClause_createState ($1); }
d9a28762 672 | conditionClause { $$ = $1; }
28bf4b0b 673 | warnClause { $$ = functionClause_createWarn ($1); }
2f2892c2 674;
28bf4b0b 675
676functionClausePlain
677 : globalsClausePlain { $$ = functionClause_createGlobals ($1); }
678 | modifiesClausePlain { $$ = functionClause_createModifies ($1); }
679 | nomodsClause { $$ = functionClause_createModifies ($1); }
680 | stateClausePlain { $$ = functionClause_createState ($1); }
d9a28762 681 | conditionClausePlain { $$ = $1; }
28bf4b0b 682 | warnClausePlain { $$ = functionClause_createWarn ($1); }
2f2892c2 683;
28bf4b0b 684
685globalsClause
686 : globalsClausePlain QENDMACRO { $$ = $1; }
2f2892c2 687;
28bf4b0b 688
689globalsClausePlain
690 : QGLOBALS { setProcessingGlobalsList (); }
691 globIdList optSemi
692 {
693 unsetProcessingGlobals ();
694 $$ = globalsClause_create ($1, $3);
695 }
2f2892c2 696;
93307a76 697
28bf4b0b 698nomodsClause
699 : QNOMODS { $$ = modifiesClause_createNoMods ($1); }
2f2892c2 700;
93307a76 701
28bf4b0b 702modifiesClause
703 : modifiesClausePlain QENDMACRO { $$ = $1; }
2f2892c2 704;
38496f11 705
28bf4b0b 706modifiesClausePlain
707 : QMODIFIES
708 {
709 context_setProtectVars (); enterParamsTemp ();
710 sRef_setGlobalScopeSafe ();
711 }
712 locModifies
713 {
714 exitParamsTemp ();
715 sRef_clearGlobalScopeSafe ();
716 context_releaseVars ();
717 $$ = modifiesClause_create ($1, $3);
718 }
2f2892c2 719;
93307a76 720
28bf4b0b 721flagSpec
722 : flagId
723 { $$ = flagSpec_createPlain ($1); }
724 | flagId TBAR flagSpec
725 { $$ = flagSpec_createOr ($1, $3); }
2f2892c2 726;
885824d3 727
28bf4b0b 728flagId
729 : NEW_IDENTIFIER
2f2892c2 730;
885824d3 731
e83c79ec 732optWarnClause
733 : warnClause
734 | /* empty */ { $$ = warnClause_undefined; }
2f2892c2 735;
e83c79ec 736
28bf4b0b 737warnClause
738 : warnClausePlain QENDMACRO { $$ = $1; }
2f2892c2 739;
28bf4b0b 740
741warnClausePlain
742 : QWARN flagSpec cconstantExpr
6970c11b 743 {
744 llassert (exprNode_knownStringValue ($3));
745 $$ = warnClause_create ($1, $2, cstring_copy (multiVal_forceString (exprNode_getValue ($3))));
746 exprNode_free ($3);
747 }
28bf4b0b 748 | QWARN flagSpec
6970c11b 749 { $$ = warnClause_create ($1, $2, cstring_undefined); }
2f2892c2 750;
885824d3 751
885824d3 752globIdList
28bf4b0b 753 : globIdListExpr { $$ = globSet_single ($1); }
754 | globIdList TCOMMA globIdListExpr { $$ = globSet_insert ($1, $3); }
2f2892c2 755;
885824d3 756
757globIdListExpr
28bf4b0b 758 : optGlobQuals globId { $$ = clabstract_createGlobal ($2, $1); }
2f2892c2 759;
28bf4b0b 760
761optGlobQuals
762 : /* empty */ { $$ = qualList_undefined; }
763 | globQual optGlobQuals { $$ = qualList_add ($2, $1); }
2f2892c2 764;
885824d3 765
766globId
767 : id { $$ = uentry_getSref ($1); }
28bf4b0b 768 | NEW_IDENTIFIER { $$ = clabstract_unrecognizedGlobal ($1); }
769 | initializer { $$ = clabstract_checkGlobal ($1); }
2f2892c2 770;
885824d3 771
772globQual
773 : QUNDEF { $$ = qual_createUndef (); }
774 | QKILLED { $$ = qual_createKilled (); }
775 | QOUT { $$ = qual_createOut (); }
776 | QIN { $$ = qual_createIn (); }
777 | QPARTIAL { $$ = qual_createPartial (); }
2f2892c2 778;
885824d3 779
28bf4b0b 780stateTag
885824d3 781 : QDEFINES
782 | QUSES
783 | QALLOCATES
784 | QSETS
785 | QRELEASES
2f2892c2 786;
885824d3 787
28bf4b0b 788conditionTag
885824d3 789 : QPRECLAUSE
790 | QPOSTCLAUSE
2f2892c2 791;
885824d3 792
885824d3 793fcnDefHdrAux
794 : namedDecl
795 {
01a8227e 796 /**!!! deal with fred; fred (int); declarations! **/
797 qtype qint = qtype_create (ctype_int);
885824d3 798 $$ = idDecl_fixBase ($1, qint);
799 qtype_free (qint);
800 }
801 | completeTypeSpecifier NotType namedDecl
802 { $$ = idDecl_fixBase ($3, $1); }
2f2892c2 803;
885824d3 804
805fcnBody
806 : TLBRACE { checkDoneParams (); context_enterInnerContext (); }
807 compoundStmtRest
808 {
809 exprNode_checkFunctionBody ($3); $$ = $3;
810 context_exitInner ($3);
811 }
7ebcc5bb 812 | { context_enterOldStyleScope (); } initializerList
813 { oldStyleDoneParams (); context_enterInnerContext (); }
885824d3 814 compoundStmt
815 {
7ebcc5bb 816 exprNode_checkFunctionBody ($4);
817 $$ = $4; /* oldstyle */
818 context_exitInner ($4);
885824d3 819 }
2f2892c2 820;
885824d3 821
822fcnDef
823 : fcnDefHdr fcnBody
824 {
825 context_setFunctionDefined (exprNode_loc ($2));
dfd82dce 826 exprNode_checkFunction (context_getHeader (), $2);
4cccc6ad 827 /* DRL 8 8 2000 */
828
885824d3 829 context_exitFunction ();
830 }
2f2892c2 831;
885824d3 832
833locModifies
885824d3 834 : modList optSemi { $$ = $1; }
835 | optSemi { $$ = sRefSet_new (); }
2f2892c2 836;
885824d3 837
838modListExpr
839 : id { $$ = uentry_getSref ($1); checkModifiesId ($1); }
840 | NEW_IDENTIFIER { $$ = fixModifiesId ($1); }
2f2892c2 841 | TYPE_NAME_OR_ID { $$ = fixModifiesId ($1); }
885824d3 842 | modListExpr TLSQBR TRSQBR { $$ = modListArrayFetch ($1, sRef_undefined); }
843 | modListExpr TLSQBR mExpr TRSQBR { $$ = modListArrayFetch ($1, $3); }
844 | TMULT modListExpr { $$ = modListPointer ($2); }
845 | TLPAREN modListExpr TRPAREN { $$ = $2; }
846 | modListExpr TDOT newId { $$ = modListFieldAccess ($1, $3); }
847 | modListExpr ARROW_OP newId { $$ = modListArrowAccess ($1, $3); }
2f2892c2 848;
885824d3 849
850mExpr
28bf4b0b 851 : modListExpr { $$ = $1; }
852 | cconstantExpr { $$ = sRef_makeUnknown (); /* sRef_makeConstant ($1); ? */ }
885824d3 853 /* arithmetic? */
2f2892c2 854;
885824d3 855
856modList
857 : modListExpr { $$ = sRefSet_single ($1); }
858 | modList TCOMMA modListExpr { $$ = sRefSet_insert ($1, $3); }
2f2892c2 859;
885824d3 860
861specClauseListExpr
862 : id
28bf4b0b 863 { $$ = checkStateClausesId ($1); }
885824d3 864 | NEW_IDENTIFIER
28bf4b0b 865 { $$ = fixStateClausesId ($1); }
885824d3 866 | specClauseListExpr TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
867 | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
868 | TMULT specClauseListExpr { $$ = sRef_constructPointer ($2); }
869 | TLPAREN specClauseListExpr TRPAREN { $$ = $2; }
870 | specClauseListExpr TDOT newId { cstring_markOwned ($3);
871 $$ = sRef_buildField ($1, $3); }
872 | specClauseListExpr ARROW_OP newId { cstring_markOwned ($3);
873 $$ = sRef_makeArrow ($1, $3); }
2f2892c2 874;
885824d3 875
28bf4b0b 876optSpecClauseList
877 : /* empty */ { $$ = sRefSet_undefined }
878 | specClauseList
2f2892c2 879 ;
28bf4b0b 880
885824d3 881specClauseList
882 : specClauseListExpr
883 { if (sRef_isValid ($1)) { $$ = sRefSet_single ($1); }
884 else { $$ = sRefSet_undefined; }
885 }
886 | specClauseList TCOMMA specClauseListExpr
887 { if (sRef_isValid ($3))
888 {
889 $$ = sRefSet_insert ($1, $3);
890 }
891 else
892 {
893 $$ = $1;
894 }
895 }
2f2892c2 896;
885824d3 897
898primaryExpr
899 : id { $$ = exprNode_fromIdentifier ($1); }
900 | NEW_IDENTIFIER { $$ = exprNode_fromUIO ($1); }
28bf4b0b 901 | cconstantExpr
885824d3 902 | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
16c024b5 903 | TYPE_NAME_OR_ID { $$ = exprNode_fromIdentifier (cscannerHelp_coerceId ($1)); }
885824d3 904 | QEXTENSION { $$ = exprNode_makeError (); }
abd7f895 905 | TLPAREN { exprChecks_inCompoundStatementExpression (); }
906 compoundStmt TRPAREN
907 { exprChecks_leaveCompoundStatementExpression (); $$ = exprNode_compoundStatementExpression ($1, $3); }
2f2892c2 908;
885824d3 909
910postfixExpr
911 : primaryExpr
912 | postfixExpr TLSQBR expr TRSQBR { $$ = exprNode_arrayFetch ($1, $3); }
913 | postfixExpr TLPAREN TRPAREN { $$ = exprNode_functionCall ($1, exprNodeList_new ()); }
914 | postfixExpr TLPAREN argumentExprList TRPAREN { $$ = exprNode_functionCall ($1, $3); }
915 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN { $$ = exprNode_vaArg ($1, $3, $5); }
28bf4b0b 916 | postfixExpr NotType TDOT newId IsType { $$ = exprNode_fieldAccess ($1, $3, $4); }
917 | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
885824d3 918 | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
919 | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
abd7f895 920 | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE
921 { /* added for C99 */ $$ = exprNode_undefined; /*@i87 no checking */ }
2f2892c2 922;
abd7f895 923
885824d3 924argumentExprList
925 : assignExpr { $$ = exprNodeList_singleton ($1); }
926 | argumentExprList TCOMMA assignExpr { $$ = exprNodeList_push ($1, $3); }
2f2892c2 927;
885824d3 928
929unaryExpr
930 : postfixExpr
931 | INC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
932 | DEC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
933 | TAMPERSAND castExpr { $$ = exprNode_preOp ($2, $1); }
934 | TMULT castExpr { $$ = exprNode_preOp ($2, $1); }
935 | TPLUS castExpr { $$ = exprNode_preOp ($2, $1); }
936 | TMINUS castExpr { $$ = exprNode_preOp ($2, $1); }
937 | TTILDE castExpr { $$ = exprNode_preOp ($2, $1); }
938 | TEXCL castExpr { $$ = exprNode_preOp ($2, $1); }
939 | sizeofExpr { $$ = $1; }
940 | offsetofExpr { $$ = $1; }
2f2892c2 941;
885824d3 942
943fieldDesignator
6fcd0b1e 944 : fieldDesignator TDOT newId { $$ = cstringList_add ($1, $3); lltok_free ($2); }
945 | fieldDesignator TLSQBR expr TRSQBR { $$ = $1; lltok_free2 ($2, $4); }
ce7034f0 946 /* evans 2002-07-02: offsetof designators can use array indexes */
947 | newId { $$ = cstringList_single ($1); }
2f2892c2 948;
885824d3 949
950offsetofExpr
951 : COFFSETOF IsType TLPAREN typeExpression NotType TCOMMA fieldDesignator TRPAREN IsType
6fcd0b1e 952 { $$ = exprNode_offsetof ($4, $7);
953 lltok_free3 ($1, $3, $6); lltok_free ($8); }
2f2892c2 954;
885824d3 955
956sizeofExpr
957 : IsType { context_setProtectVars (); }
958 sizeofExprAux { context_sizeofReleaseVars (); $$ = $3; }
2f2892c2 959;
885824d3 960
961sizeofExprAux
6fcd0b1e 962 : CSIZEOF TLPAREN typeExpression TRPAREN { $$ = exprNode_sizeofType ($3); lltok_free3 ($1, $2, $4); }
963 | CSIZEOF unaryExpr { $$ = exprNode_sizeofExpr ($2); lltok_free ($1); }
964 | CALIGNOF TLPAREN typeExpression TRPAREN { $$ = exprNode_alignofType ($3); lltok_free3 ($1, $2, $4); }
965 | CALIGNOF unaryExpr { $$ = exprNode_alignofExpr ($2); lltok_free ($1); }
2f2892c2 966;
885824d3 967
968castExpr
969 : unaryExpr
970 | TLPAREN typeExpression TRPAREN castExpr
6fcd0b1e 971 { $$ = exprNode_cast ($1, $4, $2); lltok_free ($3); }
2f2892c2 972;
885824d3 973
974timesExpr
975 : castExpr
976 | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
977 | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
978 | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 979;
885824d3 980
981plusExpr
982 : timesExpr
983 | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
984 | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 985;
885824d3 986
987shiftExpr
988 : plusExpr
989 | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
990 | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 991;
885824d3 992
993relationalExpr
994 : shiftExpr
995 | relationalExpr TLT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
996 | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
997 | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
998 | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 999;
885824d3 1000
1001equalityExpr
1002 : relationalExpr
1003 | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
1004 | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 1005;
885824d3 1006
1007bitandExpr
1008 : equalityExpr
1009 | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 1010;
885824d3 1011
1012xorExpr
1013 : bitandExpr
1014 | xorExpr TCIRC bitandExpr { $$ = exprNode_op ($1, $3, $2); }
1015;
1016
1017bitorExpr
1018 : xorExpr
1019 | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 1020;
885824d3 1021
1022andExpr
1023 : bitorExpr
1024 | andExpr AND_OP
1025 { exprNode_produceGuards ($1);
1026 context_enterAndClause ($1);
1027 }
1028 bitorExpr
1029 {
1030 $$ = exprNode_op ($1, $4, $2);
1031 context_exitAndClause ($$, $4);
1032 }
2f2892c2 1033;
885824d3 1034
1035orExpr
1036 : andExpr
1037 | orExpr OR_OP
1038 {
1039 exprNode_produceGuards ($1);
1040 context_enterOrClause ($1);
1041 }
1042 andExpr
1043 {
1044 $$ = exprNode_op ($1, $4, $2);
1045 context_exitOrClause ($$, $4);
1046 }
2f2892c2 1047;
885824d3 1048
1049conditionalExpr
1050 : orExpr
1051 | orExpr TQUEST { exprNode_produceGuards ($1); context_enterTrueClause ($1); } expr TCOLON
1052 { context_enterFalseClause ($1); } conditionalExpr
1053 { $$ = exprNode_cond ($1, $4, $7); context_exitClause ($1, $4, $7); }
2f2892c2 1054;
885824d3 1055
1056assignExpr
1057 : conditionalExpr
1058 | unaryExpr TASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1059 | unaryExpr MUL_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1060 | unaryExpr DIV_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1061 | unaryExpr MOD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1062 | unaryExpr ADD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1063 | unaryExpr SUB_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1064 | unaryExpr LEFT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1065 | unaryExpr RIGHT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1066 | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1067 | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
1068 | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2f2892c2 1069;
885824d3 1070
1071expr
1072 : assignExpr
1073 | expr TCOMMA assignExpr { $$ = exprNode_comma ($1, $3); }
2f2892c2 1074;
885824d3 1075
1076optExpr
1077 : /* empty */ { $$ = exprNode_undefined; }
1078 | expr
2f2892c2 1079 ;
885824d3 1080
1081constantExpr
1082 : conditionalExpr
2f2892c2 1083;
885824d3 1084
1085/* instance_orTypeDecl_and_possible_initialization */
1086
1087initializer
1088 : instanceDecl { $$ = $1; }
1089 | VA_DCL { doVaDcl (); $$ = exprNode_makeError (); }
1090 | typeDecl { $$ = exprNode_makeError (); }
2f2892c2 1091;
885824d3 1092
1093instanceDecl
28bf4b0b 1094 : completeTypeSpecifier IsType TSEMI
f9264521 1095 { $$ = exprNode_makeError (); }
1096 /*
885824d3 1097 ** This causes r/r conflicts with function definitions.
1098 ** Instead we need to snarf one first. (gack)
1099 **
1100 ** | completeTypeSpecifier { setProcessingVars ($1); }
1101 ** NotType
1102 ** namedInitializerList IsType TSEMI
1103 ** { unsetProcessingVars (); }
1104 **;
1105 **
1106 ** the solution is pretty ugly:
1107 */
1108 | completeTypeSpecifier NotType namedDecl NotType
1109 {
28bf4b0b 1110 setProcessingVars ($1);
1111 processNamedDecl ($3);
1112 }
1113 IsType optDeclarators TSEMI IsType
1114 {
1115 unsetProcessingVars ();
1116 $$ = exprNode_makeEmptyInitialization ($3);
1117 DPRINTF (("Empty initialization: %s", exprNode_unparse ($$)));
1118 }
885824d3 1119 | completeTypeSpecifier NotType namedDecl NotType TASSIGN
28bf4b0b 1120 { setProcessingVars ($1); processNamedDecl ($3); }
885824d3 1121 IsType init optDeclarators TSEMI IsType
1122 { $$ = exprNode_concat ($9, exprNode_makeInitialization ($3, $8));
1123 unsetProcessingVars ();
1124 }
2f2892c2 1125;
28bf4b0b 1126
3dabb077 1127namedInitializerType
1128 : namedInitializer { $$ = $1; }
1129 | TYPE_NAME { $$ = exprNode_fromIdentifier (usymtab_getTypeEntry (ctype_typeId ($1))); }
1130;
1131
885824d3 1132namedInitializer
28bf4b0b 1133 : namedDecl NotType
1134 {
1135 processNamedDecl ($1);
1136 $$ = exprNode_makeEmptyInitialization ($1);
1137 }
885824d3 1138 | namedDecl NotType TASSIGN { processNamedDecl ($1); } IsType init
1139 { $$ = exprNode_makeInitialization ($1, $6); }
2f2892c2 1140;
885824d3 1141
885824d3 1142typeDecl
1143 : CTYPEDEF completeTypeSpecifier { setProcessingTypedef ($2); }
3dabb077 1144 NotType namedInitializerTypeList IsType optWarnClause TSEMI
e83c79ec 1145 { clabstract_declareType ($5, $7); }
885824d3 1146 | CTYPEDEF completeTypeSpecifier IsType TSEMI { /* in the ANSI grammar, semantics unclear */ }
1147 | CTYPEDEF namedInitializerList IsType TSEMI { /* in the ANSI grammar, semantics unclear */ }
2f2892c2 1148;
885824d3 1149
1150IsType
16c024b5 1151 : { cscannerHelp_setExpectingTypeName (); }
2f2892c2 1152;
885824d3 1153
1154PushType
16c024b5 1155 : { cscannerHelp_setExpectingTypeName (); context_pushLoc (); }
2f2892c2 1156;
885824d3 1157
1158namedInitializerList
e83c79ec 1159 : namedInitializerListAux IsType { $$ = $1; }
2f2892c2 1160;
885824d3 1161
1162namedInitializerListAux
e83c79ec 1163 : namedInitializer { $$ = exprNodeList_singleton ($1); }
1164 | namedInitializerList TCOMMA NotType namedInitializer { $$ = exprNodeList_push ($1, $4); }
2f2892c2 1165;
885824d3 1166
3dabb077 1167namedInitializerTypeList
1168 : namedInitializerTypeListAux IsType { $$ = $1; }
1169;
1170
1171namedInitializerTypeListAux
1172 : namedInitializerType { $$ = exprNodeList_singleton ($1); }
1173 | namedInitializerTypeList TCOMMA NotType namedInitializerType { $$ = exprNodeList_push ($1, $4); }
1174;
1175
885824d3 1176optDeclarators
1177 : /* empty */ { $$ = exprNode_makeError (); }
1178 | optDeclarators TCOMMA NotType namedInitializer { $$ = exprNode_concat ($1, $4); }
2f2892c2 1179;
885824d3 1180
1181init
28bf4b0b 1182 : assignExpr
6fcd0b1e 1183 | TLBRACE initList TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); lltok_free ($3); }
1184 | TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); lltok_free2 ($3, $4); }
1214340e 1185 | designation init { $$ = exprNode_undefined; }
2f2892c2 1186;
1214340e 1187
1188/*
1189** Splint parses these (added in ISO C99), but no checking yet...
1190*/
1191
1192designation
1193 : designatorList TASSIGN { $$ = $1; }
1194 | newId TCOLON { $$ = exprNode_undefined;
1195 /* gcc extension, obsolete since 2.5 */ }
2f2892c2 1196;
1214340e 1197
1198designatorList
1199 : designator { $$ = exprNode_undefined; }
1200 | designatorList designator { $$ = exprNode_undefined; }
2f2892c2 1201;
885824d3 1202
1214340e 1203designator
1204 : TLSQBR constantExpr TRSQBR { $$ = exprNode_undefined; }
1205 | TDOT newId { $$ = exprNode_undefined; }
2f2892c2 1206;
885824d3 1207
1208initList
1209 : init
1210 { $$ = exprNodeList_singleton ($1); }
1211 | initList TCOMMA init
1212 { $$ = exprNodeList_push ($1, $3); }
2f2892c2 1213;
885824d3 1214
1215/*
1216** need to do the storage class global hack so tags are
1217** declared with the right storage class.
1218*/
1219
1220storageSpecifier
1221 : QEXTERN { setStorageClass (SCEXTERN); $$ = qual_createExtern (); }
1222 | QINLINE { $$ = qual_createInline (); }
1223 | QSTATIC { setStorageClass (SCSTATIC); $$ = qual_createStatic (); }
1224 | QAUTO { $$ = qual_createAuto (); }
1225 | QREGISTER { $$ = qual_createRegister (); }
2f2892c2 1226;
885824d3 1227
28bf4b0b 1228stateClause
1229 : stateClausePlain QENDMACRO { $$ = $1; }
2f2892c2 1230;
28bf4b0b 1231
1232stateClausePlain
1233 : stateTag NotType
1234 {
1235 context_setProtectVars ();
1236 enterParamsTemp ();
1237 sRef_setGlobalScopeSafe ();
1238 }
1239 specClauseList optSemi IsType
1240 {
1241 exitParamsTemp ();
1242 sRef_clearGlobalScopeSafe ();
1243 context_releaseVars ();
1244 $$ = stateClause_createPlain ($1, $4);
1245 }
2f2892c2 1246;
28bf4b0b 1247
1248conditionClause
1249 : conditionClausePlain QENDMACRO { $$ = $1; }
2f2892c2 1250;
28bf4b0b 1251
d9a28762 1252startConditionClause
1253: conditionTag NotType { $$ = $1; context_enterFunctionHeader (); }
2f2892c2 1254;
d9a28762 1255
28bf4b0b 1256conditionClausePlain
d9a28762 1257 : startConditionClause stateQualifier
28bf4b0b 1258 {
1259 context_exitFunctionHeader ();
1260 context_setProtectVars ();
1261 enterParamsTemp ();
1262 sRef_setGlobalScopeSafe ();
1263 }
1264 optSpecClauseList optSemi IsType
1265 {
1266 exitParamsTemp ();
1267 sRef_clearGlobalScopeSafe ();
1268 context_releaseVars ();
d9a28762 1269 $$ = functionClause_createState (stateClause_create ($1, $2, $4));
1270 }
1271 | startConditionClause
1272 {
1273 context_setProtectVars ();
1274 enterParamsTemp ();
1275 sRef_setGlobalScopeSafe ();
1276 }
3814599d 1277 functionConstraint optSemi IsType
d9a28762 1278 {
1279 context_exitFunctionHeader ();
1280 exitParamsTemp ();
1281 sRef_clearGlobalScopeSafe ();
1282 context_releaseVars ();
1283 DPRINTF (("done optGlobBufConstraintsAux\n"));
1284
1285 if (lltok_isEnsures ($1))
1286 {
1287 $$ = functionClause_createEnsures ($3);
1288 }
1289 else if (lltok_isRequires ($1))
1290 {
1291 $$ = functionClause_createRequires ($3);
1292 }
1293 else
1294 {
1295 BADBRANCH;
1296 }
ba45e1e4 1297
1298 DPRINTF (("FunctionclauseS: %s", functionClause_unparse ($$)));
08eb3d0e 1299 }
2f2892c2 1300;
08eb3d0e 1301
3814599d 1302functionConstraint
1303 : BufConstraintList { $$ = functionConstraint_createBufferConstraint ($1); }
ba45e1e4 1304 | metaStateConstraint { $$ = functionConstraint_createMetaStateConstraint ($1); DPRINTF (("Made constraint: %s", functionConstraint_unparse ($$))); }
2f2892c2 1305;
28bf4b0b 1306
1307exitsQualifier
1308 : QEXITS { $$ = qual_createExits (); }
1309 | QMAYEXIT { $$ = qual_createMayExit (); }
1310 | QTRUEEXIT { $$ = qual_createTrueExit (); }
1311 | QFALSEEXIT { $$ = qual_createFalseExit (); }
1312 | QNEVEREXIT { $$ = qual_createNeverExit (); }
2f2892c2 1313;
28bf4b0b 1314
1315checkQualifier
1316 : QCHECKED { $$ = qual_createChecked (); }
1317 | QCHECKMOD { $$ = qual_createCheckMod (); }
1318 | QUNCHECKED { $$ = qual_createUnchecked (); }
1319 | QCHECKEDSTRICT { $$ = qual_createCheckedStrict (); }
2f2892c2 1320;
28bf4b0b 1321
1322stateQualifier
1323 : QOWNED { $$ = qual_createOwned (); }
1324 | QDEPENDENT { $$ = qual_createDependent (); }
1325 | QYIELD { $$ = qual_createYield (); }
1326 | QTEMP { $$ = qual_createTemp (); }
1327 | QONLY { $$ = qual_createOnly (); }
1328 | QKEEP { $$ = qual_createKeep (); }
1329 | QKEPT { $$ = qual_createKept (); }
1330 | QSHARED { $$ = qual_createShared (); }
1331 | QUNIQUE { $$ = qual_createUnique (); }
1332 | QNULL { $$ = qual_createNull (); }
1333 | QISNULL { $$ = qual_createIsNull (); }
1334 | QRELNULL { $$ = qual_createRelNull (); }
1335 | QNOTNULL { $$ = qual_createNotNull (); }
1336 | QEXPOSED { $$ = qual_createExposed (); }
1337 | QOBSERVER { $$ = qual_createObserver (); }
e26e911c 1338 | QNULLTERMINATED { $$ = qual_createNullTerminated (); }
28bf4b0b 1339 | CANNOTATION { $$ = qual_createMetaState ($1); }
2f2892c2 1340;
e26e911c 1341
28bf4b0b 1342paramQualifier
1343 : QRETURNED { $$ = qual_createReturned (); }
1344 | QSEF { $$ = qual_createSef (); }
2f2892c2 1345;
28bf4b0b 1346
1347visibilityQualifier
1348 : QUNUSED { $$ = qual_createUnused (); }
1349 | QEXTERNAL { $$ = qual_createExternal (); }
2f2892c2 1350;
28bf4b0b 1351
1352returnQualifier
1353 : QTRUENULL { $$ = qual_createTrueNull (); }
1354 | QFALSENULL { $$ = qual_createFalseNull (); }
2f2892c2 1355;
28bf4b0b 1356
1357typedefQualifier
1358 : QABSTRACT { $$ = qual_createAbstract (); }
e5081f8c 1359 | QNUMABSTRACT { $$ = qual_createNumAbstract (); }
28bf4b0b 1360 | QCONCRETE { $$ = qual_createConcrete (); }
1361 | QMUTABLE { $$ = qual_createMutable (); }
1362 | QIMMUTABLE { $$ = qual_createImmutable (); }
2f2892c2 1363;
28bf4b0b 1364
1365refcountQualifier
1366 : QREFCOUNTED { $$ = qual_createRefCounted (); }
1367 | QREFS { $$ = qual_createRefs (); }
1368 | QKILLREF { $$ = qual_createKillRef (); }
1369 | QRELDEF { $$ = qual_createRelDef (); }
1370 | QNEWREF { $$ = qual_createNewRef (); }
1371 | QTEMPREF { $$ = qual_createTempRef (); }
2f2892c2 1372;
11ed4f45 1373
885824d3 1374typeModifier
1375 : QSHORT { $$ = qual_createShort (); }
1376 | QLONG { $$ = qual_createLong (); }
1377 | QSIGNED { $$ = qual_createSigned (); }
1378 | QUNSIGNED { $$ = qual_createUnsigned (); }
2f2892c2 1379;
885824d3 1380
28bf4b0b 1381definedQualifier
1382 : QOUT { $$ = qual_createOut (); }
1383 | QIN { $$ = qual_createIn (); }
1384 | QPARTIAL { $$ = qual_createPartial (); }
1385 | QSPECIAL { $$ = qual_createSpecial (); }
2f2892c2 1386;
28bf4b0b 1387
1388typeQualifier
1389 : QCONST IsType { $$ = qual_createConst (); }
1390 | QVOLATILE IsType { $$ = qual_createVolatile (); }
f9264521 1391 | QRESTRICT IsType { $$ = qual_createRestrict (); }
28bf4b0b 1392 | definedQualifier IsType { $$ = $1; }
1393 | stateQualifier IsType { $$ = $1; }
1394 | exitsQualifier IsType { $$ = $1; }
1395 | paramQualifier IsType { $$ = $1; }
1396 | checkQualifier IsType { $$ = $1; }
1397 | returnQualifier IsType { $$ = $1; }
1398 | visibilityQualifier IsType { $$ = $1; }
1399 | typedefQualifier IsType { $$ = $1; }
1400 | refcountQualifier IsType { $$ = $1; }
2f2892c2 1401;
28bf4b0b 1402
1403/*
1404** This is copied into the mtgrammar!
1405*/
1406
885824d3 1407typeSpecifier
1408 : CGCHAR NotType
1409 | CINT NotType
1410 | CBOOL NotType
1411 | CGFLOAT NotType
1412 | CDOUBLE NotType
1413 | CVOID NotType
d5047b91 1414 | QANYTYPE NotType { $$ = ctype_makeAnytype (); }
885824d3 1415 | QINTEGRALTYPE NotType { $$ = ctype_anyintegral; }
1416 | QUNSIGNEDINTEGRALTYPE NotType { $$ = ctype_unsignedintegral; }
1417 | QSIGNEDINTEGRALTYPE NotType { $$ = ctype_signedintegral; }
1418 | typeName NotType
1419 | suSpc NotType
1420 | enumSpc NotType
02b84d4b 1421 | typeModifier NotType { $$ = ctype_fromQual ($1); }
2f2892c2 1422;
885824d3 1423
1424completeType
1425 : IsType completeTypeSpecifier IsType
1426 { $$ = qtype_resolve ($2); }
2f2892c2 1427;
885824d3 1428
1429completeTypeSpecifier
1430 : completeTypeSpecifierAux { $$ = $1; }
1431 | completeTypeSpecifierAux QALT altType QENDMACRO
1432 { $$ = qtype_mergeAlt ($1, $3); }
2f2892c2 1433;
885824d3 1434
1435altType
1436 : typeExpression
1437 | typeExpression TCOMMA altType
1438 { $$ = qtype_mergeAlt ($1, $3); }
2f2892c2 1439;
885824d3 1440
1441completeTypeSpecifierAux
1442 : storageSpecifier optCompleteType { $$ = qtype_addQual ($2, $1); }
1443 | typeQualifier optCompleteType { $$ = qtype_addQual ($2, $1); }
1444 | typeSpecifier optCompleteType { $$ = qtype_combine ($2, $1); }
2f2892c2 1445;
885824d3 1446
1447optCompleteType
1448 : /* empty */ { $$ = qtype_unknown (); }
1449 | completeTypeSpecifier { $$ = $1; }
2f2892c2 1450;
86d93ed3 1451
1452optStructInvariant
1453: /* empty */ { $$ = constraintList_undefined; }
d9daf826 1454/* drl commenting before a CVS commit
86d93ed3 1455 | QINVARIANT BufConstraintList QENDMACRO { $$ = $2 }
1456*/
2f2892c2 1457;
1458
885824d3 1459suSpc
1460 : NotType CSTRUCT newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1461 CreateStructInnerScope
86d93ed3 1462 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
885824d3 1463 TRBRACE
288cbc5c 1464 optStructInvariant
c3be2604 1465 { ctype ct; ct = declareStruct ($3, $8); context_setGlobalStructInfo(ct, $12); $$ = ct; }
885824d3 1466 | NotType CUNION newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1467 CreateStructInnerScope
1468 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
1469 TRBRACE
1470 { $$ = declareUnion ($3, $8); }
1471 | NotType CSTRUCT newId IsType TLBRACE TRBRACE
1472 { $$ = declareStruct ($3, uentryList_new ()); }
1473 | NotType CUNION newId IsType TLBRACE TRBRACE
1474 { $$ = declareUnion ($3, uentryList_new ()); }
1475 | NotType CSTRUCT IsType TLBRACE { sRef_setGlobalScopeSafe (); }
1476 CreateStructInnerScope
1477 structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
1478 TRBRACE
1479 { $$ = declareUnnamedStruct ($7); }
28bf4b0b 1480 | NotType CUNION IsType TLBRACE { sRef_setGlobalScopeSafe (); }
c8dda690 1481 CreateStructInnerScope structDeclList DeleteStructInnerScope
1482 { sRef_clearGlobalScopeSafe (); }
885824d3 1483 TRBRACE
1484 { $$ = declareUnnamedUnion ($7); }
1485 | NotType CSTRUCT IsType TLBRACE TRBRACE
1486 { $$ = ctype_createUnnamedStruct (uentryList_new ()); }
288cbc5c 1487 | NotType CUNION IsType TLBRACE TRBRACE
885824d3 1488 { $$ = ctype_createUnnamedUnion (uentryList_new ()); }
1489 | NotType CSTRUCT newId NotType { $$ = handleStruct ($3); }
288cbc5c 1490 | NotType CUNION newId NotType { $$ = handleUnion ($3); }
2f2892c2 1491;
885824d3 1492
1493NotType
16c024b5 1494: { cscannerHelp_clearExpectingTypeName (); }
2f2892c2 1495;
885824d3 1496
1497structDeclList
1498 : structDecl
1499 | macroDef { $$ = uentryList_undefined; /* bogus! */ }
1500 | structDeclList structDecl { $$ = uentryList_mergeFields ($1, $2); }
2f2892c2 1501;
885824d3 1502
1503structDecl
1504 : completeTypeSpecifier NotType structNamedDeclList IsType TSEMI
1505 { $$ = fixUentryList ($3, $1); }
1506 | completeTypeSpecifier IsType TSEMI
1507 { $$ = fixUnnamedDecl ($1); }
2f2892c2 1508;
885824d3 1509
1510structNamedDeclList
1511 : structNamedDecl NotType
1512 { $$ = idDeclList_singleton ($1); }
1513 | structNamedDeclList TCOMMA structNamedDecl NotType
1514 { $$ = idDeclList_add ($1, $3); }
2f2892c2 1515;
885824d3 1516
1517structNamedDecl /* hack to get around namespace problems */
1518 : namedDecl { $$ = $1; }
1519 | TCOLON IsType constantExpr { $$ = idDecl_undefined; }
1520 | namedDecl TCOLON IsType constantExpr { $$ = $1; }
1521 /* Need the IsType in case there is a cast in the constant expression. */
2f2892c2 1522;
885824d3 1523
1524enumSpc
1525 : NotType CENUM TLBRACE enumeratorList TRBRACE IsType
1526 { $$ = declareUnnamedEnum ($4); }
1527 | NotType CENUM newId TLBRACE { context_pushLoc (); } enumeratorList TRBRACE IsType
1528 { context_popLoc (); $$ = declareEnum ($3, $6); }
1529 | NotType CENUM newId IsType { $$ = handleEnum ($3); }
2f2892c2 1530;
885824d3 1531
1532enumeratorList
1533 : enumerator
1534 { $$ = enumNameList_single ($1); }
1535 | enumeratorList TCOMMA enumerator
1536 { $$ = enumNameList_push ($1, $3); }
1537 | enumeratorList TCOMMA
2f2892c2 1538 ;
885824d3 1539
1540enumerator
1541 : newId
1542 { uentry ue = uentry_makeEnumConstant ($1, ctype_unknown);
1543 usymtab_supGlobalEntry (ue);
1544 $$ = $1;
1545 }
1546 | newId TASSIGN IsType constantExpr
1547 { uentry ue = uentry_makeEnumInitializedConstant ($1, ctype_unknown, $4);
1548 usymtab_supGlobalEntry (ue);
1549 $$ = $1;
1550 }
2f2892c2 1551;
885824d3 1552
1553optNamedDecl
1554 : namedDeclBase
1555 | optAbstractDeclBase { $$ = idDecl_create (cstring_undefined, qtype_create ($1)); }
1556 | pointers TYPE_NAME
1557 {
1558 qtype qt = qtype_unknown ();
885824d3 1559 qtype_adjustPointers ($1, qt);
16c024b5 1560 $$ = idDecl_create (cstring_copy (cscannerHelp_observeLastIdentifier ()), qt);
885824d3 1561 }
1562 | pointers optNamedDecl
1563 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
2f2892c2 1564;
885824d3 1565
1566namedDecl
1567 : namedDeclBase
1568 | pointers namedDeclBase
1569 { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
2f2892c2 1570;
885824d3 1571
1572genericParamList
1573 : paramTypeList { $$ = handleParamTypeList ($1); }
1574 | NotType paramIdList { $$ = handleParamIdList ($2); }
2f2892c2 1575;
885824d3 1576
1577innerMods
f9264521 1578 : QCONST { $$ = qual_createConst (); }
1579 | QRESTRICT { $$ = qual_createRestrict (); }
1580 | QVOLATILE { $$ = qual_createVolatile (); }
2f2892c2 1581;
885824d3 1582
1583innerModsList
f9264521 1584 : innerMods { $$ = qualList_single ($1); }
1585 | innerModsList innerMods { $$ = qualList_add ($1, $2); }
2f2892c2 1586;
885824d3 1587
1588pointers
f9264521 1589 : TMULT { $$ = pointers_create ($1); }
1590 | TMULT innerModsList { $$ = pointers_createMods ($1, $2); }
1591 | TMULT pointers { $$ = pointers_extend (pointers_create ($1), $2); }
1592 | TMULT innerModsList pointers { $$ = pointers_extend (pointers_createMods ($1, $2), $3); }
2f2892c2 1593;
885824d3 1594
1595paramIdList
1596 : idList
1597 | idList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
2f2892c2 1598;
885824d3 1599
1600idList
1601 : newId { $$ = uentryList_single (uentry_makeVariableLoc ($1, ctype_int)); }
1602 | idList TCOMMA newId { $$ = uentryList_add ($1, uentry_makeVariableLoc ($3, ctype_int)); }
2f2892c2 1603;
885824d3 1604
1605paramTypeList
1606 : CTOK_ELIPSIS { $$ = uentryList_single (uentry_makeElipsisMarker ()); }
1607 | paramList
1608 | paramList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
2f2892c2 1609;
885824d3 1610
1611paramList
1612 : { storeLoc (); } paramDecl { $$ = uentryList_single ($2); }
1613 | paramList TCOMMA { storeLoc (); } paramDecl
1614 { $$ = uentryList_add ($1, $4); }
2f2892c2 1615;
885824d3 1616
1617paramDecl
1618 : IsType completeTypeSpecifier optNamedDecl IsType
1619 {
1620 if (isFlipOldStyle ())
1621 {
1622 llparseerror (cstring_makeLiteral ("Inconsistent function parameter syntax (mixing old and new style declaration)"));
1623 }
1624 else
1625 {
1626 setNewStyle ();
1627 }
1628 $$ = makeCurrentParam (idDecl_fixParamBase ($3, $2));
1629 }
1630 | newId /* its an old-style declaration */
1631 {
1632 idDecl tparam = idDecl_create ($1, qtype_unknown ());
1633
1634 if (isNewStyle ())
1635 {
1636 llparseerror (message ("Inconsistent function parameter syntax: %q",
1637 idDecl_unparse (tparam)));
1638 }
1639
1640 setFlipOldStyle ();
1641 $$ = makeCurrentParam (tparam);
1642 idDecl_free (tparam);
1643 }
2f2892c2 1644;
885824d3 1645
1646typeExpression
1647 : completeType
1648 | completeType abstractDecl { $$ = qtype_newBase ($1, $2); }
2f2892c2 1649;
885824d3 1650
1651abstractDecl
1652 : pointers { $$ = ctype_adjustPointers ($1, ctype_unknown); }
1653 | abstractDeclBase
1654 | pointers abstractDeclBase { $$ = ctype_adjustPointers ($1, $2); }
2f2892c2 1655;
885824d3 1656
1657optAbstractDeclBase
1658 : /* empty */ { $$ = ctype_unknown; }
1659 | abstractDeclBase
2f2892c2 1660 ;
885824d3 1661
1662abstractDeclBase
1663 : IsType TLPAREN NotType abstractDecl TRPAREN
1664 { $$ = ctype_expectFunction ($4); }
1665 | TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
a0a162cd 1666 | TLSQBR constantExpr TRSQBR
1667 { $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
393e573f 1668 | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeInnerArray ($1); }
a0a162cd 1669 | abstractDeclBase TLSQBR constantExpr TRSQBR
077d4458 1670 { $$ = ctype_makeInnerFixedArray ($1, exprNode_getLongValue ($3)); }
885824d3 1671 | IsType TLPAREN TRPAREN
1672 { $$ = ctype_makeFunction (ctype_unknown, uentryList_makeMissingParams ()); }
1673 | IsType TLPAREN paramTypeList TRPAREN
1674 { $$ = ctype_makeParamsFunction (ctype_unknown, $3); }
1675 | abstractDeclBase IsType TLPAREN TRPAREN
1676 { $$ = ctype_makeFunction ($1, uentryList_makeMissingParams ()); }
1677 | abstractDeclBase IsType TLPAREN paramTypeList TRPAREN
1678 { $$ = ctype_makeParamsFunction ($1, $4); }
2f2892c2 1679;
885824d3 1680
1681/* statement */
1682
1683stmt
1684 : labeledStmt
1685 | caseStmt
1686 | defaultStmt
1687 | compoundStmt
1688 | expressionStmt
1689 | selectionStmt
1690 | iterationStmt
1691 | iterStmt
1692 | jumpStmt
2f2892c2 1693;
11ed4f45 1694
86d93ed3 1695
885824d3 1696iterBody
1697 : iterDefStmtList { $$ = $1; }
2f2892c2 1698;
885824d3 1699
1700endBody
1701 : iterBody
2f2892c2 1702;
885824d3 1703
1704iterDefStmtList
1705 : iterDefStmt
1706 | iterDefStmtList iterDefStmt
1707 { $$ = exprNode_concat ($1, $2); }
2f2892c2 1708;
885824d3 1709
1710iterDefIterationStmt
1711 : iterWhilePred iterDefStmtList
1712 { $$ = exprNode_while ($1, $2); }
1713 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
1714 { $$ = exprNode_doWhile ($2, $5); }
1715 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
1716 { $$ = exprNode_doWhile ($2, $5); }
1717 | forPred iterDefStmt
1718 { $$ = exprNode_for ($1, $2); }
2f2892c2 1719;
885824d3 1720
1721forPred
1722 : CFOR TLPAREN optExpr TSEMI optExpr TSEMI
1723 { context_setProtectVars (); } optExpr { context_sizeofReleaseVars (); }
1724 TRPAREN
1725 { $$ = exprNode_forPred ($3, $5, $8);
1726 context_enterForClause ($5); }
2f2892c2 1727;
885824d3 1728
1729partialIterStmt
1730 : ITER_NAME CreateInnerScope TLPAREN
1731 { setProcessingIterVars ($1); }
1732 iterArgList TRPAREN
1733 { $$ = exprNode_iterStart ($1, $5); }
1734 | ITER_ENDNAME { $$ = exprNode_createId ($1); }
2f2892c2 1735;
885824d3 1736
1737iterDefStmt
1738 : labeledStmt
1739 | caseStmt
1740 | defaultStmt
28bf4b0b 1741 | openScope initializerList { $$ = $1; DPRINTF (("def stmt: %s", exprNode_unparse ($$))); }
885824d3 1742 | openScope
1743 | closeScope
1744 | expressionStmt
1745 | iterSelectionStmt
1746 | iterDefIterationStmt
1747 | partialIterStmt
1748 | jumpStmt
1749 | TLPAREN iterDefStmt TRPAREN { $$ = $2; }
1750 | error { $$ = exprNode_makeError (); }
2f2892c2 1751;
885824d3 1752
1753iterSelectionStmt
2e127cb8 1754 : ifPred { exprNode_checkIfPred ($1); } iterDefStmt
885824d3 1755 { /* don't: context_exitTrueClause ($1, $2); */
2e127cb8 1756 $$ = exprNode_if ($1, $3);
885824d3 1757 }
2f2892c2 1758;
885824d3 1759
1760openScope
1761 : CreateInnerScope TLBRACE { $$ = exprNode_createTok ($2); }
2f2892c2 1762;
885824d3 1763
1764closeScope
1765 : DeleteInnerScopeSafe TRBRACE { $$ = exprNode_createTok ($2); }
2f2892c2 1766;
885824d3 1767
1768macroBody
1769 : stmtErr
1770 | stmtListErr
2f2892c2 1771;
885824d3 1772
1773stmtErr
1774 : labeledStmt
1775 | caseStmt
1776 | defaultStmt
1777 | compoundStmtErr
1778 | expressionStmtErr
1779 | selectionStmt
1780 | iterStmt
1781 | iterationStmtErr
1782 | TLPAREN stmtErr TRPAREN { $$ = exprNode_addParens ($1, $2); }
1783 | jumpStmt
1784 | error { $$ = exprNode_makeError (); }
2f2892c2 1785;
885824d3 1786
1787labeledStmt
a0a162cd 1788 : newId TCOLON { $$ = exprNode_labelMarker ($1); }
1789 | QNOTREACHED stmt { $$ = exprNode_notReached ($2); }
2f2892c2 1790;
885824d3 1791
fafc64cf 1792/*
1793** We allow more than one QFALLTHROUGH token to support mixed lint/splint markers.
1794*/
1795
1796optExtraFallThroughs
1797 : /* empty */ { ; }
1798 | QFALLTHROUGH optExtraFallThroughs { ; }
2f2892c2 1799;
fafc64cf 1800
885824d3 1801/* Note that we can semantically check that the object to the case is
1802 indeed constant. In this case, we may not want to go through this effort */
1803
1804caseStmt
1805 : CASE constantExpr { context_enterCaseClause ($2); }
1806 TCOLON { $$ = exprNode_caseMarker ($2, FALSE); }
fafc64cf 1807 | QFALLTHROUGH optExtraFallThroughs CASE constantExpr { context_enterCaseClause ($4); }
1808 TCOLON { $$ = exprNode_caseMarker ($4, TRUE); }
2f2892c2 1809;
885824d3 1810
1811defaultStmt
1812 : DEFAULT { context_enterCaseClause (exprNode_undefined); }
1813 TCOLON { $$ = exprNode_defaultMarker ($1, FALSE); }
fafc64cf 1814 | QFALLTHROUGH optExtraFallThroughs DEFAULT { context_enterCaseClause (exprNode_undefined); }
1815 TCOLON { $$ = exprNode_defaultMarker ($3, TRUE); }
2f2892c2 1816;
885824d3 1817
1818compoundStmt
1819 : TLPAREN compoundStmt TRPAREN { $$ = $2; }
1820 | CreateInnerScope compoundStmtAux
1821 { $$ = $2; context_exitInner ($2); }
2f2892c2 1822;
885824d3 1823
1824compoundStmtErr
1825 : CreateInnerScope compoundStmtAuxErr DeleteInnerScope { $$ = $2; }
2f2892c2 1826;
885824d3 1827
1828CreateInnerScope
1829 : { context_enterInnerContext (); }
2f2892c2 1830;
885824d3 1831
1832DeleteInnerScope
1833 : { context_exitInnerPlain (); }
2f2892c2 1834;
885824d3 1835
1836CreateStructInnerScope
1837 : { context_enterStructInnerContext (); }
2f2892c2 1838;
885824d3 1839
1840DeleteStructInnerScope
1841 : { context_exitStructInnerContext (); }
2f2892c2 1842;
885824d3 1843
1844DeleteInnerScopeSafe
1845 : { context_exitInnerSafe (); }
2f2892c2 1846;
885824d3 1847
1848compoundStmtRest
1849 : TRBRACE { $$ = exprNode_createTok ($1); }
1850 | QNOTREACHED TRBRACE { $$ = exprNode_notReached (exprNode_createTok ($2)); }
1851 | stmtList TRBRACE { $$ = exprNode_updateLocation ($1, lltok_getLoc ($2)); }
1852 | stmtList QNOTREACHED TRBRACE
1853 { $$ = exprNode_notReached (exprNode_updateLocation ($1, lltok_getLoc ($3))); }
1854 | initializerList TRBRACE { $$ = exprNode_updateLocation ($1, lltok_getLoc ($2)); }
1855 | initializerList QNOTREACHED TRBRACE
1856 { $$ = exprNode_notReached (exprNode_updateLocation ($1, lltok_getLoc ($3))); }
1857 | initializerList stmtList TRBRACE
1858 { $$ = exprNode_updateLocation (exprNode_concat ($1, $2), lltok_getLoc ($3)); }
1859 | initializerList stmtList QNOTREACHED TRBRACE
1860 { $$ = exprNode_notReached (exprNode_updateLocation (exprNode_concat ($1, $2),
1861 lltok_getLoc ($3)));
1862 }
2f2892c2 1863;
885824d3 1864
885824d3 1865compoundStmtAux
1866 : TLBRACE compoundStmtRest
1867 { $$ = exprNode_makeBlock ($2); }
2f2892c2 1868;
885824d3 1869
1870compoundStmtAuxErr
1871 : TLBRACE TRBRACE
1872 { $$ = exprNode_createTok ($2); }
1873 | TLBRACE stmtListErr TRBRACE
1874 { $$ = exprNode_updateLocation ($2, lltok_getLoc ($3)); }
1875 | TLBRACE initializerList TRBRACE
1876 { $$ = exprNode_updateLocation ($2, lltok_getLoc ($3)); }
1877 | TLBRACE initializerList stmtList TRBRACE
1878 { $$ = exprNode_updateLocation (exprNode_concat ($2, $3), lltok_getLoc ($4)); }
2f2892c2 1879;
885824d3 1880
1881stmtListErr
1882 : stmtErr
1883 | stmtListErr stmtErr { $$ = exprNode_concat ($1, $2); }
2f2892c2 1884;
885824d3 1885
1886initializerList
1887 : initializer { $$ = $1; }
1888 | initializerList initializer { $$ = exprNode_concat ($1, $2); }
2f2892c2 1889;
885824d3 1890
abd7f895 1891typeInitializerList
1892 : typeInitializer { $$ = $1; }
1893 | typeInitializerList TCOMMA typeInitializer { $$ = exprNode_concat ($1, $3); }
2f2892c2 1894;
abd7f895 1895
1896typeInitializer
1897 : assignExpr { $$ = $1; }
1898 | TLBRACE typeInitializerList optComma TRBRACE { $$ = $2; }
2f2892c2 1899;
abd7f895 1900
885824d3 1901stmtList
a0a162cd 1902 : stmt { $$ = $1; }
1903 | stmtList stmt { $$ = exprNode_concat ($1, $2); }
2f2892c2 1904;
1905
885824d3 1906expressionStmt
1907 : TSEMI { $$ = exprNode_createTok ($1); }
4cccc6ad 1908 | expr TSEMI { $$ = exprNode_statement ($1, $2); }
2f2892c2 1909;
885824d3 1910
1911expressionStmtErr
1912 : TSEMI { $$ = exprNode_createTok ($1); }
4cccc6ad 1913 | expr TSEMI { $$ = exprNode_statement ($1, $2); }
885824d3 1914 | expr { $$ = exprNode_checkExpr ($1); }
2f2892c2 1915;
885824d3 1916
1917ifPred
1918 : CIF TLPAREN expr TRPAREN
2e127cb8 1919 {
1920 exprNode_produceGuards ($3); context_enterTrueClause ($3);
1921 exprNode_checkIfPred ($3);
1922 $$ = $3;
1923 }
1924
885824d3 1925 /*
1926 ** not ANSI: | CIF TLPAREN compoundStmt TRPAREN
1927 ** { $$ = $3; context_enterTrueClause (); }
1928 */
2f2892c2 1929;
885824d3 1930
1931selectionStmt
1932 : ifPred stmt
1933 {
1934 context_exitTrueClause ($1, $2);
1935 $$ = exprNode_if ($1, $2);
1936 }
2e127cb8 1937 | ifPred stmt CELSE { context_enterFalseClause ($1); } stmt
885824d3 1938 {
1939 context_exitClause ($1, $2, $5);
1940 $$ = exprNode_ifelse ($1, $2, $5);
1941 }
1942 | SWITCH TLPAREN expr { context_enterSwitch ($3); }
1943 TRPAREN stmt { $$ = exprNode_switch ($3, $6); }
2f2892c2 1944;
885824d3 1945
1946whilePred
1947 : WHILE TLPAREN expr TRPAREN
1948 { $$ = exprNode_whilePred ($3); context_enterWhileClause ($3); }
1949 /* not ANSI: | WHILE TLPAREN compoundStmt TRPAREN stmt { $$ = exprNode_while ($3, $5); } */
2f2892c2 1950;
885824d3 1951
1952iterWhilePred
1953 : WHILE TLPAREN expr TRPAREN { $$ = exprNode_whilePred($3); }
2f2892c2 1954;
885824d3 1955
1956iterStmt
1957 : ITER_NAME { context_enterIterClause (); }
1958 CreateInnerScope TLPAREN { setProcessingIterVars ($1); }
1959 iterArgList TRPAREN
1960 compoundStmt endIter DeleteInnerScope
1961 {
1962 $$ = exprNode_iter ($1, $6, $8, $9);
1963
1964 }
2f2892c2 1965;
885824d3 1966
1967iterArgList
1968 : iterArgExpr { $$ = exprNodeList_singleton ($1); }
1969 | iterArgList { nextIterParam (); } TCOMMA iterArgExpr
1970 { $$ = exprNodeList_push ($1, $4); }
2f2892c2 1971;
885824d3 1972
1973iterArgExpr
1974 : assignIterExpr { $$ = exprNode_iterExpr ($1); }
1975 | id { $$ = exprNode_iterId ($1); }
16c024b5 1976 | TYPE_NAME_OR_ID { uentry ue = cscannerHelp_coerceIterId ($1);
885824d3 1977
1978 if (uentry_isValid (ue))
1979 {
1980 $$ = exprNode_iterId (ue);
1981 }
1982 else
1983 {
16c024b5 1984 $$ = exprNode_iterNewId (cstring_copy (cscannerHelp_observeLastIdentifier ()));
885824d3 1985 }
1986 }
1987 | NEW_IDENTIFIER { $$ = exprNode_iterNewId ($1); }
2f2892c2 1988;
885824d3 1989
1990/*
1991** everything is the same, EXCEPT it cannot be a NEW_IDENTIFIER
1992*/
1993
28bf4b0b 1994cconstantExpr
1995 : CCONSTANT
1996 | cconstantExpr CCONSTANT { $$ = exprNode_combineLiterals ($1, $2); }
2f2892c2 1997;
28bf4b0b 1998
885824d3 1999primaryIterExpr
28bf4b0b 2000 : cconstantExpr
885824d3 2001 | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
2f2892c2 2002;
885824d3 2003
2004postfixIterExpr
2005 : primaryIterExpr
2006 | postfixExpr TLSQBR expr TRSQBR { $$ = exprNode_arrayFetch ($1, $3); }
2007 | postfixExpr TLPAREN TRPAREN { $$ = exprNode_functionCall ($1, exprNodeList_new ()); }
2008 | postfixExpr TLPAREN argumentExprList TRPAREN { $$ = exprNode_functionCall ($1, $3); }
2009 | VA_ARG TLPAREN assignExpr TCOMMA typeExpression TRPAREN
2010 { $$ = exprNode_vaArg ($1, $3, $5); }
28bf4b0b 2011 | postfixExpr NotType TDOT newId IsType { $$ = exprNode_fieldAccess ($1, $3, $4); }
2012 | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
885824d3 2013 | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
2014 | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
2f2892c2 2015;
885824d3 2016
2017unaryIterExpr
2018 : postfixIterExpr
2019 | INC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
2020 | DEC_OP unaryExpr { $$ = exprNode_preOp ($2, $1); }
2021 | TAMPERSAND castExpr { $$ = exprNode_preOp ($2, $1); }
2022 | TMULT castExpr { $$ = exprNode_preOp ($2, $1); }
2023 | TPLUS castExpr { $$ = exprNode_preOp ($2, $1); }
2024 | TMINUS castExpr { $$ = exprNode_preOp ($2, $1); }
2025 | TTILDE castExpr { $$ = exprNode_preOp ($2, $1); }
2026 | TEXCL castExpr { $$ = exprNode_preOp ($2, $1); }
2027 | sizeofExpr { $$ = $1; }
2f2892c2 2028;
885824d3 2029
2030castIterExpr
2031 : unaryIterExpr
2032 | TLPAREN typeExpression TRPAREN castExpr { $$ = exprNode_cast ($1, $4, $2); }
2f2892c2 2033;
885824d3 2034
2035timesIterExpr
2036 : castIterExpr
2037 | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
2038 | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
2039 | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2040;
885824d3 2041
2042plusIterExpr
2043 : timesIterExpr
2044 | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
2045 | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2046;
885824d3 2047
2048shiftIterExpr
2049 : plusIterExpr
2050 | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
2051 | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2052;
885824d3 2053
2054relationalIterExpr
2055 : shiftIterExpr
2056 | relationalExpr TLT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
2057 | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
2058 | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
2059 | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2060;
885824d3 2061
2062equalityIterExpr
2063 : relationalIterExpr
2064 | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
2065 | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2066;
885824d3 2067
2068bitandIterExpr
2069 : equalityIterExpr
2070 | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2071;
885824d3 2072
2073xorIterExpr
2074 : bitandIterExpr
2075 | xorExpr TCIRC bitandExpr { $$ = exprNode_op ($1, $3, $2); }
2076;
2077
2078bitorIterExpr
2079 : xorIterExpr
2080 | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2081;
885824d3 2082
2083andIterExpr
2084 : bitorIterExpr
2085 | andExpr AND_OP bitorExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2086;
885824d3 2087
2088orIterExpr
2089 : andIterExpr
2090 | orExpr OR_OP andExpr { $$ = exprNode_op ($1, $3, $2); }
2f2892c2 2091;
885824d3 2092
2093conditionalIterExpr
2094 : orIterExpr
2095 | orExpr TQUEST { context_enterTrueClause ($1); }
2096 expr TCOLON { context_enterFalseClause ($1); } conditionalExpr
2097 { $$ = exprNode_cond ($1, $4, $7); }
2f2892c2 2098;
885824d3 2099
2100assignIterExpr
2101 : conditionalIterExpr
2102 | unaryExpr TASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2103 | unaryExpr MUL_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2104 | unaryExpr DIV_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2105 | unaryExpr MOD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2106 | unaryExpr ADD_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2107 | unaryExpr SUB_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2108 | unaryExpr LEFT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2109 | unaryExpr RIGHT_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2110 | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2111 | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2112 | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); }
2f2892c2 2113;
885824d3 2114
2115endIter
2116 : ITER_ENDNAME { $$ = $1; }
2117 | /* empty */ { $$ = uentry_undefined; }
2f2892c2 2118;
885824d3 2119
2120doHeader
2121 : DO { context_enterDoWhileClause (); $$ = $1; }
2f2892c2 2122;
885824d3 2123
2124iterationStmt
2125 : whilePred stmt
2126 { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
2127 | doHeader stmt WHILE TLPAREN expr TRPAREN TSEMI
4cccc6ad 2128 { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
885824d3 2129 | forPred stmt
2130 { $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
2f2892c2 2131;
885824d3 2132
2133iterationStmtErr
2134 : whilePred stmtErr { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
2135 | doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
4cccc6ad 2136 { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
885824d3 2137 | doHeader stmtErr WHILE TLPAREN expr TRPAREN
2138 { $$ = exprNode_doWhile ($2, $5); }
2139 | forPred stmtErr { $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
2f2892c2 2140;
885824d3 2141
2142jumpStmt
2143 : GOTO newId TSEMI { $$ = exprNode_goto ($2); }
2144 | CONTINUE TSEMI { $$ = exprNode_continue ($1, BADTOK); }
2145 | QINNERCONTINUE CONTINUE TSEMI
2146 { $$ = exprNode_continue ($1, QINNERCONTINUE); }
2147 | BREAK TSEMI { $$ = exprNode_break ($1, BADTOK); }
2148 | QSWITCHBREAK BREAK TSEMI { $$ = exprNode_break ($2, QSWITCHBREAK); }
2149 | QLOOPBREAK BREAK TSEMI { $$ = exprNode_break ($2, QLOOPBREAK); }
2150 | QINNERBREAK BREAK TSEMI { $$ = exprNode_break ($2, QINNERBREAK); }
2151 | QSAFEBREAK BREAK TSEMI { $$ = exprNode_break ($2, QSAFEBREAK); }
2152 | RETURN TSEMI { $$ = exprNode_nullReturn ($1); }
2153 | RETURN expr TSEMI { $$ = exprNode_return ($2); }
2f2892c2 2154;
885824d3 2155
2156optSemi
2157 :
2158 | TSEMI { ; }
2f2892c2 2159;
885824d3 2160
abd7f895 2161optComma
2162 :
2163 | TCOMMA { ; }
2f2892c2 2164;
abd7f895 2165
885824d3 2166id
2167 : IDENTIFIER
2f2892c2 2168;
885824d3 2169
2170newId
2171 : NEW_IDENTIFIER
2172 | ITER_NAME { $$ = uentry_getName ($1); }
2173 | ITER_ENDNAME { $$ = uentry_getName ($1); }
2174 | id { $$ = uentry_getName ($1); }
2175 | TYPE_NAME_OR_ID { $$ = $1; }
2f2892c2 2176;
885824d3 2177
2178typeName
2179 : TYPE_NAME
2180 | TYPE_NAME_OR_ID { $$ = ctype_unknown; }
abd7f895 2181 | CTYPEOF TLPAREN expr TRPAREN { $$ = exprNode_getType ($3); exprNode_free ($3); }
2182 | CTYPEOF TLPAREN typeExpression TRPAREN { $$ = qtype_getType ($3); }
2f2892c2 2183;
885824d3 2184
2185%%
2186
60eced23 2187/*@-redecl@*/ /*@-namechecks@*/
885824d3 2188extern char *yytext;
60eced23 2189/*@=redecl@*/ /*@=namechecks@*/
885824d3 2190
2191# include "bison.reset"
2192
2193void yyerror (/*@unused@*/ char *s)
2194{
2195 static bool givehint = FALSE;
2196
2197 if (context_inIterDef ())
2198 {
2199 llerror (FLG_SYNTAX, message ("Iter syntax not parseable: %s",
2200 context_inFunctionName ()));
2201 }
2202 else if (context_inIterEnd ())
2203 {
2204 llerror (FLG_SYNTAX, message ("Iter finalizer syntax not parseable: %s",
2205 context_inFunctionName ()));
2206 }
2207 else if (context_inMacro ())
2208 {
2209 llerror (FLG_SYNTAX, message ("Macro syntax not parseable: %s",
2210 context_inFunctionName ()));
2211
b7e84605 2212 if (context_inUnknownMacro ())
885824d3 2213 {
2214 if (!givehint)
2215 {
2216 llhint (cstring_makeLiteral
2217 ("Precede macro definition with /*@notfunction@*/ "
2218 "to suppress checking and force expansion"));
2219 givehint = TRUE;
2220 }
2221 }
2222
16c024b5 2223 cscannerHelp_swallowMacro ();
28bf4b0b 2224 context_exitAllClausesQuiet ();
885824d3 2225 }
2226 else
2227 {
2228 llparseerror (cstring_undefined);
2229 }
2230}
2231
2232
11ed4f45 2233
2234
28bf4b0b 2235
2236
2237
11ed4f45 2238
2239
2240
2241
2242
This page took 0.446317 seconds and 5 git commands to generate.