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.
- Source:
Properties:
| Name | Type | Argument | Description |
|---|---|---|---|
expect |
module:EBNF~Set | set of terminals which a node
expects to see as |
|
follow |
module:EBNF~Set |
<nullable> |
see |
Methods
-
check(error, name)
-
Check for ambiguity, override to report an error.
Parameters:
Name Type Description errorfunction should be bound to
grammar.error().namestring current rule, to label errors.
Returns:
error message, if any.
- Type
- undefined | string
-
deep()
-
Manage
.expectduring grammar checking:shallow()acts as getter; override to compute.expectfrom 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.
Returns:
the set, maps terminal names to true.
- Type
- module:EBNF~Set
-
dump()
-
Displays the same as
toString(). -
follow( [increment])
-
Manage
.followduring grammar checking, creates initial set.follow()getter, may returnnull.follow(increment)setter, adds to.follow, creates if necessary, override to compute from right to left.
Parameters:
Name Type Argument Description incrementmodule:EBNF~Set <optional>
<nullable>
controls getter/setter behavior, setter adds.
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 parsermodule:EBNF~Parser context.
Throws:
-
if recognition fails.
- Type
- string
Returns:
the input string.
- Type
- string
-
-
shallow( [increment])
-
Manage
.expectduring grammar checking:shallow()acts as getter; override to compute.expectfrom 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 incrementmodule:EBNF~Set <optional>
<nullable>
controls getter/setter behavior, setter adds.
Returns:
the (incremented) set, maps terminal names to true.
- Type
- module:EBNF~Set