Private
currentThe current target for the current execution.
Each execution has a unique target that stays the same during execution. When the target changes, we know that a new execution takes place and can clear the memotable.
Private
memotableA memoisation table to map ParseState inputs to ParseState outputs produced by the parser, for those inputs.
Readonly
transformerThe state transformer function that performs the parser logic.
Runs the parser for the specified target
and optional index
and data
asynchronously
Returns a promise that resolves to an array that contains a single ParseState result for compatibility with the SymbolParser interface.
A promise which resolves to an array containing a single ParseState with the parse result or an error.
The complete input to be parsed.
Optional
data: DAn optional initial semantic value. Defaults to null
Optional
index: numberAn optional initial index in the target
. Defaults to 0.
Runs this
parser for the specified input target
, with optional
index
and data
semantic value.
Returns an array that contains a single ParseState result for compatibility with the SymbolParser interface.
An array containing a single ParseState with the parse result or an error.
The complete input to be parsed.
Optional
data: DAn optional initial semantic value. Defaults to null
Optional
index: numberAn optional initial index in the target
. Defaults to 0.
A parser with recursive-descent like parsing capabilities.
It can be used to define any LL(k) parser with arbitrary k lookahead, but it falls short of recognising grammars with
It uses a simple approach to parsing where each parser applies a ParseStateTransformer to the input ParseState and returns the result of the ParseStateTransformer transformation.
All parsers of this type resolve their parsing in O(n) linear time to the input. They will all return a single parse result (no ambiguity is supported) or an error.
Localised Memoisation is employed on the parser level to store intermediate results for specific inputs and prevent recalculations and loops that might occur. There exists an automatic flush policy on each parser where the memoisation tables will be flushed each time the target of parsing changes, where it usually means that a new parsing is requested and, thus, the old memoisation table entries are now irrelevant. This is there to prevent heap allocation issues that might occur.