summaryrefslogtreecommitdiff
path: root/src/GF/Shell.hs
diff options
context:
space:
mode:
authoraarne <unknown>2004-04-30 05:02:49 +0000
committeraarne <unknown>2004-04-30 05:02:49 +0000
commitcbbb6d65c7bd05a0543c4e023610a2a9bbfe2054 (patch)
tree6c1eb5d9f55147a9942396a30e615649f3955827 /src/GF/Shell.hs
parent9e23c25e283c551d84913994b5d54a7fcd460aa7 (diff)
gr F ? ?
Diffstat (limited to 'src/GF/Shell.hs')
-rw-r--r--src/GF/Shell.hs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs
index a14461928..9e922171f 100644
--- a/src/GF/Shell.hs
+++ b/src/GF/Shell.hs
@@ -15,6 +15,9 @@ import Compile
---- import GFTex
import TeachYourself -- also a subshell
+import Randomized ---
+import Editing (goFirstMeta) ---
+
import ShellState
import Option
import Information
@@ -24,6 +27,8 @@ import PrGrammar
import Monad (foldM)
import System (system)
+import Random (newStdGen) ----
+import Zipper ----
import Operations
import UseIO
@@ -168,9 +173,19 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = case comm of
CTranslate il ol -> do
let a' = opST2CommandArg (optParseArgErr opts (sgr il)) a
returnArg (opTS2CommandArg (optLinearizeTreeVal opts (sgr ol)) a') sa
- CGenerateRandom n -> do
- ts <- randomTreesIO opts gro (optIntOrN opts flagNumber n)
- returnArg (ATrms ts) sa
+ CGenerateRandom n -> case a of
+ ASTrm _ -> do
+ case s2t a of
+ ATrms [trm] -> do
+ g <- newStdGen
+ case (goFirstMeta (tree2loc trm) >>= refineRandom g 41 cgr) of
+ Ok trm' -> returnArg (ATrms [loc2tree trm']) sa
+ Bad s -> returnArg (AError s) sa
+ _ -> returnArg a sa
+ _ -> do
+ ts <- randomTreesIO opts gro (optIntOrN opts flagNumber n)
+ returnArg (ATrms ts) sa
+
CPutTerm -> changeArg (opTT2CommandArg (optTermCommand opts gro) . s2t) sa
----- CWrapTerm f -> changeArg (opTT2CommandArg (return . wrapByFun opts gro f)) sa
CMorphoAnalyse -> changeArg (AString . morphoAnalyse opts gro . prCommandArg) sa
@@ -229,6 +244,7 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = case comm of
gro = grammarOfOptState opts st
opts = addOptions opts0 (globalOptions st)
src = srcModules st
+ cgr = canModules st
s2t a = case a of
ASTrm s -> err AError (ATrms . return) $ string2treeErr gro s