]> andersk Git - splint.git/blobdiff - src/cgrammar.y
Added support for omitted if clauses in conditionals, patch provided by peteran.
[splint.git] / src / cgrammar.y
index 3e8646ec1d0a3003f1434fca57a7b92b0bf9be8e..0a4f0bba4d5ca46300536df69af9a16fa8d46805 100644 (file)
@@ -1,32 +1,37 @@
 /*;-*-C-*-;
-** Copyright (c) Massachusetts Institute of Technology 1994-1998.
-**          All Rights Reserved.
-**          Unpublished rights reserved under the copyright laws of
-**          the United States.
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 University of Virginia,
+**         Massachusetts Institute of Technology
 **
-** THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
-** OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License as published by the
+** Free Software Foundation; either version 2 of the License, or (at your
+** option) any later version.
+** 
+** This program is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+** General Public License for more details.
+** 
+** The GNU General Public License is available from http://www.gnu.org/ or
+** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+** MA 02111-1307, USA.
 **
-** This code is distributed freely and may be used freely under the 
-** following conditions:
-**
-**     1. This notice may not be removed or altered.
-**
-**     2. Works derived from this code are not distributed for
-**        commercial gain without explicit permission from MIT 
-**        (for permission contact lclint-request@sds.lcs.mit.edu).
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
 */
 %{
 /*
 **
 ** cgrammar.y
 **
-** Yacc/Bison grammar for extended ANSI C used by LCLint.
+** Yacc/Bison grammar for extended ANSI C used by Splint.
 **
 ** original grammar by Nate Osgood ---
 **    hacrat@catfish.lcs.mit.edu Mon Jun 14 13:06:32 1993
 **
-** changes for LCLint --- handle typedef names correctly
+** changes for Splint --- handle typedef names correctly
 ** fix struct/union parsing bug (empty struct is accepted)
 ** add productions to handle macros --- require
 ** error correction --- main source of conflicts in grammar.
 /*@=allmacros@*/
 
 extern int yylex ();
-extern void swallowMacro (void);
 extern void yyerror (char *);
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
+# include "cscanner.h"
+# include "cscannerHelp.h"
 # include "cgrammar.h"
 # include "exprChecks.h"
 
@@ -88,6 +94,13 @@ extern void yyerror (char *);
   /*@only@*/ modifiesClause modsclause;
   /*@only@*/ warnClause warnclause;
   /*@only@*/ stateClause stateclause;
+  /*@only@*/ pointers pointers;
+  /*@only@*/ functionConstraint fcnconstraint; 
+
+  /*@only@*/ metaStateConstraint msconstraint;
+  /*@only@*/ metaStateSpecifier msspec;
+  /*@only@*/ metaStateExpression msexpr;
+  /*@observer@*/ metaStateInfo msinfo;
 
   /*@only@*/ sRefList srlist;
   /*@only@*/ globSet globset;
@@ -102,9 +115,10 @@ extern void yyerror (char *);
   /*@only@*/ uentry oentry;
   /*@only@*/ exprNode expr;
   /*@only@*/ enumNameList enumnamelist;
-  /*@only@*/ exprNodeList alist;
+  /*@only@*/ exprNodeList exprlist;
   /*@only@*/ sRefSet srset; 
   /*@only@*/ cstringList cstringlist;
+
   /*drl
     added 1/19/2001
   */
@@ -122,7 +136,7 @@ extern void yyerror (char *);
 %token <tok> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN 
 %token <tok> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
 %token <tok> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
-%token <tok> CSIZEOF CALIGNOF ARROW_OP CTYPEDEF COFFSETOF
+%token <tok> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
 %token <tok> INC_OP DEC_OP LEFT_OP RIGHT_OP
 %token <tok> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
 %token <tok> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
@@ -142,14 +156,18 @@ extern void yyerror (char *);
 %token <tok> QSETS
 %token <tok> QRELEASES 
 %token <tok> QPRECLAUSE 
-%token <tok> QPOSTCLAUSE 
+%token <tok> QPOSTCLAUSE
+%token <tok> QINVARIANT
 %token <tok> QALT 
 %token <tok> QUNDEF QKILLED
 %token <tok> QENDMACRO
 
-/* additional tokens introduced by lclint pre-processor. */
+/* additional tokens introduced by splint pre-processor. */
 %token <tok> LLMACRO LLMACROITER LLMACROEND TENDMACRO
 
+/* For debugging purposes */
+%token <tok> QDREVEALSTATE
+
 /* break comments: */
 %token <tok> QSWITCHBREAK QLOOPBREAK QINNERBREAK QSAFEBREAK
 %token <tok> QINNERCONTINUE
@@ -168,20 +186,19 @@ extern void yyerror (char *);
 %token <tok> QNOTREACHED
 
 /* type qualifiers: */
-%token <tok> QCONST QVOLATILE QINLINE QEXTENSION QEXTERN QSTATIC QAUTO QREGISTER
+%token <tok> QCONST QRESTRICT QVOLATILE QINLINE QEXTENSION QEXTERN QSTATIC QAUTO QREGISTER
 %token <tok> QOUT QIN QYIELD QONLY QTEMP QSHARED QREF QUNIQUE
 %token <tok> QCHECKED QUNCHECKED QCHECKEDSTRICT QCHECKMOD
 %token <tok> QKEEP QKEPT QPARTIAL QSPECIAL QOWNED QDEPENDENT
 %token <tok> QRETURNED QEXPOSED QNULL QOBSERVER QISNULL 
 %token <tok> QEXITS QMAYEXIT QNEVEREXIT QTRUEEXIT QFALSEEXIT
 %token <tok> QLONG QSIGNED QUNSIGNED QSHORT QUNUSED QSEF QNOTNULL QRELNULL
-%token <tok> QABSTRACT QCONCRETE QMUTABLE QIMMUTABLE
+%token <tok> QABSTRACT QNUMABSTRACT QCONCRETE QMUTABLE QIMMUTABLE
 %token <tok> QTRUENULL QFALSENULL QEXTERNAL
 %token <tok> QREFCOUNTED QREFS QNEWREF QTEMPREF QKILLREF QRELDEF
 %token <ctyp> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID 
 %token <tok> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
 
-%type <typequal> nullterminatedQualifier
 %token <tok> QNULLTERMINATED
 %token <tok> QSETBUFFERSIZE
 %token <tok> QSETSTRINGLENGTH
@@ -204,20 +221,26 @@ extern void yyerror (char *);
 %type <entry> endIter 
 
 %type <funcclauselist> functionClauses functionClausesPlain
-%type <funcclause> functionClause functionClause functionClausePlain
+%type <funcclause> functionClause functionClausePlain
 
 %type <globsclause> globalsClause globalsClausePlain
 %type <modsclause> modifiesClause modifiesClausePlain nomodsClause
-%type <warnclause> warnClause warnClausePlain
+%type <warnclause> warnClause warnClausePlain optWarnClause
 %type <funcclause> conditionClause conditionClausePlain
 %type <stateclause> stateClause stateClausePlain
+%type <msconstraint> metaStateConstraint 
+%type <fcnconstraint> functionConstraint
+%type <msspec> metaStateSpecifier
+%type <msexpr> metaStateExpression
 
 %type <sr> globId globIdListExpr
 %type <globset> globIdList
 
 %token <ctyp>  TYPE_NAME 
+%token <msinfo> METASTATE_NAME 
+%type <msinfo> metaStateName
 %type <cname> enumerator newId  /*@-varuse@*/ /* yacc declares yytranslate here */
-%type <count> pointers /*@=varuse@*/
+%type <pointers> pointers /*@=varuse@*/
 
 %type <tok> doHeader stateTag conditionTag startConditionClause
 %type <typequal> exitsQualifier checkQualifier stateQualifier 
@@ -239,14 +262,14 @@ extern void yyerror (char *);
 %type <ntyplist> structNamedDeclList
 
 %type <entrylist> genericParamList paramTypeList paramList idList paramIdList
-%type <alist> argumentExprList iterArgList
-%type <alist> initList
+%type <exprlist> argumentExprList iterArgList
+%type <exprlist> initList namedInitializerList namedInitializerListAux namedInitializerTypeList namedInitializerTypeListAux
 %type <flist> structDeclList structDecl
 %type <srset> locModifies modList specClauseList optSpecClauseList
 %type <sr>    mExpr modListExpr specClauseListExpr
 
 /*drl*/
-%type <con>    BufConstraint
+%type <con> BufConstraint
 %type <tok> relationalOp
 %type <tok> BufBinaryOp
 %type <tok> bufferModifier
@@ -256,16 +279,21 @@ extern void yyerror (char *);
 %type <conE> BufConstraintTerm
 %type <sr> BufConstraintSrefExpr
 
-%type <conL>    BufConstraintList
+%type <conL> BufConstraintList
+
+%type <conL> optStructInvariant
 
 %type <tok>  BufUnaryOp
 
+/*drl 1/6/2002 either /\ or && */
+%type <tok> constraintSeperator
+
 %type <enumnamelist> enumeratorList 
 %type <cstringlist> fieldDesignator
 
 %type <expr> sizeofExpr sizeofExprAux offsetofExpr
 %type <expr> openScope closeScope 
-%type <expr> instanceDecl namedInitializer optDeclarators
+%type <expr> instanceDecl namedInitializer optDeclarators namedInitializerType
 %type <expr> primaryExpr postfixExpr primaryIterExpr postfixIterExpr
 %type <expr> unaryExpr castExpr timesExpr plusExpr
 %type <expr> unaryIterExpr castIterExpr timesIterExpr plusIterExpr
@@ -277,18 +305,20 @@ extern void yyerror (char *);
 %type <expr> orIterExpr conditionalIterExpr assignIterExpr iterArgExpr
 %type <expr> expr optExpr constantExpr
 %type <expr> init macroBody iterBody endBody partialIterStmt iterSelectionStmt
-%type <expr> stmt stmtList fcnBody iterStmt iterDefStmt iterDefStmtList
+%type <expr> stmt stmtList fcnBody iterStmt iterDefStmt iterDefStmtList debugStmt
 %type <expr> labeledStmt caseStmt defaultStmt 
 %type <expr> compoundStmt compoundStmtAux compoundStmtRest compoundStmtAuxErr
 %type <expr> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt 
 %type <expr> stmtErr stmtListErr compoundStmtErr expressionStmtErr 
-%type <expr> iterationStmtErr initializerList initializer ifPred whilePred forPred iterWhilePred
+%type <expr> iterationStmtErr initializerList typeInitializerList initializer
+%type <expr> ifPred whilePred forPred iterWhilePred typeInitializer
+
+%type <expr> designator designatorList designation
 
-%type <typequal> storageSpecifier typeQualifier typeModifier globQual
-%type <tquallist> optGlobQuals
+%type <typequal> storageSpecifier typeQualifier typeModifier globQual innerMods
+%type <tquallist> optGlobQuals innerModsList
 %type <qtyp> completeType completeTypeSpecifier optCompleteType
 %type <qtyp> completeTypeSpecifierAux altType typeExpression 
-/*%type <expr> lclintassertion*/
 
 %start file
 
@@ -297,10 +327,12 @@ extern void yyerror (char *);
 file
  :              
  | externalDefs
+ ;
 
 externalDefs
- : externalDef
- | externalDefs externalDef 
+ : externalDef { context_checkGlobalScope (); }
+ | externalDefs externalDef { context_checkGlobalScope (); }
+ ;
 
 externalDef
  : fcnDef optSemi { uentry_clearDecl (); } 
@@ -309,20 +341,25 @@ externalDef
  | iterDecl       { uentry_clearDecl (); } 
  | macroDef       { uentry_clearDecl (); } 
  | initializer    { uentry_checkDecl (); exprNode_free ($1); }
+ | TSEMI          { uentry_clearDecl (); lltok_free ($1); /* evans 2002-02-08: okay to have a null statement */ }  
  | error          { uentry_clearDecl (); } 
+ ;
 
 constantDecl
  : QCONSTANT completeTypeSpecifier NotType namedDecl NotType optSemi IsType QENDMACRO
-   { checkConstant ($2, $4); }
+   { checkConstant ($2, $4); lltok_free2 ($1, $8); }
  | QCONSTANT completeTypeSpecifier NotType namedDecl NotType TASSIGN IsType init optDeclarators optSemi QENDMACRO
-   { checkValueConstant ($2, $4, $8) ; }
+   { checkValueConstant ($2, $4, $8); lltok_free3 ($1, $6, $11); }
+;
 
 fcnDecl
  : QFUNCTION { context_enterFunctionHeader (); } plainFcn optSemi QENDMACRO 
    { 
      declareStaticFunction ($3); context_quietExitFunction (); 
      context_exitFunctionHeader (); 
+     lltok_free2 ($1, $5); /*!*/
    }
+;
 
 plainFcn
  : plainNamedDecl
@@ -333,49 +370,105 @@ plainFcn
    }
  | completeTypeSpecifier NotType plainNamedDecl
    { $$ = idDecl_fixBase ($3, $1); }
