Re: [Java Spec Report] JSR 201 enhanced-for comments
Eric Blake <[email protected]> Wed, 18 Feb 2004 07:17:11 -0700
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Message-ID | <[email protected]> |
In trying to implement this, I found a HUGE problem - the proposed grammar is
not LALR(1). Remember how JSR 41 (assert statement) changed its grammar long
after the public draft closed, because the proposed grammar was not LALR(1)?
> /EnhancedForStatement:/
> for ( /FormalParameter/ : /Expression/ )
> /Statement/
When the parser sees "for (@A final int i", your proposal makes it impossible
to decide whether you are starting a FormalParameter or
LocalVariableDeclaration (as part of ForInitopt). You are going to have to
factor this statement out; I haven't yet had time to tackle the problem, but
if I can find a factorization that works, I will post it.
You also need to add:
EnhancedForStatementNoShortIf:
'for' '(' <whatever factorization works> ':' Expression ')'
StatementNoShortIf
And you should explicitly list:
Statement:
<all existing productions>
EnhancedForStatement
StatementNoShortIf:
<all existing productions>
EnhancedForStatementNoShortIf:
--
Someday, I might put a cute statement here.
Eric Blake [email protected]
To unsubscribe from this mailing list, send an email to:
[email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/java-spec-report/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/