std::string sexprToString(api::Term sexpr)
{
- // if sexpr is a spec constant and not a string, return the result of calling
- // Term::toString
- if (sexpr.getKind() == api::CONST_BOOLEAN
- || sexpr.getKind() == api::CONST_FLOATINGPOINT
- || sexpr.getKind() == api::CONST_RATIONAL)
+ // if sexpr is a constant string, return the stored constant string. We don't
+ // call Term::toString as its result depends on the output language.
+ // Notice that we only check for string constants. The sexprs generated by the
+ // parser don't contains other constants, so we can ignore them.
+ if (sexpr.isString())
{
- return sexpr.toString();
- }
-
- // if sexpr is a constant string, return the result of calling Term::toString.
- // However, strip the surrounding quotes
- if (sexpr.getKind() == api::CONST_STRING)
- {
- return sexpr.toString().substr(1, sexpr.toString().length() - 2);
+ // convert std::wstring to std::string
+ std::wstring wstring = sexpr.getString();
+ return std::string(wstring.cbegin(), wstring.cend());
}
// if sexpr is not a spec constant, make sure it is an array of sub-sexprs
DeclareFunctionCommand::DeclareFunctionCommand(const std::string& id,
api::Term func,
api::Sort sort)
- : DeclarationDefinitionCommand(id),
- d_func(func),
- d_sort(sort)
+ : DeclarationDefinitionCommand(id), d_func(func), d_sort(sort)
{
}
/**
* Convert a symbolic expression to string. This method differs from
- * Term::toString in that it does not surround constant strings with double
- * quote symbols.
+ * Term::toString in that it does not depend on the output language.
*
* @param sexpr the symbolic expression to convert
* @return the symbolic expression as string