Class TreeFormatterGenerator

java.lang.Object
EDU.purdue.jtb.generate.TreeFormatterGenerator

public class TreeFormatterGenerator extends 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 Details

  • Constructor Details

    • TreeFormatterGenerator

      public TreeFormatterGenerator(JTBOptions aJopt, CommonCodeGenerator aCcg, Messages aMess, 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
      aMess - - the messages handler
      classes - - the list of classes
  • Method Details

    • saveToFile

      public int saveToFile() throws 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:
      IOException - if IO problem
    • generateTreeFormatter

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