+;
 
 plainNamedDecl
  : plainNamedDeclBase
  | pointers plainNamedDeclBase 
    { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
+;
 
 namedDeclBase
  : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
  | IsType TLPAREN NotType namedDecl IsType TRPAREN
-   { $$ = idDecl_expectFunction ($4); }
+   { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
  | namedDeclBase TLSQBR TRSQBR 
-   { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+   { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); lltok_free2 ($2, $3); }
  | namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
-   { 
-     $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
+   {
+     exprNode_findValue ($4);
+     idDecl_notExpectingFunction ($1);
+
+     if (exprNode_hasValue ($4)) 
+       {
+        $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), 
+                                                                 exprNode_getLongValue ($4)));
+       } 
+     else
+       {
+        $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); 
+       }
+
+     lltok_free2 ($2, $5);
    }
  | namedDeclBase PushType TLPAREN TRPAREN 
    { setCurrentParams (uentryList_missingParams); }
    functionClauses
    { /* need to support globals and modifies here! */
+     functionClauseList fcl;
      ctype ct = ctype_makeFunction (idDecl_getCtype ($1), 
                                    uentryList_makeMissingParams ());
      
      $$ = idDecl_replaceCtype ($1, ct);
-     idDecl_addClauses ($$, $6);
-     context_popLoc (); 
+
+     /*drl 7/25/01 added*/
+     setImplicitfcnConstraints();
+
+     DPRINTF((message("namedDeclBase PushType TLPAREN TRPAREN...:\n adding implict constraints to functionClause List: %s",
+                     functionClauseList_unparse($6)
+                     )
+             ));
+     
+     fcl = functionClauseList_setImplicitConstraints($6);
+
+     idDecl_addClauses ($$, fcl);
+
+     DPRINTF((message("1 added fuctionClause List: %s to the Id",
+                     functionClauseList_unparse(fcl)
+                     )
+             ));
+
+     
+     context_popLoc ();
+     lltok_free2 ($3, $4);
    }
  | namedDeclBase PushType TLPAREN genericParamList TRPAREN 
    { setCurrentParams ($4); } 
    functionClauses
-   { setImplictfcnConstraints ();
+   {
+     functionClauseList fcl;
+     setImplicitfcnConstraints ();
      clearCurrentParams ();
      $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
-     idDecl_addClauses ($$, $7);
+
+     DPRINTF((message("namedDeclBase PushType TLPAREN genericParamList TRPAREN...:\n adding implict constraints to functionClause List: %s",
+                     functionClauseList_unparse($7)
+                     )
+             )) ;
+     
+     fcl = functionClauseList_setImplicitConstraints($7);
+
+     idDecl_addClauses ($$, fcl);
+
+     DPRINTF((message("added fuctionClause List: %s to the Id",
+                     functionClauseList_unparse(fcl)
+                     )
+             ));
+
+     
      context_popLoc (); 
+     lltok_free2 ($3, $5);
    }
+;
 
 plainNamedDeclBase
  : newId { $$ = idDecl_create ($1, qtype_unknown ()); }
  | IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
-   { $$ = idDecl_expectFunction ($4); }
+   { $$ = idDecl_expectFunction ($4); lltok_free2 ($2, $6); }
  | plainNamedDeclBase TLSQBR TRSQBR 
-   { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+   { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); 
+     lltok_free2 ($2, $3); 
+   }
  | plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
    { 
      int value;
@@ -390,7 +483,8 @@ plainNamedDeclBase
         value = 0;
        }
 
-     $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), value));
+     $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), value));
+     lltok_free2 ($2, $5);
    }
  | plainNamedDeclBase PushType TLPAREN TRPAREN 
    { setCurrentParams (uentryList_missingParams); }
@@ -402,6 +496,7 @@ plainNamedDeclBase
      $$ = idDecl_replaceCtype ($1, ct);
      idDecl_addClauses ($$, $6);
      context_popLoc (); 
+     lltok_free2 ($3, $4);
    }
  | plainNamedDeclBase PushType TLPAREN genericParamList TRPAREN 
    { setCurrentParams ($4); } 
@@ -411,42 +506,86 @@ plainNamedDeclBase
      $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
      idDecl_addClauses ($$, $7);
      context_popLoc (); 
+     lltok_free ($3);
+     /*!! lltok_free2 ($3, $5); */
    }
+;
 
 iterDecl
  : QITER newId TLPAREN genericParamList TRPAREN 
    { setCurrentParams ($4); } functionClausesPlain
    { clearCurrentParams (); } optSemi QENDMACRO
-   { declareCIter ($2, $4); }
+   { declareCIter ($2, $4); 
+     lltok_free3 ($1, $3, $5); 
+   }
+;
 
 macroDef
- : LLMACRO macroBody TENDMACRO     { exprNode_checkMacroBody ($2); }
- | LLMACROITER iterBody TENDMACRO  { exprNode_checkIterBody ($2); }
- | LLMACROEND endBody TENDMACRO    { exprNode_checkIterEnd ($2); }
- | LLMACRO TENDMACRO /* no stmt */ { exprChecks_checkEmptyMacroBody (); } 
+ : LLMACRO macroBody TENDMACRO     { exprNode_checkMacroBody ($2); lltok_free2 ($1, $3); }
+ | LLMACROITER iterBody TENDMACRO  { exprNode_checkIterBody ($2); lltok_free2 ($1, $3); }
+ | LLMACROEND endBody TENDMACRO    { exprNode_checkIterEnd ($2); lltok_free2 ($1, $3);}
+ | LLMACRO TENDMACRO /* no stmt */ { exprChecks_checkEmptyMacroBody (); lltok_free2 ($1, $2); } 
+;
 
 fcnDefHdr
