]> andersk Git - splint.git/blobdiff - src/llgrammar.y
Fixed problem with loop guards in loop test effects. New test case
[splint.git] / src / llgrammar.y
index e1dfe60f187a5fe05a4ab4f9e59546d45f8ae779..24039b079722d51f493c1fa30829ac2c36ae6d73 100644 (file)
@@ -1,41 +1,32 @@
 /*;-*-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-2002 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 code is distributed freely and may be used freely under the 
-** following conditions:
-**
-**     1. This notice may not be removed or altered.
+** 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.
 **
-**     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: splint@cs.virginia.edu
+** To report a bug: splint-bug@cs.virginia.edu
+** For more information: http://www.splint.org
 */
 /*
-**      Copyright (c) Massachusetts Institute of Technology, 1993
-**         All Rights Reserved.  Unpublished rights reserved
-**         under the copyright laws of the United States.
-**++
-**  FACILITY:  LSLC
-**
-**  MODULE DESCRIPTION:
-**
-**      FILENAME: llgramar.y
-**
-**     PURPOSE:  bison grammar for LCL language.
-** 
-**  AUTHORS:
-**     Yang Meng Tan, Massachusetts Institute of Technology
+** Original author: Yang Meng Tan, Massachusetts Institute of Technology
 */
-
 %{
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 # include "lclscan.h"
 # include "checking.h"
@@ -48,7 +39,7 @@ static /*@unused@*/ void yyprint ();
 /*@=noparams@*/
 
 /*@-redecl@*/
-void ylerror (char *) /*@modifies *g_msgstream@*/ ;
+void ylerror (char *) /*@modifies *g_warningstream@*/ ;
 /*@=redecl@*/
 
 bool g_inTypeDef = FALSE;
@@ -75,6 +66,8 @@ bool g_inTypeDef = FALSE;
 
 %}
 
+/*@-readonlytrans@*/
+
 %union 
 {
   ltoken ltok;  /* a leaf is also an ltoken */
@@ -139,7 +132,8 @@ bool g_inTypeDef = FALSE;
   /*@only@*/ interfaceNode iface;
   /*@only@*/ interfaceNodeList interfacelist; 
   /*@only@*/ CTypesNode ctypes;
-}
+  /*@-redef@*/
+} /*@=redef@*/
 
 /* Order of precedence is increasing going down the list */
 
@@ -264,6 +258,7 @@ bool g_inTypeDef = FALSE;
 %token <ltok> LLT_RELNULL
 %token <ltok> LLT_RELDEF
 %token <ltok> LLT_KILLREF
+%token <ltok> LLT_NULLTERMINATED
 %token <ltok> LLT_TEMPREF
 %token <ltok> LLT_NEWREF
 %token <ltok> LLT_PRIVATE
@@ -376,6 +371,9 @@ bool g_inTypeDef = FALSE;
 **   the call to the static semantic routine. 
 */ 
 
+/*@=redef@*/
+/*@=readonlytrans@*/
+
 %%
 
 interface
@@ -438,7 +436,7 @@ iterParamList
  
 realIterParamList  
  : iterParam           
-   { $$ = paramNodeList_add (paramNodeList_new (), $1); }
+   { $$ = paramNodeList_add (paramNodeList_new (),  $1); }
  | realIterParamList LLT_COMMA iterParam  
    { $$ = paramNodeList_add ($1,$3); }     
    
@@ -484,7 +482,7 @@ special
 fcn   
  : lclTypeSpec declarator globals { enteringFcnScope ($1, $2, $3); } LLT_LBRACE
    privateInits optLetDecl optChecks optRequire optModify optEnsure optClaim LLT_RBRACE
