aboutsummaryrefslogtreecommitdiff
path: root/Sil/Util/Parser.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Util/Parser.icl')
-rw-r--r--Sil/Util/Parser.icl16
1 files changed, 8 insertions, 8 deletions
diff --git a/Sil/Util/Parser.icl b/Sil/Util/Parser.icl
index f0895fe..d13bc09 100644
--- a/Sil/Util/Parser.icl
+++ b/Sil/Util/Parser.icl
@@ -10,7 +10,7 @@ from Data.Func import $
import Data.Functor
import Data.List
-import Sil.Parse
+import Sil.Error
instance Functor (Parser a) where
fmap f m = liftM f m
@@ -25,7 +25,7 @@ instance Monad (Parser a) where
(Error e, _) -> (Error e, i)
instance Alternative (Parser a) where
- empty = Parser \i -> (Error UnknownError, i)
+ empty = Parser \i -> (Error $ UnknownError "empty in Parser", i)
(<|>) p1 p2 = Parser \i -> case runParser p1 i of
(Ok r, rest) -> (Ok r, rest)
(Error e1, rest) -> case runParser p2 i of
@@ -34,10 +34,10 @@ instance Alternative (Parser a) where
instance name String where name s = s
-runParser :: (Parser a b) [a] -> (MaybeError ParseError b, [a])
+runParser :: (Parser a b) [a] -> (MaybeError Error b, [a])
runParser (Parser f) i = f i
-(<?>) :: (Parser a b) ParseError -> Parser a b
+(<?>) :: (Parser a b) Error -> Parser a b
(<?>) p e = Parser \i -> case runParser p i of
(Error _, rest) -> (Error e, rest)
o -> o
@@ -47,12 +47,12 @@ fail = empty
top :: Parser a a
top = Parser \i -> case i of
- [] = (Error UnknownError, [])
+ [] = (Error $ UnknownError "top in Parser failed", [])
[x:xs] = (Ok x, xs)
peek :: Parser a a
peek = Parser \i -> case i of
- [] = (Error UnknownError, [])
+ [] = (Error $ UnknownError "peek in Parser failed", [])
[x:xs] = (Ok x, [x:xs])
satisfy :: (a -> Bool) -> Parser a a
@@ -77,7 +77,7 @@ where
(Ok r, rest) -> (Ok r, rest)
item :: a -> Parser a a | ==, name a
-item a = satisfy ((==) a) <?> Expected (name a)
+item a = satisfy ((==) a) <?> P_Expected (name a)
list :: [a] -> Parser a [a] | ==, name a
list as = mapM item as
@@ -90,4 +90,4 @@ seplist sep p = liftM2 (\es e-> es ++ [e]) (some (p <* item sep)) p
eof :: Parser a ()
eof = Parser \i -> case i of
[] = (Ok (), [])
- _ = (Error $ Expected "eof", i)
+ _ = (Error $ P_Expected "eof", i)