[antlr-interest] Question on parsing the loop structure of java.tree.g

Terence Parr parrt at cs.usfca.edu
Mon Aug 18 16:11:44 PDT 2003


On Monday, August 18, 2003, at 01:53 PM, zhangcharles wrote:

> Hi, I'm using the current java.tree.g which seems not to parse the
> initialization condition of "for" loops correctly.My code looks like
> the following:
> for(int i=0,j=0;i<j+1;i++)
> {
>   //some action
> }
> The tree walker only walks the first variable "i".
> I changed the rule to
> #(FOR_INIT ((variableDef)* | elist)?)

I see my depot having:

     |   #(  "for"
             #(FOR_INIT ((variableDef)+ | elist)?)
             #(FOR_CONDITION (expression)?)
             #(FOR_ITERATOR (elist)?)
             stat
         )

like yours, but with (...)+.  I suspect that I fixed this after 2.7.2 
:) ;)

Thanks,
Terence

> The walk is correct but there is "none-determinism" warning with the
> antlr compilation.
> I'm just wondering if this is a bug or something I'm not aware of.
>
> Thanks a lot.
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list