/** * Generate a pretty-printed description of this abstract syntax node using the concrete syntax of * the mini programming language. */ public void print(TextOutput out, int n) { out.indent(n); out.println("{"); this.printBlock(out, n + 1); out.indent(n); out.println("}"); }
/** * Print this statement as the "ifTrue" branch of an if-then-else having just printed the * parenthesized test, but no newline. This allows us to override the behaviour for Blocks to * match the desired output formatting. The elseStmt parameter specifies the corresponding else * statement that should also be printed. For current purposes, there are no if-then-else * statements that do not have an else branch. */ public void printThenElse(TextOutput out, int n, Stmt elseStmt) { out.println(" {"); printBlock(out, n + 1); out.indent(n); out.print("} else"); elseStmt.printElse(out, n); }