From ca59050abc8efccfb59b93cfbd8da93556605928 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 10 Nov 2008 16:23:09 +0000 Subject: [PATCH] print "no trees found" in GF shell if an empty tree list is returned by p or pt --- src/GF/Command/Commands.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs index 63d7ff06a..22978cc6c 100644 --- a/src/GF/Command/Commands.hs +++ b/src/GF/Command/Commands.hs @@ -186,7 +186,7 @@ allCommands cod pgf = Map.fromList [ let pgfr = optRestricted opts let dp = return $ valIntOpts "depth" 4 opts let ts = generateAllDepth pgfr (optType opts) dp - return $ fromTrees $ take (optNumInf opts) ts + returnFromTrees $ take (optNumInf opts) ts }), ("h", emptyCommandInfo { longname = "help", @@ -304,7 +304,7 @@ allCommands cod pgf = Map.fromList [ "The default start category can be overridden by the -cat flag.", "See also the ps command for lexing and character encoding." ], - exec = \opts -> return . fromTrees . concatMap (par opts) . toStrings, + exec = \opts -> returnFromTrees . concatMap (par opts) . toStrings, flags = [ ("cat","target category of parsing"), ("lang","the languages of parsing (comma-separated, no spaces)") @@ -382,7 +382,7 @@ allCommands cod pgf = Map.fromList [ "pt -compute (plus one two) -- compute value", "p \"foo\" | pt -typecheck -- type check parse results" ], - exec = \opts -> return . fromTrees . treeOps (map prOpt opts), + exec = \opts -> returnFromTrees . treeOps (map prOpt opts), options = treeOpOptions pgf }), ("q", emptyCommandInfo { @@ -593,6 +593,10 @@ allCommands cod pgf = Map.fromList [ toStrings = map showAsString toString = unwords . toStrings + returnFromTrees ts = return $ case ts of + [] -> (ts, "no trees found") + _ -> fromTrees ts + prGrammar opts = case opts of _ | isOpt "cats" opts -> unwords $ map showType $ categories pgf _ | isOpt "fullform" opts -> concatMap