Class ParserOptions
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
ConstructorsConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionvoiddisablePragma(String pragma) Disable the specified pragma.voidenablePragma(String pragma) Disable the specified pragma.voidexposeState(String state) Expose a state.booleanAllow empty string to represent an alternative?booleanAllow multiple definitions?booleanAllow undefined symbols?booleanAllow unproductive symbols?booleanAllow unreachable symbols?booleanRaise an exception if invalid XML characters are used in text or attribute values that are serialized.booleanRaise an exception if invalid XML names are used in nonterminals that are serialized.Where's the GraphViz 'dot' command?booleanIf a UTF-8 input stream begins with a byte order mark (BOM), ignore it.booleanIgnore trailing whitespace?booleanAttempt to parse modular grammars?booleanEnforce strict compliance to the Invisible XML specification.booleanAttempt to pretty print the result?org.nineml.coffeefilter.model.RuleRewriternet.sf.saxon.ConfigurationGet the Saxon configuration that will be used by CoffeeFilter.booleanbooleanShow the Earley chart in error results?booleanWhere should parsing start?booleanIf a grammar contains priority pragmas that uniquely determine the outcome of every potentially ambiguous choice, report that the grammar is ambiguous anyway.booleanMake sure the output ends with a newline?booleanShould validate VXML grammars?booleanisSuppressedState(String state) Is the specified state suppressed?booleanpragmaDisabled(String pragma) Is the specified pragma disabled?voidsetAllowEmptyAlts(boolean allow) Set thegetAllowEmptyAlts()()} property.voidsetAllowMultipleDefinitions(boolean allow) Set thegetAllowMultipleDefinitions()property.voidsetAllowUndefinedSymbols(boolean allow) Set thegetAllowUndefinedSymbols()property.voidsetAllowUnproductiveSymbols(boolean allow) Set thegetAllowUnproductiveSymbols()property.voidsetAllowUnreachableSymbols(boolean allow) Set thegetAllowUnreachableSymbols()property.voidsetAssertValidXmlCharacters(boolean valid) Set thegetAssertValidXmlCharacters()property.voidsetAssertValidXmlNames(boolean valid) Set thegetAssertValidXmlNames()property.voidsetGraphviz(String dot) Set thegetGraphviz()property.voidsetIgnoreBOM(boolean ignore) Set thegetIgnoreBOM()property.voidsetIgnoreTrailingWhitespace(boolean ignore) Set thegetIgnoreTrailingWhitespace()property.voidsetModularity(boolean modularity) Set thegetModularity()property.voidsetPedantic(boolean pedantic) Set thegetPedantic()property.voidsetPrettyPrint(boolean prettPrint) Set thegetPrettyPrint()property.voidsetRuleRewriter(org.nineml.coffeefilter.model.RuleRewriter rewriter) voidsetSaxonConfiguration(net.sf.saxon.Configuration saxonConfiguration) Set the Saxon configuration to be used by this instance of CoffeeFilter.voidsetShowBnfNonterminals(boolean show) voidsetShowChart(boolean show) Set thegetShowChart()property.voidsetShowMarks(boolean show) voidsetStartSymbol(String name) Set thegetStartSymbol()property.voidsetStrictAmbiguity(boolean strict) Set thegetStrictAmbiguity()property.voidsetTrailingNewlineOnOutput(boolean newline) Set thegetTrailingNewlineOnOutput()property.voidsetValidateVxml(boolean validate) Set thegetValidateVxml()property.voidsuppressState(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 Details
-
ParserOptions
public ParserOptions()Create the parser options.The initial logger will be a
DefaultLoggerinitialized withLogger.readSystemProperties(). -
ParserOptions
public ParserOptions(org.nineml.logging.Logger logger) Create the parser options with an explicit logger.- Parameters:
logger- the logger.
-
ParserOptions
Create a new set of options from an existing set.- Parameters:
copy- the options to copy
-
-
Method Details
-
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 definesSto 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
Where's the GraphViz 'dot' command?- Returns:
- the path of the dot command.
-
setGraphviz
Set thegetGraphviz()property.Setting the path to
nulldisables SVG output.- Parameters:
dot- the path to the dot command.
-
isSuppressedState
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
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
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
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
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
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
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
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
-
getModularity
public boolean getModularity()Attempt to parse modular grammars?- Returns:
- true if the grammar should be parsed with the modularity grammar.
-
setModularity
public void setModularity(boolean modularity) Set thegetModularity()property.- Parameters:
modularity- true if a modular parse should be attempted
-
getSaxonConfiguration
public net.sf.saxon.Configuration getSaxonConfiguration()Get the Saxon configuration that will be used by CoffeeFilter.A processor is required when managing modular grammars.
- Returns:
- the processor
-
setSaxonConfiguration
public void setSaxonConfiguration(net.sf.saxon.Configuration saxonConfiguration) Set the Saxon configuration to be used by this instance of CoffeeFilter.- Parameters:
saxonConfiguration- the configuration
-