Class SyntaxTreePrinter

  • All Implemented Interfaces:
    TreePrinter

    public class SyntaxTreePrinter
    extends Object
    Printer used for generating human-readable representations of trees using an iterative approach. Each node of the subtree is represented as follows:
    
          optional_field_name: node_name [start_column:start_row] - [end_column:end_row]
     
    While indentation is used to represent the tree structure.
    Since:
    1.2.0
    Author:
    Ozren Dabić
    See Also:
    Syntax Tree Playground
    • Constructor Detail

      • SyntaxTreePrinter

        public SyntaxTreePrinter​(TreeCursor cursor)
    • Method Detail

      • print

        public String print()
        Generates a human-readable representation of the tree, starting from the node currently pointed to by the cursor.
        Returns:
        A human-readable print-out of the tree
      • export

        public File export()
                    throws IOException
        Description copied from interface: TreePrinter
        Generates a file containing the string representation of an Abstract Syntax Tree (AST). This method should be preferred over TreePrinter.print() when dealing with extremely wide, or deep trees.
        Returns:
        A file containing human-readable print-out of the tree
        Throws:
        IOException - if an I/O error occurs