/*;-*-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"
/*@=noparams@*/
/*@-redecl@*/
-void ylerror (char *) /*@modifies *g_msgstream@*/ ;
+void ylerror (char *) /*@modifies *g_warningstream@*/ ;
/*@=redecl@*/
bool g_inTypeDef = FALSE;
%}
+/*@-readonlytrans@*/
+
%union
{
ltoken ltok; /* a leaf is also an ltoken */
/*@only@*/ interfaceNode iface;
/*@only@*/ interfaceNodeList interfacelist;
/*@only@*/ CTypesNode ctypes;
-}
+ /*@-redef@*/
+} /*@=redef@*/
/* Order of precedence is increasing going down the list */
%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
** the call to the static semantic routine.
*/
+/*@=redef@*/
+/*@=readonlytrans@*/
+
%%
interface
realIterParamList
: iterParam
- { $$ = paramNodeList_add (paramNodeList_new (), $1); }
+ { $$ = paramNodeList_add (paramNodeList_new (), $1); }
| realIterParamList LLT_COMMA iterParam
{ $$ = paramNodeList_add ($1,$3); }
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 */
importNameList
: importName
- { $$ = importNodeList_add (importNodeList_new (), $1); }
+ { $$ = importNodeList_add (importNodeList_new (), $1); }
| importNameList LLT_COMMA importName
{ $$ = importNodeList_add ($1, $3); }
traitRefNodeList
: traitRef
- { $$ = traitRefNodeList_add (traitRefNodeList_new (), $1); }
+ { $$ = traitRefNodeList_add (traitRefNodeList_new (), $1); }
| traitRefNodeList LLT_COMMA traitRef
{ $$ = traitRefNodeList_add ($1, $3); }
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
initDecls
: initDecl
- { $$ = initDeclNodeList_add (initDeclNodeList_new (), $1); }
+ { $$ = initDeclNodeList_add (initDeclNodeList_new (), $1); }
| initDecls LLT_COMMA initDecl
{ $$ = initDeclNodeList_add ($1, $3); }
| 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
| 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
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
{ $$ = 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
| 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); }
}
declaratorInvs
- : declaratorInv { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (), $1); }
+ : declaratorInv { $$ = declaratorInvNodeList_add (declaratorInvNodeList_new (), $1); }
| declaratorInvs LLT_COMMA declaratorInv
{ $$ = declaratorInvNodeList_add ($1, $3); }
| LLT_RETURNED { $$ = qual_createReturned (); }
| LLT_EXPOSED { $$ = qual_createExposed (); }
| LLT_PARTIAL { $$ = qual_createPartial (); }
+ | LLT_NULLTERMINATED { $$ = qual_createNullTerminated () ; }
| LLT_UNDEF { $$ = qual_createUndef (); }
| LLT_KILLED { $$ = qual_createKilled (); }
| 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 */
declaratorList
: declarator
- { $$ = declaratorNodeList_add (declaratorNodeList_new (), $1); }
+ { $$ = declaratorNodeList_add (declaratorNodeList_new (), $1); }
| declaratorList LLT_COMMA declarator
{ $$ = declaratorNodeList_add ($1, $3); }
| 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
| 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
| 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); }
{ $$ = $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
quantifiers
: quantifier
- { $$ = quantifierNodeList_add (quantifierNodeList_new (), $1); }
+ { $$ = quantifierNodeList_add (quantifierNodeList_new (), $1); }
| quantifiers quantifier
{ $$ = quantifierNodeList_add ($1, $2); }
{ $$ = 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