[antlr-interest] Line and Column information lost during AST creation

Christophe Boutter boutter at ps.uni-sb.de
Thu Jan 4 04:48:54 PST 2007


Xue Yong Zhi wrote:
> You need to replace the default AST class with the one like this:
> http://xruby.googlecode.com/svn/trunk/src/com/xruby/compiler/parser/ASTWithLineNumber.java

I now wrote something very similar.

> Then call setASTNodeClass in your parser to use your AST class, e.g.
> setASTNodeClass("com.xruby.compiler.parser.ASTWithLineNumber");

I've done that too. I call:
setASTNodeClass("modesteditor.core.antlrparser.ASTWithOffsetInfos");

That gives me the following error message:
Can't find/access AST Node
typemodesteditor.core.antlrparser.ASTWithOffsetInfos

I came across a tutorial for self designed ASTs and found that one
should include in the options of the parser and tree walker the statement:
ASTLabelType="modesteditor.core.antlrparser.ASTWithOffsetInfos"

But that wouldn't help either.

The problem may be that the TokenTypeToASTClassMap isn't initialized and
I think therefore the right AST class is not used. This is probably due
to the fact that the parser doesn't find the AST Node type. But why?

Thanks for help.
Chris

> 
> Christophe Boutter wrote:
>> My problem is that during the AST creation in the parser all information
>> about lines and columns of the lexer Token is lost. But I need this
>> informations badly. Why is that?
>>
> 
> 


-- 
Try not to become a man of success, but rather try to become a man of value.
-- Albert Einstein


More information about the antlr-interest mailing list