diff options
author | Erin van der Veen | 2018-02-07 14:52:05 +0100 |
---|---|---|
committer | Erin van der Veen | 2018-02-07 14:52:05 +0100 |
commit | 432f9a5afb8e4b021d66ee1b2f1820ef7077b926 (patch) | |
tree | 955ad3ca0dca1622016c6022a836ea33ea6704ed /src/SPL/Parse.hs | |
parent | Implement all functions in PrettyPrinter.hs (diff) | |
parent | Merge branch 'master' of gitlab.science.ru.nl:cstaps/compiler-construction (diff) |
Merge branch 'master' of gitlab.science.ru.nl:cstaps/compiler-construction
Diffstat (limited to 'src/SPL/Parse.hs')
-rw-r--r-- | src/SPL/Parse.hs | 14 |
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] |