"boolbv" { return BOOL_TO_BV_TOK;}
(({LETTER})|(_)({ANYTHING}))({ANYTHING})* {
- BEEV::ASTNode nptr = parserInterface->LookupOrCreateSymbol(smttext);
-
- // Check valuesize to see if it's a prop var. I don't like doing
- // type determination in the lexer, but it's easier than rewriting
- // the whole grammar to eliminate the term/formula distinction.
- smtlval.node = new BEEV::ASTNode(parserInterface->letMgr.ResolveID(nptr));
- //smtlval.node = new BEEV::ASTNode(nptr);
- if ((smtlval.node)->GetType() == BOOLEAN_TYPE)
- return FORMID_TOK;
- else
- return TERMID_TOK;
+ string str(smttext);
+ bool found = false;
+ ASTNode nptr;
+
+ if (BEEV::parserInterface->isSymbolAlreadyDeclared(str)) // it's a symbol.
+ {
+ nptr= BEEV::parserInterface->LookupOrCreateSymbol(str);
+ found = true;
+ }
+ else if (BEEV::parserInterface->letMgr.isLetDeclared(str)) // a let.
+ {
+ nptr= BEEV::parserInterface->letMgr.resolveLet(str);
+ found = true;
+ }
+
+ if (found)
+ {
+ smtlval.node = BEEV::parserInterface->newNode(nptr);
+ if ((smtlval.node)->GetType() == BEEV::BOOLEAN_TYPE)
+ return FORMID_TOK;
+ else
+ return TERMID_TOK;
+ }
+
+ // It hasn't been found. So it's not already declared.
+ // it has not been seen before.
+ smtlval.str = new std::string(str);
+ return STRING_TOK;
}
. { smterror("Illegal input character."); }
%%
%type <node> status
%type <vec> bench_attributes an_formulas an_terms
-%type <node> benchmark bench_name bench_attribute
+%type <node> benchmark bench_attribute
%type <node> an_term an_nonbvconst_term an_formula
-%type <node> var fvar logic_name
-%type <str> user_value
+%type <node> var fvar
+%type <str> user_value logic_name bench_name
%token <uintval> NUMERAL_TOK
%token <str> BVCONST_TOK
;
bench_name:
-FORMID_TOK
+STRING_TOK
{
}
;
}
| COLON_TOK LOGIC_TOK logic_name
{
- if (!(0 == strcmp($3->GetName(),"QF_UFBV") ||
- 0 == strcmp($3->GetName(),"QF_BV") ||
- //0 == strcmp($3->GetName(),"QF_UF") ||
- 0 == strcmp($3->GetName(),"QF_AUFBV"))) {
+ if (!(0 == strcmp($3->c_str(),"QF_UFBV") ||
+ 0 == strcmp($3->c_str(),"QF_BV") ||
+ //0 == strcmp($3->c_str(),"QF_UF") ||
+ 0 == strcmp($3->c_str(),"QF_AUFBV"))) {
yyerror("Wrong input logic:");
}
delete $3;
;
logic_name:
-FORMID_TOK LBRACKET_TOK NUMERAL_TOK RBRACKET_TOK
+STRING_TOK LBRACKET_TOK NUMERAL_TOK RBRACKET_TOK
{
$$ = $1;
}
-| FORMID_TOK
+| STRING_TOK
{
$$ = $1;
}
}
;
+// There are some gulwani benchmarks that create multiple variables in the same header.
+// Maybe you shouldn'.t..
var_decls:
var_decl
-{
-}
-// | LPAREN_TOK var_decl RPAREN_TOK
+{}
|
var_decls var_decl
-{
-}
+{}
;
+
+
var_decl:
-LPAREN_TOK FORMID_TOK sort_symbs RPAREN_TOK
+LPAREN_TOK STRING_TOK sort_symbs RPAREN_TOK
{
- parserInterface->letMgr._parser_symbol_table.insert(*$2);
+ ASTNode s = BEEV::parserInterface->LookupOrCreateSymbol($2->c_str());
//Sort_symbs has the indexwidth/valuewidth. Set those fields in
//var
- $2->SetIndexWidth($3.indexwidth);
- $2->SetValueWidth($3.valuewidth);
+ s.SetIndexWidth($3.indexwidth);
+ s.SetValueWidth($3.valuewidth);
+ parserInterface->letMgr._parser_symbol_table.insert(s);
delete $2;
}
-| LPAREN_TOK FORMID_TOK RPAREN_TOK
+| LPAREN_TOK STRING_TOK RPAREN_TOK
{
- parserInterface->letMgr._parser_symbol_table.insert(*$2);
+ ASTNode s = BEEV::parserInterface->LookupOrCreateSymbol($2->c_str());
+ s.SetIndexWidth(0);
+ s.SetValueWidth(0);
+ parserInterface->letMgr._parser_symbol_table.insert(s);
//Sort_symbs has the indexwidth/valuewidth. Set those fields in
//var
- $2->SetIndexWidth(0);
- $2->SetValueWidth(0);
delete $2;
}
;
;
letexpr_mgmt:
-LPAREN_TOK LET_TOK LPAREN_TOK QUESTION_TOK FORMID_TOK an_term RPAREN_TOK
+LPAREN_TOK LET_TOK LPAREN_TOK QUESTION_TOK STRING_TOK an_term RPAREN_TOK
{
-
- //set the valuewidth of the identifier
- $5->SetValueWidth($6->GetValueWidth());
- $5->SetIndexWidth($6->GetIndexWidth());
-
//populate the hashtable from LET-var -->
//LET-exprs and then process them:
//
delete $5;
delete $6;
}
-| LPAREN_TOK FLET_TOK LPAREN_TOK DOLLAR_TOK FORMID_TOK an_formula RPAREN_TOK
+| LPAREN_TOK FLET_TOK LPAREN_TOK DOLLAR_TOK STRING_TOK an_formula RPAREN_TOK
{
- //Expr must typecheck
-
- //set the valuewidth of the identifier
- $5->SetValueWidth($6->GetValueWidth());
- $5->SetIndexWidth($6->GetIndexWidth());
-
//Do LET-expr management
parserInterface->letMgr.LetExprMgr(*$5,*$6);
delete $5;
BITCONST_TOK { $$ = $1; }
| var
{
- $$ = new ASTNode(parserInterface->letMgr.ResolveID(*$1));
+ $$ = new ASTNode((*$1));
delete $1;
}
| LPAREN_TOK an_term RPAREN_TOK
var:
FORMID_TOK
{
- $$ = new ASTNode(parserInterface->letMgr.ResolveID(*$1));
+ $$ = new ASTNode((*$1));
delete $1;
}
| TERMID_TOK
{
- $$ = new ASTNode(parserInterface->letMgr.ResolveID(*$1));
+ $$ = new ASTNode((*$1));
delete $1;
}
| QUESTION_TOK TERMID_TOK
}
| FORMID_TOK
{
- $$ = new ASTNode(parserInterface->letMgr.ResolveID(*$1));
+ $$ = new ASTNode((*$1));
delete $1;
}
;