diff options
author | Camil Staps | 2017-07-30 11:35:16 +0200 |
---|---|---|
committer | Camil Staps | 2017-07-30 11:35:16 +0200 |
commit | c5c4788b282a371fdc989e2d13430701f3457441 (patch) | |
tree | 156653073824d4e6a770d33072b0af558723f51e /Sil/Error.dcl | |
parent | Add positions to Statements (diff) |
Better errors
Diffstat (limited to 'Sil/Error.dcl')
-rw-r--r-- | Sil/Error.dcl | 11 |
1 files changed, 9 insertions, 2 deletions
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 |