[antlr-interest] Error report in tree walker after semantic predicate

Dubravko Gorupic dubravko.gorupic at wbs-tech.hr
Tue Dec 19 01:04:51 PST 2006


Hi there.
I have a tree parser that extends TreeParser. In my tree parser I use semantic 
predicates which, on false evaluation, throw exceptions. When I catch those 
exceptions (SemanticException), I can't get line number of last recognized 
AST node before exception was risen, so could inform on which line of code 
was error.
Is there any way to find out line number of last AST node which was recognized 
before exception from semantic predicate happened? I also use extended 
CommonAST class with new getLine() and initialize() methods like was in most 
examples on internet.
Thanx, Dubravko.

P.S.

Part of tree.g:
.....
options
{
  language="Cpp";
}

class cMyWalker extends TreeParser;

options
{
  importVocab=actVocab;
  ASTLabelType = "RefNodeAST";
  defaultErrorHandler = false;
}
.....


More information about the antlr-interest mailing list