mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
work-around in Tree.expr2tree to make Paraphrase work
This commit is contained in:
@@ -24,7 +24,7 @@ import qualified Data.Map as Map
|
|||||||
import Debug.Trace ----
|
import Debug.Trace ----
|
||||||
|
|
||||||
paraphrase :: PGF -> Expr -> [Expr]
|
paraphrase :: PGF -> Expr -> [Expr]
|
||||||
paraphrase pgf = nub . paraphraseN 2 pgf
|
paraphrase pgf t = nub (paraphraseN 2 pgf t)
|
||||||
|
|
||||||
paraphraseN :: Int -> PGF -> Expr -> [Expr]
|
paraphraseN :: Int -> PGF -> Expr -> [Expr]
|
||||||
paraphraseN i pgf = map tree2expr . paraphraseN' i pgf . expr2tree
|
paraphraseN i pgf = map tree2expr . paraphraseN' i pgf . expr2tree
|
||||||
@@ -53,8 +53,9 @@ fromDef pgf t@(Fun f ts) = defDown t ++ defUp t where
|
|||||||
isClosed d || (length equs == 1 && isLinear d)]
|
isClosed d || (length equs == 1 && isLinear d)]
|
||||||
|
|
||||||
equss = [(f,[(Fun f (map patt2tree ps), expr2tree d) | (Equ ps d) <- eqs]) |
|
equss = [(f,[(Fun f (map patt2tree ps), expr2tree d) | (Equ ps d) <- eqs]) |
|
||||||
(f,(_,_,Just eqs,_)) <- Map.assocs (funs (abstract pgf)), not (null eqs)]
|
(f,(_,_,Just eqs,_)) <- Map.assocs (funs (abstract pgf)), not (null eqs)]
|
||||||
|
---- AR 14/12/2010: (expr2tree d) fails unless we send the variable list from ps in eqs;
|
||||||
|
---- cf. PGF.Tree.expr2tree
|
||||||
trequ s f e = True ----trace (s ++ ": " ++ show f ++ " " ++ show e) True
|
trequ s f e = True ----trace (s ++ ": " ++ show f ++ " " ++ show e) True
|
||||||
|
|
||||||
subst :: Subst -> Tree -> Tree
|
subst :: Subst -> Tree -> Tree
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ expr2tree e = abs [] [] e
|
|||||||
| List.null as = Meta n
|
| List.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 xs 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 xs as (EVar i) = Var (xs !! i)
|
app xs as (EVar i) = if length xs > i then Var (xs !! i) else Meta i
|
||||||
|
---- AR 14/12/2010: work-around needed in PGF.Paraphrase.fromDef
|
||||||
app xs as (EFun f) = Fun f as
|
app xs as (EFun f) = Fun f as
|
||||||
app xs as (ETyped e _) = app xs as e
|
app xs as (ETyped e _) = app xs as e
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user