Package EDU.purdue.jtb.parser
Class Options
- java.lang.Object
-
- EDU.purdue.jtb.parser.Options
-
- Direct Known Subclasses:
JTBOptions
public class Options extends java.lang.ObjectA class that stores all JTB / JavaCC file options information.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>optionValuesA mapping of option names (Strings) to values (Integer, Boolean, String).
-
Constructor Summary
Constructors Constructor Description Options()Limit sub classing to derived classes.
MMa : modified (public) for JTB
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanbooleanValue(java.lang.String option)Convenience method to retrieve boolean options.booleangetBuildParser()Find the build parser value.booleangetBuildTokenManager()Find the build token manager value.booleangetCacheTokens()Find the cache tokens value.intgetChoiceAmbiguityCheck()Find the choice ambiguity check value.booleangetCommonTokenAction()Find the common token action value.booleangetDebugLookahead()Find the debug lookahead value.booleangetDebugParser()Find the debug parser value.booleangetDebugTokenManager()Find the debug TokenManager value.booleangetErrorReporting()Find the error reporting value.booleangetForceLaCheck()Find the force lookahead check value.booleangetGenerateAnnotations()Should the generated code contain Annotations?booleangetGenerateChainedException()Should the generated code create Exceptions using a constructor taking a nested exception?booleangetGenerateGenerics()Should the generated code contain Generics?booleangetGenerateStringBuilder()Should the generated code use StringBuilder rather than StringBuilder?booleangetIgnoreCase()Find the ignore case value.booleangetJavaUnicodeEscape()Find the Java Unicode escape value.java.lang.StringgetJdkVersion()Find the JDK version.booleangetKeepLineColumn()Find the keep line column value.intgetLookahead()Find the lookahead setting.java.util.Map<java.lang.String,java.lang.Object>getOptions()java.lang.StringgetOptionsString(java.lang.String[] interestingOptions)Returns a string representation of the specified options of interest.intgetOtherAmbiguityCheck()Find the other ambiguity check value.java.io.FilegetOutputDirectory()Find the output directory.booleangetSanityCheck()Find the sanity check value.booleangetStatic()Find the static value.booleangetSupportClassVisibilityPublic()Should the generated code class visibility public?java.lang.StringgetTokenExtends()Return the Token's superclass.java.lang.StringgetTokenFactory()Return the Token's factory class.booleangetTokenManagerUsesParser()Find the token manager uses parser value.booleangetUnicodeInput()Find the Unicode input value.booleangetUserCharStream()Find the user CharStream value.booleangetUserTokenManager()Find the user TokenManager value.voidinit()Initialize for JavaCC / JJTree / JTBprotected intintValue(java.lang.String option)Convenience method to retrieve integer options.static booleanisOption(java.lang.String opt)Determine 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.voidnormalize()Normalizes the options (ie checks coherence and dependences).voidsetCmdLineOption(java.lang.String arg)Process a single command line option.voidsetInputFileOption(java.lang.Object nameloc, java.lang.Object valueloc, java.lang.String name, java.lang.Object value)Sets an option for the input file.java.lang.StringstringBufOrBuild()protected java.lang.StringstringValue(java.lang.String option)Convenience method to retrieve string options.static java.lang.ObjectupgradeValue(java.lang.String name, java.lang.Object value)Help function to handle cases where the meaning of an option has changed over time.
-
-
-
Field Detail
-
optionValues
protected java.util.Map<java.lang.String,java.lang.Object> 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
-
-
Method Detail
-
intValue
protected int intValue(java.lang.String option)
Convenience method to retrieve integer options.- Parameters:
option- - the option string key- Returns:
- the option integer value
-
booleanValue
protected boolean booleanValue(java.lang.String option)
Convenience method to retrieve boolean options.- Parameters:
option- - the option string key- Returns:
- the option boolean value
-
stringValue
protected java.lang.String stringValue(java.lang.String option)
Convenience method to retrieve string options.- Parameters:
option- - the option string key- Returns:
- the option string value
-
getOptions
public java.util.Map<java.lang.String,java.lang.Object> 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
public java.lang.String getOptionsString(java.lang.String[] interestingOptions)
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
public static boolean isOption(java.lang.String opt)
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
public static java.lang.Object upgradeValue(java.lang.String name, java.lang.Object value)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
public void setInputFileOption(java.lang.Object nameloc, java.lang.Object valueloc, java.lang.String name, java.lang.Object value)Sets an option for the input file.- Parameters:
nameloc- - the option name locationvalueloc- - the option value locationname- - the option namevalue- - the option value
-
setCmdLineOption
public void setCmdLineOption(java.lang.String arg)
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
public java.lang.String 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
public java.io.File 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
public java.lang.String 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
public java.lang.String 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
public java.lang.String stringBufOrBuild()
- Returns:
- the "StringBuilder" or "StringBuffer" string
-
-