-
Notifications
You must be signed in to change notification settings - Fork 102
Add bucklescript support #205
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
Conversation
5d3cd47 to
d1b6412
Compare
05cfe9d to
f519d19
Compare
|
The ocaml-ci arm32 failure isn't related to this PR. There is a minor change in behavior that I haven't added to the changelog: if someone hands in a binary AST with an unknown OCaml version to the standalone, we now raise instead of packing that error into an extension point and returning the corresponding AST; and same if the input file doesn't exist. Should I mention that in the changelog? |
ghost
left a comment
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.
Looks good overall. The code definitely looks more straightforward now!
It should go into the changelog, so that users can quickly identify which version introduced this change in behaviour. But thinking about this again, packing such errors using the compiler AST versions seems like a reasonable behaviour and is more conservative, so I think we should do that instead. Could you do this change? |
e05a533 to
f62c4bd
Compare
Ok, I've done that now. Therefore, I've had to restructure the loading logic a bit. |
f62c4bd to
ef5bc6f
Compare
About that, looking at the |
ghost
left a comment
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.
Changes since last review are looking good. Just need to avoid the double file opening, and perhaps factorise a bit more the *run_as_ppx functions
|
I also pushed a slightly more idiomatic version of |
0847c68 to
242167f
Compare
|
Thanks! I think I've implemented all the changes you've suggested. |
Besides taking away a burden for Astlib, implementing run_as_ppx_rewriter internally has two advantages: - it allows making changes with more flexibility - run_as_ppx_rewriter gets syncronized with standalone_run_as_ppx_rewriter With this change, the three flags -loc-filename, apply, dont-apply are taken into account when given. Before, they were allowed to be passed in but not taken into account. Signed-off-by: Sonja Heinze <[email protected]>
Signed-off-by: Sonja Heinze <[email protected]>
Signed-off-by: Sonja Heinze <[email protected]>
Signed-off-by: Sonja Heinze <[email protected]>
db60b77 to
cfd2aa1
Compare
ghost
left a comment
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.
Looks all good!
Before, the OCaml version of any binary ast input had to coincide with the version the ppxlib driver got compiled with. That was a problem for bucklescript/rescript. With this commit, all versions from the Versions module are accepted as input. The input version is preserved by ppxlib when outputting a binary AST. Signed-off-by: Sonja Heinze <[email protected]> More idiomatic version of create_versioned_error_f Signed-off-by: Jeremie Dimino <[email protected]> tweak Signed-off-by: Jeremie Dimino <[email protected]>
cfd2aa1 to
a50690c
Compare
CHANGES: - Driver (important for bucklescript): handling binary AST's, accept any supported version as input; preserve that version (ocaml-ppx/ppxlib#205, @pitag-ha) - `-as-ppx`: take into account the `-loc-filename` argument (ocaml-ppx/ppxlib#197, @pitag-ha) - Add input name to expansion context (ocaml-ppx/ppxlib#202, @pitag-ha) - Add Driver.V2: give access to expansion context in whole file transformation callbacks of `register_transformation` (ocaml-ppx/ppxlib#202, @pitag-ha) - Driver: take `-cookie` argument into account, also when the input is a binary AST (@pitag-ha, ocaml-ppx/ppxlib#209) - `run_as_ppx_rewriter`: take into account the arguments `-loc-filename`, `apply` and `dont-apply` (ocaml-ppx/ppxlib#205, @pitag-ha) - Location.Error: add functions `raise` and `update_loc` (ocaml-ppx/ppxlib#205, @pitag-ha)
CHANGES: - Fix ppxlib.traverse declaration and make it a deriver and not a rewriter (ocaml-ppx/ppxlib#213, @NathanReb) - Driver (important for bucklescript): handling binary AST's, accept any supported version as input; preserve that version (ocaml-ppx/ppxlib#205, @pitag-ha) - `-as-ppx`: take into account the `-loc-filename` argument (ocaml-ppx/ppxlib#197, @pitag-ha) - Add input name to expansion context (ocaml-ppx/ppxlib#202, @pitag-ha) - Add Driver.V2: give access to expansion context in whole file transformation callbacks of `register_transformation` (ocaml-ppx/ppxlib#202, @pitag-ha) - Driver: take `-cookie` argument into account, also when the input is a binary AST (@pitag-ha, ocaml-ppx/ppxlib#209) - `run_as_ppx_rewriter`: take into account the arguments `-loc-filename`, `apply` and `dont-apply` (ocaml-ppx/ppxlib#205, @pitag-ha) - Location.Error: add functions `raise` and `update_loc` (ocaml-ppx/ppxlib#205, @pitag-ha)
The two important commits are:
Support binary AST's of any supported version
Before, the OCaml version of any binary ast input had to coincide with the version the ppxlib driver got compiled with. That was a problem for bucklescript/rescript.
With this commit, all versions from the Versions module are accepted as input. The input version is preserved by ppxlib when outputting a binary AST.
Implement
run_as_ppx_rewriterinternallyBesides taking away a burden for Astlib, implementing
run_as_ppx_rewriterinternally has two advantages:run_as_ppx_rewritergets syncronized withstandalone_run_as_ppx_rewriterWith this change, the three flags
-loc-filename,apply,dont-applyare taken into account when given. Before, they were allowed to be passed in but not taken into account.