[antlr-interest] Some Problem with antlrv3

femtowin1 femtowin1 at gmail.com
Sun May 6 22:55:09 PDT 2007


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.

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.

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.)
  
XRuby http://xruby.com
femto http://hi.baidu.com/femto
______________________________________
Sent from my www.pageflakes.com startpage


More information about the antlr-interest mailing list