From: pimjager Date: Mon, 29 Feb 2016 12:42:26 +0000 (+0100) Subject: Improved error reporting with positions X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=178532b9e5843308b2b076b4d8881f6971cd718c;hp=-c;p=cc1516.git Improved error reporting with positions --- 178532b9e5843308b2b076b4d8881f6971cd718c diff --git a/src/main.prj b/src/main.prj index d50d00f..f2d50f9 100644 --- a/src/main.prj +++ b/src/main.prj @@ -686,6 +686,20 @@ OtherModules ReadableABC: False ReuseUniqueNodes: True Fusion: False + Module + Name: StdMaybe + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent/Deprecated/StdLib + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False Module Name: System.OS Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Mac @@ -728,6 +742,20 @@ OtherModules ReadableABC: False ReuseUniqueNodes: True Fusion: False + Module + Name: GenPrint + Dir: {Application}/lib/iTasks-SDK/Patches/Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False Module Name: StdGeneric Dir: {Application}/lib/iTasks-SDK/Patches/StdEnv diff --git a/src/parse.icl b/src/parse.icl index 5fc8f8c..f5cb0c8 100644 --- a/src/parse.icl +++ b/src/parse.icl @@ -12,6 +12,7 @@ import Control.Applicative import Data.Func from Data.List import intercalate, replicate, instance Functor [] from Text import class Text(concat), instance Text String +import GenPrint import yard import lex @@ -172,8 +173,9 @@ trans2 t f = satTok t >>= \(_, r).pure (f r) trans1 :: TokenValue a -> Parser Token a trans1 t r = trans2 t $ const r +derive gPrint TokenValue satTok :: TokenValue -> Parser Token Token -satTok t = top >>= \tok=:(pos, tv) -> if (t === tok) (return tok) (fail ("Token", pos)) +satTok t = top >>= \tok=:(pos, tv) -> if (t === tok) (return tok) (fail (printToString t, pos)) parseSepList :: TokenValue (Parser Token a) -> Parser Token [a] parseSepList sep p = diff --git a/src/yard.icl b/src/yard.icl index 278bac8..932999a 100644 --- a/src/yard.icl +++ b/src/yard.icl @@ -4,6 +4,9 @@ import StdTuple import StdClass import StdString import StdList +import StdInt +from Data.List import intersperse +from Text import instance Text String, class Text(concat) import Data.Functor import Data.Either import Control.Monad @@ -13,6 +16,8 @@ from Data.Func import $ instance toString Error where toString ParseError = "General parse error" toString (LexError e) = "Lexer error: " +++ e + toString (Expected ts pos) = "Expected " +++ (concat $ intersperse ", " ts) + +++ " at position " +++ (toString pos) instance + Error where (+) (Expected as _) (Expected bs p) = Expected (as++bs) p