summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command/Interpreter.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-09-25 11:42:32 +0000
committerhallgren <hallgren@chalmers.se>2012-09-25 11:42:32 +0000
commit69de623c17ad9b71005beff1cb208ed9a0b90ee5 (patch)
treea1bd6455f4f1c8e70bf1ba0f5cd4b6ab0f09d963 /src/compiler/GF/Command/Interpreter.hs
parentbf49f3c246de1c110044bddb9f693da325974299 (diff)
GF.Command.Commands: allCommands is now a constant
The dependency on PGFEnv has been moved from the list to the exec function of the commands in the list. This means that the help command no longer needs to generate a new list of commands and that the state of the shell (type GF.Command.Interpreter.CommandEnv) no longer needs to contain the list of commands.
Diffstat (limited to 'src/compiler/GF/Command/Interpreter.hs')
-rw-r--r--src/compiler/GF/Command/Interpreter.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/compiler/GF/Command/Interpreter.hs b/src/compiler/GF/Command/Interpreter.hs
index 4f146bb93..5758c24f4 100644
--- a/src/compiler/GF/Command/Interpreter.hs
+++ b/src/compiler/GF/Command/Interpreter.hs
@@ -1,5 +1,5 @@
module GF.Command.Interpreter (
- CommandEnv (..),
+ CommandEnv,commands,multigrammar,commandmacros,expmacros,
mkCommandEnv,
emptyCommandEnv,
interpretCommandLine,
@@ -24,15 +24,16 @@ import qualified Data.Map as Map
data CommandEnv = CommandEnv {
multigrammar :: PGF,
morphos :: Map.Map Language Morpho,
- commands :: Map.Map String CommandInfo,
+--commands :: Map.Map String CommandInfo,
commandmacros :: Map.Map String CommandLine,
expmacros :: Map.Map String Expr
}
+commands _ = allCommands
mkCommandEnv :: PGF -> CommandEnv
mkCommandEnv pgf =
let mos = Map.fromList [(la,buildMorpho pgf la) | la <- languages pgf] in
- CommandEnv pgf mos (allCommands (pgf, mos)) Map.empty Map.empty
+ CommandEnv pgf mos {-allCommands-} Map.empty Map.empty
emptyCommandEnv :: CommandEnv
emptyCommandEnv = mkCommandEnv emptyPGF
@@ -86,7 +87,8 @@ interpret env trees comm =
case getCommand env trees comm of
Left msg -> do putStrLn ('\n':msg)
return ([],[])
- Right (info,opts,trees) -> do tss@(_,s) <- exec info opts trees
+ Right (info,opts,trees) -> do let cmdenv = (multigrammar env,morphos env)
+ tss@(_,s) <- exec info cmdenv opts trees
if isOpt "tr" opts
then putStrLn s
else return ()