Skip to content

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Dec 2, 2024

  • Move the legacy untyped ast to Parsetree0.
  • Parsetree can now be changed and modernised.
  • Ast_mapper_to0 and Ast_mapper_from0 added to convert both ways and maintained whenever Parsetree changes.
  • When a ppx is called, Parsetree is converted to legacy Parsetree0, then the ppx is run, then the result is converted back to Parsetree.

@cristianoc cristianoc marked this pull request as draft December 2, 2024 08:51
There's `Parsetree`, the current parse tree, and `Parsetree0`, the legacy parse tree.
Module `Parsetree.Legacy` contains functions to map to the legacy parse tree.
When a ppx is applied:
1 Parsetree is converted to Parsetree0
2 the ppx is run
3 the result is converted to Parsetree
@cristianoc cristianoc marked this pull request as ready for review December 3, 2024 09:37
@cristianoc cristianoc requested review from cknitt and zth December 3, 2024 09:37
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Let's get the AST cleanup started! 🎉

@cristianoc
Copy link
Collaborator Author

I'll merge as soon as it's tested on some ppx.

@zth
Copy link
Member

zth commented Dec 3, 2024

If nobody gets to it before me I'll test it on one of my PPXes, but it might be a day or so before I get time.

@cristianoc
Copy link
Collaborator Author

I have added a simple ppx test, which will be useful as sanity check to extend when changing the ast more.

@cristianoc cristianoc merged commit eee569e into master Dec 4, 2024
20 checks passed
@cristianoc cristianoc deleted the modernise_ast branch December 4, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants