]> andersk Git - splint.git/blobdiff - src/llgrammar.y
Committed my changes (but there are several splintme errors currently).
[splint.git] / src / llgrammar.y
index 94d003ac7263e2139f062e8be2da32bbd80e877b..09ce6ba25f08c77d14dc209fde54e3fd9460f75e 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 */
@@ -112,6 +105,7 @@ bool g_inTypeDef = FALSE;
   /*@only@*/ abstBodyNode abstbody;
   /*@only@*/ abstractNode abstract;
   /*@only@*/ exposedNode exposed;
+  /*@only@*/ pointers pointers;
   /*    taggedUnionNode taggedunion; */
   /*@only@*/ globalList globals;
   /*@only@*/ constDeclarationNode constdeclaration;
@@ -139,7 +133,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 */
 
@@ -324,7 +319,8 @@ bool g_inTypeDef = FALSE;
 %type <opform> opForm
 %type <signature> signature
 %type <typname> typeName
-%type <count> middle placeList pointers 
+%type <count> middle placeList 
+%type <pointers> pointers 
 %type <abstDecl> optAbstDeclarator 
 %type <lcltypespec> lclTypeSpec lclType sortSpec
 %type <ltokenList> enumeratorList postfixOps
@@ -377,6 +373,9 @@ bool g_inTypeDef = FALSE;
 **   the call to the static semantic routine. 
 */ 
 
+/*@=redef@*/
+/*@=readonlytrans@*/
+
 %%
 
 interface
@@ -439,7 +438,7 @@ iterParamList
  
 realIterParamList  
  : iterParam           
-   { $$ = paramNodeList_add (paramNodeList_new (), $1); }
+   { $$ = paramNodeList_add (paramNodeList_new (),  $1); }
  | realIterParamList LLT_COMMA iterParam  
    { $$ = paramNodeList_add ($1,$3); }     
    
@@ -485,7 +484,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 */
@@ -547,7 +546,7 @@ exposed
 
 importNameList  
  : importName        
-   { $$ = importNodeList_add (importNodeList_new (), $1); } 
+   { $$ = importNodeList_add (importNodeList_new (),  $1); } 
  | importNameList LLT_COMMA importName  
    { $$ = importNodeList_add ($1, $3); } 
 
@@ -567,7 +566,7 @@ interfaceName
 
 traitRefNodeList   
  : traitRef
-   { $$ = traitRefNodeList_add (traitRefNodeList_new (), $1); } 
+   { $$ = traitRefNodeList_add (traitRefNodeList_new (),  $1); } 
  | traitRefNodeList LLT_COMMA traitRef
    { $$ = traitRefNodeList_add ($1, $3); } 
 
@@ -587,19 +586,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
@@ -618,7 +617,7 @@ constLclExpr : term
 
 initDecls
  : initDecl 
-   { $$ = initDeclNodeList_add (initDeclNodeList_new (), $1); } 
+   { $$ = initDeclNodeList_add (initDeclNodeList_new (),  $1); } 
  | initDecls LLT_COMMA initDecl      
    { $$ = initDeclNodeList_add ($1, $3); } 
 
@@ -650,7 +649,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   
@@ -674,7 +673,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   
@@ -698,7 +697,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   
@@ -744,7 +743,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   
@@ -755,7 +754,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); } 
 
@@ -783,7 +782,7 @@ typeInv
    }
 
 declaratorInvs     
- : declaratorInv        { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (), $1); } 
+ : declaratorInv        { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (),  $1); } 
  | declaratorInvs LLT_COMMA declaratorInv
    { $$ = declaratorInvNodeList_add ($1, $3); } 
 
@@ -888,8 +887,8 @@ lclType
      $1->pointers = $2; $$ = $1; }
 
 pointers   
- : LLT_MULOP          { $$ = 1; }
- | pointers LLT_MULOP { $$ = $1 + 1; } 
+ : LLT_MULOP          { $$ = pointers_createLt ($1); }
+ | pointers LLT_MULOP { $$ = pointers_extend ($1, pointers_createLt ($2)); }
 
 structOrUnionSpec  
  : LLT_STRUCT optTagId 
@@ -910,7 +909,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 */
@@ -920,7 +919,7 @@ structDecl
 
 declaratorList   
  : declarator                       
-   { $$ = declaratorNodeList_add (declaratorNodeList_new (), $1); } 
+   { $$ = declaratorNodeList_add (declaratorNodeList_new (),  $1); } 
  | declaratorList LLT_COMMA declarator  
    { $$ = declaratorNodeList_add ($1, $3); } 
 
@@ -1146,7 +1145,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   
@@ -1169,18 +1168,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   
@@ -1198,7 +1197,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); }
@@ -1206,7 +1205,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   
@@ -1249,7 +1248,7 @@ cLiteral
 
 quantifiers   
  : quantifier
-   { $$ = quantifierNodeList_add (quantifierNodeList_new (), $1); } 
+   { $$ = quantifierNodeList_add (quantifierNodeList_new (),  $1); } 
  | quantifiers quantifier
    { $$ = quantifierNodeList_add ($1, $2); } 
 
@@ -1261,7 +1260,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.047635 seconds and 4 git commands to generate.