From abe8da32fd5c3d0d69695bb89ca53be57f7166cc Mon Sep 17 00:00:00 2001 From: krasimir Date: Mon, 20 Oct 2008 07:52:14 +0000 Subject: add parser and pretty printer for types --- src/PGF/Expr.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/PGF/Expr.hs') diff --git a/src/PGF/Expr.hs b/src/PGF/Expr.hs index 55bd90441..454989728 100644 --- a/src/PGF/Expr.hs +++ b/src/PGF/Expr.hs @@ -7,7 +7,7 @@ module PGF.Expr(readTree, showTree, pTree, ppTree, Value(..), Env, eval, apply, -- helpers - pIdent,pStr + pIdent,pStr,pFactor ) where import PGF.CId @@ -68,18 +68,9 @@ pExpr = RP.skipSpaces >> (pAbs RP.<++ pTerm RP.<++ pEqs) where pTerm = fmap (foldl1 EApp) (RP.sepBy1 pFactor RP.skipSpaces) - pFactor = fmap EVar pCId - RP.<++ fmap ELit pLit - RP.<++ pMeta - RP.<++ RP.between (RP.char '(') (RP.char ')') pExpr - pAbs = do xs <- RP.between (RP.char '\\') (RP.skipSpaces >> RP.string "->") (RP.sepBy1 (RP.skipSpaces >> pCId) (RP.skipSpaces >> RP.char ',')) e <- pExpr return (foldr EAbs e xs) - - pMeta = do RP.char '?' - n <- fmap read (RP.munch1 isDigit) - return (EMeta n) pEqs = fmap EEq $ RP.between (RP.skipSpaces >> RP.char '{') @@ -92,6 +83,15 @@ pExpr = RP.skipSpaces >> (pAbs RP.<++ pTerm RP.<++ pEqs) e <- pExpr return (Equ pats e) +pFactor = fmap EVar pCId + RP.<++ fmap ELit pLit + RP.<++ pMeta + RP.<++ RP.between (RP.char '(') (RP.char ')') pExpr + where + pMeta = do RP.char '?' + n <- fmap read (RP.munch1 isDigit) + return (EMeta n) + pLit :: RP.ReadP Literal pLit = pNum RP.<++ liftM LStr pStr -- cgit v1.2.3