-  : fcnDefHdrAux { clabstract_declareFunction ($1); }
+ : fcnDefHdrAux { clabstract_declareFunction ($1); }
+;
+
+metaStateConstraint
+ : metaStateSpecifier TASSIGN metaStateExpression 
+   { $$ = metaStateConstraint_create ($1, $3); lltok_free ($2); }
+;
+
+metaStateSpecifier
+  : BufConstraintSrefExpr { cscannerHelp_expectingMetaStateName (); } TCOLON metaStateName
+    { cscannerHelp_clearExpectingMetaStateName ();
+      $$ = metaStateSpecifier_create ($1, $4); 
+      lltok_free ($3); 
+    }
+  | CTOK_ELIPSIS { cscannerHelp_expectingMetaStateName (); } TCOLON metaStateName
+    { cscannerHelp_clearExpectingMetaStateName ();
+      $$ = metaStateSpecifier_createElipsis ($4); 
+      lltok_free2 ($1, $3);
+    }
+;
+
+metaStateExpression
+: metaStateSpecifier { $$ = metaStateExpression_create ($1); }
+| metaStateSpecifier TBAR metaStateExpression { $$ = metaStateExpression_createMerge ($1, $3); lltok_free ($2); }
+;
+
+metaStateName
+: METASTATE_NAME
+;
 
 /*drl*/
 
+constraintSeperator
+: TCAND
+| AND_OP
+;
+
 BufConstraintList
-: BufConstraint TCAND BufConstraintList { $$ = constraintList_add ($3, $1); }
-| BufConstraint {constraintList c; c = constraintList_makeNew(); c = constraintList_add (c, $1); $$ = c}
+: BufConstraint constraintSeperator BufConstraintList { $$ = constraintList_add ($3, $1); }
+| BufConstraint { $$ = constraintList_single ($1); } 
+;
 
 BufConstraint
 :  BufConstraintExpr relationalOp BufConstraintExpr {
  $$ = makeConstraintParse3 ($1, $2, $3);
  DPRINTF(("Done BufConstraint1\n")); }
+;
 
 bufferModifier
  : QMAXSET
  | QMAXREAD
+;
 
 relationalOp
  : GE_OP
  | LE_OP
  | EQ_OP
+;
 
 BufConstraintExpr
  : BufConstraintTerm 
@@ -454,31 +593,37 @@ BufConstraintExpr
  | TLPAREN BufConstraintExpr BufBinaryOp BufConstraintExpr TRPAREN {
    DPRINTF( ("Got BufConstraintExpr BINary Op ") );
    $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
+;
 
 BufConstraintTerm
-: BufConstraintSrefExpr { $$ =  constraintExpr_makeTermsRef($1);} 
- | CCONSTANT {  char *t; int c;
-  t =  cstring_toCharsSafe (exprNode_unparse($1));
-  c = atoi( t );
-  $$ = constraintExpr_makeIntLiteral (c);
-}
-
+ : BufConstraintSrefExpr { $$ =  constraintExpr_makeTermsRef ($1);} 
+ | CCONSTANT { $$ = constraintExpr_makeIntLiteral (exprNode_getLongValue ($1)); }
+;
 
 BufConstraintSrefExpr
-: id                               { /*@-onlytrans@*/ $$ = checkbufferConstraintClausesId ($1); /*@=onlytrans@*/ /*@i523@*/ }
-| NEW_IDENTIFIER                   { $$ = fixStateClausesId ($1); }
-| BufConstraintSrefExpr TLSQBR TRSQBR       { $$ = sRef_makeAnyArrayFetch ($1); }
-|  BufConstraintSrefExpr  TLSQBR CCONSTANT TRSQBR {
-  char *t; int c; 
-  t =  cstring_toCharsSafe (exprNode_unparse($3)); /*@i5234 yuck!@*/
-  c = atoi( t );
-  $$ = sRef_makeArrayFetchKnown($1, c); }
-| TMULT  BufConstraintSrefExpr               { $$ = sRef_constructPointer ($2); }
-| TLPAREN BufConstraintSrefExpr TRPAREN     { $$ = $2; }  
-|  BufConstraintSrefExpr TDOT newId          { cstring_markOwned ($3);
- $$ = sRef_buildField ($1, $3); }
-|  BufConstraintSrefExpr ARROW_OP newId      { cstring_markOwned ($3);
- $$ = sRef_makeArrow ($1, $3); }
+: id            
+  { /*@-onlytrans@*/ $$ = checkbufferConstraintClausesId ($1); /*@=onlytrans@*/ /*@i523@*/ }
+| NEW_IDENTIFIER                   
+  { $$ = fixStateClausesId ($1); }
+| BufConstraintSrefExpr TLSQBR TRSQBR       
+  { $$ = sRef_makeAnyArrayFetch ($1); }
+| BufConstraintSrefExpr  TLSQBR CCONSTANT TRSQBR 
+  {
+    /*
+    char *t; int c; 
+    t =  cstring_toCharsSafe (exprNode_unparse($3)); 
+    c = atoi( t );
+    */
+    $$ = sRef_makeArrayFetchKnown ($1, exprNode_getLongValue ($3));
+  }
+| TMULT  BufConstraintSrefExpr               
+  { $$ = sRef_constructPointer ($2); }
+| TLPAREN BufConstraintSrefExpr TRPAREN     
+  { $$ = $2; }  
+| BufConstraintSrefExpr TDOT newId          
+  { cstring_markOwned ($3); $$ = sRef_buildField ($1, $3); }
+| BufConstraintSrefExpr ARROW_OP newId      
+  { cstring_markOwned ($3); $$ = sRef_makeArrow ($1, $3); }
 
 /*
 | BufConstraintTerm TLSQBR TRSQBR       { $$ = sRef_makeAnyArrayFetch ($1); }
@@ -487,6 +632,7 @@ BufConstraintSrefExpr
  | specClauseListExpr TDOT newId          { cstring_markOwned ($3);
                                            $$ = sRef_buildField ($1, $3); }
 */
+;
 
 /*BufConstraintExpr
 : BufConstraintTerm 
@@ -508,6 +654,7 @@ functionClauses
  : { $$ = functionClauseList_new (); }
  | functionClause functionClauses
    { $$ = functionClauseList_prepend ($2, $1); }
+;
 
 /*
 ** Inside macro definitions, there are no end macros.
@@ -518,6 +665,7 @@ functionClausesPlain
    { $$ = functionClauseList_new (); }
  | functionClausePlain functionClausesPlain
    { $$ = functionClauseList_prepend ($2, $1); }
+;
 
 functionClause
  : globalsClause   { $$ = functionClause_createGlobals ($1); }
@@ -526,6 +674,7 @@ functionClause
  | stateClause     { $$ = functionClause_createState ($1); }  
  | conditionClause { $$ = $1; }
  | warnClause      { $$ = functionClause_createWarn ($1); }
+;
 
 functionClausePlain
  : globalsClausePlain   { $$ = functionClause_createGlobals ($1); }
@@ -534,9 +683,11 @@ functionClausePlain
  | stateClausePlain     { $$ = functionClause_createState ($1); }  
  | conditionClausePlain { $$ = $1; }
  | warnClausePlain      { $$ = functionClause_createWarn ($1); }
+;
 
 globalsClause
  : globalsClausePlain QENDMACRO { $$ = $1; }
+;
 
 globalsClausePlain
  : QGLOBALS { setProcessingGlobalsList (); } 
@@ -545,12 +696,15 @@ globalsClausePlain
      unsetProcessingGlobals (); 
      $$ = globalsClause_create ($1, $3); 
    }
+;
 
 nomodsClause
  : QNOMODS { $$ = modifiesClause_createNoMods ($1); }
+;
 
 modifiesClause
  : modifiesClausePlain QENDMACRO { $$ = $1; }
+;
 
 modifiesClausePlain
  : QMODIFIES 
@@ -565,40 +719,58 @@ modifiesClausePlain
      context_releaseVars ();
      $$ = modifiesClause_create ($1, $3);
    }
+;
 
 flagSpec
  : flagId 
    { $$ = flagSpec_createPlain ($1); }
  | flagId TBAR flagSpec
    { $$ = flagSpec_createOr ($1, $3); }
+;
 
 flagId
  : NEW_IDENTIFIER
+;
+
+optWarnClause
+ : warnClause
+ | /* empty */ { $$ = warnClause_undefined; }
+;
 
 warnClause
  : warnClausePlain QENDMACRO { $$ = $1; }
+;
 
 warnClausePlain
  : QWARN flagSpec cconstantExpr
-   { $$ = warnClause_create ($1, $2, $3); }
+   {      
+     llassert (exprNode_knownStringValue ($3));
+     $$ = warnClause_create ($1, $2, cstring_copy (multiVal_forceString (exprNode_getValue ($3)))); 
+     exprNode_free ($3);
+   }
  | QWARN flagSpec
-   { $$ = warnClause_create ($1, $2, exprNode_undefined); }
+   { $$ = warnClause_create ($1, $2, cstring_undefined); }
+;
 
 globIdList
  : globIdListExpr                     { $$ = globSet_single ($1); }
  | globIdList TCOMMA globIdListExpr   { $$ = globSet_insert ($1, $3); }
+;
  
 globIdListExpr 
  : optGlobQuals globId { $$ = clabstract_createGlobal ($2, $1); }
+;
 
 optGlobQuals
  : /* empty */           { $$ = qualList_undefined; }
  | globQual optGlobQuals { $$ = qualList_add ($2, $1); }
+;
 
 globId
  : id             { $$ = uentry_getSref ($1); }
  | NEW_IDENTIFIER { $$ = clabstract_unrecognizedGlobal ($1); }
  | initializer    { $$ = clabstract_checkGlobal ($1); }
+;
 
 globQual
  : QUNDEF   { $$ = qual_createUndef (); }
@@ -606,6 +778,7 @@ globQual
  | QOUT     { $$ = qual_createOut (); }
  | QIN      { $$ = qual_createIn (); }
  | QPARTIAL { $$ = qual_createPartial (); }
+;
 
 stateTag
  : QDEFINES
@@ -613,20 +786,24 @@ stateTag
  | QALLOCATES
  | QSETS
  | QRELEASES
+;
 
 conditionTag
  : QPRECLAUSE
  | QPOSTCLAUSE
+;
 
 fcnDefHdrAux
  : namedDecl                               
    { 
-     qtype qint = qtype_create (ctype_int);
+     /**!!! deal with fred; fred (int); declarations! **/
+     qtype qint = qtype_create (ctype_int); 
      $$ = idDecl_fixBase ($1, qint);
      qtype_free (qint);
    }
  | completeTypeSpecifier NotType namedDecl 
    { $$ = idDecl_fixBase ($3, $1); }
+;
  
 fcnBody
  : TLBRACE { checkDoneParams (); context_enterInnerContext (); } 
@@ -635,48 +812,54 @@ fcnBody
      exprNode_checkFunctionBody ($3); $$ = $3; 
      context_exitInner ($3); 
    }
