Skip to content

Commit bb805e2

Browse files
committed
SMV: rename STRING_Token, QSTRING_Token and QUOTE_Token
This renames the token identifiers used for SMV identifiers to better match the NuSMV manual.
1 parent 2728d52 commit bb805e2

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
syntax1.smv
33

4-
^file .* line 3: syntax error, unexpected VAR, expecting string or "'" before 'VAR'$
4+
^file .* line 3: syntax error, unexpected VAR, expecting identifier or quoted string before 'VAR'$
55
^EXIT=1$
66
^SIGNAL=0$
77
--
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
syntax3.smv
33

4-
^file .* line 3: syntax error, unexpected string, expecting number before 'not_a_number'$
4+
^file .* line 3: syntax error, unexpected identifier, expecting number before 'not_a_number'$
55
^EXIT=1$
66
^SIGNAL=0$
77
--

src/smvlang/parser.y

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ static void new_module(YYSTYPE &module)
273273
%token ADD_Token
274274
%token SUB_Token
275275

276-
%token STRING_Token "string"
277-
%token QSTRING_Token "quoted string"
278-
%token QUOTE_Token "'"
276+
%token IDENTIFIER_Token "identifier"
277+
%token QIDENTIFIER_Token "quoted identifier"
278+
%token STRING_Token "quoted string"
279279
%token NUMBER_Token "number"
280280

281281
/* operator precedence, low to high */
@@ -310,8 +310,8 @@ modules : module
310310
module : module_head module_body
311311
;
312312

313-
module_name: STRING_Token
314-
| QUOTE_Token
313+
module_name: IDENTIFIER_Token
314+
| STRING_Token
315315
;
316316

317317
module_head: MODULE_Token module_name { new_module($2); }
@@ -421,7 +421,7 @@ ltl_specification:
421421
}
422422
;
423423

424-
extern_var : variable_identifier EQUAL_Token QUOTE_Token
424+
extern_var : variable_identifier EQUAL_Token STRING_Token
425425
{
426426
const irep_idt &identifier=stack_expr($1).get(ID_identifier);
427427
smv_parse_treet::mc_vart &var=PARSER.module->vars[identifier];
@@ -532,7 +532,7 @@ enum_list : enum_element
532532
}
533533
;
534534

535-
enum_element: STRING_Token
535+
enum_element: IDENTIFIER_Token
536536
{
537537
$$=$1;
538538
PARSER.module->enum_set.insert(stack_expr($1).id_string());
@@ -783,7 +783,12 @@ formula_list:
783783
| formula_list ',' formula { $$=$1; mto($$, $3); }
784784
;
785785

786-
identifier : STRING_Token
786+
identifier : IDENTIFIER_Token
787+
| QIDENTIFIER_Token
788+
{
789+
// not supported by NuSMV
790+
init($$, std::string(stack_expr($1).id_string(), 1)); // remove backslash
791+
}
787792
;
788793

789794
variable_identifier: complex_identifier
@@ -816,7 +821,7 @@ variable_identifier: complex_identifier
816821
//PARSER.module->vars[stack_expr($1).id()];
817822
}
818823
}
819-
| QUOTE_Token
824+
| STRING_Token
820825
{
821826
const irep_idt &id=stack_expr($1).id();
822827

@@ -826,19 +831,16 @@ variable_identifier: complex_identifier
826831
}
827832
;
828833

829-
complex_identifier: QSTRING_Token
830-
{
831-
init($$, std::string(stack_expr($1).id_string(), 1)); // remove backslash
832-
}
833-
| STRING_Token
834-
| complex_identifier DOT_Token QSTRING_Token
834+
complex_identifier:
835+
identifier
836+
| complex_identifier DOT_Token QIDENTIFIER_Token
835837
{
836838
std::string id(stack_expr($1).id_string());
837839
id+=".";
838840
id+=std::string(stack_expr($3).id_string(), 1); // remove backslash
839841
init($$, id);
840842
}
841-
| complex_identifier DOT_Token STRING_Token
843+
| complex_identifier DOT_Token IDENTIFIER_Token
842844
{
843845
std::string id(stack_expr($1).id_string());
844846
id+=".";

src/smvlang/scanner.l

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ void newlocation(YYSTYPE &x)
176176
[\$A-Za-z_][A-Za-z0-9_\$#-]* {
177177
newstack(yysmvlval);
178178
stack_expr(yysmvlval).id(yytext);
179-
return STRING_Token;
179+
return IDENTIFIER_Token;
180180
}
181181
\\[A-Za-z0-9_\$#-]* {
182182
newstack(yysmvlval);
183183
stack_expr(yysmvlval).id(yytext);
184-
return QSTRING_Token;
184+
return QIDENTIFIER_Token;
185185
}
186186
[0-9][0-9]* {
187187
newstack(yysmvlval);
@@ -192,7 +192,7 @@ void newlocation(YYSTYPE &x)
192192
newstack(yysmvlval);
193193
std::string tmp(yytext);
194194
stack_expr(yysmvlval).id(std::string(tmp, 1, tmp.size()-2));
195-
return QUOTE_Token;
195+
return STRING_Token;
196196
}
197197

198198
"?" return IF_Token;

0 commit comments

Comments
 (0)