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