[antlr-interest] ENHANCEMENT: Add invoke(...) method(s) on parser
Austin Hastings
Austin_Hastings at Yahoo.com
Wed Oct 24 11:37:31 PDT 2007
While it's possible to do "different" things with the generated parsers,
especially tree parsers, there aren't *that* many different things
possible. I'd like to suggest generating an "invoke()" method that calls
the top-level production.
There might be several signatures - invoke on File, on String, on
Stream, but the basic paradigm of
CharStream input = ANTLRxyzStream(whatever);
CommonTokenStream tokens = new CommonTokenStream(new
$grammarName$Lexer(input));
$grammarName$Parser parser = new $grammarName$Parser(tokens);
$methodName$_result result = parser.$methodName$();
is too much of a gimme not to be autogenerated. Of course, there's a
potential option or antlr grammar change there, to indicate the "main"
target. If not, then the first one in the file seems obvious.
=Austin
More information about the antlr-interest
mailing list