From 6c5763615fc3e2c5fb40b15daec39d301a0a9a18 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 2 Mar 2006 20:27:42 +0000 Subject: [PATCH] several treebanks in shell state --- src/GF/Compile/ShellState.hs | 3 ++- src/GF/Shell.hs | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs index 696b3776e..269b9adb1 100644 --- a/src/GF/Compile/ShellState.hs +++ b/src/GF/Compile/ShellState.hs @@ -273,7 +273,8 @@ prShellStateInfo sh = unlines [ "canonical modules :" +++ unwords (map (P.prt .fst) (M.modules (canModules sh))), "source modules : " +++ unwords (map (P.prt .fst) (M.modules (srcModules sh))), "global options : " +++ prOpts (gloptions sh), - "transfer modules : " +++ unwords (map (P.prt . fst) (transfers sh)) + "transfer modules : " +++ unwords (map (P.prt . fst) (transfers sh)), + "treebanks : " +++ unwords (map (P.prt . fst) (treebanks sh)) ] abstractName :: ShellState -> String diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs index 39460b2f2..d502b74ce 100644 --- a/src/GF/Shell.hs +++ b/src/GF/Shell.hs @@ -308,13 +308,18 @@ execC co@(comm, opts0) sa@(sh@(st,(h,_,_,_)),a) = checkOptions st co >> case com returnArg (AString $ unlines $ mkTreebank opts st comm ts) sa CLookupTreebank -> do - case treebanks st of - [] -> returnArg (AError "no treebank") sa - (_,tb):_ -> do - let s = prCommandArg a - let tes = map (string2treeErr gro . snd) $ lookupTreebank tb s - terms = [t | Ok t <- tes] - returnArg (ATrms terms) sa + let tbs = treebanks st + if null tbs + then returnArg (AError "no treebank") sa + else do + let tbi = maybe (fst $ head tbs) I.identC (getOptVal opts (aOpt "treebank")) + case lookup tbi tbs of + Nothing -> returnArg (AError ("no treebank" +++ prt tbi)) sa + Just tb -> do + let s = prCommandArg a + let tes = map (string2treeErr gro . snd) $ lookupTreebank tb s + terms = [t | Ok t <- tes] + returnArg (ATrms terms) sa CShowTreeGraph | oElem emitCode opts -> do -- -o returnArg (AString $ visualizeTrees opts $ strees $ s2t a) sa