[antlr-interest] using the generatred parser and lexer classes

Jose María Chumo Mata jmchuma at gmail.com
Mon Mar 15 03:37:25 PDT 2010


Hello there.

I've not been usign ANTLR for a long time so maybe I'm wrong but I
think you looked at the lexer. As far as I know, the parser rules
always return something. The return type for each method correspondig
to a rule in the parser is a inner class of the generated parser.
Let's say you declared the rule parserRule in the parser MyParser. The
get the result from parsing a file starting from that rule you do
something like this:
MyParser.parserRule_return result = parser.parserRule();

Hope this helps.
Regards

On Mon, Mar 15, 2010 at 09:47, Ketan Maheshwari
<ketancmaheshwari at gmail.com> wrote:
> Hello Friends
>
> While looking at the ways I can use the generated Lexer and Parser classes
> of my grammar I stumbled thru this page:
>
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=789
>
> It says that we can use the parser something like this:
>
> RuleReturnScope result = parser.compilationUnit();
>
> But, on my Parser class I do not see any method that really returns result
> of this type.
>
> All my methods for the grammar rules are simply void. panic!
>
> Am I missing anything here?
>
> Many thanks!
> Ketan
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list