[antlr-interest] question concerning ANTLR java grammar (again)
Micheal J
open.zone at virgin.net
Sat Sep 10 05:21:42 PDT 2005
> Hi,
>
> I used the current java grammar
> (http://www.antlr.org/grammar/1109874324096/ja> va1.5.zip) and
> noticed that it accepts code that isn't
> allowed in Java.
>
> I show it on a small example:
>
> public class E {
> public static void main(String[] args) {
> java.lang.String;
> new ChildOfInner();
> }
> }
>
> The wrong thing on that is the expression: java.lang.String;
>
> Eclipse tells: "Syntax error. Insert "AssignmentOperator
> ArrayInitializer" to complete expression"
>
> Because Eclipse doesn't accept it, I suppose this isn't
> legal java code. But the ANTLR java grammar accepts it as an
> expression.
>
> Is this a bug?
No.
> If yes, is it already known?
Yes. The ANTLR grammar is a parser for the java language not a full java
front end (it lacks symbol tables, type-checking etc).
You can use it to build a full front end that will catch this kind of error
during it's type resolution/checking/binding phase.
Micheal
More information about the antlr-interest
mailing list