Charj: better names for ast modification passes
authorAaron Becker <akbecker@gmail.com>
Tue, 19 Apr 2011 19:26:47 +0000 (14:26 -0500)
committerAaron Becker <akbecker@gmail.com>
Tue, 19 Apr 2011 19:26:47 +0000 (14:26 -0500)
src/langs/charj/src/charj/translator/CharjPostAnalysis.g
src/langs/charj/src/charj/translator/CharjPreAnalysis.g
src/langs/charj/src/charj/translator/Translator.java

index b8b85daf7594e00e679187d2a6e61bd8dde3cdb9..9df0030e50ad4e5b35834f25537ad43b833c5014 100644 (file)
@@ -2,7 +2,7 @@
  *  TODO add a description
  */
 
  *  TODO add a description
  */
 
-tree grammar CharjASTModifier2;
+tree grammar CharjPostAnalysis;
 
 options {
     backtrack = true; 
 
 options {
     backtrack = true; 
@@ -88,9 +88,9 @@ externDeclaration
 
 typeDeclaration returns [ClassSymbol sym]
     :   ^(TYPE classType IDENT { currentClass = (ClassSymbol) $IDENT.def.type; }
 
 typeDeclaration returns [ClassSymbol sym]
     :   ^(TYPE classType IDENT { currentClass = (ClassSymbol) $IDENT.def.type; }
-            (^('extends' parent=type))? (^('implements' type+))?
+            (^(EXTENDS parent=type))? (^('implements' type+))?
                 classScopeDeclaration*)
                 classScopeDeclaration*)
-    |   ^('interface' IDENT (^('extends' type+))?  interfaceScopeDeclaration*)
+    |   ^('interface' IDENT (^(EXTENDS type+))?  interfaceScopeDeclaration*)
     |   ^('enum' IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
     ;
 
     |   ^('enum' IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
     ;
 
@@ -520,10 +520,10 @@ primaryExpression returns [Type type]
                        $type = $ARRAY_ELEMENT_ACCESS.symbolType; // TODO this is not correct, as it's always null
                        if($pe.type instanceof ProxyType && $domainExpression.ranges.get(0).size() > 1)
                        {
                        $type = $ARRAY_ELEMENT_ACCESS.symbolType; // TODO this is not correct, as it's always null
                        if($pe.type instanceof ProxyType && $domainExpression.ranges.get(0).size() > 1)
                        {
-                               System.out.println("creating a new ArraySectionInitializer");
+                               //System.out.println("creating a new ArraySectionInitializer");
                                ArraySectionInitializer asi = new ArraySectionInitializer($domainExpression.ranges, ((ProxyType)$pe.type).baseType.getTypeName());
                                currentClass.sectionInitializers.add(asi);
                                ArraySectionInitializer asi = new ArraySectionInitializer($domainExpression.ranges, ((ProxyType)$pe.type).baseType.getTypeName());
                                currentClass.sectionInitializers.add(asi);
-                               System.out.println(asi);
+                               //System.out.println(asi);
                        }
                }
                        ->      { $pe.type instanceof ProxyType && $domainExpression.ranges.get(0).size() > 1 }? ^(METHOD_CALL IDENT["arraySectionInitializer" + (ArraySectionInitializer.getCount() - 1)] ^(ARGUMENT_LIST ^(EXPR primaryExpression)))
                        }
                }
                        ->      { $pe.type instanceof ProxyType && $domainExpression.ranges.get(0).size() > 1 }? ^(METHOD_CALL IDENT["arraySectionInitializer" + (ArraySectionInitializer.getCount() - 1)] ^(ARGUMENT_LIST ^(EXPR primaryExpression)))
index fcc78d3d9f0448974a4b55480aaf047133b28807..64725856aa2af47601a694451907ea944ea81dc9 100644 (file)
@@ -2,7 +2,7 @@
  *  fill a description in
  */
 
  *  fill a description in
  */
 
-tree grammar CharjASTModifier;
+tree grammar CharjPreAnalysis;
 
 options {
     backtrack = true; 
 
 options {
     backtrack = true; 
index f3bb3e364801a2d8bac9b03f4e1e998f27288d01..5a88fe045e79e2d3533a0bdc367f387774438d53 100644 (file)
@@ -103,9 +103,9 @@ public class Translator {
         m_nodes.setTreeAdaptor(m_adaptor);
 
         // do AST rewriting and semantic checking
         m_nodes.setTreeAdaptor(m_adaptor);
 
         // do AST rewriting and semantic checking
-        if (m_printAST) printAST("Before PreSemantics Pass", "before_presem.html");
-        preSemanticPass();
-        if (m_printAST) printAST("After PreSemantics Pass", "after_presem.html");
+        if (m_printAST) printAST("Before Preanalysis Pass", "before_preanalysis.html");
+        preAnalysisPass();
+        if (m_printAST) printAST("After Preanalysis Pass", "after_preanalysis.html");
 
         resolveTypes();
         if (m_printAST) printAST("After Type Resolution", "after_types.html");
 
         resolveTypes();
         if (m_printAST) printAST("After Type Resolution", "after_types.html");
@@ -113,8 +113,8 @@ public class Translator {
         initPupCollect();
         if (m_printAST) printAST("After Collector Pass", "after_collector.html");
 
         initPupCollect();
         if (m_printAST) printAST("After Collector Pass", "after_collector.html");
 
-        postSemanticPass();
-        if (m_printAST) printAST("After PostSemantics Pass", "after_postsem.html");
+        postAnalysisPass();
+        if (m_printAST) printAST("After Postanalysis Pass", "after_postanalysis.html");
 
                m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
 
                m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
@@ -142,25 +142,25 @@ public class Translator {
             ccHeader + ccOutput + footer;
     }
 
             ccHeader + ccOutput + footer;
     }
 
-    private void preSemanticPass() throws
+    private void preAnalysisPass() throws
         RecognitionException, IOException, InterruptedException
     {
         m_nodes.reset();
         RecognitionException, IOException, InterruptedException
     {
         m_nodes.reset();
-        CharjASTModifier mod = new CharjASTModifier(m_nodes);
-        mod.setTreeAdaptor(m_adaptor);
-        m_ast = (CommonTree)mod.charjSource().getTree();
+        CharjPreAnalysis pass = new CharjPreAnalysis(m_nodes);
+        pass.setTreeAdaptor(m_adaptor);
+        m_ast = (CommonTree)pass.charjSource().getTree();
         m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
         m_nodes.setTreeAdaptor(m_adaptor);
     }
 
         m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
         m_nodes.setTreeAdaptor(m_adaptor);
     }
 
-    private void postSemanticPass() throws
+    private void postAnalysisPass() throws
         RecognitionException, IOException, InterruptedException
     {
         m_nodes.reset();
         RecognitionException, IOException, InterruptedException
     {
         m_nodes.reset();
-        CharjASTModifier2 mod = new CharjASTModifier2(m_nodes);
-        mod.setTreeAdaptor(m_adaptor);
-        m_ast = (CommonTree)mod.charjSource(m_symtab).getTree();
+        CharjPostAnalysis pass = new CharjPostAnalysis(m_nodes);
+        pass.setTreeAdaptor(m_adaptor);
+        m_ast = (CommonTree)pass.charjSource(m_symtab).getTree();
         m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
         m_nodes.setTreeAdaptor(m_adaptor);
         m_nodes = new CommonTreeNodeStream(m_ast);
         m_nodes.setTokenStream(m_tokens);
         m_nodes.setTreeAdaptor(m_adaptor);