diff options
author | davve <davve@dtek.chalmers.se> | 2006-08-11 20:31:51 +0000 |
---|---|---|
committer | davve <davve@dtek.chalmers.se> | 2006-08-11 20:31:51 +0000 |
commit | d7097e0d05c37652402971093a2ce2c2a73281f4 (patch) | |
tree | c8c0ab24e2ec3e65c6b91f5dc0b052b1afa9d647 /src/HsParseMonad.lhs | |
parent | 20c21b530551f5174a10905e2517edff1333357f (diff) |
Cleanup
Diffstat (limited to 'src/HsParseMonad.lhs')
-rw-r--r-- | src/HsParseMonad.lhs | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/src/HsParseMonad.lhs b/src/HsParseMonad.lhs deleted file mode 100644 index 27032c37..00000000 --- a/src/HsParseMonad.lhs +++ /dev/null @@ -1,73 +0,0 @@ ------------------------------------------------------------------------------ --- $Id: HsParseMonad.lhs,v 1.2 2002/07/24 09:42:18 simonmar Exp $ --- --- (c) The GHC Team 1997-2000 --- --- Monad for the Haskell parser. --- ------------------------------------------------------------------------------ - -\begin{code} -module HsParseMonad where - -import HsSyn2 -\end{code} - -\begin{code} -data ParseResult a = Ok ParseState a | Failed String - deriving Show - -data LexContext = NoLayout | Layout Int - deriving (Eq,Ord,Show) - -type ParseState = [LexContext] - -type P a - = String -- input string - -> SrcLoc -- location of last token read - -> Int -- current line - -> Int -- current column - -> FilePath -- current original filename - -> ParseState -- layout info. - -> ParseResult a - -thenP :: P a -> (a -> P b) -> P b -m `thenP` k = \i l n c f s0 -> - case m i l n c f s0 of - Failed s -> Failed s - Ok s' a -> case k a of k' -> k' i l n c f s' - -thenP_ :: P a -> P b -> P b -m `thenP_` k = m `thenP` \_ -> k - -mapP :: (a -> P b) -> [a] -> P [b] -mapP _ [] = returnP [] -mapP f (a:as) = - f a `thenP` \b -> - mapP f as `thenP` \bs -> - returnP (b:bs) - -returnP :: a -> P a -returnP a = \_ _ _ _ _ s -> Ok s a - -failP :: String -> P a -failP err = \_ _ _ _ _ _ -> Failed err - -getSrcLoc :: P SrcLoc -getSrcLoc = \_ l _ _ _ s -> Ok s l - -getContext :: P [LexContext] -getContext = \_ _ _ _ _ s -> Ok s s - -pushContext :: LexContext -> P () -pushContext ctxt = ---trace ("pushing lexical scope: " ++ show ctxt ++"\n") $ - \_ _ _ _ _ s -> Ok (ctxt:s) () - -popContext :: P () -popContext = \_ _ _ _ _ stk -> - case stk of - (_:s) -> --trace ("popping lexical scope, context now "++show s ++ "\n") $ - Ok s () - [] -> error "Internal error: empty context in popContext" -\end{code} |