diff options
| author | krasimir <krasimir@chalmers.se> | 2008-10-20 07:52:14 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-10-20 07:52:14 +0000 |
| commit | abe8da32fd5c3d0d69695bb89ca53be57f7166cc (patch) | |
| tree | 48154cb2c97503e000638ac65f2f77c63e9e3928 /src/PGF/Expr.hs | |
| parent | 418856d9bfe23944528ba3d41710be0dbfab8d27 (diff) | |
add parser and pretty printer for types
Diffstat (limited to 'src/PGF/Expr.hs')
| -rw-r--r-- | src/PGF/Expr.hs | 20 |
1 files changed, 10 insertions, 10 deletions
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
|
