#include "dom.hh"
#include "TDictionary.hh"
#include "TTokenizer.hh"
+#include "CLoggerConsole.hh"
static TDictionary::Entry undefinedEntry;
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")
{
if (entry.cls != MACRO)
cerr << "WARNING: `" << name << "' table ignored for non-macro" << endl;
-
+
std::istringstream is(el.getAttribute("table"));
unsigned table;
is >> table;
// 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;
+}