Charj: Wrote the second part of the constructorHelper, actually generating the helper...
authorJonathan Lifflander <jliffl2@illinois.edu>
Thu, 24 Jun 2010 01:52:15 +0000 (20:52 -0500)
committerJonathan Lifflander <jliffl2@illinois.edu>
Thu, 24 Jun 2010 01:52:15 +0000 (20:52 -0500)
Replacing functionality that was in Java with ANTLR.

src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjEmitter.g

index e9d28d1f2be581a252749f93997e5baf2447cc58..c7ad835382a37472561099861525597a8225fbd8 100644 (file)
@@ -58,20 +58,33 @@ readonlyDeclaration
     :   ^(READONLY localVariableDeclaration)
     ;
 
+typeOfType returns [boolean array_type]
+    : CLASS 
+    | chareType 
+    | chareArrayType { $array_type = true; }
+    ;
+
 typeDeclaration
 @init {
     boolean array_type = false;
+    CharjAST chelperNode = new CharjAST(new CommonToken(CharjParser.IDENT, "constructorHelper"));
     astmod = new AstModifier();
 }
-    :   ^(TYPE (CLASS | (chareType | (chareArrayType { array_type = true; }))) IDENT
+    :   ^(TYPE typeOfType IDENT
         (^('extends' parent=type))? (^('implements' type+))? classScopeDeclaration*)
         {
-            $TYPE.tree.addChild(astmod.getPupRoutineNode());
-            $TYPE.tree.addChild(astmod.getInitRoutineNode());
-            $TYPE.tree.addChild(astmod.getCtorHelperNode());
-            astmod.ensureDefaultCtor($TYPE.tree);
-            if (array_type) astmod.ensureMigrationCtor($TYPE.tree);
+            array_type = $typeOfType.array_type;
+            //$TYPE.tree.addChild(astmod.getPupRoutineNode());
+            //$TYPE.tree.addChild(astmod.getInitRoutineNode());
+            //$TYPE.tree.addChild(astmod.getCtorHelperNode());
+            //astmod.ensureDefaultCtor($TYPE.tree);
+            //if (array_type) astmod.ensureMigrationCtor($TYPE.tree);
         }
+        -> ^(TYPE typeOfType IDENT
+            (^('extends' type))? (^('implements' type+))? classScopeDeclaration* 
+        ^(FUNCTION_METHOD_DECL 
+            ^(MODIFIER_LIST ^(ACCESS_MODIFIER_LIST PROTECTED) LOCAL_MODIFIER_LIST CHARJ_MODIFIER_LIST OTHER_MODIFIER_LIST)
+            VOID {chelperNode} FORMAL_PARAM_LIST BLOCK))
     |   ^(INTERFACE IDENT (^('extends' type+))?  interfaceScopeDeclaration*)
     |   ^(ENUM IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
     ;
index 529dcad3038c8f47c3060e81679772ff4c408db9..e63672cf5097279e9c763d51ed3e1a2faed5aebf 100644 (file)
@@ -489,7 +489,7 @@ type
         -> {$objectType.st}
     |   VOID
         {
-            $st = %{$start.getText()};
+            $st = %{"void"};
         }
     ;