mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 09:32:53 -06:00
bugfix: restore the check for bound variables in expr2tree
This commit is contained in:
@@ -214,22 +214,24 @@ tree2expr (Var x) = EVar x
|
|||||||
-- | Converts an expression to tree. The conversion is only partial.
|
-- | Converts an expression to tree. The conversion is only partial.
|
||||||
-- Variables and meta variables of function type and beta redexes are not allowed.
|
-- Variables and meta variables of function type and beta redexes are not allowed.
|
||||||
expr2tree :: Expr -> Tree
|
expr2tree :: Expr -> Tree
|
||||||
expr2tree e = abs [] e
|
expr2tree e = abs [] [] e
|
||||||
where
|
where
|
||||||
abs xs (EAbs x e) = abs (x:xs) e
|
abs ys xs (EAbs x e) = abs ys (x:xs) e
|
||||||
abs xs e = case xs of
|
abs ys xs e = case xs of
|
||||||
[] -> app [] e
|
[] -> app ys [] e
|
||||||
xs -> Abs (reverse xs) (app [] e)
|
xs -> Abs (reverse xs) (app (xs++ys) [] e)
|
||||||
|
|
||||||
app as (EApp e1 e2) = app ((abs [] e2) : as) e1
|
app xs as (EApp e1 e2) = app xs ((abs xs [] e2) : as) e1
|
||||||
app as (ELit l)
|
app xs as (ELit l)
|
||||||
| null as = Lit l
|
| null as = Lit l
|
||||||
| otherwise = error "literal of function type encountered"
|
| otherwise = error "literal of function type encountered"
|
||||||
app as (EMeta n)
|
app xs as (EMeta n)
|
||||||
| null as = Meta n
|
| null as = Meta n
|
||||||
| otherwise = error "meta variables of function type are not allowed in trees"
|
| 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 xs as (EAbs x e) = error "beta redexes are not allowed in trees"
|
||||||
app as (EVar x) = Fun x as
|
app xs as (EVar x)
|
||||||
|
| x `elem` xs = Var x
|
||||||
|
| otherwise = Fun x as
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user