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: Syms.hpp Progetto: graehl/hyp
inline std::string typedStr(Sym sym, IVocabulary const* pVoc) {
  return sym.getTypeNameShort() + str(sym, pVoc);
}
Esempio n. 3
0
File: Syms.hpp Progetto: graehl/hyp
inline std::string typedIndexStr(Sym sym) {
  return sym.getTypeNameShort() + indexStr(sym);
}