- chain<TToken, TOptions, TValue1, TValue2>(p: Parser<TToken, TOptions, TValue1>, f: ((v1: TValue1, data: Data<TToken, TOptions>, i: number, j: number) => Parser<TToken, TOptions, TValue2>)): Parser<TToken, TOptions, TValue2>
-
Type Parameters
-
TToken
-
TOptions
-
TValue1
-
TValue2
Parameters
-
p: Parser<TToken, TOptions, TValue1>
-
f: ((v1: TValue1, data: Data<TToken, TOptions>, i: number, j: number) => Parser<TToken, TOptions, TValue2>)
-
- (v1: TValue1, data: Data<TToken, TOptions>, i: number, j: number): Parser<TToken, TOptions, TValue2>
-
Parameters
-
v1: TValue1
-
data: Data<TToken, TOptions>
-
i: number
-
j: number
Returns Parser<TToken, TOptions, TValue2>
Returns Parser<TToken, TOptions, TValue2>
Make a parser that runs a given parser, passes the matched value into a parser-generating function and then runs the returned parser.
A nonmatch is returned if any of two parsers did not match.
Similar to decide in that it allows for complex logic.
Use condition if there is no dependency on the value of the first parser.
Combine with chainReduce to get a stack-safe chain of arbitrary length.