package edu.asu.plp.compile.parser.tree;

import java.util.List;

public interface ParseNode
{
	/**
	 * @return The type of this node
	 */
	NodeType getType();
	
	/**
	 * Some data will require a value expression (for instance a variable reference, or a
	 * primitive value). Other data will not. In the latter case, an empty String will be
	 * returned.
	 * 
	 * @return The value held by this node, or an empty String if no value is present
	 */
	String getValue();
	
	/**
	 * @return The children of this node, ordered from left to right, or an empty list if
	 *         no children are present
	 */
	List<ParseNode> getChildren();
}

@@ -59,16 +59,72 @@
 .List;%0A%0A
+import org.json.JSONArray;%0Aimport org.json.JSONObject;%0A%0A
 public i
@@ -684,10 +684,343 @@
 dren();%0A
+%09%0A%09default JSONObject toJSON()%0A%09%7B%0A%09%09JSONObject object = new JSONObject();%0A%09%09object.append(%22type%22, getType().name());%0A%09%09object.append(%22value%22, getValue());%0A%09%09%0A%09%09JSONArray children = new JSONArray();%0A%09%09for (ParseNode child : getChildren())%0A%09%09%09children.put(child.toJSON());%0A%09%09%0A%09%09object.append(%22children%22, children);%0A%09%09return object;%0A%09%7D%0A
 %7D%0A

Add JSON conversion