summaryrefslogtreecommitdiff
path: root/src/GF/Command/Interpreter.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-05-23 21:33:52 +0000
committerkrasimir <krasimir@chalmers.se>2009-05-23 21:33:52 +0000
commite5c8636a5f608af83d918e62533306cf7ddc7118 (patch)
tree813d9b452133b4283de850bd1d634f76678f46b8 /src/GF/Command/Interpreter.hs
parent41b263cf6aa38e7c6ef090c0fa18949b86eec62c (diff)
now in the command shell the primary type in the pipe is Expr not Tree. This makes the pt -compute and pt -typecheck more interesting
Diffstat (limited to 'src/GF/Command/Interpreter.hs')
-rw-r--r--src/GF/Command/Interpreter.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/GF/Command/Interpreter.hs b/src/GF/Command/Interpreter.hs
index 7c962b375..23b928ed6 100644
--- a/src/GF/Command/Interpreter.hs
+++ b/src/GF/Command/Interpreter.hs
@@ -27,7 +27,7 @@ data CommandEnv = CommandEnv {
morphos :: Map.Map Language Morpho,
commands :: Map.Map String CommandInfo,
commandmacros :: Map.Map String CommandLine,
- expmacros :: Map.Map String Tree
+ expmacros :: Map.Map String Expr
}
mkCommandEnv :: Encoding -> PGF -> CommandEnv
@@ -72,18 +72,20 @@ interpretPipe enc env cs = do
appLine es = map (map (appCommand es))
-- macro definition applications: replace ?i by (exps !! i)
-appCommand :: [Tree] -> Command -> Command
+appCommand :: [Expr] -> Command -> Command
appCommand xs c@(Command i os arg) = case arg of
- ATree e -> Command i os (ATree (app e))
+ AExpr e -> Command i os (AExpr (app e))
_ -> c
where
app e = case e of
- Meta i -> xs !! i
- Fun f as -> Fun f (map app as)
- Abs x b -> Abs x (app b)
+ EAbs x e -> EAbs x (app e)
+ EApp e1 e2 -> EApp (app e1) (app e2)
+ ELit l -> ELit l
+ EMeta i -> xs !! i
+ EVar x -> EVar x
-- return the trees to be sent in pipe, and the output possibly printed
-interpret :: (String -> String) -> CommandEnv -> [Tree] -> Command -> IO CommandOutput
+interpret :: (String -> String) -> CommandEnv -> [Expr] -> Command -> IO CommandOutput
interpret enc env trees0 comm = case lookCommand co comms of
Just info -> do
checkOpts info
@@ -108,15 +110,15 @@ interpret enc env trees0 comm = case lookCommand co comms of
-- analyse command parse tree to a uniform datastructure, normalizing comm name
--- the env is needed for macro lookup
-getCommand :: CommandEnv -> Command -> [Tree] -> (String,[Option],[Tree])
+getCommand :: CommandEnv -> Command -> [Expr] -> (String,[Option],[Expr])
getCommand env co@(Command c opts arg) ts =
(getCommandOp c,opts,getCommandArg env arg ts)
-getCommandArg :: CommandEnv -> Argument -> [Tree] -> [Tree]
+getCommandArg :: CommandEnv -> Argument -> [Expr] -> [Expr]
getCommandArg env a ts = case a of
AMacro m -> case Map.lookup m (expmacros env) of
Just t -> [t]
_ -> []
- ATree t -> [t] -- ignore piped
+ AExpr t -> [t] -- ignore piped
ANoArg -> ts -- use piped