[kaffe] kjc compiler bug?

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


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

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

I made another patch that works without showing such warnings.

bash$ diff -u Kjc.g.orig Kjc.g
--- Kjc.g.orig	2002-07-16 03:53:32.000000000 +0900
+++ Kjc.g	2003-12-23 11:36:28.000000000 +0900
@@ -604,7 +604,7 @@
     ( ( "this" |  "super") LPAREN ) =>
     constructorCall = jExplicitConstructorInvocation[]
   |
-    (jPrimaryExpression[] DOT "super" LPAREN) =>
+    (jPrimaryExpression2[] DOT "super" LPAREN) =>
     constructorCall = jExplicitConstructorInvocation[]
   |
     // nothing
@@ -704,7 +704,7 @@
      ("super") => "super"
       { functorIsThis = false; }
   |
-    ( expr = jPrimaryExpression[] )? DOT "super"
+    ( expr = jPrimaryExpression2[] )? DOT "super"
       { functorIsThis = false; }
   )
   LPAREN args = jArgList[] RPAREN
@@ -1967,6 +1967,33 @@
     { self = new JClassExpression(buildTokenReference(), type, bounds); }
 ;
 
+// the basic element of an expression used for jExplicitConstructorInvocation[]
+// jExplicitConstructorInvocation[] needs ClassName.this.super(),
+// but including this rule in jPrimaryExpression[] may considerably worsen
+// the performance. So another jPrimaryExpression[] is here.
+jPrimaryExpression2 []
+  returns [JExpression self = null]
+{
+  TokenReference	sourceRef = buildTokenReference();
+}
+:
+  (IDENT (DOT IDENT)* DOT "this") =>
+  (
+    ident1 : IDENT
+      { self = new JNameExpression(sourceRef, ident1.getText()); }
+    (
+      DOT
+      ident2 : IDENT
+        { self = new JNameExpression(sourceRef, self, ident2.getText()); }
+    )*
+    DOT
+    "this"
+      { self = new JThisExpression(sourceRef, self); }
+  )
+|
+  self = jPrimaryExpression[]
+;
+
 jUnqualifiedNewExpression []
   returns [JExpression self = null]
 {
bash$ java at.dms.compiler.tools.antlr.compiler.Main Kjc.g
bash$