class Parser<S, Token>
package hxparse
Parser is the base class for all custom parsers.
The intended usage is to extend it and utilize its method as an API where required.
Constructor
Variables
read onlylast:Token
Returns the last matched token.
This is a convenience property for accessing cache[offset - 1]
.
Methods
privateinline junk ():Void
Consumes the current token.
This method is automatically called after a successful match.
privateparseOptional<T> (f:Void ‑> T):T
Returns the result of calling f()
if a match is made, or null
otherwise.
privateparseRepeat<T> (f:Void ‑> T):Array<T>
Calls f
until no match can be made.
The result is an Array containing the results of all calls to f
.
privateparseSeparated<T> (separatorFunc:Token ‑> Bool, f:Void ‑> T):Array<T>
Invokes f
and then separatorFunc
with the current token until the
result of that call is false
.
The result is an Array containing the results of all calls to f
.
A typical use case is parsing function arguments which are separated by a comma.