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 booleanbooleanValue(String option) Convenience method to retrieve boolean options.booleanFind the build parser value.booleanFind the build token manager value.booleanFind the cache tokens value.intFind the choice ambiguity check value.booleanFind the common token action value.booleanFind the debug lookahead value.booleanFind the debug parser value.booleanFind the debug TokenManager value.booleanFind the error reporting value.booleanFind the force lookahead check value.booleanShould the generated code contain Annotations?booleanShould the generated code create Exceptions using a constructor taking a nested exception?booleanShould the generated code contain Generics?booleanShould the generated code use StringBuilder rather than StringBuilder?booleanFind the ignore case value.booleanFind the Java Unicode escape value.Find the JDK version.booleanFind the keep line column value.intFind the lookahead setting.getOptionsString(String[] interestingOptions) Returns a string representation of the specified options of interest.intFind the other ambiguity check value.Find the output directory.booleanFind the sanity check value.booleanFind the static value.booleanShould the generated code class visibility public?Return the Token's superclass.Return the Token's factory class.booleanFind the token manager uses parser value.booleanFind the Unicode input value.booleanFind the user CharStream value.booleanFind the user TokenManager value.voidinit()Initialize for JavaCC / JJTree / JTBprotected intConvenience method to retrieve integer options.static booleanDetermine if a given command line argument might be an option flag.booleanjdkVersionAtLeast(double version) Determine if the output language is at least the specified version.voidNormalizes the options (ie checks coherence and dependences).voidsetCmdLineOption(String arg) Process a single command line option.voidsetInputFileOption(Object nameloc, Object valueloc, String name, Object value) Sets an option for the input file.protected StringstringValue(String option) Convenience method to retrieve string options.static ObjectupgradeValue(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
-
getOptions
-
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
-
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
-
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
-