summaryrefslogtreecommitdiff
path: root/src-3.0/GFI.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-06-18 07:22:30 +0000
committeraarne <aarne@cs.chalmers.se>2008-06-18 07:22:30 +0000
commit0f21f8f3436d732838dc76da0c1005eb332961ff (patch)
treeacf77a40a85c6522bdc4fbe763a25184ee9d62b8 /src-3.0/GFI.hs
parent23b8136af27b0baaa8fcb5272a613d5f2ee447fa (diff)
macros for commands (dc) and terms (dt)
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