Mixin: Node

EBNF~ Node

Acts as a superclass of all elements of a grammar tree, specifies the methods to recursively check LL(1) and defines the parse method for terminal symbols.

Properties:
Name Type Argument Description
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:

Methods


check(error, name)

Check for ambiguity, override to report an error.

Parameters:
Name Type Description
error function

should be bound to grammar.error().

name string

current rule, to label errors.

Source:
Returns:

error message, if any.

Type
undefined | string

deep()

Manage .expect during grammar checking:

  • shallow() acts as getter; override to compute .expect from left to right as far as necessary.
  • shallow( increment ) acts as setter; adds to .expect.
  • deep() also acts as getter, override to completely compute .expect.
Source:
Returns:

the set, maps terminal names to true.

Type
module:EBNF~Set

dump()

Displays the same as toString().

Source:

follow( [increment])

Manage .follow during grammar checking, creates initial set.

  • follow() getter, may return null.
  • follow( increment ) setter, adds to .follow, creates if necessary, override to compute from right to left.
Parameters:
Name Type Argument Description
increment module:EBNF~Set <optional>
<nullable>

controls getter/setter behavior, setter adds.

Source:
Returns:

getter: the set, maps terminal names to true, setter: undefined.

Type
module:EBNF~Set

parse(parser)

Consume the current input symbol (because it is expected). This method should be redefined in all but the classes representing terminal symbols.

Parameters:
Name Type Description
parser module:EBNF~Parser

context.

Source:
Throws:

if recognition fails.

Type
string
Returns:

the input string.

Type
string

shallow( [increment])

Manage .expect during grammar checking:

  • shallow() acts as getter; override to compute .expect from left to right as far as necessary.
  • shallow( increment ) acts as setter; adds to .expect.
  • deep() also acts as getter, override to completely compute .expect.
Parameters:
Name Type Argument Description
increment module:EBNF~Set <optional>
<nullable>

controls getter/setter behavior, setter adds.

Source:
Returns:

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

Type
module:EBNF~Set