[antlr-interest] Bug in java grammar 1.18 (again)

Terence Parr parrt at jguru.com
Thu Apr 25 17:53:33 PDT 2002


On Friday, January 25, 2002, at 10:04  AM, John P N Pybus wrote:
> On Friday 18 Jan 2002 9:54 am, you (Sander Mägi) wrote:
>> // (new Outer()).super()  (create enclosing instance) (SM: but does not
>> work for 'holder.outer.super();')
>>
>>     | primaryExpression DOT! "super"! lp3:LPAREN^
>>     | {#lp3.setType(SUPER_CTOR_CALL);#lp3.setText("super");} argList
>>     | RPAREN! SEMI!
>>
>> ...
>
> Indeed, it should be "postfixExpression DOT super", to allow multipart 
> outer
> expressions.  This runs into the problem that postfixExpression itself
> matches id.id.super().

According to the java spec it should be primaryExpression, but I may 
have a radically different version of primary than the book.

Anyway, excuse my ignorance, but what does holder.out.super() mean?  How 
can you call anything but your immediate super?  I can't think of what 
that would mean to say f.g.super().  Certainly the Java spec doesn't 
seem to think you can do it (well syntactically you can but semantically 
you cannot).  Here is from the 2nd edition spec:

Explicit constructor invocation statements can be divided into two kinds:

•  Alternate constructor invocations begin with the keyword this. They 
are used to invoke an alternate constructor of the same class.
•  Superclass constructor invocations begin with either the keyword 
super or a Primary expression. They are used to invoke a constructor of 
the direct superclass. Superclass constructor invocations may be further 
subdivided:
-  Unqualified superclass constructor invocations begin with the keyword 
super.
-  Qualified superclass constructor invocations begin with a Primary 
expression. They allow a subclass constructor to explicitly specify the 
newly created object's immediately enclosing instance with respect to 
the direct superclass (§8.1.2). This may be necessary when the 
superclass is an inner class.

So, it's either

"this(...)"
"super(...)"

or

"(new Outer()).super();"

Can somebody "unconfuse" me?  I've not become an expert on Java 
semantics...I'm just codin' in it.  I can't even contrive an example to 
test with the compiler.

Thanks,
Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list