Class ParserOptions


  • public class ParserOptions
    extends org.nineml.coffeegrinder.parser.ParserOptions
    Options to the Invisible XML processor.

    This object is extended by other members of the NineML family to provide additional options. It started out as a collection of public fields, but changed to a more traditional collection of getters and setters when it began to develop options that were not entirely independent.

    • Constructor Detail

      • ParserOptions

        public ParserOptions()
        Create the parser options.

        The initial logger will be a DefaultLogger initialized with Logger.readSystemProperties().

      • ParserOptions

        public ParserOptions​(org.nineml.logging.Logger logger)
        Create the parser options with an explicit logger.
        Parameters:
        logger - the logger.
      • ParserOptions

        public ParserOptions​(ParserOptions copy)
        Create a new set of options from an existing set.
        Parameters:
        copy - the options to copy
    • Method Detail

      • getIgnoreTrailingWhitespace

        public boolean getIgnoreTrailingWhitespace()
        Ignore trailing whitespace?

        If a parse fails where it would have succeeded if trailing whitespace was removed from the input, report success.

        Returns:
        true if trailing whitespace is ignored
      • setIgnoreTrailingWhitespace

        public void setIgnoreTrailingWhitespace​(boolean ignore)
        Parameters:
        ignore - ignore trailing whitespace?
      • getTrailingNewlineOnOutput

        public boolean getTrailingNewlineOnOutput()
        Make sure the output ends with a newline?

        If this option is true, a newline will be added to the end of the output.

        Returns:
        the trailing newline setting.
      • setTrailingNewlineOnOutput

        public void setTrailingNewlineOnOutput​(boolean newline)
        Parameters:
        newline - add a trailing newline?
      • getAllowUndefinedSymbols

        public boolean getAllowUndefinedSymbols()
        Allow undefined symbols?

        A grammar with undefined symbols isn't necessarily unusable. But Invisible XML forbids them.

        Returns:
        true if undefined symbols are allowed
      • setAllowUndefinedSymbols

        public void setAllowUndefinedSymbols​(boolean allow)
        Set the getAllowUndefinedSymbols() property.

        Allowing undefined symbols implies getAllowUnproductiveSymbols() and getAllowUndefinedSymbols(). An undefined symbol is always part of an unproductive rule and avoiding errors for undefined rules often introduces undefined symbols.

        Parameters:
        allow - allow undefined symbols?
      • getAllowUnreachableSymbols

        public boolean getAllowUnreachableSymbols()
        Allow unreachable symbols?

        A grammar with unreachable symbols isn't forbidden by Invisible XML, but might still be an error.

        Returns:
        true if unreachable symbols are allowed.
      • setAllowUnreachableSymbols

        public void setAllowUnreachableSymbols​(boolean allow)
        Parameters:
        allow - allow unreachable symbols?
      • getAllowUnproductiveSymbols

        public boolean getAllowUnproductiveSymbols()
        Allow unproductive symbols?

        An unproductive symbol is one which can never produce output in a valid parse.

        Returns:
        true if unproductive rules are allowed
      • setAllowUnproductiveSymbols

        public void setAllowUnproductiveSymbols​(boolean allow)
        Parameters:
        allow - allow unproductive rules?
      • getAllowMultipleDefinitions

        public boolean getAllowMultipleDefinitions()
        Allow multiple definitions?

        A grammar with multiply defined symbols isn't a problem for the underlying Earley parser, but it is forbidden by Invisible XML.

        Returns:
        true if multiple definitions are allowed.
      • setAllowMultipleDefinitions

        public void setAllowMultipleDefinitions​(boolean allow)
        Parameters:
        allow - allow multiple definitions?
      • getAllowEmptyAlts

        public boolean getAllowEmptyAlts()
        Allow empty string to represent an alternative?

        This is a purely stylistic option. Invisible XML allows the empty string to represent an empty alternative, S = "a" | . That defines S to be either @code{"a"} or empty, "nothing". Another way to represent an empty alternative is with an empty pair of parentheses, S = "a" | () .. That's more visually distinct and can be enforced with this option.

        Returns:
        true if the empty string can represent an alternative.
      • setAllowEmptyAlts

        public void setAllowEmptyAlts​(boolean allow)
        Set the getAllowEmptyAlts() ()} property.
        Parameters:
        allow - allow empty string to represent an alternative?
      • getPrettyPrint

        public boolean getPrettyPrint()
        Attempt to pretty print the result?

        If the result is pretty printed, extra newlines and spaces for indentation will be added to the result.

        Returns:
        true if the result should be pretty printed.
      • setPrettyPrint

        public void setPrettyPrint​(boolean prettPrint)
        Set the getPrettyPrint() property.
        Parameters:
        prettPrint - pretty print?
      • getShowChart

        public boolean getShowChart()
        Show the Earley chart in error results?
        Returns:
        true if the early chart should appear in error results.
      • setShowChart

        public void setShowChart​(boolean show)
        Set the getShowChart() property.
        Parameters:
        show - show the chart?
      • getGraphviz

        public java.lang.String getGraphviz()
        Where's the GraphViz 'dot' command?
        Returns:
        the path of the dot command.
      • setGraphviz

        public void setGraphviz​(java.lang.String dot)
        Set the getGraphviz() property.

        Setting the path to null disables SVG output.

        Parameters:
        dot - the path to the dot command.
      • isSuppressedState

        public boolean isSuppressedState​(java.lang.String state)
        Is the specified state suppressed?

        The Invisible XML processor adds state values to the root element to report conditions such as ambiguity or a prefix parse. These states can be suppressed.

        Parameters:
        state - the state
        Returns:
        true if the state is suppressed.
      • suppressState

        public void suppressState​(java.lang.String state)
        Suppress a state.

        The Invisible XML processor adds state values to the root element to report conditions such as ambiguity or a prefix parse. These states can be suppressed.

        Parameters:
        state - the state to suppress.
      • exposeState

        public void exposeState​(java.lang.String state)
        Expose a state.

        The Invisible XML processor adds state values to the root element to report conditions such as ambiguity or a prefix parse. These states can be suppressed.

        Parameters:
        state - the state to (no longer) suppress
      • getAssertValidXmlNames

        public boolean getAssertValidXmlNames()
        Raise an exception if invalid XML names are used in nonterminals that are serialized.
        Returns:
        true if invalid XML names should raise an exception
      • setAssertValidXmlNames

        public void setAssertValidXmlNames​(boolean valid)
        Set the getAssertValidXmlNames() property.
        Parameters:
        valid - assert valid names?
      • getAssertValidXmlCharacters

        public boolean getAssertValidXmlCharacters()
        Raise an exception if invalid XML characters are used in text or attribute values that are serialized.
        Returns:
        true if invalid XML characters should raise an exception
      • setAssertValidXmlCharacters

        public void setAssertValidXmlCharacters​(boolean valid)
        Parameters:
        valid - assert valid characters?
      • getPedantic

        public boolean getPedantic()
        Enforce strict compliance to the Invisible XML specification.

        In pedantic mode, the processor won't allow grammar extensions, like pragmas, that are not yet officially incorporated into the specification.

        Returns:
        true if pedantic mode is enabled
      • setPedantic

        public void setPedantic​(boolean pedantic)
        Set the getPedantic() property.

        In pedantic mode, the processor won't allow grammar extensions, like pragmas, that are not yet officially incorporated into the specification. Enabling pedantic mode also resets the allowed grammar hygiene rules to their defaults.

        Parameters:
        pedantic - be pedantic?
      • getShowMarks

        public boolean getShowMarks()
      • setShowMarks

        public void setShowMarks​(boolean show)
      • getShowBnfNonterminals

        public boolean getShowBnfNonterminals()
      • setShowBnfNonterminals

        public void setShowBnfNonterminals​(boolean show)
      • setRuleRewriter

        public void setRuleRewriter​(org.nineml.coffeefilter.model.RuleRewriter rewriter)
      • getRuleRewriter

        public org.nineml.coffeefilter.model.RuleRewriter getRuleRewriter()
      • getIgnoreBOM

        public boolean getIgnoreBOM()
        If a UTF-8 input stream begins with a byte order mark (BOM), ignore it.
        Returns:
        the ignore BOM setting.
      • setIgnoreBOM

        public void setIgnoreBOM​(boolean ignore)
        Set the getIgnoreBOM() property.
        Parameters:
        ignore - Ignore the BOM?
      • getStrictAmbiguity

        public boolean getStrictAmbiguity()
        If a grammar contains priority pragmas that uniquely determine the outcome of every potentially ambiguous choice, report that the grammar is ambiguous anyway.
        Returns:
        the strict ambiguity setting
      • setStrictAmbiguity

        public void setStrictAmbiguity​(boolean strict)
        Set the getStrictAmbiguity() property.
        Parameters:
        strict - Strictly report ambiguity?
      • pragmaDisabled

        public boolean pragmaDisabled​(java.lang.String pragma)
        Is the specified pragma disabled?

        The user can selectively disable pragmas in a grammar. This method determines whether the specified pragma is disabled.

        Parameters:
        pragma - the pragma name
        Returns:
        true if the pragma is disabled.
      • disablePragma

        public void disablePragma​(java.lang.String pragma)
        Disable the specified pragma.

        The user can selectively ignore pragmas in a grammar. This method specifies that a particular pragma should be disabled. The token "#all" disables all pragmas.

        Parameters:
        pragma - the pragma to disable.
      • enablePragma

        public void enablePragma​(java.lang.String pragma)
        Disable the specified pragma.

        The user can selectively ignore pragmas in a grammar. This method specifies that a particular pragma should be enabled. The token "#all" enables all pragmas.

        Parameters:
        pragma - the state to suppress.
      • getStartSymbol

        public java.lang.String getStartSymbol()
        Where should parsing start?

        Invisible XML defines the start symbol as the symbol defined by the first rule in the grammar. In practice, the parser can start with any symbol in the grammar. This option returns the start symbol, if one was specified, or null. If null is returned, the parser will use the default start symbol. An exception will be raised if the symbol named is not defined in the grammar.

        Returns:
        the start symbol, or null if none was specified
      • setStartSymbol

        public void setStartSymbol​(java.lang.String name)
        Set the getStartSymbol() property.

        This option allows you to specify what the "seed" symbol should be for parsing. This will result in nonconformant parser behavior if the symbol specified isn't the symbol defined by the first rule in the grammar.

        Parameters:
        name - the symbol name
      • getValidateVxml

        public boolean getValidateVxml()
        Should validate VXML grammars?
        Returns:
        true if the grammar should be validated
      • setValidateVxml

        public void setValidateVxml​(boolean validate)
        Set the getValidateVxml() property.
        Parameters:
        validate - true if VXML grammars should be validated