mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
cc -table
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" ++
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user