- | initializerList 
-   { doneParams (); context_enterInnerContext (); }
+ | { context_enterOldStyleScope (); } initializerList 
+   { oldStyleDoneParams (); context_enterInnerContext (); } 
    compoundStmt 
    {
-     context_exitInner ($3);
-     exprNode_checkFunctionBody ($3); 
-     $$ = $3; /* old style */ 
+     exprNode_checkFunctionBody ($4); 
+     $$ = $4; /* oldstyle */ 
+     context_exitInner ($4);
    } 
+;
  
 fcnDef
  : fcnDefHdr fcnBody 
    { 
      context_setFunctionDefined (exprNode_loc ($2)); 
-     exprNode_checkFunction (context_getHeader (), $2); 
+     exprNode_checkFunction (context_getHeader (),  $2); 
      /* DRL 8 8 2000 */
      
      context_exitFunction ();
    }
+;
 
 locModifies
  : modList optSemi           { $$ = $1; }
  | optSemi                   { $$ = sRefSet_new (); }
+;
  
 modListExpr
  : id                              { $$ = uentry_getSref ($1); checkModifiesId ($1); }
  | NEW_IDENTIFIER                  { $$ = fixModifiesId ($1); }
+ | TYPE_NAME_OR_ID                 { $$ = fixModifiesId ($1); }
  | modListExpr TLSQBR TRSQBR       { $$ = modListArrayFetch ($1, sRef_undefined); }
  | modListExpr TLSQBR mExpr TRSQBR { $$ = modListArrayFetch ($1, $3); }
  | TMULT modListExpr               { $$ = modListPointer ($2); }
  | TLPAREN modListExpr TRPAREN     { $$ = $2; }  
  | modListExpr TDOT newId          { $$ = modListFieldAccess ($1, $3); }
  | modListExpr ARROW_OP newId      { $$ = modListArrowAccess ($1, $3); }
-
+;
 
 mExpr
   : modListExpr     { $$ = $1; }
   | cconstantExpr   { $$ = sRef_makeUnknown (); /* sRef_makeConstant ($1); ? */ }
     /* arithmetic? */
+;
 
 modList
   : modListExpr                { $$ = sRefSet_single ($1); }
   | modList TCOMMA modListExpr { $$ = sRefSet_insert ($1, $3); }
+;
 
 specClauseListExpr
  : id                                     
@@ -691,15 +874,19 @@ specClauseListExpr
                                            $$ = sRef_buildField ($1, $3); }
  | specClauseListExpr ARROW_OP newId      { cstring_markOwned ($3);
                                             $$ = sRef_makeArrow ($1, $3); }
+;
 
 optSpecClauseList
- : /* empty */ { $$ = sRefSet_undefined }
+ : /* empty */ { DPRINTF ((message("Empty optSpecClauseList") )); $$ = sRefSet_undefined }
  | specClauseList
+ ;
 
 specClauseList
   : specClauseListExpr                       
     { if (sRef_isValid ($1)) { $$ = sRefSet_single ($1); } 
-      else { $$ = sRefSet_undefined; } 
+      else {
+       DPRINTF((message("returning sRefSEt_undefined ")  ));
+       $$ = sRefSet_undefined; } 
     }
   | specClauseList TCOMMA specClauseListExpr 
     { if (sRef_isValid ($3))
@@ -711,14 +898,19 @@ specClauseList
          $$ = $1;
        }
     }
+;
 
 primaryExpr
  : id { $$ = exprNode_fromIdentifier ($1); }
  | NEW_IDENTIFIER { $$ = exprNode_fromUIO ($1); } 
  | cconstantExpr
  | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
- | TYPE_NAME_OR_ID { $$ = exprNode_fromIdentifier (coerceId ($1)); } 
+ | TYPE_NAME_OR_ID { $$ = exprNode_fromIdentifier (cscannerHelp_coerceId ($1)); } 
  | QEXTENSION { $$ = exprNode_makeError (); }
+ | TLPAREN { exprChecks_inCompoundStatementExpression (); } 
+   compoundStmt TRPAREN 
+   { exprChecks_leaveCompoundStatementExpression (); $$ = exprNode_compoundStatementExpression ($1, $3); }
+;
  
 postfixExpr
  : primaryExpr 
@@ -730,10 +922,14 @@ postfixExpr
  | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
  | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
  | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
+ | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE 
+   { /* added for C99 */ $$ = exprNode_undefined; /*@i87 no checking */ }
+;
+
 argumentExprList
  : assignExpr { $$ = exprNodeList_singleton ($1); }
  | argumentExprList TCOMMA assignExpr { $$ = exprNodeList_push ($1, $3); }
+;
  
 unaryExpr
  : postfixExpr 
@@ -745,47 +941,67 @@ unaryExpr
  | TMINUS castExpr { $$ = exprNode_preOp ($2, $1); }
  | TTILDE castExpr { $$ = exprNode_preOp ($2, $1); }
  | TEXCL castExpr  { $$ = exprNode_preOp ($2, $1); }
- | sizeofExpr      { $$ = $1; }
+ | processSizeof sizeofExpr endprocessSizeof      { $$ = $2; }
  | offsetofExpr    { $$ = $1; }
+;
 
 fieldDesignator
- : fieldDesignator TDOT newId { $$ = cstringList_add ($1, $3); }
- | newId                      { $$ = cstringList_single ($1); }
+ : fieldDesignator TDOT newId         { $$ = cstringList_add ($1, $3); lltok_free ($2); }
+ | fieldDesignator TLSQBR expr TRSQBR { $$ = $1; lltok_free2 ($2, $4); }
+   /* evans 2002-07-02: offsetof designators can use array indexes */
+ | newId                              { $$ = cstringList_single ($1); }
+;
 
 offsetofExpr
  : COFFSETOF IsType TLPAREN typeExpression NotType TCOMMA fieldDesignator TRPAREN IsType
-   { $$ = exprNode_offsetof ($4, $7); }
+   { $$ = exprNode_offsetof ($4, $7); 
+     lltok_free3 ($1, $3, $6); lltok_free ($8); }
+;
 
 sizeofExpr
  : IsType { context_setProtectVars (); } 
    sizeofExprAux { context_sizeofReleaseVars (); $$ = $3; }
+;
+
+processSizeof: {context_enterSizeof()};
+
+
+endprocessSizeof: {context_leaveSizeof()};
+
 
 sizeofExprAux 
- : CSIZEOF TLPAREN typeExpression TRPAREN { $$ = exprNode_sizeofType ($3); } 
- | CSIZEOF unaryExpr                      { $$ = exprNode_sizeofExpr ($2); }
- | CALIGNOF TLPAREN typeExpression TRPAREN { $$ = exprNode_alignofType ($3); } 
- | CALIGNOF unaryExpr                      { $$ = exprNode_alignofExpr ($2); }
+ : CSIZEOF TLPAREN typeExpression TRPAREN { $$ = exprNode_sizeofType ($3); lltok_free3 ($1, $2, $4);  } 
+ | CSIZEOF  unaryExpr                      { $$ = exprNode_sizeofExpr ($2); lltok_free ($1); }
+ | CALIGNOF TLPAREN typeExpression TRPAREN { $$ = exprNode_alignofType ($3); lltok_free3 ($1, $2, $4); } 
+ | CALIGNOF unaryExpr                      { $$ = exprNode_alignofExpr ($2); lltok_free ($1); }
+;
+
+
+
 castExpr
  : unaryExpr 
  | TLPAREN typeExpression TRPAREN castExpr 
-   { $$ = exprNode_cast ($1, $4, $2); } 
+   { $$ = exprNode_cast ($1, $4, $2); lltok_free ($3); } 
+;
  
 timesExpr
  : castExpr 
  | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
  | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
  | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 plusExpr
  : timesExpr 
  | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
  | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 shiftExpr
  : plusExpr 
  | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
  | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 relationalExpr
  : shiftExpr 
@@ -793,15 +1009,18 @@ relationalExpr
  | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
  | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
  | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
+;
  
 equalityExpr 
  : relationalExpr 
  | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
  | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 bitandExpr
  : equalityExpr 
  | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 xorExpr
  : bitandExpr 
@@ -811,6 +1030,7 @@ xorExpr
 bitorExpr
  : xorExpr 
  | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 andExpr 
  : bitorExpr 
@@ -823,6 +1043,7 @@ andExpr
      $$ = exprNode_op ($1, $4, $2); 
      context_exitAndClause ($$, $4);
    }
+;
 
 orExpr
  : andExpr 
@@ -836,12 +1057,19 @@ orExpr
      $$ = exprNode_op ($1, $4, $2); 
      context_exitOrClause ($$, $4);
    }
+;
 
 conditionalExpr 
  : orExpr 
