Function
| Static Public Summary | ||
| public |
alphabet(productions: *): * |
|
| public |
anyIterator(object: *): * |
|
| public |
List all reasons why a given grammar is not ll(1). |
|
| public |
Compiles the predictive parsing table for a grammar. |
|
| public |
expandobject(object: *): * |
|
| public |
async * flatten(root: *) |
|
| public |
Generate FOLLOW set for any rule given the FOLLOW sets for the nonterminals. |
|
| public |
from(object: *): * |
|
| public |
from(grammar: *): * |
|
| public |
Check if grammar is ll(1). |
|
| public |
Applies a given callable to each of the child of a given children async iterable. |
|
| public |
async materialize(root: *): * |
|
| public |
Parse |
|
| public |
Applies a given callable to each part of a given grammar rule (given as an iterable). |
|
| public |
Adds an element to a set and returns true if the set has changed. |
|
| public |
Adds all elements of an iterable to a set and returns true if the set has changed. |
|
| public |
async transform(tree: *, match: *, ctx: *): * |
|
| Static Private Summary | ||
| private |
async _children_exhaust(children: Iterator) Exhausts the input children iterator. |
|
| private |
async _children_next_lazy(eof: Object, productions: Map, table: Map, tape: Tape, expected: Object): Promise<object> Get next child of table-driven predictive lazy parsing. |
|
| private |
Generates the rows of the predictive parsing table for a grammar. |
|
| private |
* _expandproduction(production: *) |
|
| private |
Computes the FOLLOW table for all nonterminals. |
|
| private |
_parse_lazy(eof: Object, productions: Map, table: Map, rule: Array, tape: Tape, nonterminal: String, production: String): Object Table-driven predictive lazy parsing. |
|
Static Public
public alphabet(productions: *): * source
import alphabet from '@formal-language/grammar/src/grammar/alphabet.js'Params:
| Name | Type | Attribute | Description |
| productions | * |
Return:
| * |
public anyIterator(object: *): * source
import anyIterator from '@formal-language/grammar/src/util/anyIterator.js'Params:
| Name | Type | Attribute | Description |
| object | * |
Return:
| * |
public * audit(grammar: Grammar): IterableIterator<any> source
import audit from '@formal-language/grammar/src/ll1/audit.js'List all reasons why a given grammar is not ll(1).
Params:
| Name | Type | Attribute | Description |
| grammar | Grammar |
Return:
| IterableIterator<any> |
public compile(productions: Map): Map source
import compile from '@formal-language/grammar/src/ll1/compile.js'Compiles the predictive parsing table for a grammar. Corresponds to Algorithm 4.31 in Dragon Book (2006) on page 224.
Params:
| Name | Type | Attribute | Description |
| productions | Map |
public expandobject(object: *): * source
import expandobject from '@formal-language/grammar/src/grammar/expandobject.js'Params:
| Name | Type | Attribute | Description |
| object | * |
Return:
| * |
public async * flatten(root: *) source
import flatten from '@formal-language/grammar/src/ast/flatten.js'Params:
| Name | Type | Attribute | Description |
| root | * |
public follow(FOLLOW: Map, rule: Array): Set source
import follow from '@formal-language/grammar/src/ll1/follow.js'Generate FOLLOW set for any rule given the FOLLOW sets for the nonterminals.
public from(object: *): * source
import from from '@formal-language/grammar/src/grammar/from.js'Params:
| Name | Type | Attribute | Description |
| object | * |
Return:
| * |
public from(grammar: *): * source
import from from '@formal-language/grammar/src/ll1/from.js'Params:
| Name | Type | Attribute | Description |
| grammar | * |
Return:
| * |
public is(grammar: Grammar): Boolean source
import is from '@formal-language/grammar/src/ll1/is.js'Check if grammar is ll(1).
Params:
| Name | Type | Attribute | Description |
| grammar | Grammar |
public map(callable: Function, children: AsyncIterable): AsyncIterable source
import map from '@formal-language/grammar/src/ast/map.js'Applies a given callable to each of the child of a given children async iterable.
Params:
| Name | Type | Attribute | Description |
| callable | Function | The callable to use. |
|
| children | AsyncIterable | The input children. |
Return:
| AsyncIterable |
public async materialize(root: *): * source
import materialize from '@formal-language/grammar/src/ast/materialize.js'Params:
| Name | Type | Attribute | Description |
| root | * |
Return:
| * |
public parse(root: *, start: *, eof: *, productions: *, table: *, tape: *): Object source
import parse from '@formal-language/grammar/src/ll1/parse.js'Parse
Params:
| Name | Type | Attribute | Description |
| root | * | ||
| start | * | ||
| eof | * | ||
| productions | * | ||
| table | * | ||
| tape | * |
public async * rmap(callable: Function, rule: Iterable): AsyncIterator source
import rmap from '@formal-language/grammar/src/ast/rmap.js'Applies a given callable to each part of a given grammar rule (given as an iterable).
Params:
| Name | Type | Attribute | Description |
| callable | Function | The callable to use. |
|
| rule | Iterable | The input grammar rule. |
Return:
| AsyncIterator |
public setadd(set: Set<any>, element: any): boolean source
import setadd from '@formal-language/grammar/src/util/setadd.js'Adds an element to a set and returns true if the set has changed.
Params:
| Name | Type | Attribute | Description |
| set | Set<any> | The set to add to. |
|
| element | any | The element to add to the set. |
public setaddall(set: Set<any>, iterable: Iterable<any>): boolean source
import setaddall from '@formal-language/grammar/src/util/setaddall.js'Adds all elements of an iterable to a set and returns true if the set has changed.
Params:
| Name | Type | Attribute | Description |
| set | Set<any> | The set to add to. |
|
| iterable | Iterable<any> | The iterable of elements to add to the set. |
public async transform(tree: *, match: *, ctx: *): * source
import transform from '@formal-language/grammar/src/ast/transform.js'Params:
| Name | Type | Attribute | Description |
| tree | * | ||
| match | * | ||
| ctx | * |
Return:
| * |
Static Private
private async _children_exhaust(children: Iterator) source
import _children_exhaust from '@formal-language/grammar/src/ast/_children_exhaust.js'Exhausts the input children iterator.
Params:
| Name | Type | Attribute | Description |
| children | Iterator | The input children iterator. |
private async _children_next_lazy(eof: Object, productions: Map, table: Map, tape: Tape, expected: Object): Promise<object> source
import _children_next_lazy from '@formal-language/grammar/src/ll1/_children_next_lazy.js'Get next child of table-driven predictive lazy parsing.
private * _compile(productions: Map): Iterable source
import _compile from '@formal-language/grammar/src/ll1/_compile.js'Generates the rows of the predictive parsing table for a grammar. Corresponds to Algorithm 4.31 in Dragon Book (2006) on page 224.
Params:
| Name | Type | Attribute | Description |
| productions | Map |
Return:
| Iterable |
private * _expandproduction(production: *) source
import _expandproduction from '@formal-language/grammar/src/grammar/_expandproduction.js'Params:
| Name | Type | Attribute | Description |
| production | * |
private _follow(FIRST: Map, productions: Map): Map source
import _follow from '@formal-language/grammar/src/ll1/_follow.js'Computes the FOLLOW table for all nonterminals.
private _parse_lazy(eof: Object, productions: Map, table: Map, rule: Array, tape: Tape, nonterminal: String, production: String): Object source
import _parse_lazy from '@formal-language/grammar/src/ll1/_parse_lazy.js'Table-driven predictive lazy parsing.
Params:
| Name | Type | Attribute | Description |
| eof | Object | The end-of-file symbol. |
|
| productions | Map | The ll1 productions. |
|
| table | Map | The symbol table. |
|
| rule | Array | The production rule in use. |
|
| tape | Tape | The tape from which to read the symbols from. |
|
| nonterminal | String | The nonterminal that produced |
|
| production | String | The production that corresponds to |
