Package EDU.purdue.jtb.parser
Class Options
java.lang.Object
EDU.purdue.jtb.parser.Options
- Direct Known Subclasses:
JTBOptions
A class that stores all JTB / JavaCC file options information.
-
Field Summary
FieldsModifier and TypeFieldDescriptionA mapping of option names (Strings) to values (Integer, Boolean, String). -
Constructor Summary
ConstructorsConstructorDescriptionOptions()
Limit sub classing to derived classes.
MMa : modified (public) for JTB -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
booleanValue
(String option) Convenience method to retrieve boolean options.boolean
Find the build parser value.boolean
Find the build token manager value.boolean
Find the cache tokens value.int
Find the choice ambiguity check value.boolean
Find the common token action value.boolean
Find the debug lookahead value.boolean
Find the debug parser value.boolean
Find the debug TokenManager value.boolean
Find the error reporting value.boolean
Find the force lookahead check value.boolean
Should the generated code contain Annotations?boolean
Should the generated code create Exceptions using a constructor taking a nested exception?boolean
Should the generated code contain Generics?boolean
Should the generated code use StringBuilder rather than StringBuilder?boolean
Find the ignore case value.boolean
Find the Java Unicode escape value.Find the JDK version.boolean
Find the keep line column value.int
Find the lookahead setting.getOptionsString
(String[] interestingOptions) Returns a string representation of the specified options of interest.int
Find the other ambiguity check value.Find the output directory.boolean
Find the sanity check value.boolean
Find the static value.boolean
Should the generated code class visibility public?Return the Token's superclass.Return the Token's factory class.boolean
Find the token manager uses parser value.boolean
Find the Unicode input value.boolean
Find the user CharStream value.boolean
Find the user TokenManager value.void
init()
Initialize for JavaCC / JJTree / JTBprotected int
Convenience method to retrieve integer options.static boolean
Determine if a given command line argument might be an option flag.boolean
jdkVersionAtLeast
(double version) Determine if the output language is at least the specified version.void
Normalizes the options (ie checks coherence and dependences).void
setCmdLineOption
(String arg) Process a single command line option.void
setInputFileOption
(Object nameloc, Object valueloc, String name, Object value) Sets an option for the input file.protected String
stringValue
(String option) Convenience method to retrieve string options.static Object
upgradeValue
(String name, Object value) Help function to handle cases where the meaning of an option has changed over time.
-
Field Details
-
optionValues
A mapping of option names (Strings) to values (Integer, Boolean, String). This table is initialized by the main program. Its contents defines the set of legal options. Its initial values define the default option values, and the option types can be determined from these values too.
MMa : modified (allocated here) for JTB
-
-
Constructor Details
-
Options
public Options()Limit sub classing to derived classes.
MMa : modified (public) for JTB
-
-
Method Details
-
intValue
Convenience method to retrieve integer options.- Parameters:
option
- - the option string key- Returns:
- the option integer value
-
booleanValue
Convenience method to retrieve boolean options.- Parameters:
option
- - the option string key- Returns:
- the option boolean value
-
stringValue
Convenience method to retrieve string options.- Parameters:
option
- - the option string key- Returns:
- the option string value
-
getOptions
- Returns:
- the option string value corresponding to the option string key
MMa : modified (direct reference) for JTB
-
init
public void init()Initialize for JavaCC / JJTree / JTB -
getOptionsString
Returns a string representation of the specified options of interest. Used when, for example, generating Token.java to record the JavaCC options that were used to generate the file. All of the options must be boolean values.- Parameters:
interestingOptions
- - the options of interest, eg {"STATIC", "CACHE_TOKENS"}- Returns:
- the string representation of the options, eg "STATIC=true,CACHE_TOKENS=false"
-
isOption
Determine if a given command line argument might be an option flag. Command line options start with a dash (-).- Parameters:
opt
- - The command line argument to examine.- Returns:
- True when the argument looks like an option flag.
-
upgradeValue
Help function to handle cases where the meaning of an option has changed over time. If the user has supplied an option in the old format, it will be converted to the new format.- Parameters:
name
- - The name of the option being checked.value
- - The option's value.- Returns:
- The upgraded value.
-
setInputFileOption
Sets an option for the input file.- Parameters:
nameloc
- - the option name locationvalueloc
- - the option value locationname
- - the option namevalue
- - the option value
-
setCmdLineOption
Process a single command line option. The option is parsed and stored in the optionValues map. (overriden by JTB).- Parameters:
arg
- - the command line option
-
normalize
public void normalize()Normalizes the options (ie checks coherence and dependences). -
getBuildParser
public boolean getBuildParser()Find the build parser value.- Returns:
- The requested build parser value.
-
getBuildTokenManager
public boolean getBuildTokenManager()Find the build token manager value.- Returns:
- The requested build token manager value.
-
getCacheTokens
public boolean getCacheTokens()Find the cache tokens value.- Returns:
- The requested cache tokens value.
-
getChoiceAmbiguityCheck
public int getChoiceAmbiguityCheck()Find the choice ambiguity check value.- Returns:
- The requested choice ambiguity check value.
-
getCommonTokenAction
public boolean getCommonTokenAction()Find the common token action value.- Returns:
- The requested common token action value.
-
getDebugParser
public boolean getDebugParser()Find the debug parser value.- Returns:
- The requested debug parser value.
-
getDebugLookahead
public boolean getDebugLookahead()Find the debug lookahead value.- Returns:
- The requested debug lookahead value.
-
getDebugTokenManager
public boolean getDebugTokenManager()Find the debug TokenManager value.- Returns:
- The requested debug TokenManager value.
-
getErrorReporting
public boolean getErrorReporting()Find the error reporting value.- Returns:
- The requested error reporting value.
-
getForceLaCheck
public boolean getForceLaCheck()Find the force lookahead check value.- Returns:
- The requested force lookahead value.
-
getGenerateAnnotations
public boolean getGenerateAnnotations()Should the generated code contain Annotations?- Returns:
- The generate annotations value
-
getGenerateChainedException
public boolean getGenerateChainedException()Should the generated code create Exceptions using a constructor taking a nested exception?- Returns:
- The generate chained exception value
-
getGenerateGenerics
public boolean getGenerateGenerics()Should the generated code contain Generics?- Returns:
- The generate Generics value
-
getGenerateStringBuilder
public boolean getGenerateStringBuilder()Should the generated code use StringBuilder rather than StringBuilder?- Returns:
- The generate StringBuilder exception value
-
getIgnoreCase
public boolean getIgnoreCase()Find the ignore case value.- Returns:
- The requested ignore case value.
-
getJavaUnicodeEscape
public boolean getJavaUnicodeEscape()Find the Java Unicode escape value.- Returns:
- The requested Java Unicode escape value.
-
getJdkVersion
Find the JDK version.- Returns:
- The requested JDK version.
-
getKeepLineColumn
public boolean getKeepLineColumn()Find the keep line column value.- Returns:
- The requested keep line column value.
-
getLookahead
public int getLookahead()Find the lookahead setting.- Returns:
- The requested lookahead value.
-
getOtherAmbiguityCheck
public int getOtherAmbiguityCheck()Find the other ambiguity check value.- Returns:
- The requested other ambiguity check value.
-
getOutputDirectory
Find the output directory.- Returns:
- The requested output directory.
-
getSanityCheck
public boolean getSanityCheck()Find the sanity check value.- Returns:
- The requested sanity check value.
-
getStatic
public boolean getStatic()Find the static value.- Returns:
- requested static value.
-
getSupportClassVisibilityPublic
public boolean getSupportClassVisibilityPublic()Should the generated code class visibility public?- Returns:
- The class visibility public value
-
getTokenExtends
Return the Token's superclass.- Returns:
- The required base class for Token.
-
getTokenManagerUsesParser
public boolean getTokenManagerUsesParser()Find the token manager uses parser value.- Returns:
- The requested token manager uses parser value;
-
getTokenFactory
Return the Token's factory class.- Returns:
- The required factory class for Token.
-
getUnicodeInput
public boolean getUnicodeInput()Find the Unicode input value.- Returns:
- The requested Unicode input value.
-
getUserCharStream
public boolean getUserCharStream()Find the user CharStream value.- Returns:
- The requested user CharStream value.
-
getUserTokenManager
public boolean getUserTokenManager()Find the user TokenManager value.- Returns:
- The requested user TokenManager value.
-
jdkVersionAtLeast
public boolean jdkVersionAtLeast(double version) Determine if the output language is at least the specified version.- Parameters:
version
- - the version to check against. E.g.1.5
- Returns:
- true if the output version is at least the specified version.
-
stringBufOrBuild
- Returns:
- the "StringBuilder" or "StringBuffer" string
-