]> 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 c9937b38a3346e16081eee7b82b7879bd4b22746..0a4f0bba4d5ca46300536df69af9a16fa8d46805 100644 (file)
@@ -165,6 +165,9 @@ extern void yyerror (char *);
 /* 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
@@ -218,7 +221,7 @@ 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
@@ -302,7 +305,7 @@ 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 
@@ -1058,6 +1061,11 @@ orExpr
 
 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); }
@@ -1700,8 +1708,12 @@ stmt
  | iterationStmt 
  | iterStmt
  | jumpStmt 
+ | debugStmt
 ;
 
+debugStmt
+ : QDREVEALSTATE TLPAREN expr TRPAREN { exprNode_revealState ($3); $$ = exprNode_undefined; }
+;
 
 iterBody
  : iterDefStmtList { $$ = $1; }
@@ -1791,6 +1803,7 @@ stmtErr
  | iterationStmtErr
  | TLPAREN stmtErr TRPAREN { $$ = exprNode_addParens ($1, $2); }
  | jumpStmt 
+ | debugStmt
  | error { $$ = exprNode_makeError (); }
 ;
 
@@ -2102,6 +2115,9 @@ orIterExpr
 
 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); }
This page took 1.058175 seconds and 4 git commands to generate.