// Path: src/main/java/regexcompiler/RegexSubexpression.java
// public enum SubexpressionType {
// 	SYMBOL,
// 	ESCAPED_SYMBOL,
// 	CHARACTER_CLASS,
// 	GROUP,
// }
// 
// Path: src/main/java/regexcompiler/RegexToken.java
// public enum TokenType {
// 	SUBEXPRESSION,
// 	OPERATOR, 
// 	ANCHOR;
// }


import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import regexcompiler.RegexSubexpression.SubexpressionType;
import regexcompiler.RegexToken.TokenType;
	
	@Override
	public String toString() {
		StringBuilder treeStringBuilder = new StringBuilder();
		dfsTree(root, treeStringBuilder);
		return treeStringBuilder.toString();
	}
	
	private void dfsTree(TreeNode currentNode, StringBuilder sb) {
		
		if (!currentNode.getChildren().isEmpty()) {
			sb.append(currentNode);
			sb.append(getBracketType(currentNode, true));
			Iterator<TreeNode> childIterator = currentNode.getChildren().iterator();
			while (childIterator.hasNext()) {
				TreeNode child = childIterator.next();
				dfsTree(child, sb);
				if (childIterator.hasNext()) {
					sb.append(", ");
				}
				
			}
			sb.append(getBracketType(currentNode, false));
		} else {
			sb.append("'" + currentNode + "'");
		}
	}
	
	private String getBracketType(TreeNode node, boolean isOpen) {
		RegexToken token = node.getRegexToken();
// Path: src/main/java/regexcompiler/RegexSubexpression.java
// public enum SubexpressionType {
// 	SYMBOL,
// 	ESCAPED_SYMBOL,
// 	CHARACTER_CLASS,
// 	GROUP,
// }
// 
// Path: src/main/java/regexcompiler/RegexToken.java
// public enum TokenType {
// 	SUBEXPRESSION,
// 	OPERATOR, 
// 	ANCHOR;
// }


// Path: src/main/java/regexcompiler/ParseTree.java
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import regexcompiler.RegexSubexpression.SubexpressionType;
import regexcompiler.RegexToken.TokenType;

	
	@Override
	public String toString() {
		StringBuilder treeStringBuilder = new StringBuilder();
		dfsTree(root, treeStringBuilder);
		return treeStringBuilder.toString();
	}
	
	private void dfsTree(TreeNode currentNode, StringBuilder sb) {
		
		if (!currentNode.getChildren().isEmpty()) {
			sb.append(currentNode);
			sb.append(getBracketType(currentNode, true));
			Iterator<TreeNode> childIterator = currentNode.getChildren().iterator();
			while (childIterator.hasNext()) {
				TreeNode child = childIterator.next();
				dfsTree(child, sb);
				if (childIterator.hasNext()) {
					sb.append(", ");
				}
				
			}
			sb.append(getBracketType(currentNode, false));
		} else {
			sb.append("'" + currentNode + "'");
		}
	}
	
	private String getBracketType(TreeNode node, boolean isOpen) {
		RegexToken token = node.getRegexToken();
		if (token.getTokenType() == TokenType.OPERATOR) {