Class: Opt

EBNF~ Opt

Represents an optional list of alternatives. Note that Seq implements optional.


new Opt(seqs)

Creates an optional list of alternatives; see opt() factory method.

Parameters:
Name Type Description
seqs Array.<module:EBNF~Seq>

the alternatives.

Properties:
Name Type Argument Description
seqs Array.<module:EBNF~Seq>

the alternatives.

expect module:EBNF~Set

set of terminals which a node expects to see as parser.current.t, maps terminal names to true; expect is not empty.

follow module:EBNF~Set <nullable>

see node.follow().

Source:

Extends

Methods


check(error, name)

Check for ambiguity: expect and follow must be disjoint; delegate to superclass.

Parameters:
Name Type Description
error function

should be bound to grammar.error().

name string

current rule.

Overrides:
Source:
Returns:

error message, if any.

Type
undefined | string

deep()

Override getter: computes the set as sum over all descendants.

Inherited From:
Overrides:
Source:
See:
  • {linkcode module:EBNF~Node#deep Node.deep(increment)}.
Returns:

the set, maps terminal names to true.

Type
module:EBNF~Set

follow( [increment])

Override setter: sets me and all descendants.

Parameters:
Name Type Argument Description
increment module:EBNF~Set <optional>
<nullable>

controls getter/setter behavior, setter adds.

Inherited From:
Overrides:
Source:
See:
  • {linkcode module:EBNF~Node#follow Node.fallow(increment)}.
Returns:

the set, maps terminal names to true.

Type
module:EBNF~Set

parse(parser)

Recognizes one of several alternatives.

Parameters:
Name Type Description
parser module:EBNF~Parser

context.

Inherited From:
Overrides:
Source:
Throws:

if recognition fails.

Type
string
Returns:

the list produced by the selected descendant Seq, see parser.parse().

Type
Array

shallow( [increment])

Override getter: computes the set as sum over all descendants.

Parameters:
Name Type Argument Description
increment module:EBNF~Set <optional>
<nullable>

controls getter/setter behavior, setter adds.

Inherited From:
Overrides:
Source:
See:
  • {linkcode module:EBNF~Node#shallow Node.shallow(increment)}.
Returns:

the (incremented) set, maps terminal names to true.

Type
module:EBNF~Set

toString()

Displays alternatives in brackets.

Overrides:
Source:
Returns:
Type
string