From b63780a44880678a0b1aef34da175107f0fe74dc Mon Sep 17 00:00:00 2001 From: "adam.gundry" Date: Thu, 20 Oct 2011 11:18:38 +0100 Subject: [PATCH] Tidy parser Ignore-this: c4abd311a54eb26267a9096db0be68b8 darcs-hash:20111020101838-e29d1-604b7a6d8741562d03f0152c9bc199eb9ca6221d.gz --- Main.lhs | 2 +- Parser.lhs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Main.lhs b/Main.lhs index b9bf1b6..7465746 100644 --- a/Main.lhs +++ b/Main.lhs @@ -27,7 +27,7 @@ > modHeader (Just m) = "module " ++ m ++ " where\n" > preprocess :: String -> String -> Either String String -> preprocess fn s = case parse program fn s of +> preprocess fn s = case parseProgram fn s of > Right (p, mn) -> case runCheckProg p of > Right (p', st) -> case runStateT (eraseProg p') st of > Right (p'', st) -> Right $ modHeader mn ++ show (prettyProgram p'') diff --git a/Parser.lhs b/Parser.lhs index 20475c0..3a11edb 100644 --- a/Parser.lhs +++ b/Parser.lhs @@ -1,10 +1,10 @@ -> module Parser where +> module Parser (parseProgram) where > import Control.Applicative > import Control.Monad > import Data.Char -> import Text.ParserCombinators.Parsec hiding (optional, many, (<|>)) +> import Text.ParserCombinators.Parsec hiding (parse, optional, many, (<|>)) > import Text.ParserCombinators.Parsec.Expr > import Text.ParserCombinators.Parsec.Language > import qualified Text.ParserCombinators.Parsec.Token as T @@ -17,12 +17,11 @@ > import Kit > import Kind hiding (kind) +> parseProgram = I.parse program -> parse = I.parse +> def = haskellDef -> toyDef = haskellDef - -> lexer = T.makeTokenParser toyDef +> lexer = T.makeTokenParser def > identifier = IT.identifier lexer > reserved = IT.reserved lexer @@ -50,7 +49,7 @@ > specialOp s = try $ -> string s >> notFollowedBy (opLetter toyDef) >> whiteSpace +> string s >> notFollowedBy (opLetter def) >> whiteSpace > doubleColon = reservedOp "::"