[antlr-interest] I'm so stupid or there are inaccuracy in java tree parser grammar
Terence Parr
parrt at jguru.com
Tue Apr 29 07:53:34 PDT 2003
Ah. You are correct. Changing my version in the main line. Sorry
about that.
Terence
On Tuesday, April 29, 2003, at 12:57 AM, dk0879 wrote:
> Hi, implemented "tiny java" interpreter based on
> java grammar from ANTLR, and found out that "FOR_INIT"
> statement rule can't process code like this:
>
> for (int i = 0, j = 0; ... )
>
> because it expect zero or one "variableDef" node:
>
> stat:
> ...
> | #( "for"
> #(FOR_INIT (variableDef | elist)?) // <-- ?
> #(FOR_CONDITION (expression)?)
> #(FOR_ITERATOR (elist)?)
> stat
> )
> | ...
>
> when I modify it:
>
> stat:
> ...
> | #( "for"
> #(FOR_INIT ((variableDef)+ | elist)?) // <-- !
> #(FOR_CONDITION (expression)?)
> #(FOR_ITERATOR (elist)?)
> stat
> )
> | ...
>
> my parser began to work.
> Are the original java grammar is correct?
>
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Co-founder, http://www.peerscope.com link sharing, pure-n-simple
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list