summaryrefslogtreecommitdiff
path: root/src
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
parent0555834d248afcfb984d2938184e33939ff99f1e (diff)
started looking at gt -all, not ready
Diffstat (limited to 'src')
-rw-r--r--src/GF/Shell.hs5
-rw-r--r--src/GF/UseGrammar/Generate.hs15
2 files changed, 18 insertions, 2 deletions
diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs
index 3dcec9fbd..66297ddc8 100644
--- a/src/GF/Shell.hs
+++ b/src/GF/Shell.hs
@@ -28,6 +28,7 @@ import qualified GF.Grammar.MMacros as MMacros
import qualified GF.Compile.GrammarToCanon as GrammarToCanon
import GF.Grammar.Values
import GF.UseGrammar.GetTree
+import GF.UseGrammar.Generate (generateAll) ---- should be in API
import GF.UseGrammar.Treebank
import GF.Shell.ShellCommands
@@ -302,6 +303,10 @@ execC co@(comm, opts0) sa@(sh@(st,(h,_,_,_)),a) = checkOptions st co >> case com
_ -> do
ts <- randomTreesIO opts gro (optIntOrN opts flagNumber 1)
returnArg (ATrms ts) sa
+
+ CGenerateTrees | oElem showAll opts -> do
+ let cat = firstAbsCat opts gro
+ justOutput opts (generateAll opts (putStrLn . prt_) cgr cat) sa
CGenerateTrees -> do
let
a' = case a of
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