-   { $$ = makeFcnNode (qual_createUnknown (), $1, $2, $3, $6, $7, 
+   { $$ = makeFcnNode (qual_createUnknown (),  $1, $2, $3, $6, $7, 
                       $8, $9, $10, $11, $12); 
      /* type, declarator, glovbls, privateinits,
        lets, checks, requires, modifies, ensures, claims */
@@ -546,7 +544,7 @@ exposed
 
 importNameList  
  : importName        
-   { $$ = importNodeList_add (importNodeList_new (), $1); } 
+   { $$ = importNodeList_add (importNodeList_new (),  $1); } 
  | importNameList LLT_COMMA importName  
    { $$ = importNodeList_add ($1, $3); } 
 
@@ -566,7 +564,7 @@ interfaceName
 
 traitRefNodeList   
  : traitRef
-   { $$ = traitRefNodeList_add (traitRefNodeList_new (), $1); } 
+   { $$ = traitRefNodeList_add (traitRefNodeList_new (),  $1); } 
  | traitRefNodeList LLT_COMMA traitRef
    { $$ = traitRefNodeList_add ($1, $3); } 
 
@@ -586,19 +584,19 @@ traitIdList
 
 renaming   
  : replaceNodeList   
-   { $$ = makeRenamingNode (typeNameNodeList_new (), $1); } 
+   { $$ = makeRenamingNode (typeNameNodeList_new (),  $1); } 
  | nameList
    { $$ = makeRenamingNode ($1, replaceNodeList_new ()); } 
  | nameList LLT_COMMA replaceNodeList { $$ = makeRenamingNode ($1, $3); } 
  
 nameList
  : typeName
-   { $$ = typeNameNodeList_add (typeNameNodeList_new (), $1); } 
+   { $$ = typeNameNodeList_add (typeNameNodeList_new (),  $1); } 
  | nameList LLT_COMMA typeName       { $$ = typeNameNodeList_add ($1, $3); } 
 
 replaceNodeList   
  : replace
-   { $$ = replaceNodeList_add (replaceNodeList_new (), $1); } 
+   { $$ = replaceNodeList_add (replaceNodeList_new (),  $1); } 
  | replaceNodeList LLT_COMMA replace { $$ = replaceNodeList_add ($1, $3); } 
 
 replace
@@ -617,7 +615,7 @@ constLclExpr : term
 
 initDecls
  : initDecl 
-   { $$ = initDeclNodeList_add (initDeclNodeList_new (), $1); } 
+   { $$ = initDeclNodeList_add (initDeclNodeList_new (),  $1); } 
  | initDecls LLT_COMMA initDecl      
    { $$ = initDeclNodeList_add ($1, $3); } 
 
@@ -649,7 +647,7 @@ optLetDecl
  | LLT_LET beDeclList LLT_SEMI         { $$ = $2; } 
 
 beDeclList   
- : beDecl                      { $$ = letDeclNodeList_add (letDeclNodeList_new (), $1); } 
+ : beDecl                      { $$ = letDeclNodeList_add (letDeclNodeList_new (),  $1); } 
  | beDeclList LLT_COMMA beDecl     { $$ = letDeclNodeList_add ($1, $3); } 
 
 beDecl   
@@ -673,7 +671,7 @@ optModify
  | LLT_MODIFIES storeRefList LLT_SEMI   { $$ = makeModifyNodeRef ($1, $2); } 
 
 storeRefList   
- : storeRef                     { $$ = storeRefNodeList_add (storeRefNodeList_new (), $1); } 
+ : storeRef                     { $$ = storeRefNodeList_add (storeRefNodeList_new (),  $1); } 
  | storeRefList LLT_COMMA storeRef  { $$ = storeRefNodeList_add ($1, $3); } 
 
 storeRef   
@@ -697,7 +695,7 @@ optParamList
 
 realParamList      
  : paramList
- | LLT_TELIPSIS                  { $$ = paramNodeList_add (paramNodeList_new (), paramNode_elipsis ()); }
+ | LLT_TELIPSIS                  { $$ = paramNodeList_add (paramNodeList_new (),  paramNode_elipsis ()); }
  | paramList LLT_COMMA LLT_TELIPSIS  { $$ = paramNodeList_add ($1, paramNode_elipsis ()); }
 
 paramList   
@@ -743,7 +741,7 @@ stmt
    { $$ = makeStmtNode ($1, $3, $5); }
 
 valueList   
- : value                 { $$ = termNodeList_push (termNodeList_new (), $1); } 
+ : value                 { $$ = termNodeList_push (termNodeList_new (),  $1); } 
  | valueList LLT_COMMA value { $$ = termNodeList_push ($1, $3); } 
 
 value   
@@ -754,7 +752,7 @@ value
  | value simpleOp value /* infix */ { $$ = makeInfixTermNode ($1, $2, $3); }
  | LLT_LPAR value LLT_RPAR                  { $$ = $2; $$->wrapped = $$->wrapped + 1; }
  | fcnId LLT_LPAR LLT_RPAR
-   { $$ = makeOpCallTermNode ($1, $2, termNodeList_new (), $3); }
+   { $$ = makeOpCallTermNode ($1, $2, termNodeList_new (),  $3); }
  | fcnId LLT_LPAR valueList LLT_RPAR
    { $$ = makeOpCallTermNode ($1, $2, $3, $4); } 
 
@@ -782,7 +780,7 @@ typeInv
    }
 
 declaratorInvs     
- : declaratorInv        { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (), $1); } 
+ : declaratorInv        { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (),  $1); } 
  | declaratorInvs LLT_COMMA declaratorInv
    { $$ = declaratorInvNodeList_add ($1, $3); } 
 
@@ -859,6 +857,7 @@ specialQualifier
  | LLT_RETURNED  { $$ = qual_createReturned (); }
  | LLT_EXPOSED   { $$ = qual_createExposed (); }
  | LLT_PARTIAL   { $$ = qual_createPartial (); }
+ | LLT_NULLTERMINATED { $$ = qual_createNullTerminated () ; }
  | LLT_UNDEF { $$ = qual_createUndef (); }
  | LLT_KILLED { $$ = qual_createKilled (); }
 
