summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-06-19 06:37:24 +0000
committerkrasimir <krasimir@chalmers.se>2009-06-19 06:37:24 +0000
commit6220ebd383920b97808056210b022fdba2616c06 (patch)
tree98046f45fecf96247d3a438c065e9f760b979a68 /src
parenteeb08bbd4d6d6545dfdefd3a35877e0e0117c514 (diff)
bugfix: restore the check for bound variables in expr2tree
Diffstat (limited to 'src')
-rw-r--r--src/PGF/Expr.hs32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/PGF/Expr.hs b/src/PGF/Expr.hs
index 0058c0463..90b1af64a 100644
--- a/src/PGF/Expr.hs
+++ b/src/PGF/Expr.hs
@@ -214,22 +214,24 @@ tree2expr (Var x) = EVar x
-- | Converts an expression to tree. The conversion is only partial.
-- Variables and meta variables of function type and beta redexes are not allowed.
expr2tree :: Expr -> Tree
-expr2tree e = abs [] e
+expr2tree e = abs [] [] e
where
- abs xs (EAbs x e) = abs (x:xs) e
- abs xs e = case xs of
- [] -> app [] e
- xs -> Abs (reverse xs) (app [] e)
-
- app as (EApp e1 e2) = app ((abs [] e2) : as) e1
- app as (ELit l)
- | null as = Lit l
- | otherwise = error "literal of function type encountered"
- app as (EMeta n)
- | null as = Meta n
- | otherwise = error "meta variables of function type are not allowed in trees"
- app as (EAbs x e) = error "beta redexes are not allowed in trees"
- app as (EVar x) = Fun x as
+ abs ys xs (EAbs x e) = abs ys (x:xs) e
+ abs ys xs e = case xs of
+ [] -> app ys [] e
+ xs -> Abs (reverse xs) (app (xs++ys) [] e)
+
+ app xs as (EApp e1 e2) = app xs ((abs xs [] e2) : as) e1
+ app xs as (ELit l)
+ | null as = Lit l
+ | otherwise = error "literal of function type encountered"
+ app xs as (EMeta n)
+ | null as = Meta n
+ | otherwise = error "meta variables of function type are not allowed in trees"
+ app xs as (EAbs x e) = error "beta redexes are not allowed in trees"
+ app xs as (EVar x)
+ | x `elem` xs = Var x
+ | otherwise = Fun x as
-----------------------------------------------------