Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I include line numbers in automatically generated ASTs?

asts automatically line Numbers
0
Posted

How can I include line numbers in automatically generated ASTs?

0

Location: http://www.jguru.com/faq/view.jsp?EID=62654 Created: Jun 7, 2000 Modified: 2000-06-07 15:47:03.119 Author: Fondement Frederic (http://www.jguru.com/guru/viewbio.jsp?EID=14817) Tree parsers are often used in type checkers. But useful error messages need the offending line number. So I have written: import antlr.CommonAST; import antlr.Token; public class CommonASTWithLines extends CommonAST { private int line = 0; public void initialize(Token tok) { super.initialize(tok); line=tok.getLine(); } public int getLine(){ return line; } } initialize is automatically called when an AST is created from a Token object, which has its own line variable.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123