+ | orExpr TQUEST 
+   { /* GCC extension: conditional with empty if */
+     exprNode_produceGuards ($1); context_enterTrueClause ($1); } TCOLON 
+   { context_enterFalseClause ($1); } conditionalExpr
+   { $$ = exprNode_condIfOmit ($1, $6); context_exitClause ($1, exprNode_undefined, $6); }
  | orExpr TQUEST { exprNode_produceGuards ($1); context_enterTrueClause ($1); } expr TCOLON 
    { context_enterFalseClause ($1); } conditionalExpr
    { $$ = exprNode_cond ($1, $4, $7); context_exitClause ($1, $4, $7); }
+;
 
 assignExpr
  : conditionalExpr 
@@ -856,17 +1084,21 @@ assignExpr
  | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
  | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
  | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
+;
 
 expr
  : assignExpr 
  | expr TCOMMA assignExpr { $$ = exprNode_comma ($1, $3); } 
+;
 
 optExpr
  : /* empty */ { $$ = exprNode_undefined; }
  | expr 
+ ;
 
 constantExpr
  : conditionalExpr 
+;
 
 /* instance_orTypeDecl_and_possible_initialization */
 
@@ -874,11 +1106,12 @@ initializer
  : instanceDecl { $$ = $1; }
  | VA_DCL       { doVaDcl (); $$ = exprNode_makeError (); } 
  | typeDecl     { $$ = exprNode_makeError (); }
+;
 
 instanceDecl
  : completeTypeSpecifier IsType TSEMI 
-   { $$ = exprNode_makeError (); }
-    /*
+   { $$ = exprNode_makeError (); } 
+     /*
      ** This causes r/r conflicts with function definitions.
      ** Instead we need to snarf one first. (gack)
      **
@@ -907,6 +1140,12 @@ instanceDecl
    { $$ = exprNode_concat ($9, exprNode_makeInitialization ($3, $8)); 
      unsetProcessingVars ();
    }
+;
+
+namedInitializerType
+ : namedInitializer { $$ = $1; } 
+ | TYPE_NAME { $$ = exprNode_fromIdentifier (usymtab_getTypeEntry (ctype_typeId ($1))); }
+;
 
 namedInitializer
  : namedDecl NotType 
@@ -916,41 +1155,80 @@ namedInitializer
    }
  | namedDecl NotType TASSIGN { processNamedDecl ($1); } IsType init
    { $$ = exprNode_makeInitialization ($1, $6); }
+;
 
 typeDecl
  : CTYPEDEF completeTypeSpecifier { setProcessingTypedef ($2); } 
-   NotType namedInitializerList IsType TSEMI { unsetProcessingTypedef (); } 
+   NotType namedInitializerTypeList IsType optWarnClause TSEMI 
+   { clabstract_declareType ($5, $7); }
  | CTYPEDEF completeTypeSpecifier IsType TSEMI { /* in the ANSI grammar, semantics unclear */ }
  | CTYPEDEF namedInitializerList IsType TSEMI { /* in the ANSI grammar, semantics unclear */ } 
+;
 
 IsType
- : { g_expectingTypeName = TRUE; }
+ : { cscannerHelp_setExpectingTypeName (); }
+;
 
 PushType
- : { g_expectingTypeName = TRUE; context_pushLoc (); }
+ : { cscannerHelp_setExpectingTypeName (); context_pushLoc (); }
+;
 
 namedInitializerList
- :  namedInitializerListAux IsType { ; }
+ :  namedInitializerListAux IsType { $$ = $1; }
+;
 
 namedInitializerListAux
- : namedInitializer { ; }
- | namedInitializerList TCOMMA NotType namedInitializer { ; }
+ : namedInitializer { $$ = exprNodeList_singleton ($1); }
+ | namedInitializerList TCOMMA NotType namedInitializer { $$ = exprNodeList_push ($1, $4); }
+;
+
+namedInitializerTypeList
+ :  namedInitializerTypeListAux IsType { $$ = $1; }
+;
+
+namedInitializerTypeListAux
+ : namedInitializerType { $$ = exprNodeList_singleton ($1); }
+ | namedInitializerTypeList TCOMMA NotType namedInitializerType { $$ = exprNodeList_push ($1, $4); }
+;
 
 optDeclarators
  : /* empty */      { $$ = exprNode_makeError (); }
  | optDeclarators TCOMMA NotType namedInitializer { $$ = exprNode_concat ($1, $4); }
+;
 
 init
  : assignExpr                      
- | TLBRACE initList TRBRACE        { $$ = exprNode_makeInitBlock ($1, $2); }
- | TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); }
+ | TLBRACE initList TRBRACE        { $$ = exprNode_makeInitBlock ($1, $2); lltok_free ($3); }
+ | TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); lltok_free2 ($3, $4); }
+ | designation init                { $$ = exprNode_undefined; }
+;
 
+/*
+** Splint parses these (added in ISO C99), but no checking yet...
+*/
+
+designation
+ : designatorList TASSIGN          { $$ = $1; }
+ | newId TCOLON                    { $$ = exprNode_undefined; 
+                                     /* gcc extension, obsolete since 2.5 */ }
+;
+
+designatorList
+ : designator                      { $$ = exprNode_undefined; } 
+ | designatorList designator       { $$ = exprNode_undefined; }
+;
+
+designator
+ : TLSQBR constantExpr TRSQBR      { $$ = exprNode_undefined; }
+ | TDOT newId                      { $$ = exprNode_undefined; }
+;
 
 initList
  : init 
    { $$ = exprNodeList_singleton ($1); }
  | initList TCOMMA init 
    { $$ = exprNodeList_push ($1, $3); }
+;
 
 /*
 ** need to do the storage class global hack so tags are
@@ -963,12 +1241,11 @@ storageSpecifier
  | QSTATIC   { setStorageClass (SCSTATIC); $$ = qual_createStatic (); }
  | QAUTO     { $$ = qual_createAuto (); }
  | QREGISTER { $$ = qual_createRegister (); }
-
-nullterminatedQualifier:
- QNULLTERMINATED IsType { $$ = qual_createNullTerminated (); }
+;
 
 stateClause
  : stateClausePlain QENDMACRO { $$ = $1; }
+;
 
 stateClausePlain
  : stateTag NotType
@@ -984,12 +1261,15 @@ stateClausePlain
      context_releaseVars ();
      $$ = stateClause_createPlain ($1, $4);
    }
+;
 
 conditionClause
  : conditionClausePlain QENDMACRO { $$ = $1; }
+;
 
 startConditionClause
 : conditionTag NotType { $$ = $1; context_enterFunctionHeader (); } 
+;
 
 conditionClausePlain
  : startConditionClause stateQualifier
@@ -1012,7 +1292,7 @@ conditionClausePlain
      enterParamsTemp (); 
      sRef_setGlobalScopeSafe (); 
    } 
-   BufConstraintList optSemi IsType
+   functionConstraint optSemi IsType
    {
      context_exitFunctionHeader ();
      exitParamsTemp ();
@@ -1032,7 +1312,15 @@ conditionClausePlain
        {
         BADBRANCH;
        }
+
+     DPRINTF (("FunctionclauseS: %s", functionClause_unparse ($$)));
    }
+;
+
+functionConstraint
+ : BufConstraintList   { $$ = functionConstraint_createBufferConstraint ($1); }
+ | metaStateConstraint { $$ = functionConstraint_createMetaStateConstraint ($1); DPRINTF (("Made constraint: %s", functionConstraint_unparse ($$))); } 
+;
  
 exitsQualifier
  : QEXITS        { $$ = qual_createExits (); }
@@ -1040,12 +1328,14 @@ exitsQualifier
  | QTRUEEXIT     { $$ = qual_createTrueExit (); }
  | QFALSEEXIT    { $$ = qual_createFalseExit (); }
  | QNEVEREXIT    { $$ = qual_createNeverExit (); }
+;
 
 checkQualifier
  : QCHECKED        { $$ = qual_createChecked (); }
  | QCHECKMOD       { $$ = qual_createCheckMod (); }
  | QUNCHECKED      { $$ = qual_createUnchecked (); }
  | QCHECKEDSTRICT  { $$ = qual_createCheckedStrict (); }
+;
 
 stateQualifier
  : QOWNED        { $$ = qual_createOwned (); }
@@ -1063,25 +1353,32 @@ stateQualifier
  | QNOTNULL      { $$ = qual_createNotNull (); }
  | QEXPOSED      { $$ = qual_createExposed (); }
  | QOBSERVER     { $$ = qual_createObserver (); }
+ | QNULLTERMINATED { $$ = qual_createNullTerminated (); } 
  | CANNOTATION   { $$ = qual_createMetaState ($1); }
+;
 
 paramQualifier
  : QRETURNED     { $$ = qual_createReturned (); }
  | QSEF          { $$ = qual_createSef (); }
+;
 
 visibilityQualifier
  : QUNUSED       { $$ = qual_createUnused (); }
  | QEXTERNAL     { $$ = qual_createExternal (); }
+;
 
 returnQualifier
  : QTRUENULL     { $$ = qual_createTrueNull (); }
  | QFALSENULL    { $$ = qual_createFalseNull (); }
+;
 
 typedefQualifier
  : QABSTRACT     { $$ = qual_createAbstract (); }
+ | QNUMABSTRACT  { $$ = qual_createNumAbstract (); }
  | QCONCRETE     { $$ = qual_createConcrete (); }
  | QMUTABLE      { $$ = qual_createMutable (); }
  | QIMMUTABLE    { $$ = qual_createImmutable (); }
+;
 
 refcountQualifier
  : QREFCOUNTED   { $$ = qual_createRefCounted (); }
@@ -1090,22 +1387,26 @@ refcountQualifier
  | QRELDEF       { $$ = qual_createRelDef (); }
  | QNEWREF       { $$ = qual_createNewRef (); }
  | QTEMPREF      { $$ = qual_createTempRef (); }
+;
 
 typeModifier
  : QSHORT            { $$ = qual_createShort (); }
  | QLONG             { $$ = qual_createLong (); }
  | QSIGNED           { $$ = qual_createSigned (); }
  | QUNSIGNED         { $$ = qual_createUnsigned (); }
+;
 
 definedQualifier
  : QOUT              { $$ = qual_createOut (); }
  | QIN               { $$ = qual_createIn (); }
  | QPARTIAL          { $$ = qual_createPartial (); }
  | QSPECIAL          { $$ = qual_createSpecial (); }
+;
 
 typeQualifier
  : QCONST IsType       { $$ = qual_createConst (); }
  | QVOLATILE IsType    { $$ = qual_createVolatile (); }
+ | QRESTRICT IsType    { $$ = qual_createRestrict (); }
  | definedQualifier IsType { $$ = $1; } 
  | stateQualifier IsType { $$ = $1; } 
  | exitsQualifier IsType { $$ = $1; }
@@ -1115,6 +1416,7 @@ typeQualifier
  | visibilityQualifier IsType { $$ = $1; }
  | typedefQualifier IsType { $$ = $1; }
  | refcountQualifier IsType { $$ = $1; }
+;
 
 /*
 ** This is copied into the mtgrammar!
@@ -1127,44 +1429,58 @@ typeSpecifier
  | CGFLOAT NotType
  | CDOUBLE NotType
  | CVOID NotType 
- | QANYTYPE NotType              { $$ = ctype_unknown; }
+ | QANYTYPE NotType              { $$ = ctype_makeAnytype (); }
  | QINTEGRALTYPE NotType         { $$ = ctype_anyintegral; }
  | QUNSIGNEDINTEGRALTYPE NotType { $$ = ctype_unsignedintegral; }
  | QSIGNEDINTEGRALTYPE NotType   { $$ = ctype_signedintegral; }
  | typeName NotType     
  | suSpc NotType 
  | enumSpc NotType
- | typeModifier NotType { $$ = ctype_fromQual ($1); }
+ | typeModifier NotType           { $$ = ctype_fromQual ($1); }
+;
 
 completeType
  : IsType completeTypeSpecifier IsType
    { $$ = qtype_resolve ($2); }
+;
 
 completeTypeSpecifier
  : completeTypeSpecifierAux { $$ = $1; }
  | completeTypeSpecifierAux QALT altType QENDMACRO  
    { $$ = qtype_mergeAlt ($1, $3); }
+;
 
 altType
  : typeExpression
  | typeExpression TCOMMA altType
    { $$ = qtype_mergeAlt ($1, $3); } 
+;
 
 completeTypeSpecifierAux
  : storageSpecifier optCompleteType        { $$ = qtype_addQual ($2, $1); }
  | typeQualifier optCompleteType           { $$ = qtype_addQual ($2, $1); } 
  | typeSpecifier optCompleteType           { $$ = qtype_combine ($2, $1); }
+;
 
 optCompleteType
  : /* empty */                             { $$ = qtype_unknown (); }
  | completeTypeSpecifier                   { $$ = $1; }
