Esempio n. 1
0
File: Syms.hpp Progetto: graehl/hyp
//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();
}
Esempio n. 2
0
File: Sym.hpp Progetto: graehl/hyp
 inline void operator-=(Sym delta) {
   assert(delta.type() == type());
   operator-=(delta.index());
 }
Esempio n. 3
0
 bool containsSym(Sym sym) const {
   assert(sym.type() == type_);
   SymInt index = sym.index();
   assert(index >= offset_);
   return index - offset_ < symbols_.size();
 }
Esempio n. 4
0
 bool boundsSym(Sym sym) const { return sym.index() < offset_ + symbols_.size(); }