Class Options

  • Direct Known Subclasses:
    JTBOptions

    public class Options
    extends java.lang.Object
    A 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> optionValues
      A 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
    • 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
    • Constructor Detail

      • Options

        public Options()
        Limit sub classing to derived classes.
        MMa : modified (public) 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 location
        valueloc - - the option value location
        name - - the option name
        value - - 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