diff options
| author | krasimir <krasimir@chalmers.se> | 2009-05-20 21:03:56 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-05-20 21:03:56 +0000 |
| commit | 7db4b641ce6abe90dd404459cd5eccb6e67f618c (patch) | |
| tree | f708d2e7ed970d71655b66cac78c8b525b010cd9 /src/GF/Command | |
| parent | 401dfc28d62584178c1187c92dece8dd0832dcb4 (diff) | |
refactor the PGF.Expr type and the evaluation of abstract expressions
Diffstat (limited to 'src/GF/Command')
| -rw-r--r-- | src/GF/Command/Commands.hs | 6 | ||||
| -rw-r--r-- | src/GF/Command/TreeOperations.hs | 6 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs index fff9e011d..f29fd3d41 100644 --- a/src/GF/Command/Commands.hs +++ b/src/GF/Command/Commands.hs @@ -600,11 +600,11 @@ allCommands cod env@(pgf, mos) = Map.fromList [ exec = \opts arg -> do case arg of [Fun id []] -> case Map.lookup id (funs (abstract pgf)) of - Just (ty,def) -> return $ fromString $ + Just (ty,eqs) -> return $ fromString $ render (text "fun" <+> text (prCId id) <+> colon <+> ppType 0 ty $$ - if def == EEq [] + if null eqs then empty - else text "def" <+> text (prCId id) <+> char '=' <+> ppExpr 0 def) + else text "def" <+> vcat [text (prCId id) <+> hsep (map (ppPatt 9) patts) <+> char '=' <+> ppExpr 0 res | Equ patts res <- eqs]) Nothing -> case Map.lookup id (cats (abstract pgf)) of Just hyps -> do return $ fromString $ render (text "cat" <+> text (prCId id) <+> hsep (map ppHypo hyps) $$ diff --git a/src/GF/Command/TreeOperations.hs b/src/GF/Command/TreeOperations.hs index a2670dc4f..ff87de563 100644 --- a/src/GF/Command/TreeOperations.hs +++ b/src/GF/Command/TreeOperations.hs @@ -4,10 +4,8 @@ module GF.Command.TreeOperations ( ) where import GF.Compile.TypeCheck -import PGF (compute,paraphrase,typecheck) +import PGF --- for conversions -import PGF.Data --import GF.Compile.GrammarToGFCC (mkType,mkExp) import qualified GF.Grammar.Grammar as G import qualified GF.Grammar.Macros as M @@ -22,7 +20,7 @@ treeOp pgf f = fmap snd $ lookup f $ allTreeOps pgf allTreeOps :: PGF -> [(String,(String,TreeOp))] allTreeOps pgf = [ ("compute",("compute by using semantic definitions (def)", - map (compute pgf))), + map (expr2tree pgf . tree2expr))), ("paraphrase",("paraphrase by using semantic definitions (def)", nub . concatMap (paraphrase pgf))), ("smallest",("sort trees from smallest to largest, in number of nodes", |
