//TODO: it would be nice to put print in a .cpp somewhere since performance //isn't critical. but we have no lib for the toplevel xmt/ headers. inline void print(std::ostream &out, Sym sym, IVocabulary const* vocab , char const* variablePrefix="X") { //TODO: consider always escaping for syntax rule formats (anything with //delimiters other than space, which we never allow inside tokens, etc) if (variablePrefix && sym.isVariable()) out << "X" << sym.index(); // some unit tests use vocabularies that don't set a variables vocab. if // that's fixed, we can remove the variablePrefix arg else if (vocab) out << vocab->str(sym); // if you want quotes + escaping, use Hypergraph/SymbolPrint.hpp else out << sym.getTypeNameShort() << sym.index(); }
inline void operator-=(Sym delta) { assert(delta.type() == type()); operator-=(delta.index()); }
bool containsSym(Sym sym) const { assert(sym.type() == type_); SymInt index = sym.index(); assert(index >= offset_); return index - offset_ < symbols_.size(); }
bool boundsSym(Sym sym) const { return sym.index() < offset_ + symbols_.size(); }