Class: Rule

BNF~ Rule

Represents a BNF rule, i.e., an ordered pair.


new Rule(nt, symbols, index [, prec])

Creates a BNF rule; see rule() factory method.

Parameters:
Name Type Argument Description
nt module:BNF~NT

left-hand side, non-terminal.

symbols Array.<module:Base~Symbol>

right-hand side.

index number

rule's index in module:BNF~Grammar.rules.

prec Object <optional>
<nullable>

precedence, if any.

Properties:
Name Type Argument Description
nt module:BNF~NT

rule's non-terminal (left-hand side).

symbols Array.<module:Base~Symbol>

rule's right-hand side.

index number

rule's index in grammar.rules.

empty boolean

computed from .symbols.

reached boolean

true if this can be reached from rule zero.

finite boolean

true if all non-terminals in the right-hand side have module:BNF~NT.finite set.

first Object.<number, module:BNF~T>

terminals at front, maps ord to module:BNF~T.

reduced boolean

true if this rule has been reduced.

prec Object <nullable>

precedence.

Properties
Name Type Description
assoc string

associativity, '%left', '%right' or '%nonassoc' if any.

level number

precedence level, from 0.

t module:BNF~T

terminal providing the precedence.

Source:

Methods


dump()

Displays index, rule, empty, and content of first.

Source:
Returns:
Type
string

toString( [mark])

Displays a rule in BNF notation.

Parameters:
Name Type Argument Description
mark number <optional>

precedes a symbol on the right-hand side if it is in range.

Source:
Returns:
Type
string