@@ -908,7 +907,7 @@ optTagId
  | tagId
 
 structDecls   
- : structDecl               { $$ = stDeclNodeList_add (stDeclNodeList_new (), $1); } 
+ : structDecl               { $$ = stDeclNodeList_add (stDeclNodeList_new (),  $1); } 
  | structDecls structDecl   { $$ = stDeclNodeList_add ($1, $2); } 
 
 /* We don't allow specification of field size */
@@ -918,7 +917,7 @@ structDecl
 
 declaratorList   
  : declarator                       
-   { $$ = declaratorNodeList_add (declaratorNodeList_new (), $1); } 
+   { $$ = declaratorNodeList_add (declaratorNodeList_new (),  $1); } 
  | declaratorList LLT_COMMA declarator  
    { $$ = declaratorNodeList_add ($1, $3); } 
 
@@ -1144,7 +1143,7 @@ postfixOps
  | postfixOps simpleOp2            { $$ = ltokenList_push ($1, $2); } 
 
 infixOpPart   
- : simpleOp2 secondary             { $$ = pushInfixOpPartNode (termNodeList_new (), $1, $2); } 
+ : simpleOp2 secondary             { $$ = pushInfixOpPartNode (termNodeList_new (),  $1, $2); } 
  | infixOpPart simpleOp2 secondary { $$ = pushInfixOpPartNode ($1, $2, $3); } 
 
 secondary   
@@ -1167,18 +1166,18 @@ sqBracketed
  | LLT_LBRACKET args LLT_RBRACKET
    { $$ = makeSqBracketedNode ($1, $2, $3); } 
  | LLT_LBRACKET  LLT_RBRACKET LLT_COLON sortId
-   { $$ = makeSqBracketedNode ($1, termNodeList_new (), $2); 
+   { $$ = makeSqBracketedNode ($1, termNodeList_new (),  $2); 
      $$->given = sort_lookupName (ltoken_getText ($4)); 
    }
  | LLT_LBRACKET  LLT_RBRACKET
-   { $$ = makeSqBracketedNode ($1, termNodeList_new (), $2); } 
+   { $$ = makeSqBracketedNode ($1, termNodeList_new (),  $2); } 
 
 matched      
  : open args  close          { $$ = makeMatchedNode ($1, $2, $3); } 
- | open close                { $$ = makeMatchedNode ($1, termNodeList_new (), $2); } 
+ | open close                { $$ = makeMatchedNode ($1, termNodeList_new (),  $2); } 
 
 args   
- : term                      { $$ = termNodeList_push (termNodeList_new (), $1); } 
+ : term                      { $$ = termNodeList_push (termNodeList_new (),  $1); } 
  | args separator term       { $$ = termNodeList_push ($1, $3); } 
 
 primary   
@@ -1196,7 +1195,7 @@ primary
  | primary mapSym simpleIdOrTypedefName
    { ltoken_markOwned ($3); $$ = makeMapTermNode ($1, $2, $3); } 
  | primary LLT_LBRACKET LLT_RBRACKET   
-   { $$ = updateSqBracketedNode ($1, makeSqBracketedNode ($2, termNodeList_new (), $3), 
+   { $$ = updateSqBracketedNode ($1, makeSqBracketedNode ($2, termNodeList_new (),  $3), 
                                (termNode)0); }
  | primary LLT_LBRACKET termList LLT_RBRACKET
    { $$ = updateSqBracketedNode ($1, makeSqBracketedNode ($2, $3, $4), (termNode)0); }
@@ -1204,7 +1203,7 @@ primary
    { $$ = $1; $$->given = sort_lookupName (ltoken_getText ($3)); }
 
 termList   
- : term0                  { $$ = termNodeList_push (termNodeList_new (), $1); } 
+ : term0                  { $$ = termNodeList_push (termNodeList_new (),  $1); } 
  | termList LLT_COMMA term0   { $$ = termNodeList_push ($1, $3); } 
 
 stateFcn   
@@ -1247,7 +1246,7 @@ cLiteral
 
 quantifiers   
  : quantifier
-   { $$ = quantifierNodeList_add (quantifierNodeList_new (), $1); } 
+   { $$ = quantifierNodeList_add (quantifierNodeList_new (),  $1); } 
  | quantifiers quantifier
    { $$ = quantifierNodeList_add ($1, $2); } 
 
@@ -1259,7 +1258,7 @@ quantifier
    { $$ = makeQuantifierNode ($3, $1); } 
 
 quantifiedList   
- : quantified                         { $$ = varNodeList_add (varNodeList_new (), $1); } 
+ : quantified                         { $$ = varNodeList_add (varNodeList_new (),  $1); } 
  | quantifiedList LLT_COMMA quantified    { $$ = varNodeList_add ($1, $3); } 
 
 quantified   
This page took 0.497022 seconds and 4 git commands to generate.