Class SyntaxPrinter

java.lang.Object
org.clafer.frontend.SyntaxPrinter

public final class SyntaxPrinter extends Object
Prints a syntax tree as the compiler's printTree prints its parse tree (PrintClafer, generated by BNFC): the same words, parentheses and line breaks. Two trees print the same text when they are the same tree, up to the spans, so the text is what the parser is compared on with the compiler's.

The output is not meant for reading: BNFC puts a line break after each brace and semicolon, and the layout of the source is gone.

  • Method Details

    • print

      public static String print(Syntax.Model model)
      Parameters:
      model - a syntax tree
      Returns:
      the text that printTree prints for the same tree
    • print

      public static String print(Syntax.Exp exp)
      Parameters:
      exp - an expression
      Returns:
      the text that printTree prints for it