[antlr-interest] better error messages in tree parsers

Terence Parr parrt at cs.usfca.edu
Sat Jan 30 11:48:18 PST 2010


On Jan 30, 2010, at 3:48 AM, Oliver Zeigermann wrote:

> As input.LT seems to return null values in case we are at the very
> start/end of the node stream, I added this check which does the job
> for me
> 
>           input.LT(-3) == null ? "" : ((Tree)input.LT(-3)).getText()+" "+
>           input.LT(-2) == null ? "" : ((Tree)input.LT(-2)).getText()+" "+
>           input.LT(-1) == null ? "" : ((Tree)input.LT(-1)).getText()+" >>>"+
>           input.LT(1) == null ? "" : ((Tree)input.LT(1)).getText()+"<<< "+
>           input.LT(2) == null ? "" : ((Tree)input.LT(2)).getText()+" "+
>           input.LT(3) == null ? "" : ((Tree)input.LT(3)).getText();

oh. right. start is a problem. end is EOF so no problem.

can u update the faq too? ;)
Ter


More information about the antlr-interest mailing list