+;
+
+optStructInvariant
+: /* empty */ { $$ = constraintList_undefined; }
+/*  drl commenting before a CVS commit 
+   |  QINVARIANT BufConstraintList QENDMACRO { $$ = $2 }
+*/
+;
 
 suSpc
  : NotType CSTRUCT newId IsType TLBRACE { sRef_setGlobalScopeSafe (); } 
    CreateStructInnerScope 
-   structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
+   structDeclList  DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
    TRBRACE 
-   { $$ = declareStruct ($3, $8); }
+   optStructInvariant 
+   { ctype ct; ct = declareStruct ($3, $8); /* context_setGlobalStructInfo(ct, $12); */ $$ = ct; } 
  | NotType CUNION  newId IsType TLBRACE { sRef_setGlobalScopeSafe (); } 
    CreateStructInnerScope 
    structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); } 
@@ -1180,42 +1496,48 @@ suSpc
    TRBRACE 
    { $$ = declareUnnamedStruct ($7); }
  | NotType CUNION IsType TLBRACE { sRef_setGlobalScopeSafe (); } 
-   CreateStructInnerScope 
-   structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
+   CreateStructInnerScope structDeclList DeleteStructInnerScope 
+   { sRef_clearGlobalScopeSafe (); }
    TRBRACE 
    { $$ = declareUnnamedUnion ($7); } 
  | NotType CSTRUCT IsType TLBRACE TRBRACE
    { $$ = ctype_createUnnamedStruct (uentryList_new ()); }
- | NotType CUNION  IsType TLBRACE TRBRACE 
+ | NotType CUNION IsType TLBRACE TRBRACE 
    { $$ = ctype_createUnnamedUnion (uentryList_new ()); } 
  | NotType CSTRUCT newId NotType { $$ = handleStruct ($3); } 
- | NotType CUNION  newId NotType { $$ = handleUnion ($3); }
+ | NotType CUNION newId NotType { $$ = handleUnion ($3); }
+;
 
 NotType
- : { g_expectingTypeName = FALSE; }
+: { cscannerHelp_clearExpectingTypeName (); }
+;
 
 structDeclList
  : structDecl 
  | macroDef { $$ = uentryList_undefined; /* bogus! */ }
  | structDeclList structDecl { $$ = uentryList_mergeFields ($1, $2); }
+;
 
 structDecl
  : completeTypeSpecifier NotType structNamedDeclList IsType TSEMI 
    { $$ = fixUentryList ($3, $1); }
  | completeTypeSpecifier IsType TSEMI 
    { $$ = fixUnnamedDecl ($1); }
+;
 
 structNamedDeclList 
  : structNamedDecl NotType                            
    { $$ = idDeclList_singleton ($1); }
  | structNamedDeclList TCOMMA structNamedDecl NotType
    { $$ = idDeclList_add ($1, $3); }
+;
 
 structNamedDecl  /* hack to get around namespace problems */ 
  : namedDecl                            { $$ = $1; }
  | TCOLON IsType constantExpr           { $$ = idDecl_undefined; }
  | namedDecl TCOLON IsType constantExpr { $$ = $1; }
    /* Need the IsType in case there is a cast in the constant expression. */
+;
 
 enumSpc
  : NotType CENUM TLBRACE enumeratorList TRBRACE IsType 
@@ -1223,6 +1545,7 @@ enumSpc
  | NotType CENUM newId TLBRACE { context_pushLoc (); } enumeratorList TRBRACE IsType
    { context_popLoc (); $$ = declareEnum ($3, $6); }
  | NotType CENUM newId IsType { $$ = handleEnum ($3); }
+;
 
 enumeratorList
  : enumerator 
@@ -1230,6 +1553,7 @@ enumeratorList
  | enumeratorList TCOMMA enumerator 
    { $$ = enumNameList_push ($1, $3); }
  | enumeratorList TCOMMA
+ ;
 
 enumerator
  : newId 
@@ -1242,6 +1566,7 @@ enumerator
      usymtab_supGlobalEntry (ue);
      $$ = $1; 
    }
+;
 
 optNamedDecl
  : namedDeclBase
@@ -1249,53 +1574,63 @@ optNamedDecl
  | pointers TYPE_NAME    
    { 
      qtype qt = qtype_unknown ();
-
      qtype_adjustPointers ($1, qt);
-     $$ = idDecl_create (cstring_copy (LastIdentifier ()), qt);
+     $$ = idDecl_create (cstring_copy (cscannerHelp_observeLastIdentifier ()), qt);
    }
  | pointers optNamedDecl 
    { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
+;
 
 namedDecl
  : namedDeclBase
  | pointers namedDeclBase 
    { $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
+;
 
 genericParamList
  : paramTypeList       { $$ = handleParamTypeList ($1); }
  | NotType paramIdList { $$ = handleParamIdList ($2); }  
+;
 
 innerMods
- : QCONST    { /* ignored for now */; }
- | QVOLATILE { ; }
+ : QCONST    { $$ = qual_createConst (); }
+ | QRESTRICT { $$ = qual_createRestrict (); }
+ | QVOLATILE { $$ = qual_createVolatile (); }
+;
 
 innerModsList
- : innerMods { ; }
- | innerModsList innerMods { ; }
+ : innerMods { $$ = qualList_single ($1); }
+ | innerModsList innerMods { $$ = qualList_add ($1, $2); }
+;
 
 pointers
- : TMULT { $$ = 1; }
- | TMULT innerModsList { $$ = 1; }
- | TMULT pointers { $$ = 1 + $2; }
- | TMULT innerModsList pointers { $$ = 1 + $3; }
+ : TMULT { $$ = pointers_create ($1); }
+ | TMULT innerModsList { $$ = pointers_createMods ($1, $2); }
+ | TMULT pointers { $$ = pointers_extend (pointers_create ($1), $2); } 
+ | TMULT innerModsList pointers { $$ = pointers_extend (pointers_createMods ($1, $2), $3); }
+;
 
 paramIdList
  : idList 
  | idList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
+;
 
 idList
  : newId { $$ = uentryList_single (uentry_makeVariableLoc ($1, ctype_int)); }
  | idList TCOMMA newId { $$ = uentryList_add ($1, uentry_makeVariableLoc ($3, ctype_int)); }
+;
 
 paramTypeList
  : CTOK_ELIPSIS { $$ = uentryList_single (uentry_makeElipsisMarker ()); }
  | paramList 
  | paramList TCOMMA CTOK_ELIPSIS { $$ = uentryList_add ($1, uentry_makeElipsisMarker ()); }
+;
 
 paramList
  : { storeLoc (); } paramDecl { $$ = uentryList_single ($2); }
  | paramList TCOMMA { storeLoc (); } paramDecl 
    { $$ = uentryList_add ($1, $4); }
+;
 
 paramDecl
  : IsType completeTypeSpecifier optNamedDecl IsType
@@ -1324,19 +1659,23 @@ paramDecl
      $$ = makeCurrentParam (tparam);
      idDecl_free (tparam);
    } 
+;
 
 typeExpression
  : completeType
  | completeType abstractDecl  { $$ = qtype_newBase ($1, $2); }
+;
 
 abstractDecl
  : pointers { $$ = ctype_adjustPointers ($1, ctype_unknown); }
  | abstractDeclBase
  | pointers abstractDeclBase { $$ = ctype_adjustPointers ($1, $2); }
+;
 
 optAbstractDeclBase
  : /* empty */ { $$ = ctype_unknown; }
  | abstractDeclBase 
+ ;
 
 abstractDeclBase
  : IsType TLPAREN NotType abstractDecl TRPAREN 
@@ -1344,9 +1683,9 @@ abstractDeclBase
  | TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
  | TLSQBR constantExpr TRSQBR 
    { $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
- | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeArray ($1); }
+ | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeInnerArray ($1); }
  | abstractDeclBase TLSQBR constantExpr TRSQBR 
