@@ -0,0 +1,1329 @@
+/**%0A *%0A */%0Apackage ca.uwaterloo.joos.parser;%0A%0Aimport java.util.List;%0A%0Aimport ca.uwaterloo.joos.parser.LR1.ProductionRule;%0Aimport ca.uwaterloo.joos.scanner.Token;%0A%0A/**%0A * @author Greg Wang%0A *%0A */%0Apublic class ParseTree %7B%0A%0A%09public interface Node %7B%0A%09%09public String toString(int level);%0A%09%7D%0A%0A%09public static class TreeNode implements Node %7B%0A%09%09public final ProductionRule productionRule;%0A%09%09public final List%3CNode%3E children;%0A%0A%09%09public TreeNode(ProductionRule productionRule, List%3CNode%3E children) %7B%0A%09%09%09this.productionRule = productionRule;%0A%09%09%09this.children = children;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public String toString(int level) %7B%0A%09%09%09String str = %22%22;%0A%09%09%09for(int i = 0; i %3C level; i++) %7B%0A%09%09%09%09str += %22  %22;%0A%09%09%09%7D%0A%0A%09%09%09str += this.productionRule + %22%5Cn%22;%0A%09%09%09for(Node node: this.children) str += node.toString(level + 1);%0A%09%09%09return str;%0A%09%09%7D%0A%09%7D%0A%0A%09public static class LeafNode implements Node %7B%0A%09%09public final Token token;%0A%0A%09%09public LeafNode(Token token) %7B%0A%09%09%09this.token = token;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public String toString(int level) %7B%0A%09%09%09String str = %22%22;%0A%09%09%09for(int i = 0; i %3C level; i++) %7B%0A%09%09%09%09str += %22  %22;%0A%09%09%09%7D%0A%0A%09%09%09str += this.token + %22%5Cn%22;%0A%09%09%09return str;%0A%09%09%7D%0A%09%7D%0A%0A%09public final Node root;%0A%0A%09/**%0A%09 *%0A%09 */%0A%09public ParseTree(Node root) %7B%0A%09%09this.root = root;%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return %22%3CParseTree%3E%5Cn%22 + this.root.toString(0);%0A%09%7D%0A%7D%0A

Implement ParseTree aka ConcreteSyntaxTree