macros for commands (dc) and terms (dt)

This commit is contained in:
aarne
2008-06-18 07:22:30 +00:00
parent ae171fc05f
commit b37db6c880
5 changed files with 107 additions and 23 deletions

View File

@@ -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