Chapter 12Parser options

12.1ParserOptions

The org.nineml.coffeepot.utils.ParserOptions class.

This class extends org.nineml.coffeefilter.ParserOptions.

12.1.1Constructor summary

Public constructors for the org.nineml.coffeepot.utils.ParserOptions class.

public ParserOptions()

Create the parser options.

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

public ParserOptions(Logger logger)

Create the parser options with an explicit logger.

public ParserOptions(ParserOptions copy)

12.1.2Method summary

Public methods on the org.nineml.coffeepot.utils.ParserOptions class.

public void addGraphOption(String name String value)
throws NullPointerException if either name or value is null.

Add a graph option.

public void disablePragma(String pragma)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public void enablePragma(String pragma)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public void exposeState(String state)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean getAllowEmptyAlts()
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean getAllowMultipleDefinitions()
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean getAllowUndefinedSymbols()
Inherited from org.nineml.coffeefilter.ParserOptions

Allow undefined symbols?

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

public boolean getAllowUnproductiveSymbols()
Inherited from org.nineml.coffeefilter.ParserOptions

Allow unproductive symbols?

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

public boolean getAllowUnreachableSymbols()
Inherited from org.nineml.coffeefilter.ParserOptions

Allow unreachable symbols?

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

public boolean getAsciiOnly()

Use only ASCII characters in output?

If this option is true, punctuation in output like the ambiguity description will include only ASCII characters. (Note: this has no effect on the output of the parse.)

public boolean getAssertValidXmlCharacters()
Inherited from org.nineml.coffeefilter.ParserOptions

Raise an exception if invalid XML characters are used in text or attribute values that are serialized.

public boolean getAssertValidXmlNames()
Inherited from org.nineml.coffeefilter.ParserOptions

Raise an exception if invalid XML names are used in nonterminals that are serialized.

public Map<String, String> getGraphOptions()

Get the default graph options.

public String getGraphviz()
Inherited from org.nineml.coffeefilter.ParserOptions

Where’s the GraphViz ‘dot’ command?

public boolean getIgnoreBOM()
Inherited from org.nineml.coffeefilter.ParserOptions

If a UTF-8 input stream begins with a byte order mark (BOM), ignore it.

public boolean getIgnoreTrailingWhitespace()
Inherited from org.nineml.coffeefilter.ParserOptions

Ignore trailing whitespace?

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

public Logger getLogger()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Get the parser logger.

The logger controls what messages are displayed, and how. This component is also used by higher-level components such as CoffeeFilter, CoffeePot, and CoffeeSacks.

public boolean getMarkAmbiguities()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Are ambiguities marked?

CoffeeGrinder doesn’t use this option, but it’s defined here so that it will be passed to CoffeeFilter. If ambiguities are to be marked, additional markup (attributes or processing instructions) are included in the forests returned in order to indicate where ambiguous choices were made).

public boolean getNormalizeLineEndings()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Normalize line endings?

If line endings are normalized, all occurrences of #D, #D#A, #85, and #2028 in the input string are replaced with a single #A. This only applies to sequences of characters in the input.

public String getParserType()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Get the parser type.

The parser type will be “Earley” or “GLL”.

public boolean getPedantic()
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean getPrefixParsing()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Is prefix parsing enabled?

If an Earley parse fails, but some prefix of the input was successfully parsed, make that available for continuing the parse. This is optional mostly because it requires internally buffering some of the input tokens, but probably no more than a few.

public boolean getPrettyPrint()
Inherited from org.nineml.coffeefilter.ParserOptions

Attempt to pretty print the result?

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

public String getPriorityStyle()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Get the priority style.

Priorities can be computed on one of two styles: max or sum.

  • If the priority style is max, the priority of any given node is the highest priority value in the subgraph rooted at that node.

  • If the priority style is sum, the priority of any given node is the sum of the priorities of the nodes in the subgraph below it.

The default is max.

public String getProgressBar()

Display a progress bar?

Three values are valid: “false” disables the display of progress indicators, “true” enables the display unconditionally, and “tty” limits the display to outputs that are believed to be TTYs (i.e., consoles).

The difference between “true” and “tty” is most readily apparent if out is redirected. If the value is “tty”, no progress messages will be written to the output in this case. If the value is “true”, the progress messages will be written to the redirected location.

public String getProgressBarCharacters()

Get progress bar characters.

The first character is used for an “empty” space in the progress bar. The last character is used for a “full” space. Any characters in between the first and the last are used for even fractions between 0 and 1.

public ProgressMonitor getProgressMonitor()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Get the progress monitor.

If a progress monitor is present, it will be called before, during, and after the parse.

public boolean getProvenance()

Should we store provenance information in the output XML?

public boolean getReturnChart()
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Return the Earley chart even for a successful parse?

If this option is enabled, the chart will be returned even for a successful parse. (If the parse fails, the chart is always returned.)

