File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1236,6 +1236,32 @@ void smt2_parsert::setup_expressions()
12361236 expressions[" fp.neg" ] = [this ] { return unary (ID_unary_minus, operands ()); };
12371237}
12381238
1239+ typet smt2_parsert::function_sort ()
1240+ {
1241+ std::vector<typet> sorts;
1242+
1243+ // (-> sort+ sort)
1244+ // The last sort is the co-domain.
1245+
1246+ while (smt2_tokenizer.peek () != smt2_tokenizert::CLOSE)
1247+ {
1248+ if (smt2_tokenizer.peek () == smt2_tokenizert::END_OF_FILE)
1249+ throw error () << " unexpected end-of-file in a function sort" ;
1250+
1251+ sorts.push_back (sort ()); // recursive call
1252+ }
1253+
1254+ next_token (); // eat the ')'
1255+
1256+ if (sorts.size () < 2 )
1257+ throw error () << " expected function sort to have at least 2 type arguments" ;
1258+
1259+ auto codomain = std::move (sorts.back ());
1260+ sorts.pop_back ();
1261+
1262+ return mathematical_function_typet (std::move (sorts), std::move (codomain));
1263+ }
1264+
12391265typet smt2_parsert::sort ()
12401266{
12411267 // a sort is one of the following three cases:
@@ -1334,6 +1360,8 @@ void smt2_parsert::setup_sorts()
13341360 else
13351361 throw error (" unsupported array sort" );
13361362 };
1363+
1364+ sorts[" ->" ] = [this ] { return function_sort (); };
13371365}
13381366
13391367smt2_parsert::signature_with_parameter_idst
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ class smt2_parsert
177177
178178 // sorts
179179 typet sort ();
180+ typet function_sort ();
180181 std::unordered_map<std::string, std::function<typet()>> sorts;
181182 void setup_sorts ();
182183
You can’t perform that action at this time.
0 commit comments