summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 19:19:10 +0200
committerKrasimir Angelov <kr.angelov@gmail.com>2017-08-30 19:19:10 +0200
commit13a854d349f345e6395b50ba11a371e9d3a37d52 (patch)
treece09e65af24eede54b37108f734e16cbd7fbbdff /src
parent34294bf36e1c35ff70686737dc12748d0e5821ca (diff)
implement rf in the C shell
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Command/Commands2.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/compiler/GF/Command/Commands2.hs b/src/compiler/GF/Command/Commands2.hs
index 76a433a1c..c6f54b051 100644
--- a/src/compiler/GF/Command/Commands2.hs
+++ b/src/compiler/GF/Command/Commands2.hs
@@ -40,7 +40,7 @@ import Data.Maybe
import qualified Data.Map as Map
--import System.Cmd(system) -- use GF.Infra.UseIO.restricedSystem instead!
--import GF.System.Process
---import GF.Text.Pretty
+import GF.Text.Pretty
--import Data.List (sort)
import Control.Monad(mplus)
--import Debug.Trace
@@ -377,7 +377,6 @@ pgfCommands = Map.fromList [
flags = [("number","take at most this many trees")] ++ treeOpFlags undefined{-pgf-}
}),
-}
-{-
("rf", emptyCommandInfo {
longname = "read_file",
synopsis = "read string or tree input from a file",
@@ -392,21 +391,21 @@ pgfCommands = Map.fromList [
("lines","return the list of lines, instead of the singleton of all contents"),
("tree","convert strings into trees")
],
- exec = \env@(pgf, mos) opts _ -> do
+ exec = needPGF $ \opts _ env@(pgf, mos) -> do
let file = valStrOpts "file" "_gftmp" opts
let exprs [] = ([],empty)
exprs ((n,s):ls) | null s
= exprs ls
- exprs ((n,s):ls) = case H.readExpr s of
+ exprs ((n,s):ls) = case readExpr s of
Just e -> let (es,err) = exprs ls
- in case H.inferExpr pgf e of
+ in case inferExpr pgf e of
Right (e,t) -> (e:es,err)
- Left tcerr -> (es,"on line" <+> n <> ':' $$ nest 2 (H.ppTcError tcerr) $$ err)
+ Left msg -> (es,"on line" <+> n <> ':' $$ msg $$ err)
Nothing -> let (es,err) = exprs ls
in (es,"on line" <+> n <> ':' <+> "parse error" $$ err)
returnFromLines ls = case exprs ls of
(es, err) | null es -> return $ pipeMessage $ render (err $$ "no trees found")
- | otherwise -> return $ pipeWithMessage es (render err)
+ | otherwise -> return $ pipeWithMessage (map hsExpr es) (render err)
s <- restricted $ readFile file
case opts of
@@ -418,7 +417,7 @@ pgfCommands = Map.fromList [
_ -> return (fromString s),
flags = [("file","the input file name")]
}),
-
+{-
("rt", emptyCommandInfo {
longname = "rank_trees",
synopsis = "show trees in an order of decreasing probability",