The chart can only be returned if the Earley parser is used. The GLL parser doesn’t manage the parse with state charts in the same way.

public RuleRewriter getRuleRewriter()
Inherited from org.nineml.coffeefilter.ParserOptions

public boolean getShowBnfNonterminals()
Inherited from org.nineml.coffeefilter.ParserOptions

public boolean getShowChart()
Inherited from org.nineml.coffeefilter.ParserOptions

Show the Earley chart in error results?

public boolean getShowMarks()
Inherited from org.nineml.coffeefilter.ParserOptions

public String getStartSymbol()
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean getStrictAmbiguity()
Inherited from org.nineml.coffeefilter.ParserOptions

If a grammar contains priority pragmas that uniquely determine the outcome of every potentially ambiguous choice, report that the grammar is ambiguous anyway.

public boolean getTrailingNewlineOnOutput()
Inherited from org.nineml.coffeefilter.ParserOptions

Make sure the output ends with a newline?

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

public boolean getValidateVxml()
Inherited from org.nineml.coffeefilter.ParserOptions

Should validate VXML grammars?

public boolean isSuppressedState(String state)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public boolean pragmaDisabled(String pragma)
Inherited from org.nineml.coffeefilter.ParserOptions

Is the specified pragma disabled?

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

public void removeGraphOption(String name)

Remove a graph option.

public void setAllowEmptyAlts(boolean allow)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAllowEmptyAlts() ()} property.

public void setAllowMultipleDefinitions(boolean allow)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAllowMultipleDefinitions() property.

public void setAllowUndefinedSymbols(boolean allow)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public void setAllowUnproductiveSymbols(boolean allow)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAllowUnproductiveSymbols() property.

public void setAllowUnreachableSymbols(boolean allow)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAllowUnreachableSymbols() property.

public void setAsciiOnly(boolean ascii)

Set the getAsciiOnly() ()} property.

public void setAssertValidXmlCharacters(boolean valid)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAssertValidXmlCharacters() property.

public void setAssertValidXmlNames(boolean valid)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getAssertValidXmlNames() property.

public void setGraphviz(String dot)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getGraphviz() property.

Setting the path to null disables SVG output.

public void setIgnoreBOM(boolean ignore)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getIgnoreBOM() property.

public void setIgnoreTrailingWhitespace(boolean ignore)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getIgnoreTrailingWhitespace() property.

public void setLogger(Logger logger)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions
throws NullPointerException if the logger is null.

Set the logger.

public void setMarkAmbiguities(boolean mark)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Shall ambiguities be marked?

public void setNormalizeLineEndings(boolean normalize)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Enable normalizing line endings?

See getNormalizeLineEndings().

public void setParserType(String parserType)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions
throws IllegalArgumentException if the parser type is not recognized

Set the parser type.

You must specify “Earley” or “GLL”.

public void setPedantic(boolean pedantic)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public void setPrefixParsing(boolean prefixParsing)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Enable prefix parsing?

public void setPrettyPrint(boolean prettPrint)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getPrettyPrint() property.

public void setPriorityStyle(String style)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions
throws IllegalArgumentException if the style is unrecognized.

Set the priority style.

The style can be max or sum.

public void setProgressBar(String bar)
throws IllegalArgumentException if the value is not supported.

Sets the getProgressBar() property.

The value must be “true”, “false”, or “tty”.

public void setProgressBarCharacters(String chars)
throws IllegalArgumentException if fewer than two characters are provided
throws NullPointerException if chars is null

Sets the getProgressBarCharacters() property.

public void setProgressMonitor(ProgressMonitor monitor)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Set the progress monitor.

Setting the monitor to null disables monitoring.

public void setProvenance(boolean outputProvenance)

Set the getProvenance() property.

public void setReturnChart(boolean returnChart)
Inherited from org.nineml.coffeegrinder.parser.ParserOptions

Set the return chart property.

See getReturnChart().

public void setRuleRewriter(RuleRewriter rewriter)
Inherited from org.nineml.coffeefilter.ParserOptions

public void setShowBnfNonterminals(boolean show)
Inherited from org.nineml.coffeefilter.ParserOptions

public void setShowChart(boolean show)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getShowChart() property.

public void setShowMarks(boolean show)
Inherited from org.nineml.coffeefilter.ParserOptions

public void setStartSymbol(String name)
Inherited from org.nineml.coffeefilter.ParserOptions

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.

public void setStrictAmbiguity(boolean strict)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getStrictAmbiguity() property.

public void setTrailingNewlineOnOutput(boolean newline)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getTrailingNewlineOnOutput() property.

public void setValidateVxml(boolean validate)
Inherited from org.nineml.coffeefilter.ParserOptions

Set the getValidateVxml() property.

public void showOptions(PrintStream stderr)

public void suppressState(String state)
Inherited from org.nineml.coffeefilter.ParserOptions

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.