58 lines
1.6 KiB
Idris
58 lines
1.6 KiB
Idris
module Quox.Parser.FromParser.Error
|
|
|
|
import Quox.Parser.Parser
|
|
import Quox.Typing
|
|
import System.File
|
|
|
|
import Quox.Pretty
|
|
|
|
|
|
public export
|
|
data Error =
|
|
AnnotationNeeded (NameContexts d n) (Term d n)
|
|
| DuplicatesInEnum (List TagVal)
|
|
| TermNotInScope Name
|
|
| DimNotInScope PBaseName
|
|
| QtyNotGlobal Qty
|
|
| DimNameInTerm PBaseName
|
|
| TypeError Typing.Error
|
|
| LoadError String FileError
|
|
| ParseError Parser.Error
|
|
%hide Typing.Error
|
|
%hide Lexer.Error
|
|
%hide Parser.Error
|
|
|
|
|
|
parameters (unicode, showContext : Bool)
|
|
export
|
|
prettyError : Error -> Doc HL
|
|
prettyError (AnnotationNeeded ctx tm) =
|
|
sep ["the term", prettyTerm unicode ctx.dnames ctx.tnames tm,
|
|
"needs a type annotation"]
|
|
-- [todo] print the original PTerm instead
|
|
|
|
prettyError (DuplicatesInEnum tags) =
|
|
sep ["duplicate tags in enum type", braces $ fillSep $ map pretty tags]
|
|
|
|
prettyError (DimNotInScope i) =
|
|
sep ["dimension", pretty0 unicode $ DV $ fromString i, "not in scope"]
|
|
|
|
prettyError (TermNotInScope x) =
|
|
sep ["term variable", pretty0 unicode $ F x {d = 0, n = 0}, "not in scope"]
|
|
|
|
prettyError (QtyNotGlobal pi) =
|
|
sep ["quantity", pretty0 unicode pi,
|
|
"can't be used on a top level declaration"]
|
|
|
|
prettyError (DimNameInTerm i) =
|
|
sep ["dimension variable", pretty0 unicode $ DV $ fromString i,
|
|
"used in a term context"]
|
|
|
|
prettyError (TypeError err) =
|
|
Typing.prettyError unicode showContext $ trimContext 2 err
|
|
|
|
prettyError (LoadError str err) =
|
|
vsep [hsep ["couldn't load file", pretty str], fromString $ show err]
|
|
|
|
prettyError (ParseError err) =
|
|
pretty $ show err
|