}
}
-static std::string maybeQuoteSymbol(const std::string& s) {
- // this is the set of SMT-LIBv2 permitted characters in "simple" (non-quoted) symbols
- if (s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- "0123456789~!@$%^&*_-+=<>.?/")
- != string::npos
- || s.empty() || (s[0] >= '0' && s[0] <= '9'))
- {
- // need to quote it
- stringstream ss;
- ss << '|' << s << '|';
- return ss.str();
- }
- return s;
-}
-
static bool stringifyRegexp(Node n, stringstream& ss) {
if(n.getKind() == kind::STRING_TO_REGEXP) {
ss << n[0].getConst<String>().toString(true);
}
else
{
- out << maybeQuoteSymbol(dt.getName());
+ out << CVC4::quoteSymbol(dt.getName());
}
break;
}
const UninterpretedConstant& uc = n.getConst<UninterpretedConstant>();
std::stringstream ss;
ss << '@' << uc;
- out << maybeQuoteSymbol(ss.str());
+ out << CVC4::quoteSymbol(ss.str());
break;
}
out << '(';
}
if(n.getAttribute(expr::VarNameAttr(), name)) {
- out << maybeQuoteSymbol(name);
+ out << CVC4::quoteSymbol(name);
}
if(n.getNumChildren() != 0) {
for(unsigned i = 0; i < n.getNumChildren(); ++i) {
string s;
if (n.getAttribute(expr::VarNameAttr(), s))
{
- out << maybeQuoteSymbol(s);
+ out << CVC4::quoteSymbol(s);
}
else
{
static std::string quoteSymbol(TNode n) {
- // #warning "check the old implementation. It seems off."
std::stringstream ss;
- ss << language::SetLanguage(language::output::LANG_SMTLIB_V2_5);
+ ss << n;
return CVC4::quoteSymbol(ss.str());
}
std::string name;
if (smt->getExpressionName(*i,name)) {
// Named assertions always get printed
- out << maybeQuoteSymbol(name) << endl;
+ out << CVC4::quoteSymbol(name) << endl;
} else if (options::dumpUnsatCoresFull()) {
// Unnamed assertions only get printed if the option is set
out << *i << endl;
static void toStream(std::ostream& out, const DeclareTypeCommand* c)
{
- out << "(declare-sort " << maybeQuoteSymbol(c->getSymbol()) << " "
+ out << "(declare-sort " << CVC4::quoteSymbol(c->getSymbol()) << " "
<< c->getArity() << ")";
}
for(Datatype::const_iterator ctor = d.begin(), ctor_end = d.end();
ctor != ctor_end; ++ctor){
if( ctor!=d.begin() ) out << " ";
- out << "(" << maybeQuoteSymbol(ctor->getName());
+ out << "(" << CVC4::quoteSymbol(ctor->getName());
for(DatatypeConstructor::const_iterator arg = ctor->begin(), arg_end = ctor->end();
arg != arg_end; ++arg){
++i)
{
const Datatype& d = i->getDatatype();
- out << "(" << maybeQuoteSymbol(d.getName());
+ out << "(" << CVC4::quoteSymbol(d.getName());
out << " " << d.getNumParameters() << ")";
}
out << ") (";
++i)
{
const Datatype& d = i->getDatatype();
- out << "(" << maybeQuoteSymbol(d.getName()) << " ";
+ out << "(" << CVC4::quoteSymbol(d.getName()) << " ";
toStream(out, d);
out << ")";
}
#include "util/smt2_quote_string.h"
+#include <sstream>
#include <string>
namespace CVC4 {
* SMT-LIB 2 quoting for symbols
*/
std::string quoteSymbol(const std::string& s){
- if(s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@$%^&*_-+=<>.?/") == std::string::npos) {
- // simple unquoted symbol
- return s;
- } else {
+ // this is the set of SMT-LIBv2 permitted characters in "simple" (non-quoted)
+ // symbols
+ if (s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789~!@$%^&*_-+=<>.?/")
+ != std::string::npos
+ || s.empty() || (s[0] >= '0' && s[0] <= '9'))
+ {
std::string tmp(s);
// must quote the symbol, but it cannot contain | or \, we turn those into _
size_t p;
}
return "|" + tmp + "|";
}
+ return s;
}
}/* CVC4 namespace */