@@ -41,7 +41,14 @@ class smv_typecheckt:public typecheckt
41
41
42
42
virtual ~smv_typecheckt () { }
43
43
44
- typedef enum { INIT, TRANS, OTHER } modet;
44
+ typedef enum
45
+ {
46
+ INIT,
47
+ TRANS,
48
+ OTHER,
49
+ LTL,
50
+ CTL
51
+ } modet;
45
52
46
53
void convert (smv_parse_treet::modulet &smv_module);
47
54
void convert (smv_parse_treet::mc_varst &vars);
@@ -936,25 +943,39 @@ void smv_typecheckt::typecheck(
936
943
}
937
944
else if (
938
945
expr.id () == ID_AG || expr.id () == ID_AX || expr.id () == ID_AF ||
939
- expr.id () == ID_EG || expr.id () == ID_EX || expr.id () == ID_EF ||
940
- expr.id () == ID_X || expr.id () == ID_F || expr.id () == ID_G)
946
+ expr.id () == ID_EG || expr.id () == ID_EX || expr.id () == ID_EF)
941
947
{
942
- if (expr.operands ().size ()!=1 )
943
- {
944
- error ().source_location =expr.find_source_location ();
945
- error () << " Expected one operand for " << expr.id ()
946
- << " operator" << eom;
947
- throw 0 ;
948
- }
949
-
950
- expr.type ()=bool_typet ();
951
-
948
+ if (mode != CTL)
949
+ throw errort ().with_location (expr.source_location ())
950
+ << " CTL operator not permitted here" ;
951
+ expr.type () = bool_typet ();
952
+ typecheck (to_unary_expr (expr).op (), expr.type (), mode);
953
+ }
954
+ else if (expr.id () == ID_X || expr.id () == ID_F || expr.id () == ID_G)
955
+ {
956
+ if (mode != LTL)
957
+ throw errort ().with_location (expr.source_location ())
958
+ << " LTL operator not permitted here" ;
959
+ expr.type () = bool_typet ();
952
960
typecheck (to_unary_expr (expr).op (), expr.type (), mode);
953
961
}
954
962
else if (
955
963
expr.id () == ID_EU || expr.id () == ID_ER || expr.id () == ID_AU ||
956
- expr.id () == ID_AR || expr. id () == ID_U || expr. id () == ID_R )
964
+ expr.id () == ID_AR)
957
965
{
966
+ if (mode != CTL)
967
+ throw errort ().with_location (expr.source_location ())
968
+ << " CTL operator not permitted here" ;
969
+ auto &binary_expr = to_binary_expr (expr);
970
+ expr.type () = bool_typet ();
971
+ typecheck (binary_expr.lhs (), expr.type (), mode);
972
+ typecheck (binary_expr.rhs (), expr.type (), mode);
973
+ }
974
+ else if (expr.id () == ID_U || expr.id () == ID_R)
975
+ {
976
+ if (mode != LTL)
977
+ throw errort ().with_location (expr.source_location ())
978
+ << " LTL operator not permitted here" ;
958
979
auto &binary_expr = to_binary_expr (expr);
959
980
expr.type () = bool_typet ();
960
981
typecheck (binary_expr.lhs (), expr.type (), mode);
@@ -1194,11 +1215,17 @@ void smv_typecheckt::typecheck(
1194
1215
mode=TRANS;
1195
1216
break ;
1196
1217
1218
+ case smv_parse_treet::modulet::itemt::CTLSPEC:
1219
+ mode = CTL;
1220
+ break ;
1221
+
1222
+ case smv_parse_treet::modulet::itemt::LTLSPEC:
1223
+ mode = LTL;
1224
+ break ;
1225
+
1197
1226
case smv_parse_treet::modulet::itemt::DEFINE:
1198
1227
case smv_parse_treet::modulet::itemt::INVAR:
1199
1228
case smv_parse_treet::modulet::itemt::FAIRNESS:
1200
- case smv_parse_treet::modulet::itemt::CTLSPEC:
1201
- case smv_parse_treet::modulet::itemt::LTLSPEC:
1202
1229
default :
1203
1230
mode=OTHER;
1204
1231
}
0 commit comments