Charj: allow multiple type definitions per file
authorAaron Becker <akbecker@gmail.com>
Sat, 29 May 2010 04:34:32 +0000 (23:34 -0500)
committerAaron Becker <akbecker@gmail.com>
Sat, 29 May 2010 04:34:32 +0000 (23:34 -0500)
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g

index e86cb200950f95dee7fa8c0f4f4e6b1ea287888d..8e5c93c0d2067c1f4c66aa4fb851afd16a758ede 100644 (file)
@@ -214,7 +214,7 @@ charjSource
 compilationUnit
     :   packageDeclaration? 
         importDeclaration* 
-        typeDeclaration
+        typeDeclaration*
     ;
 
 packageDeclaration
index 8f0101bd21d124fadef7d0d8583800c831187659..0f277a4201a6b52c13f9dc61ce54f769c7e7a6b1 100644 (file)
@@ -4,7 +4,7 @@ charjSource_ci(basename, pd, ids, tds, debug) ::=
 <<
 
 // interface for <basename>
-<tds>
+<tds; separator="\n\n">
 
 >>
 
@@ -22,7 +22,7 @@ charjSource_h(basename, pd, ids, tds, debug) ::=
  **************************************************************************/
 
 <ids>
-<tds>
+<tds; separator="\n\n">
 
 #endif // __<basename>__
 
@@ -34,7 +34,7 @@ charjSource_cc(basename, pd, ids, tds, debug) ::=
 #include "<basename>.h"
 
 <ids>
-<tds>
+<tds; separator="\n\n">
 
 >>
 
index 11eb4568f6f0e3b4f53f1dd8985999ad8c70abaf..d1fe39684a9d39c0b8ea21093bf4c82fbd7538a6 100644 (file)
@@ -48,7 +48,7 @@ charjSource[SymbolTable _symtab] returns [ClassSymbol cs]
     :   ^(CHARJ_SOURCE 
         (packageDeclaration)? 
         (importDeclarations) 
-        (typeDeclaration[$importDeclarations.packageNames]))
+        (typeDeclaration[$importDeclarations.packageNames])*)
         { $cs = $typeDeclaration.sym; }
     ;
 
@@ -65,6 +65,7 @@ typeDeclaration[List<CharjAST> imports] returns [ClassSymbol sym]
         {
             $TYPE.tree.addChild(puper.getPupRoutineNode());
             $TYPE.tree.addChild(puper.getInitRoutineNode());
+            puper = new PupRoutineCreator();
         }
     |   ^(INTERFACE IDENT (^('extends' type+))?  interfaceScopeDeclaration*)
     |   ^(ENUM IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
index c103c9ce1d3cf54f7c8352e425a1957253c80515..b6a342d5475d24f6d8bc945644bb7ace622e9c50 100644 (file)
@@ -85,10 +85,10 @@ charjSource[SymbolTable symtab, OutputMode m]
 }
     :   ^(CHARJ_SOURCE (p=packageDeclaration)? 
         (i+=importDeclaration)* 
-        (t=typeDeclaration))
-        -> {emitCC()}? charjSource_cc(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t.st}, debug={debug()})
-        -> {emitCI()}? charjSource_ci(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t.st}, debug={debug()})
-        -> {emitH()}? charjSource_h(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t.st}, debug={debug()})
+        (t+=typeDeclaration)*)
+        -> {emitCC()}? charjSource_cc(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t}, debug={debug()})
+        -> {emitCI()}? charjSource_ci(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t}, debug={debug()})
+        -> {emitH()}? charjSource_h(basename={basename()}, pd={$p.names}, ids={$i}, tds={$t}, debug={debug()})
         ->
     ;
 
@@ -185,7 +185,6 @@ classScopeDeclaration
 @init {
   boolean entry = false;
   List<String> modList = new ArrayList<String>();
-
 }
     :   ^(FUNCTION_METHOD_DECL m=modifierList? g=genericTypeParameterList? 
             ty=type IDENT f=formalParameterList a=arrayDeclaratorList? 
index 159d495b2fe55ff8ffd8edad03ab0b3f6e457b1b..079c9130f219092e39cf64bcd0d5caead6ebbc37 100644 (file)
@@ -86,7 +86,7 @@ scope ScopeStack; // default scope
     :   ^(CHARJ_SOURCE 
         (packageDeclaration)? 
         (importDeclarations) 
-        (typeDeclaration[$importDeclarations.packageNames]))
+        (typeDeclaration[$importDeclarations.packageNames])*)
         { $cs = $typeDeclaration.sym; }
     ;