- assert<D, E>(parser: TokenParser<D, E>, assertion: ((state: ParseState<D, E>) => null | E)): TokenParser<D, E>
-
Parameters
-
-
assertion: ((state: ParseState<D, E>) => null | E)
-
- (state: ParseState<D, E>): null | E
-
Returns null | E
- assert<D, E>(parser: SymbolParser<D, E>, assertion: ((state: ParseState<D, E>) => null | E)): SymbolParser<D, E>
-
Parameters
-
-
assertion: ((state: ParseState<D, E>) => null | E)
-
- (state: ParseState<D, E>): null | E
-
Returns null | E
Defines a TokenParser or SymbolParser that will execute
parserand pass it's result toassertion.parserreturns with an error, the error is propagated without executing theassertionassertionevaluates to some Identifiable object, that object will be returned as the error of the assertion.assertionevaluates tonull, then the assertion is considered successful and the result ofparseris propagated.It can be used to attach assertion operations in a
parserresult and determine if a token satisfies specific criteria at that lexical scope.Returns
A new TokenParser or SymbolParser that will execute
parserand attach assertion operations defined byassertion.