[antlr-interest] ENHANCEMENT: Add invoke(...) method(s) on parser

Terence Parr parrt at cs.usfca.edu
Wed Oct 24 16:55:58 PDT 2007


Agreed. Adding to list.

It is pretty annoying have to retype that all the time.  Thanks for  
the template ;)

http://www.antlr.org:8888/browse/ANTLR-187

I should be back to ST and ANTLR mode upon my return from china.

Ter

On Oct 25, 2007, at 2:37 AM, Austin Hastings wrote:

> 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