public void explainTemplateRules(ExpressionPresenter presenter) {
for (int i=0; i<ruleDict.length; i++) {
Rule r = ruleDict[i];
while (r != null) {
Template t = (Template)r.getAction();
int s = presenter.startElement("templateRule");
presenter.emitAttribute("match", r.getPattern().toString());
presenter.emitAttribute("precedence", r.getPrecedence()+"");
presenter.emitAttribute("priority", r.getPriority()+"");
presenter.emitAttribute("line", t.getLineNumber()+"");
presenter.emitAttribute("module", t.getSystemId());
if (t.getBody() != null) {
t.getBody().explain(presenter);
}
int e = presenter.endElement();
if (s != e) {
throw new IllegalStateException(
"tree unbalanced in template at line " + t.getLineNumber() + " of " + t.getSystemId());
}
r = r.getNext();
}
}
}