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

Print comments when pretty printing concrete syntax #1737

Merged
merged 24 commits into from Jan 24, 2023
Merged

Conversation

janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Jan 18, 2023

This pr adds a new pretty printing algorithm for scoped concrete syntax.
This new algorithm works as the old one but will also print the normal comments in the appropriate places.
This is a work in pogress. What remains to be done is printing comments that are in the middle of an expression. Currently these comments will be printed but just before the expression. Also, it should support parsed (pre-scoping) concrete syntax.

To run the new algorithm the flag --with-comments must be passed to the dev scope command.

juvix dev scope M.juvix --with-comments

When we finish the pending tasks, we may want to make this the default algorithm and have a --with-no-comments flag instead.

I have updated the juvix-format-buffer to use the --with-comments flag. Now it should be safe (sans the expression quirk mentioned above) to run the formatter within emacs.

I have adapted the scoping tests to also be executed with the new algorithm. These tests make sure that the pretty printed code is sound but do not check that the printed comments are in the appropriate places. For that, I have done some manual testing. In a future pr we should find a way to test it automatically.

@janmasrovira janmasrovira self-assigned this Jan 18, 2023
@janmasrovira janmasrovira marked this pull request as ready for review January 23, 2023 10:28
@janmasrovira janmasrovira marked this pull request as draft January 23, 2023 10:28
@janmasrovira janmasrovira marked this pull request as ready for review January 23, 2023 10:49
@jonaprieto jonaprieto linked an issue Jan 24, 2023 that may be closed by this pull request
@jonaprieto jonaprieto added this to the 0.3 milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change the name of the Juvix mode format command Code formatting removes comment strings
2 participants