[antlr-interest] help: scanning multiple lines of input

atif azad atif.azad at hotmail.com
Thu Sep 13 01:33:01 PDT 2007


Thanks a lot . I solved it. The problem was with one other rule in my 
grammer. The type rule.

So Main claass was ok and also this rule.
Thankyou again


>From: "atif azad" <atif.azad at hotmail.com>
>To: antlr at mirality.co.nz
>CC: antlr-interest at antlr.org
>Subject: Re: [antlr-interest] help: scanning multiple lines of input
>Date: Thu, 13 Sep 2007 13:25:05 +0500
>
>
>Thankyou very much for the replies.
>I am using decl+ as shown below. But in my tree grammer this is what i have 
>in my grammer.May be I am not printing the nodes in the right way in the 
>tree grammer.
>I copy it
>
>start : decl+ ;
>decl : ^(DECL type declarator+ )
>        {System.out.println("text "+$declarator.text);}
>       {System.out.println("type "+$type.text);}
>      |^(DECL type d1=declarator d2=declarator )
>             {System.out.println("text "+$d1.text);}
>   {System.out.println("text "+$d2.text);}
>       {System.out.println("type "+$type.text);}
>     ;
>
>which corresponds to these rule in grammer
>
>start : decl+ ;
>decl : (type ID) ';' -> ^(DECL type ID)
>       | (type ID ID)';' -> ^(DECL type ID ID)
>
>
>I may be doing some thing wrong while printing the nodes in my tree 
>garmmer.
>
>
>Regards
>Azad , Atif
>
>
>
>
>>From: Gavin Lambert <antlr at mirality.co.nz>
>>To: "atif azad" <atif.azad at hotmail.com>,antlr-interest at antlr.org
>>Subject: Re: [antlr-interest] help: scanning multiple lines of input
>>Date: Thu, 13 Sep 2007 19:36:56 +1200
>>
>>At 17:19 13/09/2007, atif azad wrote:
>> >and output i get is like this
>> >
>> >tree: (DECL add r2) (DECL store r2 r2)
>> >text r2
>> >type add
>> >
>> >But I want output like this
>> >
>> >tree: (DECL add r2) (DECL store r2 r2)
>> >text r2
>> >type add
>> >text r2 r2
>> >type store
>>[...]
>> >		langDumpDecl walker = new langDumpDecl(nodes);
>> >		walker.decl();
>>
>>Assuming that the "decl" rule matches one DECL-rooted tree, the problem 
>>would be that you're only calling it once, and hence only recognising one 
>>DECL tree.
>>
>>Either call it in a loop or just create a new rule containing decl* or 
>>decl+ and call that in your Main instead (depending on what you want to do 
>>with it).
>>
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today it's FREE! 
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/



More information about the antlr-interest mailing list