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:
Error.Trivialdiscards all error information.Error.Basicrecords the position and offending token of the furthest error.Error.Simplerecords all error information, without processing.
Parser error class
unexpected it treports unexpected input at iteratorit, optionally with the offending token.addMessage e it msgadds information to erroreat iteratorit.merge e₁ e₂combines the errors of two failed alternatives; by default it keepse₂.
- merge : ε → ε → ε
Instances
@[reducible, inline]
Trivial error type: discards all error information.
Equations
Instances For
@[instance_reducible]
Equations
- ParseIt.Error.instTrivial = { unexpected := fun (x : Std.Iter τ) (x_1 : Option τ) => PUnit.unit, addMessage := fun (x : ParseIt.Error.Trivial) (x_1 : Std.Iter τ) (x_2 : String) => PUnit.unit }
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 ι)]
:
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.
Simple error type: records all error information, without processing.
- unexpected
{ι τ : Type u}
[Std.Iterator ι Id τ]
[HasPos ι τ]
: HasPos.Pos ι → Option τ → Simple ι
Unexpected input at a position.
- addMessage
{ι τ : Type u}
[Std.Iterator ι Id τ]
[HasPos ι τ]
: Simple ι → HasPos.Pos ι → String → Simple ι
Error with an additional message at a position.
- merge
{ι τ : Type u}
[Std.Iterator ι Id τ]
[HasPos ι τ]
: Simple ι → Simple ι → Simple ι
Errors from two failed alternatives.
Instances For
@[instance_reducible]
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 ι)]
:
Render a simple error, listing alternatives separated by " or ".
Equations
- (ParseIt.Error.Simple.unexpected pos (some t)).toString = toString "unexpected input " ++ toString (repr t) ++ toString " at " ++ toString (repr pos)
- (ParseIt.Error.Simple.unexpected pos none).toString = toString "unexpected input at " ++ toString (repr pos)
- (e.addMessage pos msg).toString = e.toString ++ (toString "; " ++ toString msg ++ toString " at " ++ toString (repr pos))
- (e₁.merge e₂).toString = e₁.toString ++ " or " ++ e₂.toString
Instances For
@[instance_reducible]
instance
ParseIt.Error.instToStringSimpleOfReprPos
{ι τ : Type u}
[Std.Iterator ι Id τ]
[HasPos ι τ]
[Repr τ]
[Repr (HasPos.Pos ι)]
: