# 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 */
%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
{ $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
| namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
- int value;
-
- if (exprNode_hasValue ($4)
- && multiVal_isInt (exprNode_getValue ($4)))
- {
- value = (int) multiVal_forceInt (exprNode_getValue ($4));
- }
- else
- {
- value = 0;
- }
-
- $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), value));
+ $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
}
| 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 ();
}
: IsType TLPAREN NotType abstractDecl TRPAREN
{ $$ = ctype_expectFunction ($4); }
| TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
- | TLSQBR constantExpr TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
+ | TLSQBR constantExpr TRSQBR
+ { $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
| abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeArray ($1); }
- | abstractDeclBase TLSQBR constantExpr TRSQBR { $$ = ctype_makeArray ($1); }
+ | abstractDeclBase TLSQBR constantExpr TRSQBR
+ { $$ = ctype_makeFixedArray ($1, exprNode_getLongValue ($3)); }
| IsType TLPAREN TRPAREN
{ $$ = ctype_makeFunction (ctype_unknown, uentryList_makeMissingParams ()); }
| IsType TLPAREN paramTypeList TRPAREN
| 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);
}
| QSETSTRINGLENGTH id CCONSTANT QENDMACRO { printf(" QSETSTRINGLENGTH id CCONSTANT HEllo World\n"); uentry_setStringLength($2, $3); $$ = exprNode_createTok ($4);
}
-
+ | QTESTINRANGE id CCONSTANT QENDMACRO {printf(" QTESTINRANGE\n"); uentry_testInRange($2, $3); $$ = exprNode_createTok ($4);
+ }
/* | QSETBUFFERSIZE id id {$$ = $2; printf(" QSETBUFFERSIZE id id HEllo World\n");} */
| error { $$ = exprNode_makeError (); }
labeledStmt
- : newId TCOLON { $$ = exprNode_labelMarker ($1); printf("labeldStmt: newid TCOLON");}
- | QNOTREACHED stmt { $$ = exprNode_notReached ($2); printf("labeldStmt: QNOTREACHED stmt");}
+ : newId TCOLON { $$ = exprNode_labelMarker ($1); }
+ | QNOTREACHED stmt { $$ = exprNode_notReached ($2); }
/* Note that we can semantically check that the object to the case is
indeed constant. In this case, we may not want to go through this effort */
| initializerList initializer { $$ = exprNode_concat ($1, $2); }
stmtList
- : stmt { $$ = $1; printf("stmt\n"); }
- | stmtList stmt { $$ = exprNode_concat ($1, $2); printf("StmTList stmt\n"); }
+ : stmt { $$ = $1; }
+ | stmtList stmt { $$ = exprNode_concat ($1, $2); }
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); }