Beispiel #1
0
 /**
  * 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("}");
 }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
0
 /**
  * Print out a program. In general, we expect a top-level program to be represented by a Block,
  * whose contents will be displayed here without the enclosing braces that might otherwise be
  * expected. We will also define an implementation of this method for arbitrary Stmt values too so
  * that it can be used for debugging and testing.
  */
 public void printProgram(TextOutput out) {
   printBlock(out, 0);
   out.println();
 }
Beispiel #4
0
 /**
  * Print this statement as the "ifFalse" branch of an if-then-else having just printed the "else"
  * keyword but no newline. Again, this allows us to override the behavior for Blocks.
  */
 public void printElse(TextOutput out, int n) {
   out.println();
   print(out, n + 1);
 }