summaryrefslogtreecommitdiff
path: root/src-3.0/GFI.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src-3.0/GFI.hs')
-rw-r--r--src-3.0/GFI.hs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src-3.0/GFI.hs b/src-3.0/GFI.hs
index e956d5c18..c9d9db0b3 100644
--- a/src-3.0/GFI.hs
+++ b/src-3.0/GFI.hs
@@ -14,6 +14,7 @@ import GF.System.Readline
import PGF
import PGF.Data
import PGF.Macros
+import PGF.ExprSyntax (readExp)
import Data.Char
import Data.List(isPrefixOf)
@@ -26,7 +27,6 @@ import Control.Exception
import Data.Version
import Paths_gf
-
mainGFI :: Options -> [FilePath] -> IO ()
mainGFI opts files = do
putStrLn welcome
@@ -72,10 +72,26 @@ loop opts gfenv0 = do
-- other special commands, working on GFEnv
"e":_ -> loopNewCPU $ gfenv {
- commandenv=env{multigrammar=emptyPGF}, sourcegrammar = emptyGrammar
+ commandenv=emptyCommandEnv, sourcegrammar = emptyGrammar
}
- ---- "eh":file:_ ->
+ "dc":f:ws -> do
+ case readCommandLine (unwords ws) of
+ Just comm -> loopNewCPU $ gfenv {
+ commandenv = env {
+ commandmacros = Map.insert f comm (commandmacros env)
+ }
+ }
+ _ -> putStrLn "command definition not parsed" >> loopNewCPU gfenv
+
+ "dt":f:ws -> do
+ case readExp (unwords ws) of
+ Just exp -> loopNewCPU $ gfenv {
+ commandenv = env {
+ expmacros = Map.insert f exp (expmacros env)
+ }
+ }
+ _ -> putStrLn "value definition not parsed" >> loopNewCPU gfenv
"ph":_ -> mapM_ putStrLn (reverse (history gfenv0)) >> loopNewCPU gfenv
"q":_ -> putStrLn "See you." >> return gfenv