[antlr-interest] Getting line number and char position of current AST node

Terence Parr parrt at cs.usfca.edu
Thu Mar 29 10:35:19 PDT 2007

On Mar 29, 2007, at 9:25 AM, Scott Fortmann-Roe wrote:

> Hi,
> Is there a way of getting the line number of the current AST node. All
> I seem to be able to get is the line number of the next AST node using
> the following:
> (CommonTree)nodes.get(nodes.index())).getLine()
> Maybe by "current" I mean previous. Basically, if an error occurs
> during a symbol table look up I want access to the node that caused
> that error, not the node after it.

Hi. try input.LT(-1) to get the node then get payload or whatever.


More information about the antlr-interest mailing list