[antlr-interest] Post CommonTokenStream in the parser constructor

Luke Silver LukeSilver at web.de
Mon Mar 5 03:38:50 PST 2007


Hi everybody,

is it possible to call the CommonTokenStream constructor in the parser?
(ANTLR v3.0b5, Java)

Now I call it this way:

MyLexer lexer = new MyLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
MyParser parser = new MyParser(tokens);
//parse grammar
parser.grammar();

and in the class MyParser.java:

 public MyParser(TokenStream input) {
            super(input);
            ruleMemo = new HashMap[48+1];
         }


And now I would like to do something like this:

MyLexer lexer = new MyLexer(input);
MyParser parser = new MyParser(lexer);
//parse grammar
parser.grammar();

and in the class MyParser.java:

public MyParser(TokenSource tokenSource) {
     CommonTokenStream tokens = new CommonTokenStream(tokenSource);
     MyParser = new MyParser(tokens);
}


Best wishes,
Luke
__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!		
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131



More information about the antlr-interest mailing list