Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hw_cbmc_irep_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ IREP_ID_ONE(smv_extend)
IREP_ID_ONE(smv_max)
IREP_ID_ONE(smv_min)
IREP_ID_ONE(smv_next)
IREP_ID_ONE(smv_identifier)
IREP_ID_ONE(smv_iff)
IREP_ID_TWO(C_smv_iff, "#smv_iff")
IREP_ID_ONE(smv_resize)
Expand Down
31 changes: 4 additions & 27 deletions src/smvlang/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ enum_list : enum_element
enum_element: IDENTIFIER_Token
{
$$=$1;
PARSER.module->enum_set.insert(stack_expr($1).id_string());
PARSER.parse_tree.enum_set.insert(stack_expr($1).id_string());

exprt expr(ID_symbol);
expr.set(ID_identifier, stack_expr($1).id());
Expand Down Expand Up @@ -950,33 +950,10 @@ identifier : IDENTIFIER_Token

variable_identifier: complex_identifier
{
// Could be a variable, or an enum
auto id = merge_complex_identifier(stack_expr($1));

bool is_enum=(PARSER.module->enum_set.find(id)!=
PARSER.module->enum_set.end());
bool is_var=(PARSER.module->vars.find(id)!=
PARSER.module->vars.end());

if(is_var && is_enum)
{
yyerror("identifier `"+id2string(id)+"' is ambiguous");
YYERROR;
}
else if(is_enum)
{
init($$, ID_constant);
stack_expr($$).type()=typet(ID_smv_enumeration);
stack_expr($$).set(ID_value, id);
}
else // not an enum, probably a variable
{
init($$, ID_symbol);
stack_expr($$).set(ID_identifier, id);
auto var_it = PARSER.module->vars.find(id);
if(var_it!= PARSER.module->vars.end())
stack_expr($$).type()=var_it->second.type;
//PARSER.module->vars[stack_expr($1).id()];
}
init($$, ID_smv_identifier);
stack_expr($$).set(ID_identifier, id);
}
| STRING_Token
{
Expand Down
4 changes: 3 additions & 1 deletion src/smvlang/smv_parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ class smv_parse_treet
}

mc_varst vars;
enum_sett enum_set;

std::list<irep_idt> ports;
};

// enums are global
enum_sett enum_set;

typedef std::unordered_map<irep_idt, modulet, irep_id_hash> modulest;

Expand Down
Loading