Class ParserOptions
- java.lang.Object
-
- org.nineml.coffeegrinder.parser.ParserOptions
-
- org.nineml.coffeefilter.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 Summary
Constructors Constructor Description ParserOptions()
Create the parser options.ParserOptions(ParserOptions copy)
Create a new set of options from an existing set.ParserOptions(org.nineml.logging.Logger logger)
Create the parser options with an explicit logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disablePragma(java.lang.String pragma)
Disable the specified pragma.void
enablePragma(java.lang.String pragma)
Disable the specified pragma.void
exposeState(java.lang.String state)
Expose a state.boolean
getAllowEmptyAlts()
Allow empty string to represent an alternative?boolean
getAllowMultipleDefinitions()
Allow multiple definitions?boolean
getAllowUndefinedSymbols()
Allow undefined symbols?boolean
getAllowUnproductiveSymbols()
Allow unproductive symbols?boolean
getAllowUnreachableSymbols()
Allow unreachable symbols?boolean
getAssertValidXmlCharacters()
Raise an exception if invalid XML characters are used in text or attribute values that are serialized.boolean
getAssertValidXmlNames()
Raise an exception if invalid XML names are used in nonterminals that are serialized.java.lang.String
getGraphviz()
Where's the GraphViz 'dot' command?boolean
getIgnoreBOM()
If a UTF-8 input stream begins with a byte order mark (BOM), ignore it.boolean
getIgnoreTrailingWhitespace()
Ignore trailing whitespace?boolean
getPedantic()
Enforce strict compliance to the Invisible XML specification.boolean
getPrettyPrint()
Attempt to pretty print the result?org.nineml.coffeefilter.model.RuleRewriter
getRuleRewriter()
boolean
getShowBnfNonterminals()
boolean
getShowChart()
Show the Earley chart in error results?boolean
getShowMarks()
java.lang.String
getStartSymbol()
Where should parsing start?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.boolean
getTrailingNewlineOnOutput()
Make sure the output ends with a newline?boolean
getValidateVxml()
Should validate VXML grammars?boolean
isSuppressedState(java.lang.String state)
Is the specified state suppressed?boolean
pragmaDisabled(java.lang.String pragma)
Is the specified pragma disabled?void
setAllowEmptyAlts(boolean allow)
Set thegetAllowEmptyAlts()
()} property.void
setAllowMultipleDefinitions(boolean allow)
Set thegetAllowMultipleDefinitions()
property.void
setAllowUndefinedSymbols(boolean allow)
Set thegetAllowUndefinedSymbols()
property.void
setAllowUnproductiveSymbols(boolean allow)
Set thegetAllowUnproductiveSymbols()
property.void
setAllowUnreachableSymbols(boolean allow)
Set thegetAllowUnreachableSymbols()
property.void
setAssertValidXmlCharacters(boolean valid)
Set thegetAssertValidXmlCharacters()
property.void
setAssertValidXmlNames(boolean valid)
Set thegetAssertValidXmlNames()
property.void
setGraphviz(java.lang.String dot)
Set thegetGraphviz()
property.void
setIgnoreBOM(boolean ignore)
Set thegetIgnoreBOM()
property.void
setIgnoreTrailingWhitespace(boolean ignore)
Set thegetIgnoreTrailingWhitespace()
property.void
setPedantic(boolean pedantic)
Set thegetPedantic()
property.void
setPrettyPrint(boolean prettPrint)
Set thegetPrettyPrint()
property.void
setRuleRewriter(org.nineml.coffeefilter.model.RuleRewriter rewriter)
void
setShowBnfNonterminals(boolean show)
void
setShowChart(boolean show)
Set thegetShowChart()
property.void
setShowMarks(boolean show)
void
setStartSymbol(java.lang.String name)
Set thegetStartSymbol()
property.void
setStrictAmbiguity(boolean strict)
Set thegetStrictAmbiguity()
property.void
setTrailingNewlineOnOutput(boolean newline)
Set thegetTrailingNewlineOnOutput()
property.void
setValidateVxml(boolean validate)
Set thegetValidateVxml()
property.void
suppressState(java.lang.String state)
Suppress a state.-
Methods inherited from class org.nineml.coffeegrinder.parser.ParserOptions
getLogger, getMarkAmbiguities, getNormalizeLineEndings, getParserType, getPrefixParsing, getPriorityStyle, getProgressMonitor, getReturnChart, setLogger, setMarkAmbiguities, setNormalizeLineEndings, setParserType, setPrefixParsing, setPriorityStyle, setProgressMonitor, setReturnChart
-
-
-
-
Constructor Detail
-
ParserOptions
public ParserOptions()
Create the parser options.The initial logger will be a
DefaultLogger
initialized withLogger.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)
Set thegetIgnoreTrailingWhitespace()
property.- 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)
Set thegetTrailingNewlineOnOutput()
property.- 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 thegetAllowUndefinedSymbols()
property.Allowing undefined symbols implies
getAllowUnproductiveSymbols()
andgetAllowUndefinedSymbols()
. 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)
Set thegetAllowUnreachableSymbols()
property.- 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)
Set thegetAllowUnproductiveSymbols()
property.- 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)
Set thegetAllowMultipleDefinitions()
property.- 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 definesS
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 thegetAllowEmptyAlts()
()} 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 thegetPrettyPrint()
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 thegetShowChart()
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 thegetGraphviz()
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 thegetAssertValidXmlNames()
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)
Set thegetAssertValidXmlCharacters()
property.- 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 thegetPedantic()
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 thegetIgnoreBOM()
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 thegetStrictAmbiguity()
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 thegetStartSymbol()
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 thegetValidateVxml()
property.- Parameters:
validate
- true if VXML grammars should be validated
-
-