cc -table

This commit is contained in:
aarne
2007-02-23 16:28:06 +00:00
parent 446ebd229c
commit 67470b29cc
5 changed files with 26 additions and 2 deletions

View File

@@ -434,3 +434,24 @@ nonLiteralsToUTF8 ('"':cs) = '"' : l ++ nonLiteralsToUTF8 rs
takeStringLit (c:cs) = (c:xs,ys)
where (xs,ys) = takeStringLit cs
nonLiteralsToUTF8 (c:cs) = encodeUTF8 [c] ++ nonLiteralsToUTF8 cs
printParadigm :: G.Term -> String
printParadigm term =
if hasTable term then
(unlines . map prBranch . branches . head . tables) term
else
prt term
where
tables t = case t of
G.R rs -> concatMap (tables . snd . snd) rs
G.T _ cs -> [cs]
_ -> []
hasTable t = not $ null $ tables t
branches cs = [(p:ps,s) |
(p,t) <- cs,
let ts = tables t,
(ps,s) <- if null ts then [([],t)]
else concatMap branches ts
]
prBranch (ps,s) = unwords (map prt ps ++ [prt s])

View File

@@ -375,11 +375,12 @@ execC co@(comm, opts0) sa@(sh@(st,(h,_,_,_)),a) = checkOptions st co >> case com
CTestTokenizer -> changeArg (AString . optTokenizer opts gro . prCommandArg) sa
CComputeConcrete t -> do
let prin = if (oElem (iOpt "table") opts) then printParadigm else prt
m <- return $
maybe (I.identC "?") id $ -- meaningful if no opers in t
maybe (resourceOfShellState st) (return . I.identC) $ -- topmost res
getOptVal opts useResource -- flag -res=m
justOutput opts (putStrLn (err id (prt . stripTerm) (
justOutput opts (putStrLn (err id (prin . stripTerm) (
string2srcTerm src m t >>=
Ch.justCheckLTerm src >>=
Co.computeConcrete src))) sa

View File

@@ -299,6 +299,7 @@ txtHelpFile =
"\n N.B.' The resulting Term is not a term in the sense of abstract syntax," ++
"\n and hence not a valid input to a Tree-demanding command." ++
"\n flags:" ++
"\n -table show output in a similar readable format as 'l -table'" ++
"\n -res use another module than the topmost one" ++
"\n examples:" ++
"\n cc -res=ParadigmsFin (nLukko \"hyppy\") -- inflect \"hyppy\" with nLukko" ++

View File

@@ -197,7 +197,7 @@ optionsOfCommand co = case co of
CApplyTransfer _ -> flags "lang transfer"
CMorphoAnalyse -> both "short" "lang"
CTestTokenizer -> flags "lexer"
CComputeConcrete _ -> flags "res"
CComputeConcrete _ -> both "table" "res"
CShowOpers _ -> flags "res"
CTranslationQuiz _ _ -> flags "cat"

View File

@@ -270,6 +270,7 @@ cc, compute_concrete: cc Term
N.B.' The resulting Term is not a term in the sense of abstract syntax,
and hence not a valid input to a Tree-demanding command.
flags:
-table show output in a similar readable format as 'l -table'
-res use another module than the topmost one
examples:
cc -res=ParadigmsFin (nLukko "hyppy") -- inflect "hyppy" with nLukko