mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
gt with metavariables fixed
This commit is contained in:
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/04 08:12:56 $
|
-- > CVS $Date: 2005/03/04 12:05:10 $
|
||||||
-- > CVS $Author: aarne $
|
-- > CVS $Author: aarne $
|
||||||
-- > CVS $Revision: 1.12 $
|
-- > CVS $Revision: 1.13 $
|
||||||
--
|
--
|
||||||
-- Generate all trees of given category and depth. AR 30\/4\/2004
|
-- Generate all trees of given category and depth. AR 30\/4\/2004
|
||||||
--
|
--
|
||||||
@@ -73,10 +73,15 @@ str2tr t = case t of
|
|||||||
-- tr2str :: Tree -> STree
|
-- tr2str :: Tree -> STree
|
||||||
tr2str (Tr (N (_,at,val,_,_),ts)) = case (at,val) of
|
tr2str (Tr (N (_,at,val,_,_),ts)) = case (at,val) of
|
||||||
(AtC (_,f), _) -> SApp (prt_ f,map tr2str ts)
|
(AtC (_,f), _) -> SApp (prt_ f,map tr2str ts)
|
||||||
(AtM _, VCn (_,c)) -> SMeta (prt_ c)
|
(AtM _, v) -> SMeta (catOf v)
|
||||||
(AtL s, _) -> SString s
|
(AtL s, _) -> SString s
|
||||||
(AtI i, _) -> SInt i
|
(AtI i, _) -> SInt i
|
||||||
_ -> SMeta "FAILED_TO_GENERATE" ---- err monad!
|
_ -> SMeta "FAILED_TO_GENERATE" ---- err monad!
|
||||||
|
where
|
||||||
|
catOf v = case v of
|
||||||
|
VApp w _ -> catOf w
|
||||||
|
VCn (_,c) -> prt_ c
|
||||||
|
_ -> "FAILED_TO_GENERATE_FROM_META"
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
-- do the main thing with a simpler data structure
|
-- do the main thing with a simpler data structure
|
||||||
@@ -95,7 +100,7 @@ generate gr ifm cat i mn mt = case mt of
|
|||||||
|
|
||||||
allTrees = genAll i
|
allTrees = genAll i
|
||||||
|
|
||||||
-- lazy bottom-up dynamic generation
|
-- dynamic generation
|
||||||
genAll :: Int -> BinTree (SCat,[[STree]])
|
genAll :: Int -> BinTree (SCat,[[STree]])
|
||||||
genAll i = iter i genNext (mapTree (\ (c,_) -> (c,[[]])) gr)
|
genAll i = iter i genNext (mapTree (\ (c,_) -> (c,[[]])) gr)
|
||||||
|
|
||||||
@@ -110,7 +115,6 @@ generate gr ifm cat i mn mt = case mt of
|
|||||||
xs <- combinations (map look cs),
|
xs <- combinations (map look cs),
|
||||||
let fxs = SApp (f, xs),
|
let fxs = SApp (f, xs),
|
||||||
depth fxs == size]
|
depth fxs == size]
|
||||||
-- notElem fxs ts] ---- quadratic; better to check depth
|
|
||||||
: ts)
|
: ts)
|
||||||
where
|
where
|
||||||
look c = concat $ errVal [] $ lookupTree id c tr
|
look c = concat $ errVal [] $ lookupTree id c tr
|
||||||
|
|||||||
Reference in New Issue
Block a user