summaryrefslogtreecommitdiff
path: root/src/GF/Command/Commands.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-02-07 23:31:22 +0000
committerkrasimir <krasimir@chalmers.se>2009-02-07 23:31:22 +0000
commit5c2ce87cde2dee9f6af65ed5e63ee7d9f072f399 (patch)
tree3e0dd3ea1537b34657ec1c2bdc6223ed7ebfb10a /src/GF/Command/Commands.hs
parent14c13cb08077290643cb19538c7d0b3b50dc6df0 (diff)
PMCFG pretty printer
Diffstat (limited to 'src/GF/Command/Commands.hs')
-rw-r--r--src/GF/Command/Commands.hs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs
index 5674f1107..2a4a8b631 100644
--- a/src/GF/Command/Commands.hs
+++ b/src/GF/Command/Commands.hs
@@ -17,7 +17,7 @@ import PGF.Data ----
import PGF.Morphology
import PGF.VisualizeTree
import GF.Compile.Export
-import GF.Infra.Option (noOptions)
+import GF.Infra.Option (noOptions, readOutputFormat)
import GF.Infra.UseIO
import GF.Data.ErrM ----
import PGF.Expr (readTree)
@@ -376,7 +376,7 @@ allCommands cod env@(pgf, mos) = Map.fromList [
"N.B.2 This command is slightly obsolete: to produce different formats",
"the batch compiler gfc is recommended, and has many more options."
],
- exec = \opts _ -> return $ fromString $ prGrammar opts,
+ exec = \opts _ -> prGrammar opts,
flags = [
--"cat",
("lang", "select languages for the some options (default all languages)"),
@@ -651,15 +651,13 @@ allCommands cod env@(pgf, mos) = Map.fromList [
[] -> (ts, "no trees found")
_ -> fromTrees ts
- prGrammar opts = case opts of
- _ | isOpt "cats" opts -> unwords $ map showType $ categories pgf
- _ | isOpt "fullform" opts -> concatMap
- (prFullFormLexicon . morpho) $ optLangs opts
- _ | isOpt "missing" opts ->
- unlines $ [unwords (prCId la:":": map prCId cs) |
- la <- optLangs opts, let cs = missingLins pgf la]
- _ -> case valStrOpts "printer" "pgf" opts of
- v -> concatMap snd $ exportPGF noOptions (read v) pgf
+ prGrammar opts
+ | isOpt "cats" opts = return $ fromString $ unwords $ map showType $ categories pgf
+ | isOpt "fullform" opts = return $ fromString $ concatMap (prFullFormLexicon . morpho) $ optLangs opts
+ | isOpt "missing" opts = return $ fromString $ unlines $ [unwords (prCId la:":": map prCId cs) |
+ la <- optLangs opts, let cs = missingLins pgf la]
+ | otherwise = do fmt <- readOutputFormat (valStrOpts "printer" "pgf_pretty" opts)
+ return $ fromString $ concatMap snd $ exportPGF noOptions fmt pgf
morphos opts s =
[lookupMorpho (morpho la) s | la <- optLangs opts]