summaryrefslogtreecommitdiff
path: root/compiler/main/HscMain.hs
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-01-11 11:57:35 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-01-15 21:38:05 +0200
commit1ff3c5882427d704538250e6fdadd6f48bb08989 (patch)
tree56bf792993cf59c3120219dc420c06879e397883 /compiler/main/HscMain.hs
parent9d67f04d4892ea399631fd67ce91782b821a127e (diff)
downloadhaskell-1ff3c5882427d704538250e6fdadd6f48bb08989.tar.gz
Add dump-parsed-ast flag and functionality
Summary: This flag causes a dump of the ParsedSource as an AST in textual form, similar to the ghc-dump-tree on hackage. Test Plan: ./validate Reviewers: mpickering, bgamari, austin Reviewed By: mpickering Subscribers: nominolo, thomie Differential Revision: https://phabricator.haskell.org/D2958 GHC Trac Issues: #11140
Diffstat (limited to 'compiler/main/HscMain.hs')
-rw-r--r--compiler/main/HscMain.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index eb56a54209..b163cbbe21 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -81,6 +81,7 @@ module HscMain
, showModuleIndex
) where
+import Data.Data hiding (Fixity, TyCon)
import Id
import GHCi.RemoteTypes ( ForeignHValue )
import ByteCodeGen ( byteCodeGen, coreExprToBCOs )
@@ -98,6 +99,7 @@ import Module
import Packages
import RdrName
import HsSyn
+import HsDumpAst
import CoreSyn
import StringBuffer
import Parser
@@ -330,6 +332,8 @@ hscParse' mod_summary
logWarningsReportErrors (getMessages pst dflags)
liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed "Parser" $
ppr rdr_module
+ liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed_ast "Parser AST" $
+ text (showAstData NoBlankSrcSpan rdr_module)
liftIO $ dumpIfSet_dyn dflags Opt_D_source_stats "Source Statistics" $
ppSourceStats False rdr_module
@@ -1662,10 +1666,11 @@ hscParseIdentifier :: HscEnv -> String -> IO (Located RdrName)
hscParseIdentifier hsc_env str =
runInteractiveHsc hsc_env $ hscParseThing parseIdentifier str
-hscParseThing :: (Outputable thing) => Lexer.P thing -> String -> Hsc thing
+hscParseThing :: (Outputable thing, Data thing)
+ => Lexer.P thing -> String -> Hsc thing
hscParseThing = hscParseThingWithLocation "<interactive>" 1
-hscParseThingWithLocation :: (Outputable thing) => String -> Int
+hscParseThingWithLocation :: (Outputable thing, Data thing) => String -> Int
-> Lexer.P thing -> String -> Hsc thing
hscParseThingWithLocation source linenumber parser str
= withTiming getDynFlags
@@ -1684,6 +1689,8 @@ hscParseThingWithLocation source linenumber parser str
POk pst thing -> do
logWarningsReportErrors (getMessages pst dflags)
liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed "Parser" (ppr thing)
+ liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed_ast "Parser AST" $
+ text $ showAstData NoBlankSrcSpan thing
return thing