Package EDU.purdue.jtb.common
Class JTBOptions
- java.lang.Object
-
- EDU.purdue.jtb.parser.Options
-
- EDU.purdue.jtb.common.JTBOptions
-
public class JTBOptions extends Options
A subclass of the JavaCC options class to extend it to the JTB options.
It also handles the global variables reflecting the JTB options and some derived objects and methods.Class is not supposed to be run in parallel threads (on the same grammar).
TESTCASE some to add
-
-
Field Summary
Fields Modifier and Type Field Description boolean
childrenMethods
-chm option which generates children handling methods in base and user nodesboolean
depthLevel
-dl option which generates depthLevel field in all visitor classesboolean
descriptiveFieldNames
-f option which generates descriptive node class child field names such as whileStatement, nodeToken2, ...java.lang.String
externalGeneratorClass
-eg option which defines an external generator classjava.lang.String
fileExt
File extensionjava.lang.String
grammarDirectoryName
-d option which gives the grammar directoryjava.lang.String
grammarPackageName
-p option which gives the grammar package nameboolean
hook
-hk option which generates enter and exit node scope hook methods in the grammarjava.lang.String
hookDirName
-hkd & -d options which defines the node scope hook directory name (default is#DEF_HOOK_DIR_NAME
)java.lang.String
hookPackageName
-hkp & -p options which defines the node scope hook package name (default is#DEF_HOOK_PKG_NAME
)boolean
inlineAcceptMethods
-ia option which "inlines" the visitors accept methods on base classesboolean
isCpp
Helper flag for C++ output languageboolean
isJava
Helper flag for java output languageboolean
isPfxOrSfx
The flag to tell if there is at least one prefix or one suffixboolean
isStatic
static or not static option that comes from JavaCCboolean
javaDocComments
-jd option which generates JavaDoc-friendly comments in generated visitors and syntax tree classesjava.lang.String
jjOutDirName
The JavaCC output directory option (OUTPUT_DIRECTORY) name (the directory, forToken
)java.lang.String
jtbOutputFileName
-o option which defines the output (generated) file name (default is jtb.out.jj)EDU.purdue.jtb.common.JTBOptions.Lang
lang
language option that comes from JavaCC (java by default)Messages
mess
The messages handlerjava.lang.String
nodePrefix
-npfx & -nsfx options which defines the node' prefixjava.lang.String
nodesDirName
-nd & -d options which defines the nodes directory name (default is#DEF_ND_DIR_NAME
)java.lang.String
nodesPackageName
-np & -p options which defines the nodes package name (default is#DEF_ND_PKG_NAME
)java.lang.String
nodesSuperclass
-ns option which defines the nodes superclassjava.lang.String
nodeSuffix
-npfx & -nsfx options which defines the node' suffixboolean
noOverwrite
-w options which prevents JTB from overwriting existing filesboolean
noParallel
-noplg option which suppresses parallel generation of user filesboolean
noSemanticCheck
-e option which suppresses JTB semantic error checkingboolean
noSignature
-nosig option which suppresses generating signature control in visitorsboolean
noVisitors
-novis option which suppresses generating visitorsboolean
parentPointer
-pp option which generates parent pointer and getParent() and setParent() methods in all node classesboolean
printClassList
-cl option which prints the generated classes list to System.outboolean
printerToolkit
-printer option which generates TreeDumper and TreeFormatter visitorsboolean
printSpecialTokensJJ
-tkjj option which prints special tokens in the annotated JJ filejava.lang.String
signatureDirName
Signature directory name (default isvisitorsDirName
/#DEF_SIG_DIR_NAME
)java.lang.String
signaturePackageName
Signature package name (default isvisitorsPackageName
.#DEF_SIG_DIR_NAME
)boolean
storeSpecialTokens
-tk option which stores special tokens in the tree's NodeTokensjava.lang.String
visitorsDirName
-vd & -d options which defines the visitors directory name (default is#DEF_VIS_DIR_NAME
)java.util.List<VisitorInfo>
visitorsList
The list of the visitors to be generated, deriving from the -vis optionjava.lang.String
visitorsPackageName
-vp & -p options which defines the visitors package name (default is#DEF_VIS_PKG_NAME
)java.lang.String
visitorsStr
-vis option which defines the visitors to be generated-
Fields inherited from class EDU.purdue.jtb.parser.Options
optionValues
-
-
Constructor Summary
Constructors Constructor Description JTBOptions(Messages aMess)
Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
createVisitorsList(java.lang.String aVisitorsStr)
Checks -vis / JTB_VIS option string and creates the list ofVisitorInfo
.void
init()
Initialize the JavaCC & JTB options.void
loadJTBGlobalOptions(java.lang.String aGrammarDeclaredPackage)
Loads the global variables with the JTB global options from the parsed grammar (which was fed with the command line options and the grammar file options).void
setCmdLineOption(java.lang.String aKey, boolean aVal)
Stores a boolean option.void
setCmdLineOption(java.lang.String aKey, java.lang.String aVal)
Process a single command line option.-
Methods inherited from class EDU.purdue.jtb.parser.Options
booleanValue, getBuildParser, getBuildTokenManager, getCacheTokens, getChoiceAmbiguityCheck, getCommonTokenAction, getDebugLookahead, getDebugParser, getDebugTokenManager, getErrorReporting, getForceLaCheck, getGenerateAnnotations, getGenerateChainedException, getGenerateGenerics, getGenerateStringBuilder, getIgnoreCase, getJavaUnicodeEscape, getJdkVersion, getKeepLineColumn, getLookahead, getOptions, getOptionsString, getOtherAmbiguityCheck, getOutputDirectory, getSanityCheck, getStatic, getSupportClassVisibilityPublic, getTokenExtends, getTokenFactory, getTokenManagerUsesParser, getUnicodeInput, getUserCharStream, getUserTokenManager, intValue, isOption, jdkVersionAtLeast, normalize, setCmdLineOption, setInputFileOption, stringBufOrBuild, stringValue, upgradeValue
-
-
-
-
Field Detail
-
mess
public final Messages mess
The messages handler
-
childrenMethods
public boolean childrenMethods
-chm option which generates children handling methods in base and user nodes
-
printClassList
public boolean printClassList
-cl option which prints the generated classes list to System.out
-
depthLevel
public boolean depthLevel
-dl option which generates depthLevel field in all visitor classes
-
noSemanticCheck
public boolean noSemanticCheck
-e option which suppresses JTB semantic error checking
-
descriptiveFieldNames
public boolean descriptiveFieldNames
-f option which generates descriptive node class child field names such as whileStatement, nodeToken2, ... rather than f0, f1, ...
-
hook
public boolean hook
-hk option which generates enter and exit node scope hook methods in the grammar
-
inlineAcceptMethods
public boolean inlineAcceptMethods
-ia option which "inlines" the visitors accept methods on base classes
-
javaDocComments
public boolean javaDocComments
-jd option which generates JavaDoc-friendly comments in generated visitors and syntax tree classes
-
noParallel
public boolean noParallel
-noplg option which suppresses parallel generation of user files
-
noSignature
public boolean noSignature
-nosig option which suppresses generating signature control in visitors
-
noVisitors
public boolean noVisitors
-novis option which suppresses generating visitors
-
parentPointer
public boolean parentPointer
-pp option which generates parent pointer and getParent() and setParent() methods in all node classes
-
printerToolkit
public boolean printerToolkit
-printer option which generates TreeDumper and TreeFormatter visitors
-
storeSpecialTokens
public boolean storeSpecialTokens
-tk option which stores special tokens in the tree's NodeTokens
-
printSpecialTokensJJ
public boolean printSpecialTokensJJ
-tkjj option which prints special tokens in the annotated JJ file
-
noOverwrite
public boolean noOverwrite
-w options which prevents JTB from overwriting existing files
-
isStatic
public boolean isStatic
static or not static option that comes from JavaCC
-
lang
public EDU.purdue.jtb.common.JTBOptions.Lang lang
language option that comes from JavaCC (java by default)
-
grammarDirectoryName
public java.lang.String grammarDirectoryName
-d option which gives the grammar directory
-
externalGeneratorClass
public java.lang.String externalGeneratorClass
-eg option which defines an external generator class
-
hookDirName
public java.lang.String hookDirName
-hkd & -d options which defines the node scope hook directory name (default is#DEF_HOOK_DIR_NAME
)
-
hookPackageName
public java.lang.String hookPackageName
-hkp & -p options which defines the node scope hook package name (default is#DEF_HOOK_PKG_NAME
)
-
nodesDirName
public java.lang.String nodesDirName
-nd & -d options which defines the nodes directory name (default is#DEF_ND_DIR_NAME
)
-
nodePrefix
public java.lang.String nodePrefix
-npfx & -nsfx options which defines the node' prefix
-
nodeSuffix
public java.lang.String nodeSuffix
-npfx & -nsfx options which defines the node' suffix
-
isPfxOrSfx
public boolean isPfxOrSfx
The flag to tell if there is at least one prefix or one suffix
-
nodesPackageName
public java.lang.String nodesPackageName
-np & -p options which defines the nodes package name (default is#DEF_ND_PKG_NAME
)
-
nodesSuperclass
public java.lang.String nodesSuperclass
-ns option which defines the nodes superclass
-
grammarPackageName
public java.lang.String grammarPackageName
-p option which gives the grammar package name
-
visitorsDirName
public java.lang.String visitorsDirName
-vd & -d options which defines the visitors directory name (default is#DEF_VIS_DIR_NAME
)
-
visitorsStr
public java.lang.String visitorsStr
-vis option which defines the visitors to be generated
-
visitorsList
public java.util.List<VisitorInfo> visitorsList
The list of the visitors to be generated, deriving from the -vis option
-
visitorsPackageName
public java.lang.String visitorsPackageName
-vp & -p options which defines the visitors package name (default is#DEF_VIS_PKG_NAME
)
-
jtbOutputFileName
public java.lang.String jtbOutputFileName
-o option which defines the output (generated) file name (default is jtb.out.jj)
-
signatureDirName
public java.lang.String signatureDirName
Signature directory name (default isvisitorsDirName
/#DEF_SIG_DIR_NAME
)
-
signaturePackageName
public java.lang.String signaturePackageName
Signature package name (default isvisitorsPackageName
.#DEF_SIG_DIR_NAME
)
-
jjOutDirName
public java.lang.String jjOutDirName
The JavaCC output directory option (OUTPUT_DIRECTORY) name (the directory, forToken
)
-
isJava
public boolean isJava
Helper flag for java output language
-
isCpp
public boolean isCpp
Helper flag for C++ output language
-
fileExt
public java.lang.String fileExt
File extension
-
-
Constructor Detail
-
JTBOptions
public JTBOptions(Messages aMess)
Standard constructor.- Parameters:
aMess
- - the messages handler
-
-
Method Detail
-
setCmdLineOption
public void setCmdLineOption(java.lang.String aKey, boolean aVal)
Stores a boolean option.- Parameters:
aKey
- - the command line option nameaVal
- - the command line option value
-
setCmdLineOption
public void setCmdLineOption(java.lang.String aKey, java.lang.String aVal)
Process a single command line option. The option is parsed and stored in the optionValues map. (overriden by JTB).- Parameters:
aKey
- - the command line option nameaVal
- - the command line option value
-
loadJTBGlobalOptions
public void loadJTBGlobalOptions(java.lang.String aGrammarDeclaredPackage)
Loads the global variables with the JTB global options from the parsed grammar (which was fed with the command line options and the grammar file options).- Parameters:
aGrammarDeclaredPackage
- - the grammar package name in the grammar
-
createVisitorsList
public boolean createVisitorsList(java.lang.String aVisitorsStr)
Checks -vis / JTB_VIS option string and creates the list ofVisitorInfo
.- Parameters:
aVisitorsStr
- - the string specifying the visitors info- Returns:
- true if valid data, false if null or invalid string
-
-