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

Jose María Chumo Mata jmchuma at gmail.com
Wed Mar 17 04:47:56 PDT 2010


2010/3/15 Ketan Maheshwari <ketancmaheshwari at gmail.com>:
> Hello Jose
> Thanks for your reply.
> Yes, after putting the option output=AST, i got the result as you
> mentioned.
> But now i have another issue. The program never returns from the line where
> we create an instance of the parser :
> gscriptParser g = new gscriptParser(tokens,49100,null);
>
Is that a special constructor? I'm not really sure of what may be
happening. I'm using a constructor that only requireas a TokenStream.
Do you get any error? Do you use the lexer earlier in the code?
>
> Thanks for any inputs
> Ketan
> 2010/3/15 Jose María Chumo Mata <jmchuma at gmail.com>
>>
>> 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
>> >
>>
>> 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