@@ -130,6 +130,41 @@ static void j_binary(YYSTYPE & dest, YYSTYPE & op1, const irep_idt &id, YYSTYPE
130
130
131
131
/* ******************************************************************\
132
132
133
+ Function: merge_complex_identifier
134
+
135
+ Inputs:
136
+
137
+ Outputs:
138
+
139
+ Purpose:
140
+
141
+ \*******************************************************************/
142
+
143
+ irep_idt merge_complex_identifier (const exprt &expr)
144
+ {
145
+ if (expr.id () == ID_symbol)
146
+ return to_symbol_expr (expr).get_identifier ();
147
+ else if (expr.id () == ID_member)
148
+ {
149
+ auto &member_expr = to_member_expr (expr);
150
+ return id2string (merge_complex_identifier (member_expr.compound ())) + ' .' + id2string (member_expr.get_component_name ());
151
+ }
152
+ else if (expr.id () == ID_index)
153
+ {
154
+ auto &index_expr = to_index_expr (expr);
155
+ auto &index = index_expr.index ();
156
+ PRECONDITION (index.is_constant ());
157
+ auto index_string = id2string (to_constant_expr (index).get_value ());
158
+ return id2string (merge_complex_identifier (index_expr.array ())) + ' .' + index_string;
159
+ }
160
+ else
161
+ {
162
+ DATA_INVARIANT_WITH_DIAGNOSTICS (false , " unexpected complex_identifier" , expr.pretty ());
163
+ }
164
+ }
165
+
166
+ /* ******************************************************************\
167
+
133
168
Function: new_module
134
169
135
170
Inputs:
@@ -820,7 +855,7 @@ identifier : IDENTIFIER_Token
820
855
821
856
variable_identifier: complex_identifier
822
857
{
823
- const irep_idt &id= stack_expr ($1 ). id ( );
858
+ auto id = merge_complex_identifier ( stack_expr ($1 ));
824
859
825
860
bool is_enum=(PARSER.module ->enum_set .find (id)!=
826
861
PARSER.module ->enum_set .end ());
@@ -850,6 +885,7 @@ variable_identifier: complex_identifier
850
885
}
851
886
| STRING_Token
852
887
{
888
+ // Not in the NuSMV grammar.
853
889
const irep_idt &id=stack_expr ($1 ).id ();
854
890
855
891
init ($$, ID_symbol);
@@ -860,35 +896,31 @@ variable_identifier: complex_identifier
860
896
861
897
complex_identifier:
862
898
identifier
899
+ {
900
+ $$ = $1 ;
901
+ irep_idt identifier = stack_expr ($$).id ();
902
+ stack_expr ($$).id (ID_symbol);
903
+ stack_expr ($$).set (ID_identifier, identifier);
904
+ }
863
905
| complex_identifier DOT_Token QIDENTIFIER_Token
864
906
{
865
- std::string id (stack_expr ($1 ).id_string ());
866
- id+=" ." ;
867
- id+=std::string (stack_expr ($3 ).id_string (), 1 ); // remove backslash
868
- init ($$, id);
907
+ unary ($$, ID_member, $1 );
908
+ auto component = std::string (stack_expr ($3 ).id_string (), 1 ); // remove backslash
909
+ stack_expr ($$).set (ID_component_name, component);
869
910
}
870
911
| complex_identifier DOT_Token IDENTIFIER_Token
871
912
{
872
- std::string id (stack_expr ($1 ).id_string ());
873
- id+=" ." ;
874
- id+=stack_expr ($3 ).id_string ();
875
- init ($$, id);
913
+ unary ($$, ID_member, $1 );
914
+ stack_expr ($$).set (ID_component_name, stack_expr ($3 ).id ());
876
915
}
877
- | complex_identifier ' [' NUMBER_Token ' ]'
916
+ | complex_identifier ' [' term ' ]'
878
917
{
879
- std::string id (stack_expr ($1 ).id_string ());
880
- id+=" [" ;
881
- id+=stack_expr ($3 ).id_string ();
882
- id+=" ]" ;
883
- init ($$, id);
918
+ binary ($$, $1 , ID_index, $3 );
884
919
}
885
- | complex_identifier ' (' NUMBER_Token ' )'
920
+ | complex_identifier ' (' term ' )'
886
921
{
887
- std::string id (stack_expr ($1 ).id_string ());
888
- id+=" (" ;
889
- id+=stack_expr ($3 ).id_string ();
890
- id+=" )" ;
891
- init ($$, id);
922
+ // Not in the NuSMV grammar.
923
+ binary ($$, $1 , ID_index, $3 );
892
924
}
893
925
;
894
926
0 commit comments