-   { $$ = ctype_makeFixedArray ($1, exprNode_getLongValue ($3)); }
+   { $$ = ctype_makeInnerFixedArray ($1, exprNode_getLongValue ($3)); }
  | IsType TLPAREN TRPAREN 
    { $$ = ctype_makeFunction (ctype_unknown, uentryList_makeMissingParams ()); }
  | IsType TLPAREN paramTypeList TRPAREN 
@@ -1355,6 +1694,7 @@ abstractDeclBase
    { $$ = ctype_makeFunction ($1, uentryList_makeMissingParams ()); }  
  | abstractDeclBase IsType TLPAREN paramTypeList TRPAREN 
    { $$ = ctype_makeParamsFunction ($1, $4); }  
+;
 
 /* statement */
 
@@ -1368,29 +1708,26 @@ stmt
  | iterationStmt 
  | iterStmt
  | jumpStmt 
-/* | lclintassertion {$$ = $1; printf ("Doing stmt lclintassertion\n"); }*/
-
-/*
-lclintassertion
- : QSETBUFFERSIZE id CCONSTANT QENDMACRO { printf(" QSETBUFFERSIZE id CCONSTANT HEllo World\n");  uentry_setBufferSize($2, $3); $$ = exprNode_createTok ($4);
-  }
- | QSETSTRINGLENGTH id CCONSTANT QENDMACRO { printf(" QSETSTRINGLENGTH id CCONSTANT HEllo World\n");  uentry_setStringLength($2, $3); $$ = exprNode_createTok ($4);
-  }
- | QTESTINRANGE id CCONSTANT QENDMACRO {printf(" QTESTINRANGE\n");  uentry_testInRange($2, $3); $$ = exprNode_createTok ($4);
-  }
+ | debugStmt
+;
 
-/* | QSETBUFFERSIZE id id  {$$ = $2; printf(" QSETBUFFERSIZE id id HEllo World\n");} */
+debugStmt
+ : QDREVEALSTATE TLPAREN expr TRPAREN { exprNode_revealState ($3); $$ = exprNode_undefined; }
+;
 
 iterBody
  : iterDefStmtList { $$ = $1; }
+;
 
 endBody
  : iterBody
+;
 
 iterDefStmtList
  : iterDefStmt                 
  | iterDefStmtList iterDefStmt 
    { $$ = exprNode_concat ($1, $2); }
+;
 
 iterDefIterationStmt
  : iterWhilePred iterDefStmtList         
@@ -1401,6 +1738,7 @@ iterDefIterationStmt
    { $$ = exprNode_doWhile ($2, $5); }
  | forPred iterDefStmt
    { $$ = exprNode_for ($1, $2); } 
+;
 
 forPred
  : CFOR TLPAREN optExpr TSEMI optExpr TSEMI 
@@ -1408,6 +1746,7 @@ forPred
    TRPAREN 
    { $$ = exprNode_forPred ($3, $5, $8); 
      context_enterForClause ($5); }
+;
 
 partialIterStmt
  : ITER_NAME CreateInnerScope TLPAREN 
@@ -1415,6 +1754,7 @@ partialIterStmt
    iterArgList TRPAREN 
    { $$ = exprNode_iterStart ($1, $5); }
  | ITER_ENDNAME { $$ = exprNode_createId ($1); }
+;
 
 iterDefStmt
  : labeledStmt 
@@ -1430,22 +1770,27 @@ iterDefStmt
  | jumpStmt 
  | TLPAREN iterDefStmt TRPAREN { $$ = $2; }
  | error { $$ = exprNode_makeError (); }
+;
 
 iterSelectionStmt
- : ifPred iterDefStmt 
+ : ifPred { exprNode_checkIfPred ($1); } iterDefStmt 
    { /* don't: context_exitTrueClause ($1, $2); */
-     $$ = exprNode_if ($1, $2); 
+     $$ = exprNode_if ($1, $3); 
    }
+;
 
 openScope
  : CreateInnerScope TLBRACE { $$ = exprNode_createTok ($2); }
+;
 
 closeScope
  : DeleteInnerScopeSafe TRBRACE { $$ = exprNode_createTok ($2); }
+;
 
 macroBody
  : stmtErr    
  | stmtListErr
+;
  
 stmtErr
  : labeledStmt
@@ -1458,11 +1803,23 @@ stmtErr
  | iterationStmtErr
  | TLPAREN stmtErr TRPAREN { $$ = exprNode_addParens ($1, $2); }
  | jumpStmt 
+ | debugStmt
  | error { $$ = exprNode_makeError (); }
+;
 
 labeledStmt
  : newId TCOLON      { $$ = exprNode_labelMarker ($1); }
  | QNOTREACHED stmt  { $$ = exprNode_notReached ($2); }
+;
+
+/*
+** We allow more than one QFALLTHROUGH token to support mixed lint/splint markers.
+*/
+
+optExtraFallThroughs
+ : /* empty */ { ; }
+ | QFALLTHROUGH optExtraFallThroughs { ; }
+;
 
 /* Note that we can semantically check that the object to the case is
  indeed constant. In this case, we may not want to go through this effort */
@@ -1470,37 +1827,46 @@ labeledStmt
 caseStmt
  : CASE constantExpr { context_enterCaseClause ($2); } 
    TCOLON            { $$ = exprNode_caseMarker ($2, FALSE); }
- | QFALLTHROUGH CASE constantExpr { context_enterCaseClause ($3); } 
-   TCOLON            { $$ = exprNode_caseMarker ($3, TRUE); }
+ | QFALLTHROUGH optExtraFallThroughs CASE constantExpr { context_enterCaseClause ($4); } 
+   TCOLON            { $$ = exprNode_caseMarker ($4, TRUE); }
+;
 
 defaultStmt
  : DEFAULT { context_enterCaseClause (exprNode_undefined); } 
    TCOLON { $$ = exprNode_defaultMarker ($1, FALSE); }
- | QFALLTHROUGH DEFAULT { context_enterCaseClause (exprNode_undefined); } 
-   TCOLON { $$ = exprNode_defaultMarker ($2, TRUE); }
+ | QFALLTHROUGH optExtraFallThroughs DEFAULT { context_enterCaseClause (exprNode_undefined); } 
+   TCOLON { $$ = exprNode_defaultMarker ($3, TRUE); }
+;
 
 compoundStmt
  : TLPAREN compoundStmt TRPAREN { $$ = $2; }
  | CreateInnerScope compoundStmtAux 
    { $$ = $2; context_exitInner ($2); }
+;
 
 compoundStmtErr
  : CreateInnerScope compoundStmtAuxErr DeleteInnerScope { $$ = $2; }
+;
 
 CreateInnerScope
  : { context_enterInnerContext (); }
+;
 
 DeleteInnerScope
  : { context_exitInnerPlain (); }
+;
 
 CreateStructInnerScope
  : { context_enterStructInnerContext (); }
+;
 
 DeleteStructInnerScope
  : { context_exitStructInnerContext (); }
+;
 
 DeleteInnerScopeSafe
  : { context_exitInnerSafe (); }
+;
 
 compoundStmtRest
  : TRBRACE { $$ = exprNode_createTok ($1); }
@@ -1517,11 +1883,12 @@ compoundStmtRest
    { $$ = exprNode_notReached (exprNode_updateLocation (exprNode_concat ($1, $2), 
                                                        lltok_getLoc ($3))); 
    }
-
+;
 
 compoundStmtAux
  : TLBRACE compoundStmtRest 
    { $$ = exprNode_makeBlock ($2); }
+;
 
 compoundStmtAuxErr
  : TLBRACE TRBRACE 
@@ -1532,35 +1899,57 @@ compoundStmtAuxErr
    { $$ = exprNode_updateLocation ($2, lltok_getLoc ($3)); }
  | TLBRACE initializerList stmtList TRBRACE 
    { $$ = exprNode_updateLocation (exprNode_concat ($2, $3), lltok_getLoc ($4)); }
+;
 
 stmtListErr
  : stmtErr 
  | stmtListErr stmtErr { $$ = exprNode_concat ($1, $2); }
+;
 
 initializerList
  : initializer { $$ = $1; }
  | initializerList initializer { $$ = exprNode_concat ($1, $2); }
+;
+
+typeInitializerList
+ : typeInitializer { $$ = $1; }
+ | typeInitializerList TCOMMA typeInitializer { $$ = exprNode_concat ($1, $3); }
+;
+
+typeInitializer
+ : assignExpr { $$ = $1; }
+ | TLBRACE typeInitializerList optComma TRBRACE { $$ = $2; } 
+;
 
 stmtList
  : stmt { $$ = $1; }
  | stmtList stmt { $$ = exprNode_concat ($1, $2); }
