summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-06-28 12:31:16 +0000
committeraarne <aarne@cs.chalmers.se>2006-06-28 12:31:16 +0000
commit6ee69593f06d57d1a8fd25a333fe0c934137ad45 (patch)
tree9acf0dcfb189f76d92f66fe72c63ea62bfc79fba /src/GF/UseGrammar
parent0555834d248afcfb984d2938184e33939ff99f1e (diff)
started looking at gt -all, not ready
Diffstat (limited to 'src/GF/UseGrammar')
-rw-r--r--src/GF/UseGrammar/Generate.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/GF/UseGrammar/Generate.hs b/src/GF/UseGrammar/Generate.hs
index d368056d4..a3173635e 100644
--- a/src/GF/UseGrammar/Generate.hs
+++ b/src/GF/UseGrammar/Generate.hs
@@ -17,7 +17,7 @@
-- guarantee the correctness of bindings\/dependences.
-----------------------------------------------------------------------------
-module GF.UseGrammar.Generate (generateTrees) where
+module GF.UseGrammar.Generate (generateTrees,generateAll) where
import GF.Canon.GFC
import GF.Grammar.LookAbs
@@ -29,7 +29,6 @@ import GF.Grammar.SGrammar
import GF.Data.Operations
import GF.Data.Zipper
import GF.Infra.Option
-
import Data.List
-- Generate all trees of given category and depth. AR 30/4/2004
@@ -48,6 +47,18 @@ generateTrees opts gr cat n mn mt = map str2tr $ generate gr' ifm cat' n mn mt'
mt' = maybe Nothing (return . tr2str) mt
ifm = oElem withMetas opts
+generateAll :: Options -> (Exp -> IO ()) -> GFCGrammar -> Cat -> IO ()
+generateAll opts io gr cat = mapM_ (io . str2tr) $ gen cat'
+ where
+ gr' = gr2sgr opts emptyProbs gr
+ cat' = prt $ snd cat
+ gen c = [SApp (f, xs) |
+ (f,(cs,_)) <- funs c,
+ xs <- combinations (map gen cs)
+ ]
+ funs c = errVal [] $ lookupTree id c gr'
+
+
------------------------------------------
-- do the main thing with a simpler data structure