@@ -41,7 +41,14 @@ class smv_typecheckt:public typecheckt
4141
4242 virtual ~smv_typecheckt () { }
4343
44- typedef enum { INIT, TRANS, OTHER } modet;
44+ typedef enum
45+ {
46+ INIT,
47+ TRANS,
48+ OTHER,
49+ LTL,
50+ CTL
51+ } modet;
4552
4653 void convert (smv_parse_treet::modulet &smv_module);
4754 void convert (smv_parse_treet::mc_varst &vars);
@@ -936,25 +943,39 @@ void smv_typecheckt::typecheck(
936943 }
937944 else if (
938945 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)
941947 {
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 ();
952960 typecheck (to_unary_expr (expr).op (), expr.type (), mode);
953961 }
954962 else if (
955963 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)
957965 {
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" ;
958979 auto &binary_expr = to_binary_expr (expr);
959980 expr.type () = bool_typet ();
960981 typecheck (binary_expr.lhs (), expr.type (), mode);
@@ -1194,11 +1215,17 @@ void smv_typecheckt::typecheck(
11941215 mode=TRANS;
11951216 break ;
11961217
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+
11971226 case smv_parse_treet::modulet::itemt::DEFINE:
11981227 case smv_parse_treet::modulet::itemt::INVAR:
11991228 case smv_parse_treet::modulet::itemt::FAIRNESS:
1200- case smv_parse_treet::modulet::itemt::CTLSPEC:
1201- case smv_parse_treet::modulet::itemt::LTLSPEC:
12021229 default :
12031230 mode=OTHER;
12041231 }
0 commit comments