new Rule(nt, seqs)
Creates an EBNF rule;
see rule() factory method.
Parameters:
| Name | Type | Description |
|---|---|---|
nt |
module:EBNF~NT | left-hand side, non-terminal. |
seqs |
Array.<module:EBNF~Seq> | the alternatives on the right-hand side. |
- Source:
Properties:
| Name | Type | Argument | Description |
|---|---|---|---|
nt |
module:EBNF~NT | rule's non-terminal (left-hand side). |
|
recursed |
number | counts nesting during shallow lookahead computation for all rules. |
|
reached |
boolean | true if rule is reached during deep lookahead computation from the start rule; avoids multiple computations. |
|
seqs |
Array.<module:EBNF~Seq> | the alternatives. |
|
expect |
module:EBNF~Set | set of terminals which a node
expects to see as |
|
follow |
module:EBNF~Set |
<nullable> |
see |
Extends
Methods
-
check(error, name)
-
Check for ambiguity: descendants'
expectmust be disjoint.Parameters:
Name Type Description errorfunction should be bound to
grammar.error().namestring current rule.
- Inherited From:
- Overrides:
- Source:
Returns:
error message, if any.
- Type
- undefined | string
-
deep()
-
Override getter: sets
.reached, inherits: computes the set as sum over all descendants.- 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 incrementmodule: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)
-
Delegates to superclass to recognize the descendants and processes the result with the corresponding action if any. The rule name selects either a
function-valued property or a method of theactionsobject.Parameters:
Name Type Description parsermodule:EBNF~Parser context.
- Overrides:
- Source:
Throws:
-
if recognition fails or if the action throws.
- Type
- string
Returns:
the result produced by the selected descendant and modified by the action, if any, see
parser.parse(). -
shallow( [increment])
-
Override getter: if left recursion returns empty set (which cannot happen...); otherwise inherits: computes the set as sum over all descendants.
Parameters:
Name Type Argument Description incrementmodule:EBNF~Set <optional>
<nullable>
controls getter/setter behavior, setter adds.
- 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 a rule in EBNF notation.
- Overrides:
- Source:
Returns:
- Type
- string