[antlr-interest] Line number help

Walter Schilling walter.schilling at computer.org
Fri Jul 21 12:41:13 PDT 2006


Good afternoon.

I am having some difficulty developing a Java analysis tool when it
comes to line numberings and I want to see if there is a better way to
handle what I need done.  In specific, I desire two bits of information
from my tree parser, the starting line / column location for a construct
and the ending line / column location for a construct.  Per one of the
older FAQ answers in the antlr documentation, I have extended the
CommonAST class to include line numbers and locations.  However, if I
have a rule such as:

expression
	:	#(EXPR expr)
	;

the line number and column number within the AST are always zero.  I
suspect this has to do with the way they are constructed in the parser.
As an interim measure, I have developed routines which walk the
expression structure to find the starting and ending line numbers, but
is there any easy way of appending this information right into the EXPR
node?  That is, any way short of modifying each and every rule where I
create such a tree structure when parsing the code?

Thanks,

Walt Schilling

-- 
Walter W. Schilling, Jr.
2004 - 2005 Ohio Space Grant Consortium PhD. Fellowship Recipient
University of Toledo PhD Doctoral Candidate
MSES 1998 University of Toledo
BSEE 1997 Ohio Northern University



More information about the antlr-interest mailing list