-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Pp_ast module and ppxlib-pp-ast executable for pretty-printing ppxlib ASTs #517
Conversation
I still need to add a few tests before this is good to merge. It uses a bit of private API and re-implements a few small parts of here's an example of how
I'm not a Please let me know what you think! |
Just added a config option to allow showing attributes as it turns out I needed this to investigate a migration bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I think waiting for the migration bug fix before merging might help uncover more useful features to add (e.g. you needed the --show-attrs
configuration flag).
I'll try to address the documentation related concerns and the exposure of private API parts for internal use but then I think this is good to go! |
I added loc printing and relevant configuration! |
I'm also wondering whether the tool should be installed as part of ppxlib's main package or a separate, ppxlib-tools one. |
I improved the documentation a bit, let me know what you think @patricoferris ! |
The new documentation looks great!
|
Yep, in order to keep |
In addition, we could also extend the set of dependencies for such tools to things like |
This should be the final round, I extracted I also added the ability to read source code directly from the command line which can be extremely convenient to quickly understand how to represent simple expressions or types for instance. This feature was part of I also took the time to write a bit of documentation in the manpage so hopefully the tool will be easier to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me! Happy for formatting bugs to be follow up PRs if they do arise, this would already be very useful for debugging migration issues!
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com> Co-authored-by: Patrick Ferris <patrick@sirref.org>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
This adds pretty-printing functions to our API along with a simple executable that can be used to pretty-print input
.ml
,.mli
, expressions, patterns or core types.It's API is similar to
ppx_tools
'sdumpast
except that it can also read binary ASTs of any version which I assume could come in handy in certain situation.The printing style is also similar to dumpast:
expression
s directly as theirpexp_desc
field and does so for any other such record with a_desc
field'a loc
types directly as'a
In the future we can add a bit of configuration there to control what gets printed or not but it is already pretty useful as it is.
I'd even consider using this with our
-dparsetree
driver option instead of the current sexp printer.