Class Options

java.lang.Object
org.javacc.parser.Options
Direct Known Subclasses:
JJTreeOptions

public class Options extends Object
A class with static state that stores all option information.
  • Field Details

    • NONUSER_OPTION__NAMESPACE_CLOSE

      public static final String NONUSER_OPTION__NAMESPACE_CLOSE
      These are options that are not settable by the user themselves, and that are set indirectly via some configuration of user options
      See Also:
    • NONUSER_OPTION__HAS_NAMESPACE

      public static final String NONUSER_OPTION__HAS_NAMESPACE
      See Also:
    • NONUSER_OPTION__NAMESPACE_OPEN

      public static final String NONUSER_OPTION__NAMESPACE_OPEN
      See Also:
    • NONUSER_OPTION__PARSER_NAME

      public static final String NONUSER_OPTION__PARSER_NAME
      See Also:
    • NONUSER_OPTION__PARSER_NAME_UPPER_CASE

      public static final String NONUSER_OPTION__PARSER_NAME_UPPER_CASE
      See Also:
    • NONUSER_OPTION__LEGACY_EXCEPTION_HANDLING

      public static final String NONUSER_OPTION__LEGACY_EXCEPTION_HANDLING
      See Also:
    • NONUSER_OPTION__INTERPRETER

      public static final String NONUSER_OPTION__INTERPRETER
      See Also:
    • USEROPTION__JAVA_TEMPLATE_TYPE

      public static final String USEROPTION__JAVA_TEMPLATE_TYPE
      Options that the user can specify from .javacc file
      See Also:
    • USEROPTION__GENERATE_BOILERPLATE

      public static final String USEROPTION__GENERATE_BOILERPLATE
      See Also:
    • USEROPTION__CODE_GENERATOR

      public static final String USEROPTION__CODE_GENERATOR
      See Also:
    • USEROPTION__NO_DFA

      public static final String USEROPTION__NO_DFA
      See Also:
    • USEROPTION__STATIC

      public static final String USEROPTION__STATIC
      See Also:
    • USEROPTION__LOOKAHEAD

      public static final String USEROPTION__LOOKAHEAD
      See Also:
    • USEROPTION__IGNORE_CASE

      public static final String USEROPTION__IGNORE_CASE
      See Also:
    • USEROPTION__UNICODE_INPUT

      public static final String USEROPTION__UNICODE_INPUT
      See Also:
    • USEROPTION__JAVA_UNICODE_ESCAPE

      public static final String USEROPTION__JAVA_UNICODE_ESCAPE
      See Also:
    • USEROPTION__ERROR_REPORTING

      public static final String USEROPTION__ERROR_REPORTING
      See Also:
    • USEROPTION__DEBUG_TOKEN_MANAGER

      public static final String USEROPTION__DEBUG_TOKEN_MANAGER
      See Also:
    • USEROPTION__DEBUG_LOOKAHEAD

      public static final String USEROPTION__DEBUG_LOOKAHEAD
      See Also:
    • USEROPTION__DEBUG_PARSER

      public static final String USEROPTION__DEBUG_PARSER
      See Also:
    • USEROPTION__OTHER_AMBIGUITY_CHECK

      public static final String USEROPTION__OTHER_AMBIGUITY_CHECK
      See Also:
    • USEROPTION__CHOICE_AMBIGUITY_CHECK

      public static final String USEROPTION__CHOICE_AMBIGUITY_CHECK
      See Also:
    • USEROPTION__CACHE_TOKENS

      public static final String USEROPTION__CACHE_TOKENS
      See Also:
    • USEROPTION__COMMON_TOKEN_ACTION

      public static final String USEROPTION__COMMON_TOKEN_ACTION
      See Also:
    • USEROPTION__FORCE_LA_CHECK

      public static final String USEROPTION__FORCE_LA_CHECK
      See Also:
    • USEROPTION__SANITY_CHECK

      public static final String USEROPTION__SANITY_CHECK
      See Also:
    • USEROPTION__TOKEN_MANAGER_USES_PARSER

      public static final String USEROPTION__TOKEN_MANAGER_USES_PARSER
      See Also:
    • USEROPTION__BUILD_TOKEN_MANAGER

      public static final String USEROPTION__BUILD_TOKEN_MANAGER
      See Also:
    • USEROPTION__BUILD_PARSER

      public static final String USEROPTION__BUILD_PARSER
      See Also:
    • USEROPTION__USER_CHAR_STREAM

      public static final String USEROPTION__USER_CHAR_STREAM
      See Also:
    • USEROPTION__JDK_VERSION

      public static final String USEROPTION__JDK_VERSION
      See Also:
    • USEROPTION__SUPPORT_CLASS_VISIBILITY_PUBLIC

      public static final String USEROPTION__SUPPORT_CLASS_VISIBILITY_PUBLIC
      See Also:
    • USEROPTION__GENERATE_ANNOTATIONS

      public static final String USEROPTION__GENERATE_ANNOTATIONS
      See Also:
    • USEROPTION__GENERATE_STRING_BUILDER

      public static final String USEROPTION__GENERATE_STRING_BUILDER
      See Also:
    • USEROPTION__GENERATE_GENERICS

      public static final String USEROPTION__GENERATE_GENERICS
      See Also:
    • USEROPTION__GENERATE_CHAINED_EXCEPTION

      public static final String USEROPTION__GENERATE_CHAINED_EXCEPTION
      See Also:
    • USEROPTION__OUTPUT_DIRECTORY

      public static final String USEROPTION__OUTPUT_DIRECTORY
      See Also:
    • USEROPTION__KEEP_LINE_COLUMN

      public static final String USEROPTION__KEEP_LINE_COLUMN
      See Also:
    • USEROPTION__GRAMMAR_ENCODING

      public static final String USEROPTION__GRAMMAR_ENCODING
      See Also:
    • USEROPTION__DEPTH_LIMIT

      public static final String USEROPTION__DEPTH_LIMIT
      See Also:
    • USEROPTION__CPP_NAMESPACE

      public static final String USEROPTION__CPP_NAMESPACE
      See Also:
    • USEROPTION__IGNORE_ACTIONS

      public static final String USEROPTION__IGNORE_ACTIONS
      See Also:
    • USEROPTION__CPP_STOP_ON_FIRST_ERROR

      public static final String USEROPTION__CPP_STOP_ON_FIRST_ERROR
      See Also:
    • USEROPTION__CPP_STACK_LIMIT

      public static final String USEROPTION__CPP_STACK_LIMIT
      See Also:
    • USEROPTION__CPP_USE_ARRAY

      public static final String USEROPTION__CPP_USE_ARRAY
      See Also:
    • USEROPTION__CPP_LIBRARY

      public static final String USEROPTION__CPP_LIBRARY
      See Also:
    • USEROPTION__TOKEN_EXTENDS

      public static final String USEROPTION__TOKEN_EXTENDS
      See Also:
    • USEROPTION__CPP_TOKEN_FACTORY

      public static final String USEROPTION__CPP_TOKEN_FACTORY
      See Also:
    • USEROPTION__CPP_TOKEN_INCLUDE

      public static final String USEROPTION__CPP_TOKEN_INCLUDE
      See Also:
    • USEROPTION__CPP_TOKEN_CLASS

      public static final String USEROPTION__CPP_TOKEN_CLASS
      See Also:
    • USEROPTION__CPP_TOKEN_NAMESPACE

      public static final String USEROPTION__CPP_TOKEN_NAMESPACE
      See Also:
    • USEROPTION__CPP_TOKEN_CONSTANTS_INCLUDE

      public static final String USEROPTION__CPP_TOKEN_CONSTANTS_INCLUDE
      See Also:
    • USEROPTION__CPP_TOKEN_CONSTANTS_NAMESPACE

      public static final String USEROPTION__CPP_TOKEN_CONSTANTS_NAMESPACE
      See Also:
    • USEROPTION__CPP_PARSER_INCLUDE

      public static final String USEROPTION__CPP_PARSER_INCLUDE
      See Also:
    • USEROPTION__CPP_TOKEN_MANAGER_INCLUDE

      public static final String USEROPTION__CPP_TOKEN_MANAGER_INCLUDE
      See Also:
    • USEROPTION__TOKEN_MANAGER_SUPER_CLASS

      public static final String USEROPTION__TOKEN_MANAGER_SUPER_CLASS
      See Also:
    • USEROPTION__USER_TOKEN_MANAGER

      public static final String USEROPTION__USER_TOKEN_MANAGER
      See Also:
    • JAVA_TEMPLATE_TYPE_MODERN

      public static final String JAVA_TEMPLATE_TYPE_MODERN
      2013/07/22 -- GWT Compliant Output -- no external dependencies on GWT, but generated code adds loose coupling to IO, for 6.1 release, this is opt-in, moving forward to 7.0, after thorough testing, this will likely become the default option with classic being deprecated
      See Also:
    • JAVA_TEMPLATE_TYPE_CLASSIC

      public static final String JAVA_TEMPLATE_TYPE_CLASSIC
      The old style of Java code generation (tight coupling of code to Java IO classes - not GWT compatible)
      See Also:
    • userOptions

      private static final Set<OptionInfo> userOptions
    • optionValues

      public static Map<String,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.
    • cmdLineSetting

      private static Set<String> cmdLineSetting
      Keep track of what options were set as a command line argument. We use this to see if the options set from the command line and the ones set in the input files clash in any way.
    • inputFileSetting

      private static Set<String> inputFileSetting
      Keep track of what options were set from the grammar file. We use this to see if the options set from the command line and the ones set in the input files clash in any way.
    • supportedJavaTemplateTypes

      private static final Set<String> supportedJavaTemplateTypes
  • Constructor Details

    • Options

      public Options()
      Limit subclassing to derived classes.
  • Method Details

    • init

      public static void init()
      Initialize for JavaCC
    • intValue

      public static int intValue(String option)
      Convenience method to retrieve integer options.
    • booleanValue

      public static boolean booleanValue(String option)
      Convenience method to retrieve boolean options.
    • stringValue

      public static String stringValue(String option)
      Convenience method to retrieve string options.
    • stringListValue

      public static List<String> stringListValue(String option)
      Convenience method to retrieve string list options.
    • objectValue

      public static Object objectValue(String option)
    • getOptions

      public static Map<String,Object> getOptions()
    • getOptionsString

      public static String getOptionsString(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 {Options.USEROPTION__STATIC, Options.USEROPTION__CACHE_TOKENS}
      Returns:
      the string representation of the options, eg "STATIC=true,CACHE_TOKENS=false"
    • isOption

      public static boolean isOption(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

      private static Object upgradeValue(String name, 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 static void setInputFileOption(Object nameloc, Object valueloc, String name, Object value, Context context)
    • getAllValidJavaTemplateTypes

      private static String getAllValidJavaTemplateTypes()
    • setCmdLineOption

      public static void setCmdLineOption(String arg)
      Process a single command-line option. The option is parsed and stored in the optionValues map.
      Parameters:
      arg -
    • normalize

      public static void normalize(Context context)
    • getLookahead

      public static int getLookahead()
      Find the lookahead setting.
      Returns:
      The requested lookahead value.
    • getChoiceAmbiguityCheck

      static int getChoiceAmbiguityCheck()
      Find the choice ambiguity check value.
      Returns:
      The requested choice ambiguity check value.
    • getOtherAmbiguityCheck

      static int getOtherAmbiguityCheck()
      Find the other ambiguity check value.
      Returns:
      The requested other ambiguity check value.
    • getStatic

      public static boolean getStatic()
      Find the static value.
      Returns:
      The requested static value.
    • getCodeGenerator

      public static String getCodeGenerator()
    • getNoDfa

      public static boolean getNoDfa()
    • getDebugParser

      public static boolean getDebugParser()
      Find the debug parser value.
      Returns:
      The requested debug parser value.
    • getDebugLookahead

      public static boolean getDebugLookahead()
      Find the debug lookahead value.
      Returns:
      The requested debug lookahead value.
    • getDebugTokenManager

      public static boolean getDebugTokenManager()
      Find the debug tokenmanager value.
      Returns:
      The requested debug tokenmanager value.
    • getErrorReporting

      public static boolean getErrorReporting()
      Find the error reporting value.
      Returns:
      The requested error reporting value.
    • getJavaUnicodeEscape

      public static boolean getJavaUnicodeEscape()
      Find the Java unicode escape value.
      Returns:
      The requested Java unicode escape value.
    • getUnicodeInput

      public static boolean getUnicodeInput()
      Find the unicode input value.
      Returns:
      The requested unicode input value.
    • getIgnoreCase

      public static boolean getIgnoreCase()
      Find the ignore case value.
      Returns:
      The requested ignore case value.
    • getUserTokenManager

      public static boolean getUserTokenManager()
      Find the user token manager value.
      Returns:
      The requested user tokenmanager value.
    • getUserCharStream

      public static boolean getUserCharStream()
      Find the user charstream value.
      Returns:
      The requested user charstream value.
    • getCharStreamName

      public static String getCharStreamName()
      Find the name of the char-stream
    • getBuildParser

      public static boolean getBuildParser()
      Find the build parser value.
      Returns:
      The requested build parser value.
    • getBuildTokenManager

      public static boolean getBuildTokenManager()
      Find the build token manager value.
      Returns:
      The requested build token manager value.
    • getParserInclude

      public static String getParserInclude()
      Find the parser include
      Returns:
      The requested parser includes;
    • getTokenInclude

      public static String getTokenInclude()
      Find the token include
      Returns:
      The requested token include;
    • getTokenClass

      public static String getTokenClass()
      Find the token include
      Returns:
      The requested token include;
    • getTokenNamespace

      public static String getTokenNamespace()
      Find the token include
      Returns:
      The requested token include;
    • getTokenConstantsInclude

      public static String getTokenConstantsInclude()
      Find the token constants
      Returns:
      The requested token ;
    • getTokenConstantsNamespace

      public static String getTokenConstantsNamespace()
      Find the token constants namespace
      Returns:
      The requested token namespace;
    • getTokenManagerInclude

      public static String getTokenManagerInclude()
      Find the token manager Include
      Returns:
      The requested token manager includes;
    • getTokenManagerUsesParser

      public static boolean getTokenManagerUsesParser()
      Find the token manager uses parser value.
      Returns:
      The requested token manager uses parser value;
    • getSanityCheck

      public static boolean getSanityCheck()
      Find the sanity check value.
      Returns:
      The requested sanity check value.
    • getForceLaCheck

      public static boolean getForceLaCheck()
      Find the force lookahead check value.
      Returns:
      The requested force lookahead value.
    • getCommonTokenAction

      public static boolean getCommonTokenAction()
      Find the common token action value.
      Returns:
      The requested common token action value.
    • getCacheTokens

      public static boolean getCacheTokens()
      Find the cache tokens value.
      Returns:
      The requested cache tokens value.
    • getKeepLineColumn

      public static boolean getKeepLineColumn()
      Find the keep line column value.
      Returns:
      The requested keep line column value.
    • getJdkVersion

      public static String getJdkVersion()
      Find the JDK version.
      Returns:
      The requested jdk version.
    • getGenerateChainedException

      public static boolean getGenerateChainedException()
      Should the generated code create Exceptions using a constructor taking a nested exception?
      Returns:
    • isGenerateBoilerplateCode

      public static boolean isGenerateBoilerplateCode()
    • isLegacyExceptionHandling

      public static boolean isLegacyExceptionHandling()
      As of 6.1 JavaCC now throws subclasses of RuntimeException rather than Error s (by default), as Error s typically lead to the closing down of the parent VM and are only to be used in extreme circumstances (failure of parsing is generally not regarded as such). If this value is set to true, then then Errors will be thrown (for compatibility with older .jj files)
      Returns:
      true if throws errors (legacy), false if use RuntimeException s (better approach)
    • getGenerateGenerics

      public static boolean getGenerateGenerics()
      Should the generated code contain Generics?
      Returns:
    • getGenerateStringBuilder

      public static boolean getGenerateStringBuilder()
      Should the generated code use StringBuilder rather than StringBuffer?
      Returns:
    • getGenerateAnnotations

      public static boolean getGenerateAnnotations()
      Should the generated code contain Annotations?
      Returns:
    • getSupportClassVisibilityPublic

      public static boolean getSupportClassVisibilityPublic()
      Should the generated code class visibility public?
      Returns:
    • jdkVersionAtLeast

      private static 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.
    • getTokenExtends

      public static String getTokenExtends()
      Return the Token's superclass.
      Returns:
      The required base class for Token.
    • getTokenFactory

      public static String getTokenFactory()
      Return the Token's factory class.
      Returns:
      The required factory class for Token.
    • getGrammarEncoding

      public static String getGrammarEncoding()
      Return the file encoding; this will return the file.encoding system property if no value was explicitly set
      Returns:
      The file encoding (e.g., UTF-8, ISO_8859-1, MacRoman)
    • getNamespace

      public static String getNamespace()
    • hasNamespace

      public static boolean hasNamespace()
    • getCppUseArray

      public static boolean getCppUseArray()
    • getLibrary

      public static String getLibrary()
    • getOutputDirectory

      public static File getOutputDirectory()
    • isValidJavaTemplateType

      private static boolean isValidJavaTemplateType(String type)
    • getJavaTemplateType

      public static String getJavaTemplateType()
    • set

      public static void set(String optionName, Object optionValue)
    • setStringOption

      static void setStringOption(String optionName, String optionValue)
    • getOpenCloseNamespace

      public static Pair<String,String> getOpenCloseNamespace(String namespace)
    • processNamespaceOption

      private static void processNamespaceOption(String optionValue)
    • isTokenManagerRequiresParserAccess

      public static boolean isTokenManagerRequiresParserAccess()
    • getDepthLimit

      public static int getDepthLimit()
      Get defined parser recursion depth limit.
      Returns:
      The requested recursion limit.
    • getStackLimit

      public static String getStackLimit()
      Get defined parser stack usage limit.
      Returns:
      The requested stack usage limit.
    • getUserOptions

      static Set<OptionInfo> getUserOptions()
      Gets all the user options (in order)
      Returns:
    • isNullOrEmpty

      static boolean isNullOrEmpty(String string)
    • isNotEmpty

      static boolean isNotEmpty(String string)