
public class ConsNode extends Node {
	private Object head;
	private ConsNode rest;
	private boolean blockOutput = false;

	public ConsNode(Object head, ConsNode rest) {
		this.setHead(head);
		this.setRest(rest);
	}

	public ConsNode(Object head, ConsNode rest, boolean blockOutput) {
		this(head, rest);
		this.blockOutput = blockOutput;
	}

	public void setHead(Object head) {
		this.head = head;
	}

	public Object getHead() {
		return head;
	}

	public void setRest(ConsNode rest) {
		this.rest = rest;
	}

	public ConsNode getRest() {
		return rest;
	}

	@Override
	public String toIndentedString(int surroundingIndentation) {
		ConsNode node = this;
		StringBuffer buffer = new StringBuffer();
		if(blockOutput) {
			while(node != null) {
				if(!(node.head instanceof StatementNode)) {
					buffer.append(Node.newline(surroundingIndentation + 1));
				}
				buffer.append(Node.toIndentedString(node.head, surroundingIndentation + 1));
				if(!(node.head instanceof StatementNode)) {
					buffer.append(';');
				}
				node = node.getRest();
			}
		} else {
			while(node != null) {
				buffer.append(Node.toIndentedString(node.head, surroundingIndentation + 1));
				node = node.getRest();
				if(node != null)
					buffer.append(", ");
			}
		}
		return buffer.toString();
	}

	public void setBlockOutput(boolean blockOutput) {
		this.blockOutput = blockOutput;
	}

	public boolean isBlockOutput() {
		return blockOutput;
	}
}
