aboutsummaryrefslogtreecommitdiff
path: root/Sil/Error.icl
diff options
context:
space:
mode:
authorCamil Staps2021-01-04 20:27:45 +0100
committerCamil Staps2021-01-04 20:27:45 +0100
commit88de5784428bec9a4b32bdf447c160da29b3745e (patch)
tree4b5a52c8fe2560e98aca0d74ec8dcd5cb09b2b70 /Sil/Error.icl
parentFix error reporting for illegal command line arguments (diff)
Make up to date
Diffstat (limited to 'Sil/Error.icl')
-rw-r--r--Sil/Error.icl57
1 files changed, 28 insertions, 29 deletions
diff --git a/Sil/Error.icl b/Sil/Error.icl
index 66fb338..a58dd93 100644
--- a/Sil/Error.icl
+++ b/Sil/Error.icl
@@ -4,7 +4,6 @@ import StdFile
import StdInt
import StdString
-import Data.Maybe
import Text
import Sil.Syntax
@@ -16,7 +15,7 @@ import Sil.Util.Parser
, ep_token :: Int
}
-instance < ErrorPosition where < p1 p2 = p1.ep_token < p2.ep_token
+instance < ErrorPosition where (<) p1 p2 = p1.ep_token < p2.ep_token
instance toString ErrorPosition
where
@@ -44,37 +43,37 @@ where
toString (C_BasicInitWithoutValue p n) = p <+ "Basic value '" <+ n <+ "' must have an initial value."
toString (UnknownError e) = "\tUnknown error: " <+ e <+ "."
-instance <<< Error where <<< f e = f <<< toString e <<< "\r\n"
+instance <<< Error where (<<<) f e = f <<< toString e <<< "\r\n"
instance < Error
where
- < _ (UnknownError _) = False
- < (UnknownError _) _ = True
- < e1 e2 = case (getErrorPosition e1, getErrorPosition e2) of
- (Just p1, Just p2) -> p1 < p2
- (_ , Nothing) -> False
- (Nothing, _ ) -> True
+ (<) _ (UnknownError _) = False
+ (<) (UnknownError _) _ = True
+ (<) e1 e2 = case (getErrorPosition e1, getErrorPosition e2) of
+ (?Just p1, ?Just p2) -> p1 < p2
+ (_ , ?None ) -> False
+ (?None , _ ) -> True
-getErrorPosition :: Error -> Maybe ErrorPosition
-getErrorPosition (P_Invalid w tk) = Nothing
-getErrorPosition (P_Expected p s h) = Just p
-getErrorPosition (T_IllegalApplication p ft et) = Just p
-getErrorPosition (T_IllegalField p f t) = Just p
-getErrorPosition (T_TooHighTupleArity p i) = Just p
-getErrorPosition Ck_NoMainFunction = Nothing
-getErrorPosition (Ck_MainFunctionInvalidType p t) = Just p
-getErrorPosition (Ck_DuplicateFunctionName p n) = Just p
-getErrorPosition (Ck_DuplicateLocalName p f arg) = Just p
-getErrorPosition (Ck_ReturnExpressionFromVoid p f) = Just p
-getErrorPosition (Ck_NoReturnFromNonVoid p f) = Just p
-getErrorPosition (Ck_LocalVoid p l) = Just p
-getErrorPosition (Ck_BasicGlobal p g) = Just p
-getErrorPosition (C_UndefinedName p n) = Just p
-getErrorPosition (C_UndefinedField p f) = Just p
-getErrorPosition (C_CouldNotDeduceType e) = Just (errpos e)
-getErrorPosition (C_TypeMisMatch t e u) = Just (errpos e)
-getErrorPosition (C_BasicInitWithoutValue p n) = Just p
-getErrorPosition (UnknownError e) = Nothing
+getErrorPosition :: Error -> ?ErrorPosition
+getErrorPosition (P_Invalid w tk) = ?None
+getErrorPosition (P_Expected p s h) = ?Just p
+getErrorPosition (T_IllegalApplication p ft et) = ?Just p
+getErrorPosition (T_IllegalField p f t) = ?Just p
+getErrorPosition (T_TooHighTupleArity p i) = ?Just p
+getErrorPosition Ck_NoMainFunction = ?None
+getErrorPosition (Ck_MainFunctionInvalidType p t) = ?Just p
+getErrorPosition (Ck_DuplicateFunctionName p n) = ?Just p
+getErrorPosition (Ck_DuplicateLocalName p f arg) = ?Just p
+getErrorPosition (Ck_ReturnExpressionFromVoid p f) = ?Just p
+getErrorPosition (Ck_NoReturnFromNonVoid p f) = ?Just p
+getErrorPosition (Ck_LocalVoid p l) = ?Just p
+getErrorPosition (Ck_BasicGlobal p g) = ?Just p
+getErrorPosition (C_UndefinedName p n) = ?Just p
+getErrorPosition (C_UndefinedField p f) = ?Just p
+getErrorPosition (C_CouldNotDeduceType e) = ?Just (errpos e)
+getErrorPosition (C_TypeMisMatch t e u) = ?Just (errpos e)
+getErrorPosition (C_BasicInitWithoutValue p n) = ?Just p
+getErrorPosition (UnknownError e) = ?None
errpos :: a -> ErrorPosition | getPos a
errpos x = {ep_line=p.pp_line, ep_token=p.pp_token}