Package EDU.purdue.jtb.generate
Class TreeFormatterGenerator
java.lang.Object
EDU.purdue.jtb.generate.TreeFormatterGenerator
Class
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
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 -
Constructor Summary
ConstructorsConstructorDescriptionTreeFormatterGenerator
(JTBOptions aJopt, CommonCodeGenerator aCcg, Messages aMess, List<UserClassInfo> classes) Constructor with a given list of classes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Generates the tree formatter visitor source in its file.int
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.
-
Field Details
-
outFilename
The visitor source file name- See Also:
-
-
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 optionsaCcg
- - theCommonCodeGenerator
aMess
- - the messages handlerclasses
- - the list of classes
-
-
Method Details
-
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.- 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.
-