Chapter 5. Parser options
There are two kinds of parser options: parser construction options and Invisible XML parser options. For convenience, they’re both allowed in the same options map.
5.1. Parser construction options
type
, stringThe input type. One of
ixml
(an invisible XML grammar),xml
orvxml
(a visible XML grammar), orcxml
orcompiled
(a compiled XML grammar).In most circumstances, you don’t need to specify the input type.
format
, stringThe output type. One of
xml
(an XML node; the default),json
orjson-data
(a “data” map), orjson-text
(a “text” map).choose-alternative
, functionA function that will be called to choose between alternatives when the parse is ambiguous. The function must have one argument, a sequence of elements, and must return an
xs:integer
. See Chapter 7, Choosing among alternatives.
5.2. Invisible XML parser options
The following parser options are recognized:
ignoreTrailingWhitespace
, booleanIf true, trailing whitespace on the document input string is ignored.
suppressAmbiguousState
, booleanIf a parse is ambiguous, Invisible XML mandates that an
ixml:state
attribute be added to the root element contining the valueambiguous
. If this option is true, that state will be suppressed.suppressPrefixState
, booleanIf a parse consumes only a (proper) prefix of the input, Invisible XML mandates that an
ixml:state
attribute be added to the root element contining the valueprefix
. If this option is true, that state will be suppressed.allowUndefinedSymbols
, booleanIf true, the parser will attempt to use a grammar that contains undefined symbols.
allowUnreachableSymbols
, booleanIf true, the parser will attempt to use a grammar that contains unreachable symbols.
allowUnproductiveSymbols
, booleanIf true, the parser will attempt to use a grammar that contains unproductive symbols.
allowMultipleDefinitions
, booleanIf true, the parser will attempt to use a grammar that contains multiple definitions for a given nonterminal.
allowMultipleDefinitions
, booleanIf true, the parser will attempt to use a grammar that contains multiple definitions for a given nonterminal.
showMarks
, booleanIf true, the parser will return all of the nonterminals in your grammar as elements, irrespective of their marks. The actual mark will be returned in an
ixml:mark
attribute.showBnfNonterminals
, booleanIf true, the parser will return all of the otherwise hidden nonterminals used in the parse.
parser
, stringSelects the parser type,
Earley
for the Earley parser andGLL
for the GLL parser. The Earley parser is the default.
The function will log errors (unrecognized options or values) and ignore the option.