From 65c8beecb14f6d09c49504d74beedd58cc7ddd17 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 7 Sep 2022 16:26:50 +0100 Subject: Better project layout, removed warnings --- src/Error.hs | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/Error.hs (limited to 'src/Error.hs') diff --git a/src/Error.hs b/src/Error.hs deleted file mode 100644 index d128d32..0000000 --- a/src/Error.hs +++ /dev/null @@ -1,39 +0,0 @@ -module Error where - -import Data.List (sort) -import Text.Parsec (SourcePos, errorPos) -import Text.Parsec.Error (ParseError, errorMessages, showErrorMessages) - -data ErrorType = GenericError | TypeError | UnexpectedReturn | AlreadyDefined | NonCallable | Undefined | UndefinedType | InvalidTarget deriving (Show) - -instance Enum ErrorType where - fromEnum GenericError = 0 - fromEnum TypeError = 1 - fromEnum UnexpectedReturn = 2 - fromEnum AlreadyDefined = 3 - fromEnum NonCallable = 4 - fromEnum Undefined = 5 - fromEnum UndefinedType = 6 - fromEnum InvalidTarget = 7 - toEnum _ = error "toEnum is undefined for Error" - -data Error = Error ErrorType String SourcePos - deriving (Eq) - -instance Show Error where - show (Error _ message pos) = - show pos ++ " error: " ++ message - -showParserError :: ParseError -> String -showParserError error = - show (errorPos error) ++ " error: syntax error" - ++ showErrorMessages "or" "unknown parser error" " expected:" " found:" "end of input" (errorMessages error) - -instance Ord Error where - compare (Error _ _ pos1) (Error _ _ pos2) = compare pos1 pos2 - -instance Eq ErrorType where - e1 == e2 = fromEnum e1 == fromEnum e2 - -showErrorList :: [Error] -> String -showErrorList errs = unlines $ map show (sort errs) -- cgit v1.2.3