[kaffe] kjc compiler bug?

Ito Kazumitsu ito.kazumitsu@hitachi-cable.co.jp
Mon Dec 22 04:46:02 2003


In message "Re: [kaffe] kjc compiler bug?"
    on 03/12/20, Ito Kazumitsu <ito.kazumitsu@hitachi-cable.co.jp> writes:

> I am far from familiar with the grammar of kjc/Kjc.g,  but I am
> afraid the pattern "ClassName.this" cannot be treated as an
> primary expression (jPrimaryExpression in Kjc.g), so
> the pattern "ClassName.this.super()" cannot be treated as
> an explicit constructor invocation (jExplicitConstructorInvocation
> in Kjc.g).  As a result, "ClassName.this.super()" is treated
> as an method invocation expression.

> I hope a Kjc.g hacker may fix this bug.

I made a would-be Kjc.g hacker of myself and played with Kjc.g.

bash$ diff -u Kjc.g.orig Kjc.g
--- Kjc.g.orig	2002-07-16 03:53:32.000000000 +0900
+++ Kjc.g	2003-12-22 21:43:10.000000000 +0900
@@ -1925,6 +1925,16 @@
 :
   ident : IDENT
     { self = new JNameExpression(sourceRef, ident.getText()); }
+  (
+    DOT
+    ident1 : IDENT
+      { self = new JNameExpression(sourceRef, self, ident1.getText()); }
+  )*
+  (
+    DOT
+    "this"
+      { self = new JThisExpression(sourceRef, self); }
+  )?
 |
   self = jUnqualifiedNewExpression[]
 |
bash$ java at.dms.compiler.tools.antlr.compiler.Main Kjc.g
Kjc.g:1928: warning: nondeterminism upon
Kjc.g:1928: 	k==1:DOT
Kjc.g:1928: 	k==2:IDENT
Kjc.g:1928: 	between alt 1 and exit branch of block
Kjc.g:1933: warning: nondeterminism upon
Kjc.g:1933: 	k==1:DOT
Kjc.g:1933: 	k==2:"this"
Kjc.g:1933: 	between alts 1 and 2 of block

In spite of these warnings,  the newly generated KjcParser.java
seems to work fine and the new kjc can compile Matthias's test case.