summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2018-02-07 12:32:01 +0100
committerCamil Staps2018-02-07 12:32:01 +0100
commit7436042e2b0c198a8fcc199516b73b58cdb82f53 (patch)
tree3db68d568091038e2ab16b7f9fcbfd79eb054371
parentStart with parser (diff)
Make SPL.Parse <80
-rw-r--r--src/SPL/Parse.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/SPL/Parse.hs b/src/SPL/Parse.hs
index afac84a..c05b755 100644
--- a/src/SPL/Parse.hs
+++ b/src/SPL/Parse.hs
@@ -4,7 +4,7 @@ module SPL.Parse (parse)
where
import Text.Parsec (sepBy)
-import qualified Text.Parsec
+import qualified Text.Parsec as P
import Control.Applicative
import Data.Functor
@@ -13,10 +13,10 @@ import SPL.Syntax hiding (TInt,TBool,TChar,TArrow)
import qualified SPL.Syntax
import SPL.Lex
-type Parser t = Text.Parsec.Parsec [Token] () t
+type Parser t = P.Parsec [Token] () t
satisfy :: (Token -> Bool) -> Parser Token
-satisfy p = Text.Parsec.tokenPrim
+satisfy p = P.tokenPrim
show
(const . const)
(\t -> if p t then Just t else Nothing)
@@ -25,16 +25,16 @@ token :: Token -> Parser Token
token = satisfy . (==)
check :: (Token -> Maybe a) -> Parser a
-check f = Text.Parsec.tokenPrim
+check f = P.tokenPrim
show
(const . const)
f
-parse :: [Token] -> Either Text.Parsec.ParseError Program
-parse = Text.Parsec.parse spl "Not a valid program" . filter (not . isCommentToken)
+parse :: [Token] -> Either P.ParseError Program
+parse = P.parse spl "Not a valid program" . filter (not . isCommentToken)
spl :: Parser Program
-spl = collect <$> (many toplevel <* Text.Parsec.eof)
+spl = collect <$> (many toplevel <* P.eof)
where
collect :: [Either Variable Function] -> Program
collect vfs = Program [f | Right f <- vfs] [v | Left v <- vfs]