Class TreeFormatterGenerator


  • public class TreeFormatterGenerator
    extends java.lang.Object
    Class TreeFormatterGenerator generates the TreeFormatter visitor which is a skeleton pretty-printer.
    Using some pre-defined methods, users can quickly and easily create a formatter for their grammar.
    The formatter will then take a tree, insert token location information into the Tokens of the tree.
    TreeDumper can then be used to output the result.
    Note that unlike the other automatically generated file, since this one must be edited to be useful, JTB will not overwrite this file automatically.
    JTB will take this precaution for the other files only if the "-w" command-line parameter is used. CODEJAVA

    This visitor is supposed to be run once and not supposed to be run in parallel threads (on the same grammar).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String outFilename
      The visitor source file name
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void generateTreeFormatter()
      Generates the tree formatter visitor source in its file.
      int saveToFile()
      Saves the current buffer in the output file (global variable).
      Since the user is expected to edit and customize this file, this method will never overwrite the file if it exists, regardless of the global no overwrite flag.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outFilename

        public static final java.lang.String outFilename
        The visitor source file name
        See Also:
        Constant Field Values
    • Constructor Detail

      • TreeFormatterGenerator

        public TreeFormatterGenerator​(JTBOptions aJopt,
                                      CommonCodeGenerator aCcg,
                                      Messages aMess,
                                      java.util.List<UserClassInfo> classes)
        Constructor with a given list of classes. Will create the visitors directory if it does not exist.
        Parameters:
        aJopt - - the JTB options
        aCcg - - the CommonCodeGenerator
        classes - - the list of classes
        aMess - - the messages handler
    • Method Detail

      • saveToFile

        public int saveToFile()
                       throws java.io.IOException
        Saves the current buffer in the output file (global variable).
        Since the user is expected to edit and customize this file, this method will never overwrite the file if it exists, regardless of the global no overwrite flag.
        Returns:
        OK_RC or FILE_EXISTS_RC
        Throws:
        java.io.IOException - if IO problem
      • generateTreeFormatter

        public void generateTreeFormatter()
        Generates the tree formatter visitor source in its file.