Function error

  • Defines a TokenParser that, in case of a valid result passed to it, will fail with the provided error semantic value.

    If it is passed a ParseError, it will propagate it onwards with no change. If it is passed a ParseResult, it will return the provided error ParseError and parsing will stop at that point.

    It enables error rules to be defined, that will define a part of the grammar that should always fail when detected.

    Returns

    A new TokenParser whose execution will fail with an error or error in case a valid result is passed to it.

    Type Parameters

    Parameters

    • error: E

      An error semantic value to be returned in case of a valid result.

    Returns TokenParser<D, E>