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()
1236
1236
expressions[" fp.neg" ] = [this ] { return unary (ID_unary_minus, operands ()); };
1237
1237
}
1238
1238
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
+
1239
1265
typet smt2_parsert::sort ()
1240
1266
{
1241
1267
// a sort is one of the following three cases:
@@ -1334,6 +1360,8 @@ void smt2_parsert::setup_sorts()
1334
1360
else
1335
1361
throw error (" unsupported array sort" );
1336
1362
};
1363
+
1364
+ sorts[" ->" ] = [this ] { return function_sort (); };
1337
1365
}
1338
1366
1339
1367
smt2_parsert::signature_with_parameter_idst
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ class smt2_parsert
177
177
178
178
// sorts
179
179
typet sort ();
180
+ typet function_sort ();
180
181
std::unordered_map<std::string, std::function<typet()>> sorts;
181
182
void setup_sorts ();
182
183
You can’t perform that action at this time.
0 commit comments