[antlr-interest] RE: Re: Re: yet another java 1.5 grammar
Michael Stahl
gcpa-antlr-interest at m.gmane.org
Tue Aug 31 08:21:35 PDT 2004
On Mon, 30 Aug 2004 11:39:38 +0100, Michael Studman wrote:
> Hi all.
>
> I've updated my Java 1.5 grammar hosted on ANTLR to address the issues
> Michael Stahl outlined in a previous email. In addition I fixed a few
> other bugs, did some refactoring of types to maximise reuse and
> integrated his excellent switchable enum/assert keyword checking.
cool! but it seems like you missed one...
in rule postfixExpression:
DOT "super" should be DOT typeArguments? "super"
(which will make some refactoring necessary there)
> Here are some problems I found with his grammar:
>
> * It does not allow annotations of form: @MyAnnotation() (it expects at
> least one parameter)
fixed.
> * It does not allow annotation array member initialisations with other
> annotations @MyAnno(something = { @MyOtherAnno() })
fixed.
> * It does not support annotation fields with C-style array syntax:
> @interface MyAnno
> {
> int name4()[]; //vs int[] name4();
> }
afaik this is correct, i.e. the above example is invalid.
see the draft of jls 3rd ed. that is in jsr14 public final draft
chapter 9 page 13 (page 271):
in production AnnotationTypeElementDeclaration, the only thing
that can follow the pair of parens is DefaultValue_opt.
> * There seems to be some weird incompatibility between the recogniser
> and the tree parser w.r.t. enum constant invocations (enum constant
> initialisers)
> e.g.
> public enum MyEnum
> {
> CONSTANT1(123);
> }
> seems to pass in the recognizer but fails in the tree parser.
ouch. when i first did the enums, i thought that is nothing but
a constructor invocation. then suddenly constructors grow type
parameters, and my neat hack falls to pieces...
fixed.
> * It is possibly too lenient with enum definitions: it allows enum
> constants to have static initialisers and constructors.
>
> * It's possibly too lenient with variable-length arguments: it allows
> them at any position in a variable list (mine only allows it at the end
> of a variable list) and it also allows it in variables defined within
> "for" and "catch" productions.
>
> * It accepts parameters that are declared final more than once.
>
> These last three points probably aren't major ones and would be checked
> elsewhere in a compiler etc but I thought I'd mention them as my test
> suite highlighted these as differences between the two grammars.
well, i think those are best handled at the semantic level, so
these are "wontfix".
> Regards,
> Michael Studman.
thanks,
michael stahl
PS: now how do i upload my fixed grammar? there is no "update grammar"
button that i can see... shold i just add it again and hope someone
removes the old one? or should i mail it to someone who can update?
: now how do i upload my fixed grammar? there is no "update grammar"
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list