Skip to content
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

feat: AST pretty-printer #153

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

klkvr
Copy link

@klkvr klkvr commented Dec 1, 2024

Closes #27

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

approach is fine, we can also make individual methods public, eg for expr

Cargo.toml Outdated Show resolved Hide resolved
crates/ast-pretty/src/lib.rs Outdated Show resolved Hide resolved
crates/ast-pretty/src/lib.rs Outdated Show resolved Hide resolved
@klkvr
Copy link
Author

klkvr commented Dec 8, 2024

@DaniPopes this should be complete, though no tests yet — unsure if we need those and what'd be the best approach to write them

should we add some helpers to check whether two ASTs are identical?

@klkvr klkvr marked this pull request as ready for review December 8, 2024 22:08
@klkvr klkvr requested a review from onbjerg as a code owner December 8, 2024 22:08
@klkvr klkvr changed the title [wip] feat: AST pretty-printer feat: AST pretty-printer Dec 8, 2024
@TilakMaddy
Copy link
Contributor

I was thinking if there's a method on ast nodes to "peek" into the relevant portion of the source code that would be great too

@DaniPopes
Copy link
Member

DaniPopes commented Dec 10, 2024

this should be complete, though no tests yet — unsure if we need those and what'd be the best approach to write them

You can add a -Z flag only used in these tests that re-parses pretty printed code; it should also print it to stdout so it gets checked out in a stdout file
I don't think asserting equality is necessary

I was thinking if there's a method on ast nodes to "peek" into the relevant portion of the source code that would be great too

Please check out the SourceMap APIs, I don't know what this has to do with this PR however

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.

Implement a simple AST pretty-printer
3 participants