summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar/Generate.hs
diff options
context:
space:
mode:
authoraarne <unknown>2004-05-18 20:57:13 +0000
committeraarne <unknown>2004-05-18 20:57:13 +0000
commit8963681a3b821e85185877dd61b7804661fc5c24 (patch)
treefc2f4dee924cccd3d46c4983d80bc7b9a755ef41 /src/GF/UseGrammar/Generate.hs
parent086733a6fe03c5065002a8fb414af06c9cf67d51 (diff)
peel head i ; gt nometas ; gf2hs
Diffstat (limited to 'src/GF/UseGrammar/Generate.hs')
-rw-r--r--src/GF/UseGrammar/Generate.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/GF/UseGrammar/Generate.hs b/src/GF/UseGrammar/Generate.hs
index ad15287b9..85af4e8aa 100644
--- a/src/GF/UseGrammar/Generate.hs
+++ b/src/GF/UseGrammar/Generate.hs
@@ -22,8 +22,8 @@ import List
--- if type were shown more modules should be imported
-- generateTrees ::
--- GFCGrammar -> Cat -> Int -> Maybe Int -> Maybe Tree -> [Exp]
-generateTrees gr cat n mn mt = map str2tr $ generate gr' cat' n mn mt'
+-- GFCGrammar -> Bool -> Cat -> Int -> Maybe Int -> Maybe Tree -> [Exp]
+generateTrees gr ifm cat n mn mt = map str2tr $ generate gr' ifm cat' n mn mt'
where
gr' = gr2sgr gr
cat' = prt $ snd cat
@@ -63,8 +63,8 @@ tr2str (Tr (N (_,at,val,_,_),ts)) = case (at,val) of
-- if the depth is large (more than 3)
-- If a tree is given as argument, generation concerns its metavariables.
-generate :: SGrammar -> SCat -> Int -> Maybe Int -> Maybe STree -> [STree]
-generate gr cat i mn mt = case mt of
+generate :: SGrammar -> Bool -> SCat -> Int -> Maybe Int -> Maybe STree -> [STree]
+generate gr ifm cat i mn mt = case mt of
Nothing -> [t | (c,t) <- gen 0 [], c == cat]
Just t -> genM t
@@ -77,10 +77,12 @@ generate gr cat i mn mt = case mt of
args :: [SCat] -> [(SCat,STree)] -> [[STree]]
args cs cts = combinations
- [constr (SMeta c : [t | (k,t) <- cts, k == c]) | c <- cs]
+ [constr (ifmetas c [t | (k,t) <- cts, k == c]) | c <- cs]
constr = maybe id take mn
+ ifmetas c = if ifm then (SMeta c :) else id
+
genM t = case t of
SApp (f,ts) -> [SApp (f,ts') | ts' <- combinations (map genM ts)]
SMeta k -> [t | (c,t) <- gen 0 [], c == k]