summaryrefslogtreecommitdiff
path: root/src/GF/Command
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Command')
-rw-r--r--src/GF/Command/Commands.hs6
-rw-r--r--src/GF/Command/TreeOperations.hs16
2 files changed, 9 insertions, 13 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs
index 27ac61c81..2aa616739 100644
--- a/src/GF/Command/Commands.hs
+++ b/src/GF/Command/Commands.hs
@@ -384,7 +384,7 @@ allCommands cod pgf = Map.fromList [
"p \"foo\" | pt -typecheck -- type check parse results"
],
exec = \opts -> return . fromTrees . treeOps (map prOpt opts),
- options = treeOpOptions
+ options = treeOpOptions pgf
}),
("q", emptyCommandInfo {
longname = "quit",
@@ -608,7 +608,7 @@ allCommands cod pgf = Map.fromList [
app f = maybe id id (stringOp f)
treeOps opts s = foldr app s (reverse opts) where
- app f = maybe id id (treeOp f)
+ app f = maybe id id (treeOp pgf f)
showAsString t = case t of
Lit (LStr s) -> s
@@ -641,7 +641,7 @@ stringOpOptions = [
("words","lexer that assumes tokens separated by spaces (default)")
]
-treeOpOptions = [(op,expl) | (op,(expl,_)) <- allTreeOps]
+treeOpOptions pgf = [(op,expl) | (op,(expl,_)) <- allTreeOps pgf]
translationQuiz :: String -> PGF -> Language -> Language -> Category -> IO ()
translationQuiz cod pgf ig og cat = do
diff --git a/src/GF/Command/TreeOperations.hs b/src/GF/Command/TreeOperations.hs
index f05b8dec3..0ff6ac682 100644
--- a/src/GF/Command/TreeOperations.hs
+++ b/src/GF/Command/TreeOperations.hs
@@ -2,11 +2,10 @@ module GF.Command.TreeOperations (
treeOp,
allTreeOps
--typeCheck,
- --compute
) where
import GF.Compile.TypeCheck
-import GF.Compile.AbsCompute
+import PGF (compute)
-- for conversions
import PGF.Data
@@ -18,13 +17,13 @@ import Data.List
type TreeOp = [Tree] -> [Tree]
-treeOp :: String -> Maybe TreeOp
-treeOp f = fmap snd $ lookup f allTreeOps
+treeOp :: PGF -> String -> Maybe TreeOp
+treeOp pgf f = fmap snd $ lookup f $ allTreeOps pgf
-allTreeOps :: [(String,(String,TreeOp))]
-allTreeOps = [
+allTreeOps :: PGF -> [(String,(String,TreeOp))]
+allTreeOps pgf = [
("compute",("compute by using semantic definitions (def)",
- id)),
+ map (compute pgf))),
("smallest",("sort trees from smallest to largest, in number of nodes",
smallest)),
("typecheck",("type check and solve metavariables; reject if incorrect",
@@ -34,9 +33,6 @@ allTreeOps = [
typeCheck :: PGF -> Tree -> (Tree,(Bool,[String]))
typeCheck pgf t = (t,(True,[]))
-compute :: PGF -> Tree -> Tree
-compute pgf t = t
-
smallest :: [Tree] -> [Tree]
smallest = sortBy (\t u -> compare (size t) (size u)) where
size t = case t of