Skip to content

Commit 32b9e2c

Browse files
author
Daniel Kroening
committed
smt2_parser: parse Array sort
1 parent 163bc94 commit 32b9e2c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/solvers/smt2/smt2_parser.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,38 @@ typet smt2_parsert::sort()
975975
return nil_typet();
976976
}
977977
}
978+
else if(buffer == "Array")
979+
{
980+
// this gets two sorts as arguments, domain and range
981+
auto domain = sort();
982+
auto range = sort();
983+
984+
// eat the ')'
985+
if(next_token() != CLOSE)
986+
{
987+
error() << "expected ')' at end of Array sort" << eom;
988+
return nil_typet();
989+
}
990+
991+
// we can turn arrays that map a bitvector type to something else
992+
// into our 'array_typet'
993+
if(domain.id() == ID_unsignedbv)
994+
{
995+
const auto size = to_unsignedbv_type(domain).largest_expr();
996+
return array_typet(range, size);
997+
}
998+
else if(domain.id() == ID_signedbv)
999+
{
1000+
// we are not really doing the negative indices
1001+
const auto size = to_signedbv_type(domain).largest_expr();
1002+
return array_typet(range, size);
1003+
}
1004+
else
1005+
{
1006+
error() << "unsupported array sort" << eom;
1007+
return nil_typet();
1008+
}
1009+
}
9781010
else
9791011
{
9801012
error() << "unexpected sort: `" << buffer << '\'' << eom;

0 commit comments

Comments
 (0)