类 ASTPrinter

  • 直接已知子类:
    ASTReferencedTablesPrinter

    public class ASTPrinter
    extends Object
    Utility for generating pretty "ASCII art" representations of syntax trees. This class is threadsafe: reuse instances as needed.
    作者:
    Joshua Davis, Steve Ebersole
    • 方法详细资料

      • showAsString

        public String showAsString​(antlr.collections.AST ast,
                                   String header)
        Renders the AST into 'ASCII art' form and returns that string representation.
        参数:
        ast - The AST to display.
        header - The header for the display.
        返回:
        The AST in 'ASCII art' form, as a string.
      • showAst

        public void showAst​(antlr.collections.AST ast,
                            PrintStream out)
        Prints the AST in 'ASCII art' form to the specified print stream.
        参数:
        ast - The AST to print.
        out - The print stream to which the AST should be printed.
      • showAst

        public void showAst​(antlr.collections.AST ast,
                            PrintWriter pw)
        Prints the AST in 'ASCII art' tree form to the specified print writer.
        参数:
        ast - The AST to print.
        pw - The print writer to which the AST should be written.
      • getTokenTypeName

        public String getTokenTypeName​(int type)
        Returns the token type name for the given token type.
        参数:
        type - The token type.
        返回:
        String - The token type name from the token type constant class, or just the integer as a string if none exists.
      • nodeToString

        public String nodeToString​(antlr.collections.AST ast)
      • propertyToString

        public String propertyToString​(String label,
                                       Object value,
                                       antlr.collections.AST ast)
      • appendEscapedMultibyteChars

        public static void appendEscapedMultibyteChars​(String text,
                                                       StringBuilder buf)
      • escapeMultibyteChars

        public static String escapeMultibyteChars​(String text)