Parser Error #
The class Parser.Error is used throughout the library for the purpose of reporting parser errors.
Users are encouraged to provide their own instances tailored to their applications.
Three general purpose instances are provided:
Parser.Error.Simplerecords all parsing error information, without processing.Parser.Error.Basicjust records the location of the primary parsing error.Parser.Error.Trivialdiscards all parsing error information.
These are intended for use in parser development and as building blocks (or inspiration) for tailored instances.
Parser error class
This class declares an error type for a given parser stream.
Given Parser.Stream σ τ, Parser.Error ε σ τ provides two basic mechanisms for reporting parsing
errors:
unexpected (p : Stream.Position σ) (t : Option τ) : εis used to report an unexpected input at a given position, optionally with the offending token.addMessage (e : ε) (p : Stream.Position σ) (info : String)is used to add additional error information at a given position.
This class can be extended to provide additional error reporting and processing functonality, but only these two mechanisms are used within the library.
- unexpected : Stream.Position σ → Option τ → ε
Parser error class
This class declares an error type for a given parser stream.
Given
Parser.Stream σ τ,Parser.Error ε σ τprovides two basic mechanisms for reporting parsing errors:unexpected (p : Stream.Position σ) (t : Option τ) : εis used to report an unexpected input at a given position, optionally with the offending token.addMessage (e : ε) (p : Stream.Position σ) (info : String)is used to add additional error information at a given position.
This class can be extended to provide additional error reporting and processing functonality, but only these two mechanisms are used within the library.
- addMessage : ε → Stream.Position σ → String → ε
Parser error class
This class declares an error type for a given parser stream.
Given
Parser.Stream σ τ,Parser.Error ε σ τprovides two basic mechanisms for reporting parsing errors:unexpected (p : Stream.Position σ) (t : Option τ) : εis used to report an unexpected input at a given position, optionally with the offending token.addMessage (e : ε) (p : Stream.Position σ) (info : String)is used to add additional error information at a given position.
This class can be extended to provide additional error reporting and processing functonality, but only these two mechanisms are used within the library.
Instances
Trivial error type
This error type simply discards all error information. This is useful for parsers that cannot fail, or where parsing errors are intended to be handled by other means.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Basic error type
This error type records the position and, optionally, the offending token where a parsing error occurred; any additional information is discarded. This is useful for parsers where the cause of parsing errors is predictable and only the position of the error is needed for processing.
Equations
- Parser.Error.Basic σ τ = (Parser.Stream.Position σ × Option τ)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Simple error type
This error type simply records all the error information provided, without additional processing. Users are expected to provide any necessary post-processing. This is useful for parser development.
- unexpected
{σ : Type u_1}
{τ : Type u_2}
[Parser.Stream σ τ]
: Stream.Position σ → Option τ → Simple σ τ
Unexpected input at position
- addMessage
{σ : Type u_1}
{τ : Type u_2}
[Parser.Stream σ τ]
: Simple σ τ → Stream.Position σ → String → Simple σ τ
Add error message at position
Instances For
Equations
- Parser.Error.instReprSimpleOfPosition σ τ = { reprPrec := Parser.Error.Simple.reprPrec✝ }
Equations
- Parser.Error.instToStringSimpleOfReprPosition σ τ = { toString := Parser.Error.Simple.toString✝ }
Equations
- Parser.Error.instSimple σ τ = { unexpected := Parser.Error.Simple.unexpected, addMessage := Parser.Error.Simple.addMessage }