package ca.uwaterloo.joos.ast.expr.name;

import ca.uwaterloo.joos.ast.ASTNode;
import ca.uwaterloo.joos.ast.expr.Expression;
import ca.uwaterloo.joos.ast.expr.Lefthand;
import ca.uwaterloo.joos.parser.ParseTree.Node;

public abstract class Name extends Expression implements Lefthand {

	public Name(Node node, ASTNode parent) throws Exception {
		super(node, parent);
		this.setIdentifier(this.getName());
	}

	public abstract String getName() throws Exception;

}

@@ -35,16 +35,124 @@
 .name;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport ca.uwaterloo.joos.ast.AST.ASTConstructException;%0A
 import c
@@ -313,21 +313,237 @@
 rseTree.
+Leaf
 Node;
+%0Aimport ca.uwaterloo.joos.parser.ParseTree.Node;%0Aimport ca.uwaterloo.joos.parser.ParseTree.TreeNode;%0Aimport ca.uwaterloo.joos.parser.ParseTreeTraverse;%0Aimport ca.uwaterloo.joos.parser.ParseTreeTraverse.Traverser;
 %0A%0Apublic
@@ -782,10 +782,1103 @@
 ption;%0A%0A
+%09private static class NameTraverser implements Traverser %7B%0A%09%09public Name node;%0A%09%09private ASTNode parent;%0A%0A%09%09public NameTraverser(ASTNode parent) %7B%0A%09%09%09this.parent = parent;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public List%3CNode%3E processTreeNode(TreeNode treeNode) throws Exception %7B%0A%09%09%09String kind = treeNode.productionRule.getLefthand();%0A%09%09%09if (kind.equals(%22simplename%22)) %7B%0A%09%09%09%09node = new SimpleName(treeNode, parent);%0A%09%09%09%7D else if (kind.equals(%22qualifiedname%22)) %7B%0A%09%09%09%09node = new QualifiedName(treeNode, parent);%0A%09%09%09%7D else %7B%0A%09%09%09%09List%3CNode%3E offers = new ArrayList%3CNode%3E();%0A%09%09%09%09offers.addAll(treeNode.children);%0A%09%09%09%09return offers;%0A%09%09%09%7D%0A%09%09%09return null;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void processLeafNode(LeafNode leafNode) throws Exception %7B%0A%0A%09%09%7D%0A%09%7D%0A%0A%09public static Name newName(Node node, ASTNode parent) throws Exception %7B%0A%0A%09%09NameTraverser traverser = new NameTraverser(parent);%0A%09%09ParseTreeTraverse traverse = new ParseTreeTraverse(traverser);%0A%09%09traverse.traverse(node);%0A%0A%09%09if (traverser.node == null) %7B%0A%09%09%09throw new ASTConstructException(node + %22 is not / does not contain a name%22);%0A%09%09%7D%0A%0A%09%09return traverser.node;%0A%09%7D%0A
 %7D%0A

Add static method newName to Name