Answer
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.
Is this item
helpful? yes no
Previous votes Yes: 2 No: 1
|
|
Comments and alternative answers
|
|
 |
|