Reach reparsability of core pretty-printer#1181
Merged
timsueberkrueb merged 26 commits intomasterfrom Nov 27, 2025
Merged
Conversation
timsueberkrueb
commented
Nov 5, 2025
timsueberkrueb
commented
Nov 5, 2025
| lazy val externBodyTemplate: P[Template[Expr]] = | ||
| ( | ||
| (multilineString | stringLiteral) ~ | ||
| rep((`++` ~> expr) ~ (`++` ~> (multilineString | stringLiteral))) |
Contributor
Author
There was a problem hiding this comment.
I chose the syntax "string" ++ (<expr> ++ "string")* for extern body template strings because it is easy to parse. Open to to other suggestions!
timsueberkrueb
commented
Nov 5, 2025
timsueberkrueb
commented
Nov 5, 2025
66fa66e to
186257b
Compare
timsueberkrueb
commented
Nov 17, 2025
| case _: kiama.util.StringSource => "string" | ||
| case _ => "source" | ||
| } | ||
| "<>" <+> s"@ \"$scheme://$name\":$from:$to" |
Contributor
Author
There was a problem hiding this comment.
TODO: proper escaping
9b78c7d to
72eaa10
Compare
timsueberkrueb
commented
Nov 19, 2025
| // FIXME: There is currently a limitation in TestRenamer in that it does not rename captures. | ||
| // This means, that in this example, captures for State[Int] and State[String] are both printed as "State", | ||
| // leading to a collapse of the capture set {State_1, State_2} to just {State}. | ||
| File("examples/pos/parametrized.effekt") |
Contributor
Author
There was a problem hiding this comment.
@marzipankaiser this is what I just mentioned in person.
a1597bf to
42a74c9
Compare
42a74c9 to
9755de4
Compare
jiribenes
approved these changes
Nov 26, 2025
Contributor
jiribenes
left a comment
There was a problem hiding this comment.
I went over this in five minutes, see comments below. I'm fine with merging this if you need it (though it would be nice if somebody who actually knows something about core reviewed it)
b-studios
pushed a commit
that referenced
this pull request
Dec 16, 2025
In #1181 we made the core pretty printer a lot more verbose in order to enable re-parsing. However, the additional verbosity hinders human inspection and debugging. This PR aims to mitigate this by splitting the core pretty printer in two instances: * `ReparsablePrettyPrinter` is fully verbose and can be re-parsed with `core.Parser` * `HumanReadablePrettyPrinter` is less verbose (and thus more readable) but cannot be re-parsed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, it is very hard to write tests for core. There are two main reasons for this:
While a new core frontend would subsume both of these problems, it is a lot more effort than adding a re-parsable mode to the current core pretty-printer. This would allow us to compile source programs to core and pretty-print them to use them as golden output in core tests.
In particular, when developing the new normalizer (#1127), I would like to track its behavior in unit tests, but they are currently very time-consuming to write due to the fact I cannot just use pretty-printed core for comparison.