private static void generateSleighExpression(Tree tree, StringBuilder sb) {
		switch (tree.getType()) {
			case SleighParser.BIN_INT:
			case SleighParser.DEC_INT:
			case SleighParser.HEX_INT:
			case SleighParser.IDENTIFIER:
				sb.append(tree.getText());
				break;

			case SleighParser.OP_BIN_CONSTANT:
			case SleighParser.OP_DEC_CONSTANT:
			case SleighParser.OP_HEX_CONSTANT:
			case SleighParser.OP_IDENTIFIER:
				generateSleighExpression(tree.getChild(0), sb);
				break;

			case SleighParser.OP_NOT:
				sb.append("!");
				generateSleighExpression(tree.getChild(0), sb);
				break;
			case SleighParser.OP_INVERT:
				sb.append("~");
				generateSleighExpression(tree.getChild(0), sb);
				break;
			case SleighParser.OP_NEGATE:
				sb.append("-");
				generateSleighExpression(tree.getChild(0), sb);
				break;
			case SleighParser.OP_FNEGATE:
				sb.append("f-");
				generateSleighExpression(tree.getChild(0), sb);
				break;

			case SleighParser.OP_ADD:
				catChildrenWithSep(tree, " + ", 0, 0, sb);
				break;
			case SleighParser.OP_SUB:
				catChildrenWithSep(tree, " - ", 0, 0, sb);
				break;
			case SleighParser.OP_MULT:
				catChildrenWithSep(tree, " * ", 0, 0, sb);
				break;
			case SleighParser.OP_DIV:
				catChildrenWithSep(tree, " / ", 0, 0, sb);
				break;
			case SleighParser.OP_REM:
				catChildrenWithSep(tree, " % ", 0, 0, sb);
				break;

			case SleighParser.OP_SDIV:
				catChildrenWithSep(tree, " s/ ", 0, 0, sb);
				break;
			case SleighParser.OP_SREM:
				catChildrenWithSep(tree, " s% ", 0, 0, sb);
				break;

			case SleighParser.OP_FADD:
				catChildrenWithSep(tree, " f+ ", 0, 0, sb);
				break;
			case SleighParser.OP_FSUB:
				catChildrenWithSep(tree, " f- ", 0, 0, sb);
				break;
			case SleighParser.OP_FMULT:
				catChildrenWithSep(tree, " f* ", 0, 0, sb);
				break;
			case SleighParser.OP_FDIV:
				catChildrenWithSep(tree, " f/ ", 0, 0, sb);
				break;

			case SleighParser.OP_LEFT:
				catChildrenWithSep(tree, " << ", 0, 0, sb);
				break;
			case SleighParser.OP_RIGHT:
				catChildrenWithSep(tree, " >> ", 0, 0, sb);
				break;
			case SleighParser.OP_SRIGHT:
				catChildrenWithSep(tree, " s>> ", 0, 0, sb);
				break;

			case SleighParser.OP_AND:
				catChildrenWithSep(tree, " & ", 0, 0, sb);
				break;
			case SleighParser.OP_OR:
				catChildrenWithSep(tree, " | ", 0, 0, sb);
				break;
			case SleighParser.OP_XOR:
				catChildrenWithSep(tree, " ^ ", 0, 0, sb);
				break;
			case SleighParser.OP_BOOL_AND:
				catChildrenWithSep(tree, " && ", 0, 0, sb);
				break;
			case SleighParser.OP_BOOL_OR:
				catChildrenWithSep(tree, " || ", 0, 0, sb);
				break;
			case SleighParser.OP_BOOL_XOR:
				catChildrenWithSep(tree, " ^^ ", 0, 0, sb);
				break;

			case SleighParser.OP_EQUAL:
				catChildrenWithSep(tree, " == ", 0, 0, sb);
				break;
			case SleighParser.OP_NOTEQUAL:
				catChildrenWithSep(tree, " != ", 0, 0, sb);
				break;
			case SleighParser.OP_FEQUAL:
				catChildrenWithSep(tree, " f== ", 0, 0, sb);
				break;
			case SleighParser.OP_FNOTEQUAL:
				catChildrenWithSep(tree, " f!= ", 0, 0, sb);
				break;

			case SleighParser.OP_LESS:
				catChildrenWithSep(tree, " < ", 0, 0, sb);
				break;
			case SleighParser.OP_LESSEQUAL:
				catChildrenWithSep(tree, " <= ", 0, 0, sb);
				break;
			case SleighParser.OP_GREATEQUAL:
				catChildrenWithSep(tree, " >= ", 0, 0, sb);
				break;
			case SleighParser.OP_GREAT:
				catChildrenWithSep(tree, " > ", 0, 0, sb);
				break;

			case SleighParser.OP_SLESS:
				catChildrenWithSep(tree, " s< ", 0, 0, sb);
				break;
			case SleighParser.OP_SLESSEQUAL:
				catChildrenWithSep(tree, " s<= ", 0, 0, sb);
				break;
			case SleighParser.OP_SGREATEQUAL:
				catChildrenWithSep(tree, " s>= ", 0, 0, sb);
				break;
			case SleighParser.OP_SGREAT:
				catChildrenWithSep(tree, " s> ", 0, 0, sb);
				break;

			case SleighParser.OP_FLESS:
				catChildrenWithSep(tree, " f< ", 0, 0, sb);
				break;
			case SleighParser.OP_FLESSEQUAL:
				catChildrenWithSep(tree, " f<= ", 0, 0, sb);
				break;
			case SleighParser.OP_FGREATEQUAL:
				catChildrenWithSep(tree, " f>= ", 0, 0, sb);
				break;
			case SleighParser.OP_FGREAT:
				catChildrenWithSep(tree, " f> ", 0, 0, sb);
				break;

			case SleighParser.OP_DEREFERENCE:
				if (tree.getChildCount() == 3) {
					sb.append("*[");
					generateSleighExpression(tree.getChild(0), sb);
					sb.append("]:");
					generateSleighExpression(tree.getChild(1), sb);
					sb.append(" ");
					generateSleighExpression(tree.getChild(2), sb);
				}
				else if (tree.getChildCount() == 2) {
					Tree child0 = tree.getChild(0);
					switch (child0.getType()) {
						case SleighParser.OP_IDENTIFIER:
							sb.append("*[");
							generateSleighExpression(child0, sb);
							sb.append("] ");
							generateSleighExpression(tree.getChild(1), sb);
							break;
						case SleighParser.OP_BIN_CONSTANT:
						case SleighParser.OP_DEC_CONSTANT:
						case SleighParser.OP_HEX_CONSTANT:
							sb.append("*:");
							generateSleighExpression(child0, sb);
							sb.append(" ");
							generateSleighExpression(tree.getChild(1), sb);
							break;
						default:
							throw new AssertionError(
								"OP_DEREFERENCE with 2 children where child[0] is " +
									SleighParser.tokenNames[child0.getType()]);
					}
				}
				else if (tree.getChildCount() == 1) {
					sb.append("*");
					generateSleighExpression(tree.getChild(0), sb);
				}
				else {
					throw new AssertionError(
						"OP_DEREFERENCE with " + tree.getChildCount() + " children");
				}
				break;
			case SleighParser.OP_ADDRESS_OF:
				if (tree.getChildCount() == 2) {
					sb.append("&");
					generateSleighExpression(tree.getChild(0), sb);
					sb.append(" ");
					generateSleighExpression(tree.getChild(1), sb);
				}
				else if (tree.getChildCount() == 1) {
					sb.append("&");
					generateSleighExpression(tree.getChild(0), sb);
				}
				else {
					throw new AssertionError(
						"OP_ADDRESS_OF with " + tree.getChildCount() + " children");
				}
				break;
			case SleighParser.OP_SIZING_SIZE:
				sb.append(":");
				generateSleighExpression(tree.getChild(0), sb);
				break;
			case SleighParser.OP_APPLY:
				generateSleighExpression(tree.getChild(0), sb);
				sb.append("(");
				catChildrenWithSep(tree, ", ", 1, 0, sb);
				sb.append(")");
				break;
			case SleighParser.OP_TRUNCATION_SIZE:
				generateSleighExpression(tree.getChild(0), sb);
				sb.append(":");
				generateSleighExpression(tree.getChild(1), sb);
				break;
			case SleighParser.OP_BITRANGE:
				generateSleighExpression(tree.getChild(0), sb);
				sb.append("[");
				generateSleighExpression(tree.getChild(1), sb);
				sb.append(",");
				generateSleighExpression(tree.getChild(2), sb);
				sb.append("]");
				break;
			case SleighParser.OP_BITRANGE2:
				generateSleighExpression(tree.getChild(0), sb);
				sb.append(":");
				generateSleighExpression(tree.getChild(1), sb);
				break;
			case SleighParser.OP_ARGUMENTS:
				catChildrenWithSep(tree, ", ", 0, 0, sb);
				break;
			case SleighParser.OP_PARENTHESIZED:
				sb.append("(");
				generateSleighExpression(tree.getChild(0), sb);
				sb.append(")");
				break;
			default:
				throw new AssertionError("type = " + SleighParser.tokenNames[tree.getType()]);
		}
	}
Synthesize a tree (node)

@param type the type of the node
@param text the "text" of the node
@param children the children
@return the new node
Ghidra/Framework/Emulation/src/main/java/ghidra/pcode/exec/SleighUtils.java