X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Fsrc%2FTDictionary.cc;h=8c16d2ba91327bf0dba38ed1ecc3cb554a905276;hb=7bea7bddf7ca13260f4d3965182dc4fb58d035e7;hp=303d743d441aa3399dc8639eb17354e9284bff14;hpb=89262281b6e83bd2321150f81f1a0583645eb0c8;p=helm.git diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.cc b/helm/DEVEL/mathml_editor/src/TDictionary.cc index 303d743d4..8c16d2ba9 100644 --- a/helm/DEVEL/mathml_editor/src/TDictionary.cc +++ b/helm/DEVEL/mathml_editor/src/TDictionary.cc @@ -4,6 +4,7 @@ #include "dom.hh" #include "TDictionary.hh" #include "TTokenizer.hh" +#include "CLoggerConsole.hh" static TDictionary::Entry undefinedEntry; @@ -18,7 +19,8 @@ TDictionary::load(const char* uri) DOM::Element root = doc.get_documentElement(); assert(root); - TTokenizer tokenizer; + CLoggerConsole logger; + TTokenizer tokenizer(logger); for (DOM::Node p = root.get_firstChild(); p; p = p.get_nextSibling()) if (p.get_nodeType() == DOM::Node::ELEMENT_NODE && p.get_nodeName() == "entry") @@ -134,7 +136,7 @@ TDictionary::load(const char* uri) { if (entry.cls != MACRO) cerr << "WARNING: `" << name << "' table ignored for non-macro" << endl; - + std::istringstream is(el.getAttribute("table")); unsigned table; is >> table; @@ -166,3 +168,32 @@ TDictionary::Entry::paramDelimited(unsigned i) const // AND the next argument is not a parameter return i + 1 < pattern.size() && pattern[i + 1].category != TToken::PARAMETER; } + +bool +TDictionary::Entry::lastDelimiter(unsigned i) const +{ + assert(i < pattern.size()); + assert(pattern[i].category != TToken::PARAMETER); + // a token is the last delimiter if it is the last token + // of the pattern or if the next token is a parameter) + return i + 1 == pattern.size() || pattern[i + 1].category == TToken::PARAMETER; +} + +unsigned +TDictionary::Entry::previousParam(unsigned i) const +{ + // this method return the position in the pattern of the + // parameter placed in a position preceding i. + // If no preceding i parameter present, the method return + // pattern.size(). + // To know the position of the last parameter, call this + // method with i == pattern.size() + unsigned j = i - 1; + + while (pattern[j].category != TToken::PARAMETER) + { + if (j) j--; + else return pattern.size(); + } + return j; +}