Documentation

ParseIt.Error

Parser errors #

The class ParseIt.Error is used throughout the library to report parsing errors. Users are encouraged to provide instances tailored to their applications.

Three general purpose instances are provided:

class ParseIt.HasPos (ι : Type u) (τ : outParam (Type u)) [Std.Iterator ι Id τ] :
Type (u + 1)

Position information for error reporting.

  • Pos : Type u

    Position type.

  • pos : Std.Iter τ → Pos ι

    Current position of an iterator.

Instances
    class ParseIt.Error (ε ι : Type u) (τ : outParam (Type u)) [Std.Iterator ι Id τ] :

    Parser error class

    • unexpected it t reports unexpected input at iterator it, optionally with the offending token.
    • addMessage e it msg adds information to error e at iterator it.
    • merge e₁ e₂ combines the errors of two failed alternatives; by default it keeps e₂.
    Instances
      @[reducible, inline]

      Trivial error type: discards all error information.

      Equations
      Instances For
        @[instance_reducible]
        instance ParseIt.Error.instTrivial {ι τ : Type u} [Std.Iterator ι Id τ] :
        Equations
        structure ParseIt.Error.Basic (ι : Type u) {τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] :

        Basic error type: the position and, optionally, the offending token. Merging keeps the error at the furthest position, preferring the later alternative on ties. Messages are discarded.

        • pos : HasPos.Pos ι

          Position of the error.

        • token : Option τ

          Offending token, if any.

        Instances For
          @[instance_reducible]
          instance ParseIt.Error.instBasicOfDecidableLEPos {ι τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] [LE (HasPos.Pos ι)] [DecidableLE (HasPos.Pos ι)] :
          Error (Basic ι) ι τ
          Equations
          • One or more equations did not get rendered due to their size.
          @[instance_reducible]
          instance ParseIt.Error.instToStringBasicOfReprPos {ι τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] [Repr τ] [Repr (HasPos.Pos ι)] :
          Equations
          • One or more equations did not get rendered due to their size.
          inductive ParseIt.Error.Simple (ι : Type u) {τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] :

          Simple error type: records all error information, without processing.

          Instances For
            @[instance_reducible]
            instance ParseIt.Error.instSimple {ι τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] :
            Error (Simple ι) ι τ
            Equations
            • One or more equations did not get rendered due to their size.
            def ParseIt.Error.Simple.toString {ι τ : Type u} [Std.Iterator ι Id τ] [HasPos ι τ] [Repr τ] [Repr (HasPos.Pos ι)] :
            Simple ι → String

            Render a simple error, listing alternatives separated by " or ".

            Equations
            Instances For