Add dump-parsed-ast flag and functionality
ClosedPublic

Authored by alanz on Jan 11 2017, 4:07 AM.

Details

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

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
alanz updated this revision to Diff 10422.Jan 11 2017, 4:07 AM
alanz retitled this revision from to Add dump-parsed-ast flag and functionality.
alanz edited the test plan for this revision. (Show Details)
alanz added a reviewer: mpickering.
alanz updated this object.
bgamari requested changes to this revision.Jan 11 2017, 11:29 AM
bgamari edited edge metadata.

Just a few minor points.

compiler/hsSyn/HsDumpAst.hs
10

Oops, cut-and-paste error!

Let's give this a proper Haddock module comment. I suspect we want to keep the copyright notices in a separate, non-Haddock comment though.

48

Out of curiosity, why doesn't this use Doc?

67

Minor point: We do we switch between separate signature/binding and binding-with-type-annotation styles? Seems like we should stick with the former.

docs/users_guide/debugging.rst
43

Let's be explicit: s/AST/syntax tree/

This revision now requires changes to proceed.Jan 11 2017, 11:29 AM
alanz marked 2 inline comments as done.Jan 11 2017, 12:17 PM
alanz added a subscriber: nominolo.
alanz added inline comments.
compiler/hsSyn/HsDumpAst.hs
48

It probably should. I have been using it this way for a while in various projects, and just copied it over. Will update to do so.

67

The whole thing is shamelessly copied from https://github.com/nominolo/ghc-syb/blob/master/utils/GHC/SYB/Utils.hs#L240

Which means I need to get an ok from @nominolo before it goes in.

But I will make it consistent.

alanz marked an inline comment as done.Jan 11 2017, 12:57 PM
alanz added inline comments.
compiler/hsSyn/HsDumpAst.hs
48

Looking more closely, sometimes (e.g. for a Var) it uses the debug print, other times the normal one.

Also, the normalizeLines routine needs to be inline so that the tests can pass on windows and Linux.

I am not sure that we would gain much by converting it to a SDoc.

alanz updated this revision to Diff 10435.Jan 11 2017, 2:20 PM
alanz edited edge metadata.

Fixing according to @bgamari comments. And rebase.

mpickering accepted this revision.Jan 11 2017, 5:03 PM
mpickering edited edge metadata.

1 comment, otherwise looks good!

compiler/hsSyn/HsDumpAst.hs
18

Why are these exported?

alanz added inline comments.Jan 12 2017, 12:13 AM
compiler/hsSyn/HsDumpAst.hs
18

I figured they could be useful elsewhere too. Otherwise no specific reason.

alanz added a comment.Jan 13 2017, 1:46 AM

@bgamari Are you happy with my changes? I would like to land this.

mpickering edited edge metadata.Jan 13 2017, 5:20 AM
mpickering updated the Trac tickets for this revision.
alanz updated this revision to Diff 10468.Jan 14 2017, 7:57 AM

Rebase and make @mpickering happy

This revision was automatically updated to reflect the committed changes.
alanz marked 2 inline comments as done.