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​(@NotNull
                                 @NotNull TreeCursor cursor)
    • Method Detail

      • print

        public final String print()
        Generates a string representation of the Abstract Syntax Tree (AST), starting from the node currently pointed to by the cursor.
        Specified by:
        print in interface TreePrinter
        Returns:
        A string representation of the tree
      • export

        public final File export()
                          throws IOException
        Generates a string representation of the Abstract Syntax Tree (AST), starting from the node currently pointed to by the cursor, while writing outputs directly to a file.
        Specified by:
        export in interface TreePrinter
        Returns:
        A file containing the string of the tree
        Throws:
        IOException - if an I/O error occurs