Loading ...
Sorry, an error occurred while loading the content.
 

Question on parsing the loop structure of java.tree.g

Expand Messages
  • zhangcharles
    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
    Message 1 of 2 , Aug 18, 2003
      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)?)
      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.
    • Terence Parr
      ... #(FOR_INIT ((variableDef)+ | elist)?) #(FOR_CONDITION (expression)?) #(FOR_ITERATOR (elist)?) stat ) like yours, but with (...)+. I suspect that I fixed
      Message 2 of 2 , Aug 18, 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 message has been successfully submitted and would be delivered to recipients shortly.