summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2011-08-25 15:58:38 +0000
committeraarne <aarne@chalmers.se>2011-08-25 15:58:38 +0000
commit6757ab2b41a9dc6c74f6184b8d0846970753e9fc (patch)
tree3d242e56536986c3cd8b0fb9ddf9c5282c7bebb2 /src
parent1fccece30c6da8a872499cf8bf0eaa9c7af2522a (diff)
reload command in shell
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Command/Commands.hs4
-rw-r--r--src/compiler/GF/Compile/Compute/Concrete.hs4
-rw-r--r--src/compiler/GFI.hs19
3 files changed, 21 insertions, 6 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index e7beec23e..543c05cb2 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -665,6 +665,10 @@ allCommands env@(pgf, mos) = Map.fromList [
longname = "quit",
synopsis = "exit GF interpreter"
}),
+ ("r", emptyCommandInfo {
+ longname = "reload",
+ synopsis = "repeat the latest import command"
+ }),
("rf", emptyCommandInfo {
longname = "read_file",
synopsis = "read string or tree input from a file",
diff --git a/src/compiler/GF/Compile/Compute/Concrete.hs b/src/compiler/GF/Compile/Compute/Concrete.hs
index adcb61ece..29ba8969d 100644
--- a/src/compiler/GF/Compile/Compute/Concrete.hs
+++ b/src/compiler/GF/Compile/Compute/Concrete.hs
@@ -65,7 +65,7 @@ computeTermOpt rec gr = comput True where
return $ lookup x g
case t' of
_ | t == t' -> return t
- _ -> comp g t'
+ _ -> comp g t' --- why compute again? AR 25/8/2011
-- Abs x@(IA _) b -> do
Abs _ _ _ | full -> do -- \xs -> b
@@ -391,7 +391,7 @@ computeTermOpt rec gr = comput True where
ps0 <- mapM (compPatternMacro . fst) cs
cs' <- mapM (compBranch g) (zip ps0 (map snd cs))
------ cs' <- return (zip ps0 (map snd cs)) --- probably right AR 22/8/2011
+----- cs' <- return (zip ps0 (map snd cs)) --- probably right AR 22/8/2011 but can leave uninstantiated variables :-(
---- cs' <- mapM (compBranch g) cs
return $ T i cs' -- happens with variable types
diff --git a/src/compiler/GFI.hs b/src/compiler/GFI.hs
index 58c6df92e..ffae88c7d 100644
--- a/src/compiler/GFI.hs
+++ b/src/compiler/GFI.hs
@@ -116,7 +116,7 @@ loopOptNewCPU opts gfenv'
execute1 :: Options -> GFEnv -> String -> IO (Maybe GFEnv)
execute1 opts gfenv0 s0 =
interruptible $ optionallyShowCPUTime opts $
- case pwords of
+ case pwords s0 of
-- special commands, requiring source grammar in env
{-"eh":w:_ -> do
cs <- readFile w >>= return . map words . lines
@@ -134,6 +134,7 @@ execute1 opts gfenv0 s0 =
"dc":ws -> define_command ws
"dt":ws -> define_tree ws
"ph":_ -> print_history
+ "r" :_ -> reload_last
"se":ws -> set_encoding ws
-- ordinary commands, working on CommandEnv
_ -> do interpretCommandLine env s0
@@ -145,9 +146,9 @@ execute1 opts gfenv0 s0 =
env = commandenv gfenv0
sgr = sourcegrammar gfenv0
gfenv = gfenv0 {history = s0 : history gfenv0}
- pwords = case words s0 of
- w:ws -> getCommandOp w :ws
- ws -> ws
+ pwords s = case words s of
+ w:ws -> getCommandOp w :ws
+ ws -> ws
interruptible act =
either (\e -> printException e >> return (Just gfenv)) return
@@ -256,6 +257,16 @@ execute1 opts gfenv0 s0 =
print_history = mapM_ putStrLn (reverse (history gfenv0))>> continue gfenv
+ reload_last = do
+ let imports = [(s,ws) | s <- history gfenv0, ("i":ws) <- [pwords s]]
+ case imports of
+ (s,ws):_ -> do
+ putStrLn $ "repeating latest import: " ++ s
+ import_ ws
+ _ -> do
+ putStrLn $ "no import in history"
+ continue gfenv
+
set_encoding [c] =
do let cod = renameEncoding c
#ifdef mingw32_HOST_OS