summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Interactive.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-08-18 13:13:31 +0000
committerhallgren <hallgren@chalmers.se>2015-08-18 13:13:31 +0000
commit41075fb50a846ef0ae9851b99a3468bc0e405988 (patch)
tree92ac4a600a899227f1f064ab1bd45e5d1f06016d /src/compiler/GF/Interactive.hs
parent17e7a01ae1ab33158273f7370251185b430b41cd (diff)
GF shell: restore the eh command to working order and document it
Also, when the command line parser fails, append the problematic command line to the error message "command not parsed".
Diffstat (limited to 'src/compiler/GF/Interactive.hs')
-rw-r--r--src/compiler/GF/Interactive.hs26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/compiler/GF/Interactive.hs b/src/compiler/GF/Interactive.hs
index efbbcf341..59f7a6bce 100644
--- a/src/compiler/GF/Interactive.hs
+++ b/src/compiler/GF/Interactive.hs
@@ -13,7 +13,7 @@ import GF.Command.Help(helpCommand)
import GF.Command.Abstract
import GF.Command.Parse(readCommandLine,pCommand)
import GF.Data.Operations (Err(..),done)
-import GF.Data.Utilities(repeatM)
+import GF.Data.Utilities(whenM,repeatM)
import GF.Grammar hiding (Ident,isPrefixOf)
import GF.Infra.UseIO(ioErrorText,putStrLnE)
import GF.Infra.SIO
@@ -113,17 +113,21 @@ type ShellM = StateT GFEnv SIO
-- | Execute a given command line, returning 'True' to continue execution,
-- | 'False' when it is time to quit
-execute1 :: String -> ShellM Bool
+execute1, execute1' :: String -> ShellM Bool
execute1 s0 =
do modify $ \ gfenv0 -> gfenv0 {history = s0 : history gfenv0}
- opts <- gets startOpts
+ execute1' s0
+
+-- | Execute a given command line, without adding it to the history
+execute1' s0 =
+ do opts <- gets startOpts
interruptible $ optionallyShowCPUTime opts $
case pwords s0 of
-- cc, sd, so, ss and dg are now in GF.Commands.SourceCommands
-- special commands
"q" :_ -> quit
"!" :ws -> system_command ws
- "eh":ws -> eh ws
+ "eh":ws -> execute_history ws
"i" :ws -> do import_ ws; continue
-- other special commands, working on GFEnv
"dc":ws -> define_command ws
@@ -157,12 +161,16 @@ execute1 s0 =
cs <- readFile w >>= return . map words . lines
gfenv' <- foldM (flip (process False benv)) gfenv cs
loopNewCPU gfenv' -}
- eh [w] = -- Ehhh? Reads commands from a file, but does not execute them
- do env <- gets commandenv
- cs <- lift $ restricted (readFile w) >>= return . map (interpretCommandLine env) . lines
+ execute_history [w] =
+ do execute . lines =<< lift (restricted (readFile w))
continue
- eh _ = do putStrLnE "eh command not parsed"
- continue
+ where
+ execute [] = done
+ execute (line:lines) = whenM (execute1' line) (execute lines)
+
+ execute_history _ =
+ do putStrLnE "eh command not parsed"
+ continue
define_command (f:ws) =
case readCommandLine (unwords ws) of