+;
+
 expressionStmt 
  : TSEMI { $$ = exprNode_createTok ($1); }
  | expr TSEMI { $$ = exprNode_statement ($1, $2); }
+;
 
 expressionStmtErr
  : TSEMI { $$ = exprNode_createTok ($1); }
  | expr TSEMI { $$ = exprNode_statement ($1, $2); }
  | expr { $$ = exprNode_checkExpr ($1); } 
+;
 
 ifPred
  : CIF TLPAREN expr TRPAREN 
-   { $$ = $3; exprNode_produceGuards ($3); context_enterTrueClause ($3); }
+   { 
+     exprNode_produceGuards ($3); context_enterTrueClause ($3); 
+     exprNode_checkIfPred ($3);
+     $$ = $3;
+   }
+
  /*
  ** not ANSI: | CIF TLPAREN compoundStmt TRPAREN 
  **             { $$ = $3; context_enterTrueClause (); } 
  */
+;
 
 selectionStmt
  : ifPred stmt 
@@ -1568,21 +1957,24 @@ selectionStmt
      context_exitTrueClause ($1, $2);
      $$ = exprNode_if ($1, $2); 
    }
- | ifPred stmt CELSE { context_enterFalseClause ($1); } stmt 
+ | ifPred stmt CELSE  { context_enterFalseClause ($1); } stmt 
    {
      context_exitClause ($1, $2, $5);
      $$ = exprNode_ifelse ($1, $2, $5); 
    }
  | SWITCH TLPAREN expr { context_enterSwitch ($3); } 
    TRPAREN stmt        { $$ = exprNode_switch ($3, $6); }
+;
  
 whilePred
  : WHILE TLPAREN expr TRPAREN 
    { $$ = exprNode_whilePred ($3); context_enterWhileClause ($3); }
    /* not ANSI: | WHILE TLPAREN compoundStmt TRPAREN stmt { $$ = exprNode_while ($3, $5); } */
+;
 
 iterWhilePred
  : WHILE TLPAREN expr TRPAREN { $$ = exprNode_whilePred($3); }
+;
 
 iterStmt
  : ITER_NAME { context_enterIterClause (); } 
@@ -1593,16 +1985,18 @@ iterStmt
      $$ = exprNode_iter ($1, $6, $8, $9); 
 
    } 
+;
  
 iterArgList 
  : iterArgExpr { $$ = exprNodeList_singleton ($1); }
  | iterArgList { nextIterParam (); } TCOMMA iterArgExpr 
    { $$ = exprNodeList_push ($1, $4); }
+;
 
 iterArgExpr
   : assignIterExpr  { $$ = exprNode_iterExpr ($1); }
   | id              { $$ = exprNode_iterId ($1); }
-  | TYPE_NAME_OR_ID { uentry ue = coerceIterId ($1);
+  | TYPE_NAME_OR_ID { uentry ue = cscannerHelp_coerceIterId ($1);
 
                      if (uentry_isValid (ue)) 
                        {
@@ -1610,10 +2004,11 @@ iterArgExpr
                        }
                      else
                        {
-                         $$ = exprNode_iterNewId (cstring_copy (LastIdentifier ()));
+                         $$ = exprNode_iterNewId (cstring_copy (cscannerHelp_observeLastIdentifier ()));
                        }
                    }
   | NEW_IDENTIFIER  { $$ = exprNode_iterNewId ($1); }
+;
 
 /*
 ** everything is the same, EXCEPT it cannot be a NEW_IDENTIFIER 
@@ -1622,10 +2017,12 @@ iterArgExpr
 cconstantExpr
  : CCONSTANT
  | cconstantExpr CCONSTANT { $$ = exprNode_combineLiterals ($1, $2); }  
+;
 
 primaryIterExpr
  : cconstantExpr 
  | TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
+;
  
 postfixIterExpr
  : primaryIterExpr 
@@ -1638,6 +2035,7 @@ postfixIterExpr
  | postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
  | postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
  | postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
+;
  
 unaryIterExpr
  : postfixIterExpr 
@@ -1650,26 +2048,31 @@ unaryIterExpr
  | TTILDE castExpr     { $$ = exprNode_preOp ($2, $1); }
  | TEXCL castExpr      { $$ = exprNode_preOp ($2, $1); }
  | sizeofExpr          { $$ = $1; }
+;
 
 castIterExpr
  : unaryIterExpr 
  | TLPAREN typeExpression TRPAREN castExpr { $$ = exprNode_cast ($1, $4, $2); } 
+;
  
 timesIterExpr
  : castIterExpr 
  | timesExpr TMULT castExpr { $$ = exprNode_op ($1, $3, $2); }
  | timesExpr TDIV castExpr { $$ = exprNode_op ($1, $3, $2); }
  | timesExpr TPERCENT castExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 plusIterExpr
  : timesIterExpr 
  | plusExpr TPLUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
  | plusExpr TMINUS timesExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 shiftIterExpr
  : plusIterExpr 
  | shiftExpr LEFT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
  | shiftExpr RIGHT_OP plusExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 relationalIterExpr
  : shiftIterExpr 
@@ -1677,15 +2080,18 @@ relationalIterExpr
  | relationalExpr TGT shiftExpr { $$ = exprNode_op ($1, $3, $2); }
  | relationalExpr LE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
  | relationalExpr GE_OP shiftExpr { $$ = exprNode_op ($1, $3, $2); }
+;
  
 equalityIterExpr 
  : relationalIterExpr 
  | equalityExpr EQ_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
  | equalityExpr NE_OP relationalExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 bitandIterExpr
  : equalityIterExpr 
  | bitandExpr TAMPERSAND equalityExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 xorIterExpr
  : bitandIterExpr 
@@ -1695,20 +2101,27 @@ xorIterExpr
 bitorIterExpr
  : xorIterExpr 
  | bitorExpr TBAR xorExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 andIterExpr 
  : bitorIterExpr 
  | andExpr AND_OP bitorExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 orIterExpr
  : andIterExpr 
  | orExpr OR_OP andExpr { $$ = exprNode_op ($1, $3, $2); }
+;
 
 conditionalIterExpr 
  : orIterExpr 
+ | orExpr TQUEST { context_enterTrueClause ($1); } 
+   TCOLON { context_enterFalseClause ($1); } conditionalExpr
+   { $$ = exprNode_condIfOmit ($1, $6); }
  | orExpr TQUEST { context_enterTrueClause ($1); } 
    expr TCOLON { context_enterFalseClause ($1); } conditionalExpr
    { $$ = exprNode_cond ($1, $4, $7); }
+;
 
 assignIterExpr
  : conditionalIterExpr 
@@ -1723,13 +2136,16 @@ assignIterExpr
  | unaryExpr AND_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
  | unaryExpr XOR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
  | unaryExpr OR_ASSIGN assignExpr { $$ = exprNode_assign ($1, $3, $2); } 
+;
 
 endIter
  : ITER_ENDNAME { $$ = $1; }
  | /* empty */  { $$ = uentry_undefined; } 
+;
 
 doHeader
  : DO { context_enterDoWhileClause (); $$ = $1; }
+;
   
 iterationStmt 
  : whilePred stmt 
@@ -1738,6 +2154,7 @@ iterationStmt
    { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
  | forPred stmt 
    { $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
+;
 
 iterationStmtErr 
  : whilePred stmtErr { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
@@ -1746,6 +2163,7 @@ iterationStmtErr
  | doHeader stmtErr WHILE TLPAREN expr TRPAREN 
    { $$ = exprNode_doWhile ($2, $5); }
  | forPred stmtErr { $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
+;
  
 jumpStmt
  : GOTO newId TSEMI         { $$ = exprNode_goto ($2); }
@@ -1759,13 +2177,21 @@ jumpStmt
  | QSAFEBREAK BREAK TSEMI   { $$ = exprNode_break ($2, QSAFEBREAK); }
  | RETURN TSEMI             { $$ = exprNode_nullReturn ($1); }
  | RETURN expr TSEMI        { $$ = exprNode_return ($2); }
+;
  
 optSemi
  : 
  | TSEMI { ; } 
+;
+
+optComma
+ : 
+ | TCOMMA { ; } 
+;
 
 id
  : IDENTIFIER 
+;
 
 newId
  : NEW_IDENTIFIER 
@@ -1773,10 +2199,14 @@ newId
  | ITER_ENDNAME    { $$ = uentry_getName ($1); }
  | id              { $$ = uentry_getName ($1); }
  | TYPE_NAME_OR_ID { $$ = $1; } 
+;
 
 typeName
  : TYPE_NAME
  | TYPE_NAME_OR_ID { $$ = ctype_unknown; }
+ | CTYPEOF TLPAREN expr TRPAREN { $$ = exprNode_getType ($3); exprNode_free ($3); }
+ | CTYPEOF TLPAREN typeExpression TRPAREN { $$ = qtype_getType ($3); } 
+;
 
 %%
 
@@ -1805,7 +2235,7 @@ void yyerror (/*@unused@*/ char *s)
       llerror (FLG_SYNTAX, message ("Macro syntax not parseable: %s", 
                                    context_inFunctionName ()));
       
-      if (context_inMacroUnknown ())
+      if (context_inUnknownMacro ())
        {
          if (!givehint)
            {
@@ -1816,7 +2246,7 @@ void yyerror (/*@unused@*/ char *s)
            }
        }
 
-      swallowMacro ();
+      cscannerHelp_swallowMacro ();
       context_exitAllClausesQuiet ();
     }
   else
This page took 0.107616 seconds and 4 git commands to generate.