Permalink
Browse files

remove obsolete complexity

  • Loading branch information...
1 parent 0895485 commit 1127f376d08f382e265f36cff9063d60cc798efd @gavinking gavinking committed May 25, 2012
Showing with 61 additions and 311 deletions.
  1. +47 −162 Ceylon.nodes
  2. +0 −133 treegen/Buildergen.g
  3. +4 −4 treegen/Treegen.g
  4. +4 −6 treegen/Validatorgen.g
  5. +2 −2 treegen/Visitorgen.g
  6. +4 −4 treegen/Walkergen.g
View
View
@@ -1,133 +0,0 @@
-grammar Buildergen;
-
-@parser::header {
- package com.redhat.ceylon.compiler.typechecker.treegen;
- import static com.redhat.ceylon.compiler.typechecker.treegen.Util.*;
-}
-@lexer::header {
- package com.redhat.ceylon.compiler.typechecker.treegen;
-}
-
-nodeList :
- {
- println("package com.redhat.ceylon.compiler.typechecker.tree;\n");
- println("import static com.redhat.ceylon.compiler.typechecker.tree.Tree.*;\n");
- println("import static com.redhat.ceylon.compiler.typechecker.parser.CeylonParser.*;\n");
- println("import org.antlr.runtime.tree.CommonTree;\n");
- println("import java.util.*;\n");
- println("public class Builder {\n");
- }
- (DESCRIPTION? node)+
- EOF
- { println("}"); }
- ;
-
-node : '^' '('
- ( 'abstract' n=NODE_NAME
- { println(" public void build" + className($n.text) + "(CommonTree treeNode, " + className($n.text) + " node) {"); }
- | n=NODE_NAME
- { println(" public " + className($n.text) + " build" + className($n.text) +"(CommonTree treeNode) {"); }
- { println(" " + className($n.text) + " node = new " + className($n.text) + "(treeNode);"); }
- { println(" build" + className($n.text) + "(treeNode, node);"); }
- { println(" return node;"); }
- { println(" }\n"); }
- { println(" public void build" + className($n.text) + "(CommonTree treeNode, " + className($n.text) + " node) {"); }
- )
- extendsNode?
- (
- { println(" @SuppressWarnings(\"unchecked\")"); }
- { println(" List<CommonTree> children = (List<CommonTree>) treeNode.getChildren();"); }
- { println(" if (children!=null) for (CommonTree childTreeNode: children) {"); }
- (DESCRIPTION? subnode)+
- { println(" }"); }
- )?
- (DESCRIPTION? field)*
- ')'
- { println(" }\n"); }
- ;
-
-extendsNode : ':' n=NODE_NAME
- { println(" build" + className($n.text) + "(treeNode, node);"); }
- ;
-
-subnode : n=NODE_NAME '?'? f=FIELD_NAME
- { println(" if (childTreeNode.getType()==" + $n.text + " && node.get" + initialUpper($f.text) + "()==null) {"); }
- { println(" node.set" + initialUpper($f.text) + "(build" + className($n.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- | n=NODE_NAME '?'? g=FIELD_NAME
- { println(" if (node.get" + initialUpper($g.text) + "()==null) {"); }
- '(' (
- s=NODE_NAME
- { println(" if (childTreeNode.getType()==" + $s.text + ") {"); }
- { println(" node.set" + initialUpper($g.text) + "(build" + className($s.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- )+ ')'
- { println(" }"); }
- | n=NODE_NAME '?'?
- { println(" if (childTreeNode.getType()==" + $n.text + " && node.get" + className($n.text) + "()==null) {"); }
- { println(" node.set" + className($n.text) + "(build" + className($n.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- | n=NODE_NAME '?'?
- { println(" if (node.get" + className($n.text) + "()==null) {"); }
- '(' (
- s=NODE_NAME
- { println(" if (childTreeNode.getType()==" + $s.text + ") {"); }
- { println(" node.set" + className($n.text) + "(build" + className($s.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- )+ ')'
- { println(" }"); }
- | mn=NODE_NAME '*'
- { println(" if (childTreeNode.getType()==" + $mn.text + ") {"); }
- { println(" node.add" + className($mn.text) + "(build" + className($mn.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- | mn=NODE_NAME '*' f=FIELD_NAME
- { println(" if (childTreeNode.getType()==" + $mn.text + ") {"); }
- { println(" node.add" + initialUpper($f.text) + "(build" + className($mn.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- | mn=NODE_NAME '*'
- '(' (
- s=NODE_NAME
- { println(" if (childTreeNode.getType()==" + $s.text + ") {"); }
- { println(" node.add" + className($mn.text) + "(build" + className($s.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- )+ ')'
- | mn=NODE_NAME '*' f=FIELD_NAME
- '(' (
- s=NODE_NAME
- { println(" if (childTreeNode.getType()==" + $s.text + ") {"); }
- { println(" node.add" + initialUpper($f.text) + "(build" + className($s.text) + "(childTreeNode));"); }
- { println(" continue;"); }
- { println(" }"); }
- )+ ')'
- ;
-
-field : 'abstract'? (TYPE_NAME|'boolean') FIELD_NAME ';'
- ;
-
-NODE_NAME : ('A'..'Z'|'_')+;
-
-FIELD_NAME : ('a'..'z') ('a'..'z'|'A'..'Z')*;
-TYPE_NAME : ('A'..'Z') ('a'..'z'|'A'..'Z'|'<'|'>')*;
-
-WS : (' ' | '\n' | '\t' | '\r' | '\u000C') { skip(); };
-
-CARAT : '^';
-
-LPAREN : '(';
-RPAREN : ')';
-
-MANY : '*'|'+';
-OPTIONAL : '?';
-
-EXTENDS : ':';
-
-SEMI : ';';
-
-DESCRIPTION : '\"' (~'\"')* '\"';
View
@@ -62,20 +62,20 @@ memberDescription : d=DESCRIPTION
;
subnode :
- n=NODE_NAME '?'? f=FIELD_NAME ('(' NODE_NAME* ')')?
+ n=NODE_NAME '?'? f=FIELD_NAME
{ println(" private " + className($n.text) + " " + $f.text + ";"); }
{ println(" public " + className($n.text) + " get" + initialUpper($f.text) + "() { return " + $f.text + "; }"); }
{ println(" public void set" + initialUpper($f.text) + "(" + className($n.text) + " node) { " + $f.text + " = node; connect(node); }\n"); }
- | n=NODE_NAME '?'? ('(' NODE_NAME* ')')?
+ | n=NODE_NAME '?'?
{ println(" private " + className($n.text) + " " + fieldName($n.text) + ";"); }
{ println(" public " + className($n.text) + " get" + className($n.text) + "() { return " + fieldName($n.text) + "; }"); }
{ println(" public void set" + className($n.text) + "(" + className($n.text) + " node) { " + fieldName($n.text) + " = node; connect(node); }\n"); }
- | mn=NODE_NAME '*' ('(' NODE_NAME* ')')?
+ | mn=NODE_NAME '*'
{ println(" private List<" + className($mn.text) + "> " + fieldName($mn.text) +
"s = new ArrayList<" + className($mn.text) + ">();"); }
{ println(" public List<" + className($mn.text) + "> get" + className($mn.text) + "s() { return " + fieldName($mn.text) + "s; }"); }
{ println(" public void add" + className($mn.text) + "(" + className($mn.text) + " node) { " + fieldName($mn.text) + "s.add(node); connect(node); }\n"); }
- | mn=NODE_NAME '*' f=FIELD_NAME ('(' NODE_NAME* ')')?
+ | mn=NODE_NAME '*' f=FIELD_NAME
{ println(" private List<" + className($mn.text) + "> " + $f.text +
"s = new ArrayList<" + className($mn.text) + ">();"); }
{ println(" public List<" + className($mn.text) + "> get" + initialUpper($f.text) + "s() { return " + $f.text + "s; }"); }
@@ -28,16 +28,14 @@ node : '^' '('
')'
;
-subnode : n=NODE_NAME f=FIELD_NAME ('(' NODE_NAME* ')')?
+subnode : n=NODE_NAME f=FIELD_NAME
{ println(" if (that.get" + initialUpper($f.text) + "()==null)"); }
{ println(" that.addError(\"missing tokens\");"); }
- | n=NODE_NAME ('(' NODE_NAME* ')')?
+ | n=NODE_NAME
{ println(" if (that.get" + className($n.text) + "()==null)"); }
{ println(" that.addError(\"missing " + description($n.text) + "\");"); }
- | n=NODE_NAME '?' f=FIELD_NAME ('(' NODE_NAME* ')')?
- | n=NODE_NAME '?' ('(' NODE_NAME* ')')?
- | mn=NODE_NAME '*' ('(' NODE_NAME* ')')?
- | mn=NODE_NAME '*' f=FIELD_NAME ('(' NODE_NAME* ')')?
+ | NODE_NAME '?' FIELD_NAME?
+ | NODE_NAME '*' FIELD_NAME?
;
field : 'abstract'? (TYPE_NAME|'boolean') FIELD_NAME ';'
@@ -32,8 +32,8 @@ node : '^' '('
')'
;
-subnode : n=NODE_NAME '?'? f=FIELD_NAME? ('(' NODE_NAME* ')')?
- | mn=NODE_NAME '*' f=FIELD_NAME? ('(' NODE_NAME* ')')?
+subnode : n=NODE_NAME '?'? f=FIELD_NAME?
+ | mn=NODE_NAME '*' f=FIELD_NAME?
;
field : 'abstract'? (TYPE_NAME|'boolean') FIELD_NAME ';';
View
@@ -34,16 +34,16 @@ extendsNode : ':'
{ println(" walk" + className($n.text) +"(visitor, node);"); }
;
-subnode : n=NODE_NAME '?'? f=FIELD_NAME ('(' NODE_NAME* ')')?
+subnode : n=NODE_NAME '?'? f=FIELD_NAME
{ println(" if (node.get" + initialUpper($f.text) + "()!=null)"); }
{ println(" node.get" + initialUpper($f.text) + "().visit(visitor);"); }
- | n=NODE_NAME '?'? ('(' NODE_NAME* ')')?
+ | n=NODE_NAME '?'?
{ println(" if (node.get" + className($n.text) + "()!=null)"); }
{ println(" node.get" + className($n.text) + "().visit(visitor);"); }
- | mn=NODE_NAME '*' ('(' NODE_NAME* ')')?
+ | mn=NODE_NAME '*'
{ println(" for (" + className($mn.text) + " subnode: node.get" + className($mn.text) +"s())"); }
{ println(" subnode.visit(visitor);"); }
- | mn=NODE_NAME '*' f=FIELD_NAME ('(' NODE_NAME* ')')?
+ | mn=NODE_NAME '*' f=FIELD_NAME
{ println(" for (" + className($mn.text) + " subnode: node.get" + initialUpper($f.text) +"s())"); }
{ println(" subnode.visit(visitor);"); }
;

0 comments on commit 1127f37

Please sign in to comment.