Skip to content

Commit 0160ece

Browse files
committed
SMV: IVAR declarations
This adds IVAR declarations to the SMV frontend.
1 parent 2be0696 commit 0160ece

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

regression/smv/ivar/ivar1.smv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
MODULE main
22

33
IVAR some_input : boolean;
4+
5+
-- these should all fail
6+
LTLSPEC some_input
7+
LTLSPEC !some_input
8+
LTLSPEC X some_input
9+
LTLSPEC X !some_input

src/smvlang/parser.y

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,15 @@ frozenvar_declaration:
419419

420420
simple_var_list:
421421
identifier ':' simple_type_specifier ';'
422+
{
423+
init($$);
424+
stack_expr($$).add_to_operands(unary_exprt{ID_decl, stack_expr($1), stack_type($3)});
425+
}
422426
| simple_var_list identifier ':' simple_type_specifier ';'
427+
{
428+
$$ = $1;
429+
stack_expr($$).add_to_operands(unary_exprt{ID_decl, stack_expr($2), stack_type($4)});
430+
}
423431
;
424432

425433
define_declaration:

src/smvlang/smv_parse_tree.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ std::string to_string(smv_parse_treet::modulet::itemt::item_typet i)
7676
return "DEFINE";
7777
case smv_parse_treet::modulet::itemt::ENUM:
7878
return "ENUM";
79+
case smv_parse_treet::modulet::itemt::IVAR:
80+
return "IVAR";
7981
case smv_parse_treet::modulet::itemt::VAR:
8082
return "VAR";
8183

src/smvlang/smv_parse_tree.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class smv_parse_treet
5252
FAIRNESS,
5353
INIT,
5454
INVAR,
55+
IVAR,
5556
LTLSPEC,
5657
TRANS,
5758
VAR
@@ -260,6 +261,13 @@ class smv_parse_treet
260261
items.emplace_back(itemt::TRANS, std::move(expr), std::move(location));
261262
}
262263

264+
void add_ivar(exprt expr, typet type)
265+
{
266+
expr.type() = std::move(type);
267+
auto location = expr.source_location();
268+
items.emplace_back(itemt::IVAR, std::move(expr), std::move(location));
269+
}
270+
263271
void add_var(exprt expr, typet type)
264272
{
265273
expr.type() = std::move(type);

src/smvlang/smv_typecheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,7 @@ void smv_typecheckt::typecheck(
20332033
return;
20342034

20352035
case smv_parse_treet::modulet::itemt::ENUM:
2036+
case smv_parse_treet::modulet::itemt::IVAR:
20362037
case smv_parse_treet::modulet::itemt::VAR:
20372038
return;
20382039
}

0 commit comments

Comments
 (0)