From: pimjager Date: Mon, 29 Feb 2016 12:00:03 +0000 (+0100) Subject: added errors to Yard X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=61fef22563cae53d4cf43680fe16703af4a1e822;p=cc1516.git added errors to Yard --- diff --git a/src/main.prj b/src/main.prj index 177aab2..d50d00f 100644 --- a/src/main.prj +++ b/src/main.prj @@ -31,6 +31,7 @@ Global Link LinkMethod: Static GenerateRelocations: False + GenerateSymbolTable: False GenerateLinkMap: False LinkResources: False ResourceSource: @@ -421,7 +422,7 @@ OtherModules Fusion: False Module Name: Control.Applicative - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -435,7 +436,7 @@ OtherModules Fusion: False Module Name: Control.Monad - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -449,7 +450,7 @@ OtherModules Fusion: False Module Name: Data.Either - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -463,7 +464,7 @@ OtherModules Fusion: False Module Name: Data.Foldable - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -477,7 +478,7 @@ OtherModules Fusion: False Module Name: Data.Func - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -491,7 +492,7 @@ OtherModules Fusion: False Module Name: Data.Functor - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -505,7 +506,7 @@ OtherModules Fusion: False Module Name: Data.List - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -519,7 +520,7 @@ OtherModules Fusion: False Module Name: Data.Map - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -533,7 +534,7 @@ OtherModules Fusion: False Module Name: Data.Maybe - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -547,7 +548,7 @@ OtherModules Fusion: False Module Name: Data.Monoid - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -561,7 +562,7 @@ OtherModules Fusion: False Module Name: Data.Set - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -575,7 +576,7 @@ OtherModules Fusion: False Module Name: Data.Traversable - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -589,7 +590,7 @@ OtherModules Fusion: False Module Name: Data.Void - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -603,7 +604,7 @@ OtherModules Fusion: False Module Name: System.CommandLine - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -617,7 +618,7 @@ OtherModules Fusion: False Module Name: System.IO - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -631,7 +632,7 @@ OtherModules Fusion: False Module Name: System._Pointer - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -645,7 +646,7 @@ OtherModules Fusion: False Module Name: Text - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -659,7 +660,7 @@ OtherModules Fusion: False Module Name: Text.JSON - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -673,7 +674,7 @@ OtherModules Fusion: False Module Name: Text.PPrint - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -687,7 +688,7 @@ OtherModules Fusion: False Module Name: System.OS - Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64 + Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Mac Compiler NeverMemoryProfile: False NeverTimeProfile: False diff --git a/src/yard.dcl b/src/yard.dcl index 76b6c17..266eb75 100644 --- a/src/yard.dcl +++ b/src/yard.dcl @@ -7,7 +7,7 @@ from Data.Functor import class Functor from Control.Monad import class Monad from Control.Applicative import class Applicative, class Alternative -:: Error = ParseError | LexError String +:: Error = ParseError | LexError String | Expected [String] :: Parser a b = Parser ([a] -> (Either Error b, [a])) instance Functor (Parser a) diff --git a/src/yard.icl b/src/yard.icl index 2f3c90a..5460312 100644 --- a/src/yard.icl +++ b/src/yard.icl @@ -3,6 +3,7 @@ implementation module yard import StdTuple import StdClass import StdString +import StdList import Data.Functor import Data.Either import Control.Monad @@ -13,6 +14,10 @@ instance toString Error where toString ParseError = "General parse error" toString (LexError e) = "Lexer error: " +++ e +instance + Error where + (+) (Expected as) (Expected bs) = Expected (as++bs) + (+) _ r = r + runParser :: (Parser a b) [a] -> (Either Error b, [a]) runParser (Parser f) i = f i @@ -32,7 +37,14 @@ instance Alternative (Parser a) where empty = Parser \i -> (Left ParseError, i) (<|>) p1 p2 = Parser \i -> case runParser p1 i of (Right r, rest) = (Right r, rest) - (Left _, rest) = runParser p2 i + (Left e1, rest) = case runParser p2 i of + (Right r, rest) = (Right r, rest) + (Left e2, rest) = (Left (e1+e2), rest) + + :: (Parser a b) String -> Parser a b + p e = Parser \i -> case runParser p i of + (Left e1, rest) = (Left (e1+(Expected [e])), rest) + (Right r, rest) = (Right r, rest) fail :: Parser a b fail = empty