-
Notifications
You must be signed in to change notification settings - Fork 40
Reach reparsability of core pretty-printer #1181
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
base: master
Are you sure you want to change the base?
Conversation
| //def toDoc(n: Name): Doc = n.toString | ||
|
|
||
| def toDoc(s: symbols.Symbol): Doc = s.show | ||
| def toDoc(s: symbols.Symbol): Doc = s.name.name ++ "$" ++ s.id.toString |
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.
$ is a valid character in identifiers, so we need to find another symbol. How about #?
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.
TIL, I thought we didn't allow it in source exactly for this reason. Does anybody actually use it anywhere [in source]?
| lazy val externBodyTemplate: P[Template[Expr]] = | ||
| ( | ||
| (multilineString | stringLiteral) ~ | ||
| rep((`++` ~> expr) ~ (`++` ~> (multilineString | stringLiteral))) |
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.
I chose the syntax "string" ++ (<expr> ++ "string")* for extern body template strings because it is easy to parse. Open to to other suggestions!
| | failure("Expected an identifier") | ||
| ) | ||
| | failure("Expected an identifier") | ||
| ) |
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.
Undo some of these spurious white space changes.
66fa66e to
186257b
Compare
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.