1
0
forked from GitHub/gf-core

p by lines, lin to multi

This commit is contained in:
aarne
2005-02-25 14:35:48 +00:00
parent d83c6b816d
commit f5932b9bb4
5 changed files with 45 additions and 23 deletions

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/02/24 11:46:35 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.20 $
-- > CVS $Date: 2005/02/25 15:35:48 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.21 $
--
-- Options and flags used in GF shell commands and files.
--
@@ -227,6 +227,7 @@ optimizeValues = iOpt "val"
stripQualif = iOpt "strip"
nostripQualif = iOpt "nostrip"
showAll = iOpt "all"
showMulti = iOpt "multi"
fromSource = iOpt "src"
-- ** mainly for stand-alone

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/02/24 11:46:37 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.33 $
-- > CVS $Date: 2005/02/25 15:35:48 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.34 $
--
-- GF shell command interpreter.
-----------------------------------------------------------------------------
@@ -145,15 +145,28 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of
CPrintHistory -> (returnArg $ AString $ unlines $ reverse h) sa
-- good to have here for piping; eh and ec must be done on outer level
CLinearize [] ->
changeArg (opTS2CommandArg (optLinearizeTreeVal opts gro) . s2t) sa
CLinearize []
| oElem showMulti opts ->
changeArg (opTS2CommandArg (unlines. linearizeToAll
(allStateGrammars st)) . s2t) sa
| otherwise -> changeArg (opTS2CommandArg (optLinearizeTreeVal opts gro) . s2t) sa
---- CLinearize m -> changeArg (opTS2CommandArg (optLinearizeArgForm opts gro m)) sa
CParse -> do
warnDiscont opts
case optParseArgErrMsg opts gro (prCommandArg a) of
Ok (ts,msg) -> putStrLnFlush msg >> changeArg (const $ ATrms ts) sa
Bad msg -> changeArg (const $ AError msg) sa
CParse
---- | oElem showMulti opts -> do
| oElem byLines opts -> do
let ss = (if oElem showAll opts then id else filter (not . null)) $ lines $ prCommandArg a
mts <- mapM parse ss
let a' = ATrms [t | (_,ATrms ts) <- mts, t <- ts]
changeArg (const a') sa
| otherwise -> parse $ prCommandArg a
where
parse x = do
warnDiscont opts
let p = optParseArgErrMsg opts gro x
case p of
Ok (ts,msg) -> putStrLnFlush msg >> changeArg (const $ ATrms ts) sa
Bad msg -> changeArg (const $ AError (msg +++ "input" +++ x)) sa
CTranslate il ol -> do
let a' = opST2CommandArg (optParseArgErr opts (sgr il)) a

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/02/24 11:46:37 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.23 $
-- > CVS $Date: 2005/02/25 15:35:48 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.24 $
--
-- The datatype of shell commands and the list of their options.
-----------------------------------------------------------------------------
@@ -157,8 +157,8 @@ optionsOfCommand co = case co of
CStripState -> none
CTransformGrammar _ -> flags "printer"
CConvertLatex _ -> none
CLinearize _ -> both "utf8 table struct record all" "lang number unlexer"
CParse -> both "new n ign raw v" "cat lang lexer parser number rawtrees"
CLinearize _ -> both "utf8 table struct record all multi" "lang number unlexer"
CParse -> both "new n ign raw v lines all" "cat lang lexer parser number rawtrees"
CTranslate _ _ -> opts "cat lexer parser"
CGenerateRandom -> flags "cat lang number depth"
CGenerateTrees -> both "metas" "depth alts cat lang number"