Merged
Conversation
This is an attempt to get around the complications of managing lexer + parser output, which PRQL#4397 has hit in a few incarnations by just adding comments ('aesthetics') to PL. This very very nearly works -- with chumsky we can create a function that wraps anything that might have a comment, implement a trait on the AST items that contain it, and away we go (though it did require a lot of debugging in the end). This would then be really easy to write back out. I think there's literally a single case where it doesn't work -- where a comment doesn't come directly before or directly after an AST item -- in the final trailing comma of a tuple or array. So tests fail at the moment. Next we need to consider: - Can we workaround that one case? We don't actually care about whether there's a trailing comma, so we could likely hack around it... - Are there actually other cases of this model failing? I know this approach -- of putting aesthetic items into AST -- is not generally favored, and it's really rare that there's even a single case of something not working.
Extracting this from PRQL#4639
Found this while doing the formatting, we don't yet enforce this Possibly there are other areas we don't enforce this sort of thing?
This reverts commit e5a4f26.
For using `dbg!`
Member
Author
|
This ends up being a pretty big change! We change how we handle new lines, which lets us enforce new lines for some things — previously we were just consuming 0+ new lines almost anywhere, which then means there might not be a new line character remaining to consume when we come to check before an item that requires one. I used lots of tests when trying to fix problems — ended up being a lot, and sometimes kinda complicated. So possibly the tests are a bit duplicated. We could do an effort to reduce the duplication, since there isn't a natural way for tests to reduce in number... But also not that costly to keep them. |
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.
This takes much of the work from #4639 and uses it to push doc comments through to PL.
I'll leave a comment on something I'm stuck on; I can't work out why we get such a bad error message for
from artists #! This is a doc comment:Expected one of (, [, an identifier, keyword case, keyword internal or {, but didn't find anything before the end..This needs lots more tests for doc comments specifically, and lots of clearing up.