# undef realloc
# endif
-void checkandsetBufState(idDecl id, exprNode is);
+
%}
%union
/*@only@*/ exprNodeList alist;
/*@only@*/ sRefSet srset;
/*@only@*/ cstringList cstringlist;
+ /*drl
+ added 1/19/2001
+ */
+ constraint con;
+ constraintList conL;
+ constraintExpr conE;
+ /* drl */
}
/* standard C tokens */
%token <tok> QREFCOUNTED QREFS QNEWREF QTEMPREF QKILLREF QRELDEF
%token <ctyp> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID
%token <tok> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
-%token <tok> QNULLTERMINATED
+%token <tok> QNULLTERMINATED
%token <tok> QSETBUFFERSIZE
+%token <tok> QBUFFERCONSTRAINT
+%token <tok> QENSURESCONSTRAINT
%token <tok> QSETSTRINGLENGTH
-
+%token <tok> QMAXSET
+%token <tok> QMAXREAD
%token <tok> QTESTINRANGE
+
+
/* identifiers, literals */
%token <entry> IDENTIFIER
%token <cname> NEW_IDENTIFIER TYPE_NAME_OR_ID
%type <flist> structDeclList structDecl
%type <srset> locModifies locPlainModifies modList specClauseList
%type <sr> mExpr modListExpr specClauseListExpr
+
+/*drl*/
+%type <con> BufConstraint
+%type <tok> relationalOp
+%type <tok> BufBinaryOp
+%type <tok> bufferModifier
+
+%type <conE> BufConstraintExpr
+
+%type <conE> BufConstraintTerm
+%type <sr> BufConstraintSrefExpr
+
+%type <conL> BufConstraintList
+
+%type <tok> BufUnaryOp
+
%type <enumnamelist> enumeratorList
%type <cstringlist> fieldDesignator
%type <tquallist> optGlobQuals
%type <qtyp> completeType completeTypeSpecifier optCompleteType
%type <qtyp> completeTypeSpecifierAux altType typeExpression
-%type <expr> lclintassertion
+/*%type <expr> lclintassertion*/
%start file
| namedDeclBase PushType TLPAREN TRPAREN
{ setCurrentParams (uentryList_missingParams);
}
- optGlobMods
+ optGlobMods optGlobBufConstraints
{ /* need to support globals and modifies here! */
ctype ct = ctype_makeFunction (idDecl_getCtype ($1),
uentryList_makeMissingParams ());
context_popLoc ();
}
| namedDeclBase PushType TLPAREN genericParamList TRPAREN
- { setCurrentParams ($4);
+ { setCurrentParams ($4);
+
}
- optGlobMods
- { clearCurrentParams ();
+ optGlobMods optGlobBufConstraints
+ { setImplictfcnConstraints ();
+ clearCurrentParams ();
$$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
- context_popLoc ();
+ context_popLoc ();
+
+ // printf("Done nameDeclBase\n");
}
plainNamedDeclBase
: { setProcessingGlobMods (); } optGlobModsRest
{ clearProcessingGlobMods (); }
+
+/*drl*/
+
+optGlobBufConstraints
+ : { setProcessingGlobMods (); } optGlobBufConstraintsRest
+ { clearProcessingGlobMods (); }
+
+
+optGlobBufConstraintsRest
+ : optGlobBufConstraintsAux optGlobEnsuresConstraintsAux
+
+
+optGlobEnsuresConstraintsAux
+: {
+ DPRINTF ( ("doing optGlobEnsuresConstraintsAux\n") );
+context_setProtectVars (); enterParamsTemp ();
+ sRef_setGlobalScopeSafe ();
+
+} QENSURESCONSTRAINT BufConstraintList QENDMACRO
+{
+ setEnsuresConstraints ($3);
+ exitParamsTemp ();
+ sRef_clearGlobalScopeSafe ();
+ context_releaseVars ();
+ DPRINTF (("done optGlobBufConstraintsAux\n"));}
+ | /*empty*/
+
+
+optGlobBufConstraintsAux
+: {
+ DPRINTF ( ("doing optGlobBufConstraintsAux\n") );
+context_setProtectVars (); enterParamsTemp ();
+ sRef_setGlobalScopeSafe ();
+
+} QBUFFERCONSTRAINT BufConstraintList QENDMACRO
+{
+ setFunctionConstraints ($3);
+ exitParamsTemp ();
+ sRef_clearGlobalScopeSafe ();
+ context_releaseVars ();
+ DPRINTF (("done optGlobBufConstraintsAux\n"));}
+ | /*empty*/
+
+BufConstraintList
+: BufConstraint BufConstraintList{ $$ = constraintList_add ($2, $1); }
+| BufConstraint {constraintList c; c = constraintList_makeNew(); c = constraintList_add (c, $1); $$ = c}
+
+BufConstraint
+: BufConstraintExpr relationalOp BufConstraintExpr TSEMI {
+ $$ = makeConstraintParse3 ($1, $2, $3);
+ DPRINTF(("Done BufConstraint1\n")); }
+
+bufferModifier
+ : QMAXSET
+ |QMAXREAD
+
+relationalOp
+ : GE_OP
+ | LE_OP
+ | EQ_OP
+
+BufConstraintExpr
+ : BufConstraintTerm
+ | BufUnaryOp TLPAREN BufConstraintExpr TRPAREN {$$ = constraintExpr_parseMakeUnaryOp ($1, $3); DPRINTF( ("Got BufConstraintExpr UNary Op ") ); }
+ | TLPAREN BufConstraintExpr BufBinaryOp BufConstraintExpr TRPAREN {
+ DPRINTF( ("Got BufConstraintExpr BINary Op ") );
+ $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
+
+BufConstraintTerm
+: BufConstraintSrefExpr { $$ = constraintExpr_makeTermsRef($1);}
+ | CCONSTANT { char *t; int c;
+ t = cstring_toCharsSafe (exprNode_unparse($1));
+ c = atoi( t );
+ $$ = constraintExpr_makeIntLiteral (c);
+}
+
+
+BufConstraintSrefExpr
+: id {
+ $$ =
+ checkbufferConstraintClausesId ($1);}
+ | NEW_IDENTIFIER { $$ = fixSpecClausesId ($1); }
+
+ | BufConstraintSrefExpr TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
+ | BufConstraintSrefExpr TLSQBR CCONSTANT TRSQBR {
+ char *t; int c;
+ t = cstring_toCharsSafe (exprNode_unparse($3));
+ c = atoi( t );
+ $$ = sRef_makeArrayFetchKnown($1, c); }
+ | TMULT BufConstraintSrefExpr { $$ = sRef_constructPointer ($2); }
+ | TLPAREN BufConstraintSrefExpr TRPAREN { $$ = $2; }
+ | BufConstraintSrefExpr TDOT newId { cstring_markOwned ($3);
+ $$ = sRef_buildField ($1, $3); }
+ | BufConstraintSrefExpr ARROW_OP newId { cstring_markOwned ($3);
+ $$ = sRef_makeArrow ($1, $3); }
+
+/*
+| BufConstraintTerm TLSQBR TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
+ | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
+ | TLPAREN specClauseListExpr TRPAREN { $$ = $2; }
+ | specClauseListExpr TDOT newId { cstring_markOwned ($3);
+ $$ = sRef_buildField ($1, $3); }
+*/
+
+/*BufConstraintExpr
+: BufConstraintTerm
+*/
+
+BufUnaryOp
+: bufferModifier
+;
+
+BufBinaryOp
+ : TPLUS
+| TMINUS
+;
+
+
+koptPlainGlobMods
+ : { setProcessingGlobMods (); } optPlainGlobModsRest
+ { clearProcessingGlobMods (); }
+
+
+/*: id { $$ = unentry_getSref($1); checkModifiesId ($1); }
+| NEW_INDENTIFIER { $$ = fixModifiesId ($1)} */
+
+/*end*/
+
+
optPlainGlobMods
: { setProcessingGlobMods (); } optPlainGlobModsRest
{ clearProcessingGlobMods (); }
: fcnDefHdr fcnBody
{
context_setFunctionDefined (exprNode_loc ($2));
- exprNode_checkFunction (context_getHeader (), $2);
+ /* exprNode_checkFunction (context_getHeader (), $2); */
+ /* DRL 8 8 2000 */
+
context_exitFunction ();
}
| iterationStmt
| iterStmt
| jumpStmt
-/* | tst1 */
- | lclintassertion {$$ = $1; printf ("Doing stmt lclintassertion\n"); }
-
+/* | lclintassertion {$$ = $1; printf ("Doing stmt lclintassertion\n"); }*/
+/*
lclintassertion
: QSETBUFFERSIZE id CCONSTANT QENDMACRO { printf(" QSETBUFFERSIZE id CCONSTANT HEllo World\n"); uentry_setBufferSize($2, $3); $$ = exprNode_createTok ($4);
}
expressionStmt
: TSEMI { $$ = exprNode_createTok ($1); }
- | expr TSEMI { $$ = exprNode_statement ($1); }
+ | expr TSEMI { $$ = exprNode_statement ($1, $2); }
expressionStmtErr
: TSEMI { $$ = exprNode_createTok ($1); }
- | expr TSEMI { $$ = exprNode_statement ($1); }
+ | expr TSEMI { $$ = exprNode_statement ($1, $2); }
| expr { $$ = exprNode_checkExpr ($1); }
ifPred
: whilePred stmt
{ $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
| doHeader stmt WHILE TLPAREN expr TRPAREN TSEMI
- { $$ = exprNode_statement (exprNode_doWhile ($2, $5)); }
+ { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
| forPred stmt
{ $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
iterationStmtErr
: whilePred stmtErr { $$ = exprNode_while ($1, $2); context_exitWhileClause ($1, $2); }
| doHeader stmtErr WHILE TLPAREN expr TRPAREN TSEMI
- { $$ = exprNode_statement (exprNode_doWhile ($2, $5)); }
+ { $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
| doHeader stmtErr WHILE TLPAREN expr TRPAREN
{ $$ = exprNode_doWhile ($2, $5); }
| forPred stmtErr { $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }