- otherwise<TToken, TOptions, TValueA, TValueB>(pa: Parser<TToken, TOptions, TValueA>, pb: Matcher<TToken, TOptions, TValueB>): Matcher<TToken, TOptions, TValueA | TValueB>
-
Type Parameters
-
TToken
-
TOptions
-
TValueA
-
TValueB
Parameters
-
pa: Parser<TToken, TOptions, TValueA>
-
pb: Matcher<TToken, TOptions, TValueB>
Returns Matcher<TToken, TOptions, TValueA | TValueB>
- otherwise<TToken, TOptions, TValueA, TValueB>(pa: Parser<TToken, TOptions, TValueA>, pb: Parser<TToken, TOptions, TValueB>): Parser<TToken, TOptions, TValueA | TValueB>
-
Type Parameters
-
TToken
-
TOptions
-
TValueA
-
TValueB
Parameters
-
pa: Parser<TToken, TOptions, TValueA>
-
pb: Parser<TToken, TOptions, TValueB>
Returns Parser<TToken, TOptions, TValueA | TValueB>
This overload makes a Matcher from a parser and a matcher. If the parser matched - return the match, otherwise return the match from the matcher.
Can be used to keep the matcher type when you have multiple parsing options and the last one always matches.
Combine with choice if you need multiple alternative parsers of the same value type.
Nest calls to have union of more than two different value types derived automatically.
Use option if you just want a constant alternative value without consuming input.