summaryrefslogtreecommitdiff
path: root/src/GF/Command/Interpreter.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-09-13 15:39:11 +0000
committerkrasimir <krasimir@chalmers.se>2009-09-13 15:39:11 +0000
commitcc151c42790e02d60d6a0ab18c9c56da76f0ea51 (patch)
treea18f08a52324cf3e472d917c6e4efb059a8647ab /src/GF/Command/Interpreter.hs
parent41114389790ec79a3861a3995aee1a7da59581f0 (diff)
added needsTypeCheck parameter to CommandInfo. The argument to the command is typechecked only if needsTypeCheck=True
Diffstat (limited to 'src/GF/Command/Interpreter.hs')
-rw-r--r--src/GF/Command/Interpreter.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/GF/Command/Interpreter.hs b/src/GF/Command/Interpreter.hs
index 2ace4cde6..17ff6aa29 100644
--- a/src/GF/Command/Interpreter.hs
+++ b/src/GF/Command/Interpreter.hs
@@ -56,7 +56,7 @@ interpretPipe enc env cs = do
interc es comm@(Command co opts arg) = case co of
'%':f -> case Map.lookup f (commandmacros env) of
Just css ->
- case getCommandTrees env arg es of
+ case getCommandTrees env False arg es of
Right es -> do mapM_ (interpretPipe enc env) (appLine es css)
return ([],[])
Left msg -> do putStrLn ('\n':msg)
@@ -98,7 +98,7 @@ getCommand :: CommandEnv -> [Expr] -> Command -> Either String (CommandInfo,[Opt
getCommand env es co@(Command c opts arg) = do
info <- getCommandInfo env c
checkOpts info opts
- es <- getCommandTrees env arg es
+ es <- getCommandTrees env (needsTypeCheck info) arg es
return (info,opts,es)
getCommandInfo :: CommandEnv -> String -> Either String CommandInfo
@@ -117,14 +117,16 @@ checkOpts info opts =
[o] -> fail $ "option not interpreted: " ++ o
os -> fail $ "options not interpreted: " ++ unwords os
-getCommandTrees :: CommandEnv -> Argument -> [Expr] -> Either String [Expr]
-getCommandTrees env a es =
+getCommandTrees :: CommandEnv -> Bool -> Argument -> [Expr] -> Either String [Expr]
+getCommandTrees env needsTypeCheck a es =
case a of
AMacro m -> case Map.lookup m (expmacros env) of
Just e -> return [e]
_ -> return []
- AExpr e -> case inferExpr (multigrammar env) e of
- Left tcErr -> fail $ render (ppTcError tcErr)
- Right (e,ty) -> return [e] -- ignore piped
+ AExpr e -> if needsTypeCheck
+ then case inferExpr (multigrammar env) e of
+ Left tcErr -> fail $ render (ppTcError tcErr)
+ Right (e,ty) -> return [e] -- ignore piped
+ else return [e]
ANoArg -> return es -- use piped
-
+