/*@=allmacros@*/
extern int yylex ();
-extern void swallowMacro (void);
extern void yyerror (char *);
# include "splintMacros.nf"
/*@only@*/ modifiesClause modsclause;
/*@only@*/ warnClause warnclause;
/*@only@*/ stateClause stateclause;
-
+ /*@only@*/ pointers pointers;
/*@only@*/ functionConstraint fcnconstraint;
/*@only@*/ metaStateConstraint msconstraint;
%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 <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
%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
| iterDecl { uentry_clearDecl (); }
| macroDef { uentry_clearDecl (); }
| initializer { uentry_checkDecl (); exprNode_free ($1); }
- | TSEMI { uentry_clearDecl (); /* evans 2002-02-08: okay to have a null statement */ }
+ | 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
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_makeInnerArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); lltok_free2 ($2, $3); }
| namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
exprNode_findValue ($4);
{
$$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
}
+
+ lltok_free2 ($2, $5);
}
| namedDeclBase PushType TLPAREN TRPAREN
{ setCurrentParams (uentryList_missingParams); }
uentryList_makeMissingParams ());
$$ = idDecl_replaceCtype ($1, ct);
- idDecl_addClauses ($$, $6);
- context_popLoc ();
+
/*drl 7/25/01 added*/
setImplictfcnConstraints();
+
+ functionClauseList_ImplictConstraints($6);
+
+ idDecl_addClauses ($$, $6);
+ context_popLoc ();
+ lltok_free2 ($3, $4);
}
| namedDeclBase PushType TLPAREN genericParamList TRPAREN
{ setCurrentParams ($4); }
functionClauses
- { setImplictfcnConstraints ();
+ {
+ setImplictfcnConstraints ();
+ functionClauseList_ImplictConstraints($6);
clearCurrentParams ();
$$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
idDecl_addClauses ($$, $7);
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_makeInnerArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
+ lltok_free2 ($2, $3);
+ }
| plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
int value;
}
$$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), value));
+ lltok_free2 ($2, $5);
}
| plainNamedDeclBase PushType TLPAREN TRPAREN
{ setCurrentParams (uentryList_missingParams); }
$$ = idDecl_replaceCtype ($1, ct);
idDecl_addClauses ($$, $6);
context_popLoc ();
+ lltok_free2 ($3, $4);
}
| plainNamedDeclBase PushType TLPAREN genericParamList TRPAREN
{ setCurrentParams ($4); }
$$ = 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); }
metaStateConstraint
: metaStateSpecifier TASSIGN metaStateExpression
- { $$ = metaStateConstraint_create ($1, $3); }
+ { $$ = metaStateConstraint_create ($1, $3); lltok_free ($2); }
metaStateSpecifier
: BufConstraintSrefExpr { cscanner_expectingMetaStateName (); } TCOLON metaStateName
{ cscanner_clearExpectingMetaStateName ();
- $$ = metaStateSpecifier_create ($1, $4); }
+ $$ = metaStateSpecifier_create ($1, $4);
+ lltok_free ($3);
+ }
| CTOK_ELIPSIS { cscanner_expectingMetaStateName (); } TCOLON metaStateName
{ cscanner_clearExpectingMetaStateName ();
- $$ = metaStateSpecifier_createElipsis ($4); }
+ $$ = metaStateSpecifier_createElipsis ($4);
+ lltok_free2 ($1, $3);
+ }
metaStateExpression
: metaStateSpecifier { $$ = metaStateExpression_create ($1); }
-| metaStateSpecifier TBAR metaStateExpression { $$ = metaStateExpression_createMerge ($1, $3); }
+| metaStateSpecifier TBAR metaStateExpression { $$ = metaStateExpression_createMerge ($1, $3); lltok_free ($2); }
metaStateName
: METASTATE_NAME
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);
}
| 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; }
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
instanceDecl
: completeTypeSpecifier IsType TSEMI
- { $$ = exprNode_makeError (); }
- /*
+ { $$ = exprNode_makeError (); }
+ /*
** This causes r/r conflicts with function definitions.
** Instead we need to snarf one first. (gack)
**
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; }
/*
typeQualifier
: QCONST IsType { $$ = qual_createConst (); }
| QVOLATILE IsType { $$ = qual_createVolatile (); }
+ | QRESTRICT IsType { $$ = qual_createRestrict (); }
| definedQualifier IsType { $$ = $1; }
| stateQualifier IsType { $$ = $1; }
| exitsQualifier IsType { $$ = $1; }
| 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
optStructInvariant
: /* empty */ { $$ = constraintList_undefined; }
-/* don't want to have support for structure invariant until we're
- sure it's stable
+/* drl commenting before a CVS commit
| QINVARIANT BufConstraintList QENDMACRO { $$ = $2 }
*/
-
suSpc
: NotType CSTRUCT newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
CreateStructInnerScope
structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
TRBRACE
- optStructInvariant { {ctype ct; ct = declareStruct ($3, $8); /* setGlobalStructInfo(ct, $12);*/ $$ = ct;} }
+ optStructInvariant
+ { ctype ct; ct = declareStruct ($3, $8); setGlobalStructInfo(ct, $12); $$ = ct; }
| NotType CUNION newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
CreateStructInnerScope
structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
{ $$ = 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; }
| pointers TYPE_NAME
{
qtype qt = qtype_unknown ();
-
qtype_adjustPointers ($1, qt);
- $$ = idDecl_create (cstring_copy (LastIdentifier ()), qt);
+ $$ = idDecl_create (cstring_copy (cscanner_observeLastIdentifier ()), qt);
}
| pointers optNamedDecl
{ $$ = $2; qtype_adjustPointers ($1, idDecl_getTyp ($$)); }
| 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
}
else
{
- $$ = exprNode_iterNewId (cstring_copy (LastIdentifier ()));
+ $$ = exprNode_iterNewId (cstring_copy (cscanner_observeLastIdentifier ()));
}
}
| NEW_IDENTIFIER { $$ = exprNode_iterNewId ($1); }
}
}
- swallowMacro ();
+ cscanner_swallowMacro ();
context_exitAllClausesQuiet ();
}
else