Function choice

  • Defines a TokenParser that will match the first parser from parsers that can be matched. It employs backtracking by defining the current point as a backtrackable state and trying to parse from this point onwards. If a parser from parsers succeeds, it continues from that point onwards. If no one of parsers matches, an error with a semantic error value returned by matchError gets returned.

    It can be used to add backtracking to a parser.

    It is the equivalent to alternatives for SymbolParser. It works like the pipe ( | ) operator from regexes

    Returns

    A new TokenParser that will match the first one from parsers that can match.

    See

    alternatives

    Type Parameters

    Parameters

    Returns TokenParser<D, E>