Function recovery

  • Defines a TokenParser that, in case of an error passed to it, will succeed with the provided data semantic value.

    If it is passed a ParseResult, it will propagate it onwards with no change. If it is passed a ParseError, it will return the provided data semantic value and parsing will continue from that point onwards.

    It enables error recovery capabilities and defines a synchronisation point at the position where it gets placed.

    Returns

    A new TokenParser whose execution will succeed with a valid result or data in case of an error passed to it.

    See

    error

    Type Parameters

    Parameters

    • data: D

      A semantic value to be returned in case of an error result.

    Returns TokenParser<D, E>