[antlr-interest] Some Problem with antlrv3

Terence Parr parrt at cs.usfca.edu
Mon May 7 11:56:50 PDT 2007


On May 6, 2007, at 10:55 PM, femtowin1 wrote:

> Hello, when I'm developing antlrv3 grammar for XRuby, I found  
> several issues inconvient:
> first, geneate Parser construtor:
>   public Rubyv3Parser(TokenStream input) {
>         super(input);
>     }
> actually I need some customization here,
> I need to relate Parser with Lexer
> (because ruby's heredoc lexing require parser's symtol table  
> information). I can't replace the old construtor, so instead
> I write the following and invoke this: (a different construtor)
> public Rubyv3Parser(TokenStream input, Rubyv3Parser parent) {
>         super(input);
>         ((Rubyv3Lexer) input.getTokenSource()).setParser(this); // 
> this line is what I required to customize in order to relate parser  
> and lexer
>         this.parent = parent;
>     }
> but puting the original construtor in system is confusing and  
> people may invoke it by wrong and then end up with not correctly  
> intialized parser/lexer.

Actually you want this(input).

Anyway, i don't think that is a huge problem.

>
> second, I can't specify the superClass of Lexer, yes the options  
> has a superClass option for parser, but that don't work for lexer,
> I've tried lexer::options{...} or options {lexer.superClass=...},
> none of them work.

added bug:

http://www.antlr.org:8888/secure/CreateIssueDetails.jspa

> third, for tree grammar, can't specify customized tokens type,
> TokenLabelType=MyToken; doesn't work, instead I must write
> ((MyToken)$value.getToken()), (but  this issue is minor
> because anyway I can get access to it, just typecast.)

I can't know read code and figure out that somthing will have type  
Token w/o building a compiler I'm afraid.

Thanks..
Ter


More information about the antlr-interest mailing list