static unsigned pp_symbol(std::ostream & out, symbol const & s) { if (is_smt2_quoted_symbol(s)) { std::string str = mk_smt2_quoted_symbol(s); out << str; return static_cast<unsigned>(str.length()); } else if (s.is_numerical()) { std::string str = s.str(); out << str; return static_cast<unsigned>(str.length()); } else { out << s.bare_str(); return static_cast<unsigned>(strlen(s.bare_str())); } }
virtual void set_next_arg(cmd_context & ctx, symbol const & s) { cmd * c = ctx.find_cmd(s); if (c == 0) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(err_msg); } m_cmds.push_back(s); }
void set_next_arg(cmd_context & ctx, symbol const & s) override { cmd * c = ctx.find_cmd(s); if (c == nullptr) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(std::move(err_msg)); } m_cmds.push_back(s); }
bool split_name(symbol const& name, symbol & prefix, symbol & suffix) const { if (name.is_numerical()) return false; char const* str = name.bare_str(); char const* period = strchr(str,'.'); if (!period) return false; svector<char> prefix_((unsigned)(period-str), str); prefix_.push_back(0); prefix = symbol(prefix_.c_ptr()); suffix = symbol(period + 1); return true; }
std::string mk_smt2_quoted_symbol(symbol const & s) { SASSERT(is_smt2_quoted_symbol(s)); string_buffer<> buffer; buffer.append('|'); char const * str = s.bare_str(); while (*str) { if (*str == '|' || *str == '\\') buffer.append('\\'); buffer.append(*str); str++; } buffer.append('|'); return std::string(buffer.c_str()); }
bool operator()(symbol const & s1, symbol const & s2) const { return strcmp(s1.bare_str(), s2.bare_str()) < 0; }
bool is_smt2_quoted_symbol(symbol const & s) { if (s.is_numerical()) return false; return is_smt2_quoted_symbol(s.bare_str()); }
std::string norm_param_name(symbol const & n) { return norm_param_name(n.bare_str()); }