/**
 *
 */
package ca.uwaterloo.joos.parser;

import java.util.List;

import ca.uwaterloo.joos.parser.LR1.ProductionRule;
import ca.uwaterloo.joos.scanner.Token;

/**
 * @author Greg Wang
 *
 */
public class ParseTree {

	public interface Node {
		public String toString(int level);
	}

	public static class TreeNode implements Node {
		public final ProductionRule productionRule;
		public final List<Node> children;

		public TreeNode(ProductionRule productionRule, List<Node> children) {
			this.productionRule = productionRule;
			this.children = children;
		}

		@Override
		public String toString() {
			return this.productionRule.toString();
		}

		public String toString(int level) {
			String str = "";
			for(int i = 0; i < level; i++) {
				str += "  ";
			}

			str += this.productionRule + "\n";
			for(Node node: this.children) str += node.toString(level + 1);
			return str;
		}
	}

	public static class LeafNode implements Node {
		public final Token token;

		public LeafNode(Token token) {
			this.token = token;
		}

		@Override
		public String toString() {
			return this.token.toString();
		}

		public String toString(int level) {
			String str = "";
			for(int i = 0; i < level; i++) {
				str += "  ";
			}

			str += this.token + "\n";
			return str;
		}
	}

	public final Node root;

	/**
	 *
	 */
	public ParseTree(Node root) {
		this.root = root;
	}

	@Override
	public String toString() {
		return "<ParseTree>\n" + this.root.toString(0);
	}
}

@@ -276,16 +276,43 @@
 level);%0A
+%09%09public String getKind();%0A
 %09%7D%0A%0A%09pub
@@ -904,32 +904,122 @@
 %09return str;%0A%09%09%7D
+%0A%0A%09%09@Override%0A%09%09public String getKind() %7B%0A%09%09%09return this.productionRule.getLefthand();%0A%09%09%7D
 %0A%09%7D%0A%0A%09public sta
@@ -1384,24 +1384,101 @@
 urn str;%0A%09%09%7D
+%0A%0A%09%09@Override%0A%09%09public String getKind() %7B%0A%09%09%09return this.token.getKind();%0A%09%09%7D
 %0A%09%7D%0A%0A%09public

Add getKind to Node