[867] in java-interest
Language spec syntax ambiguities
daemon@ATHENA.MIT.EDU (Scott Hudson)
Sat Aug 12 01:17:20 1995
From: "Scott Hudson" <hudson@cs.arizona.edu>
To: java-interest@java.sun.com
Date: Fri, 11 Aug 1995 16:36:40 -0700 (MST)
*** This is a repost due to apparent network failure.
*** Apologies if you get this twice.
*** Note: this is not my normal email address (but it does forward to me).
The grammar in the java language spec includes the following productions:
Expression =
Expression `=' Expression
| Expression `+=' Expression
| Expression `-=' Expression
| Expression `*=' Expression
| Expression `/=' Expression
| Expression `%=' Expression
| Expression `^=' Expression
| Expression `&=' Expression
| Expression `|=' Expression
| Expression `<<=' Expression
| Expression `>>=' Expression
| Expression `>>>=' Expression
I don't believe this is right (and its not what javac does). In
particular, they allow a bunch of things that can't be right such as:
"2+2 = 5", as well as some things which seem at least possibly right
(they would be fine in ANSI C!), but which javac does not like such
as: "(a) = 5" and "(a.b[5].c) = 5".
Clearly the left hand side of an assignment should be a more restricted
syntactic class than the right side, but *exactly* what is that class?
We also have another production with a similar problem:
Expression = Expression `(' ArgList? `)'
Again, this is clearly wrong because you can't say "2+2()" and a more
limited syntactic class for the function designator is surely required.
However, its not obvious what that class should be. In particular, javac
does not like "(f)(5)" and "(a.f)(5)" which seem a bit odd, but perfectly
reasonable (and are again fine in ANSI C).
Can we get a "ruling" on the exact syntax?
Thanks,
Scott
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com