From c5c4788b282a371fdc989e2d13430701f3457441 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 30 Jul 2017 11:35:16 +0200 Subject: Better errors --- Sil/Error.dcl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Sil/Error.dcl') diff --git a/Sil/Error.dcl b/Sil/Error.dcl index c37e445..bdfa390 100644 --- a/Sil/Error.dcl +++ b/Sil/Error.dcl @@ -1,7 +1,9 @@ definition module Sil.Error from StdFile import class <<< -from StdOverloaded import class toString +from StdOverloaded import class toString, class < + +from Data.Maybe import :: Maybe from Sil.Syntax import :: Expression from Sil.Types import :: Type @@ -9,10 +11,12 @@ from Sil.Util.Parser import :: ParsePosition, class getPos :: ErrorPosition +instance < ErrorPosition + :: Error // Parser errors = E.a: P_Invalid String a & toString a - | P_Expected String + | E.a: P_Expected ErrorPosition String a & toString a // Type errors | T_IllegalApplication Type Type | T_IllegalField String Type @@ -39,5 +43,8 @@ from Sil.Util.Parser import :: ParsePosition, class getPos instance toString Error instance <<< Error +instance < Error // Based on position in file, to choose the furthest error in the parser + +getErrorPosition :: Error -> Maybe ErrorPosition errpos :: a -> ErrorPosition | getPos a -- cgit v1.2.3