1
0
forked from GitHub/gf-core

commands mq and tq can take a tree with metas to guide generation

This commit is contained in:
aarne
2010-02-01 09:56:58 +00:00
parent 3d5864918b
commit 3dd8fb8dec
4 changed files with 47 additions and 24 deletions

View File

@@ -79,6 +79,7 @@ module PGF(
-- ** Generation
generateRandom, generateAll, generateAllDepth,
generateRandomFrom, -- from initial expression, possibly weighed
-- ** Morphological Analysis
Lemma, Analysis, Morpho,

View File

@@ -21,6 +21,10 @@ generateRandomFrom mex ps rg pgf ty =
maybe (gen ty) (generateForMetas pgf gen) mex where
gen ty = genRandomProb ps rg pgf ty
-- generic algorithm for filling holes in a generator
---- for random, should be breadth-first, since now the first metas always get the same
---- value when a list is generated
generateForMetas :: PGF -> (Type -> [Expr]) -> Expr -> [Expr]
generateForMetas pgf gen exp = case exp of
EApp f (EMeta _) -> [EApp g a | g <- gener f, a <- genArg g]