summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-11-10 16:23:09 +0000
committeraarne <aarne@cs.chalmers.se>2008-11-10 16:23:09 +0000
commitca59050abc8efccfb59b93cfbd8da93556605928 (patch)
tree0814cc5118f331467e77e7ce010c9f7d2bc60711
parent821fbe7ddbf8038178200dd998582bdf66c05881 (diff)
print "no trees found" in GF shell if an empty tree list is returned by p or pt
-rw-r--r--src/GF/Command/Commands.hs10
1 files 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