It defines a TokenParser that will match parser if it matches. If parser does not match, it will not consume any input and stay in place.
parser
It works like the question mark ( ? ) operator in regular expressions.
The same behavior is implemented for SymbolParser in the following way:
const optional_a: SymbolParser<null, null> = alternatives([ recursive(str('a')), empty, ]);
A new TokenParser that will optionally match parser.
The parser to be optionally matched.
It defines a TokenParser that will match
parser
if it matches. Ifparser
does not match, it will not consume any input and stay in place.It works like the question mark ( ? ) operator in regular expressions.
The same behavior is implemented for SymbolParser in the following way:
Returns
A new TokenParser that will optionally match
parser
.