[antlr-interest] Keeping track of errors up the chain during parsing

Arun Ramakrishnan sinchronized.arun at gmail.com
Wed Nov 21 18:12:45 PST 2012


I would like to be able to determine at which rule of the parser there was
an error at any level higher in the chain.

For example in the following grammer. since the rule a is repeated, i want
to be able to detect the part of the input that was successfully matched
and more importantly when there is an error determine which parser rule
down the chain the error occured at.

a: (b "level1")* { System.out.println("error propagated from parser
rule:xxxx"+ " input matched successfully upto:xxx");  }
b : c  "level2";
c : d  "level3";
d: "end" "level4";

I am not sure antlr parser keeps track of this.But, I am thinking that
transforming it into an AST might help achieve what I am trying to do.

thanks
Arun


More information about the antlr-interest mailing list