Class: Seq

EBNF~ Seq

Represents a sequence of nodes, i.e., one alternative.


new Seq(nodes [, terminal])

Creates a sequence of nodes, i.e., one alternative; see factory method grammar.seq().

Parameters:
Name Type Argument Description
nodes Array.<(module:Base~Symbol|module:EBNF~Opt|module:EBNF~Some)>

descendants, not empty, not all Opt.

terminal module:Base~T <optional>
<nullable>

can define precedence; only for translation to BNF.

Properties:
Name Type Argument Description
nodes Array.<(module:Base~Symbol|module:EBNF~Opt|module:EBNF~Some)>

descendants, not empty, not all Opt.

terminal module:Base~T <optional>
<nullable>

can define precedence; only for translation to BNF.

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().

Mixes In:
Source:

Methods


check(error, name)

Check for ambiguity: delegate to descendants.

Parameters:
Name Type Description
error function

should be bound to grammar.error().

name string

current rule.

Source:
Returns:

error message, if any.

Type
undefined | string

deep()

Override getter: computes the set from right to left, implements optional.

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 sets descendants, pushing from right to left; implements optional.

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

controls getter/setter behavior, setter adds.

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 a sequence of descendants; implements Opt with a result of null or the collected array.

Parameters:
Name Type Description
parser module:EBNF~Parser

context.

Source:
Throws:

if recognition fails.

Type
string
Returns:

list of results produced by the descendants, cannot be empty, see parser.parse().

Type
Array

shallow( [increment])

Override getter: computes .expect from left to right as far as necessary.

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

controls getter/setter behavior, setter adds.

Source:
See:
  • {linkcode module:EBNF~Node#shallow Node.shallow(increment)}.
Throws:

Seq: all elements are optional (cannot happen)

Type
Error
Returns:

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

Type
module:EBNF~Set

toString()

Displays all descendants and precedence terminal, if any.

Source:
Returns:
Type
string