mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
Write LPGF dump to file when DEBUG is set, rather than console
This commit is contained in:
@@ -29,8 +29,8 @@ mkCanon2lpgf :: Options -> SourceGrammar -> ModuleName -> IOE LPGF
|
|||||||
mkCanon2lpgf opts gr am = do
|
mkCanon2lpgf opts gr am = do
|
||||||
debug <- isJust <$> lookupEnv "DEBUG"
|
debug <- isJust <$> lookupEnv "DEBUG"
|
||||||
when debug $ do
|
when debug $ do
|
||||||
writeCanonical "DEBUG" canon
|
writeCanonical debugDir canon
|
||||||
dumpCanonical "DEBUG" canon
|
dumpCanonical debugDir canon
|
||||||
(an,abs) <- mkAbstract ab
|
(an,abs) <- mkAbstract ab
|
||||||
cncs <- mapM mkConcrete cncs
|
cncs <- mapM mkConcrete cncs
|
||||||
let lpgf = LPGF {
|
let lpgf = LPGF {
|
||||||
@@ -38,7 +38,7 @@ mkCanon2lpgf opts gr am = do
|
|||||||
L.abstract = abs,
|
L.abstract = abs,
|
||||||
L.concretes = Map.fromList cncs
|
L.concretes = Map.fromList cncs
|
||||||
}
|
}
|
||||||
when debug $ dumpLPGF lpgf
|
when debug $ dumpLPGF debugDir lpgf
|
||||||
return lpgf
|
return lpgf
|
||||||
where
|
where
|
||||||
canon@(C.Grammar ab cncs) = grammar2canonical opts am gr
|
canon@(C.Grammar ab cncs) = grammar2canonical opts am gr
|
||||||
@@ -310,6 +310,9 @@ fi2i (C.FunId i) = mkCId i
|
|||||||
|
|
||||||
-- Debugging
|
-- Debugging
|
||||||
|
|
||||||
|
debugDir :: FilePath
|
||||||
|
debugDir = "DEBUG"
|
||||||
|
|
||||||
-- -- | Pretty-print canonical grammar to console
|
-- -- | Pretty-print canonical grammar to console
|
||||||
-- ppCanonical :: C.Grammar -> IO ()
|
-- ppCanonical :: C.Grammar -> IO ()
|
||||||
-- ppCanonical = putStrLn . render . pp
|
-- ppCanonical = putStrLn . render . pp
|
||||||
@@ -339,8 +342,9 @@ dumpCanonical path (C.Grammar ab cncs) = do
|
|||||||
]
|
]
|
||||||
writeFile (path </> mdi2s modId <.> "canonical.dump") body
|
writeFile (path </> mdi2s modId <.> "canonical.dump") body
|
||||||
|
|
||||||
-- | Dump LPGF to console
|
-- | Dump LPGF to file
|
||||||
dumpLPGF :: LPGF -> IO ()
|
dumpLPGF :: FilePath -> LPGF -> IO ()
|
||||||
dumpLPGF lpgf =
|
dumpLPGF path lpgf =
|
||||||
forM_ (Map.toList $ L.concretes lpgf) $ \(cid,concr) ->
|
forM_ (Map.toList $ L.concretes lpgf) $ \(cid,concr) -> do
|
||||||
mapM_ print (Map.toList $ L.lins concr)
|
let body = unlines $ map show (Map.toList $ L.lins concr)
|
||||||
|
writeFile (path </> showCId cid <.> "lpgf.dump") body
|
||||||
|
|||||||
Reference in New Issue
Block a user