Repository navigation
Conversation
- Change bare keywords to prefixed form: null -> #null, true -> #true - Update error message expectations to include newline as valid escape - Add . to expected tokens (dotted identifiers are valid in KDL v2)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
==========================================
+ Coverage 74.16% 79.38% +5.22%
==========================================
Files 15 15
Lines 3847 4468 +621
Branches 3847 4468 +621
==========================================
+ Hits 2853 3547 +694
+ Misses 857 770 -87
- Partials 137 151 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @tmke8 ! Overall this looks like an outstanding set of changes! My time is pretty tight at the moment (writing up a thesis!), but I'm happy to start chipping away at this! I can review and merge things however you think is easiest, but perhaps you could split things into a PR for 1: rebase and test fixing, 2: remove span generics, 3: chumsky update, 4: last of KDL multiline? You can arrange those as stacked PRs if you'd like — Jujutsu is a great tool for that sort of thing if you've not checked it out already (it's completely replaced git for me). Thank you for this monumental effort! Excited to get it all in! |
kleinesfilmroellchen
left a comment
There was a problem hiding this comment.
A cursory review of basic code style and Rust things to speed up the process here.
| .then(take_until(newline().or(end()))) | ||
| .then( | ||
| any() | ||
| .and_is(newline().not()) | ||
| .and_is(end().not()) | ||
| .repeated() | ||
| .then(newline().or(end())), |
There was a problem hiding this comment.
This looks really silly, I assume chumsky upstream wasn’t quite in their right mind when they removed the take_until combinator…
There was a problem hiding this comment.
Note: didn’t review the multiline string additions here, too much for right now
I tried to do that, but I think this is only possible if the feature branches are all in this repository. So, I suppose we'll try to do this one-by-one. I opened the first PR here: #37 |
For error reporting, this span type can still be transformed to a different span type.
Add multi-line string support for both quoted (""") and raw (#""") strings
per the KDL v2 specification:
- Opening delimiter must be followed by newline
- Closing delimiter must be on its own line
- Auto-dedentation based on closing line's whitespace prefix
- Newline normalization (CRLF → LF)
- Escape sequences processed after dedentation
c4fd14f to
2ef7a67
Compare
|
@kleinesfilmroellchen I addressed your first two review comments over at #37 (I think the other comments are for later commits, but correct me if I'm wrong) |
|
Thanks @kleinesfilmroellchen for helping with the reviewing! For either @tmke8 or @kleinesfilmroellchen , are you interested in bumping miette to the latest version whilst we're updating chumsky? As far as I know, it should be much less of an effort / fewer breaking changes and would address #35! |
|
Unfortunately I am busy at the moment. But miette should be quite easy as their breaking changes are never that large from my experience. (Unlike what chumsky apparently did at 0.10) |
|
Yeah, I can give it a try. Would you also be open to switching the error tests from the current JSON matching approach to an approach based on snapshots (with e.g. insta) where we just verify the printed error? Currently it's a bit annoying to update the error tests and it's hard to see what the errors will actually look like for the user. |
|
@tmke8 Absolutely! I use insta in all of my projects, so that sounds great! Thanks a ton!! |
|
This PR has been replaced by a series of stacked PRs: |
This is a very big PR that I don’t expect to me merged in one piece. I’m opening it here mostly to discuss if and how to merge it.
There are 5 parts to this PR:
Rebased commits from the
kdl-v2branchThe first 14 commits are the commits from
kdl-v2, rebased onto main in order to get the recent CI fixes. As far as I remember, there were no conflicts.Changes to make the tests pass
Commit 5b1137b is there just to make CI pass. It includes a regression to an error label, but that regression is fixed in the commit that updates chumsky.
Removal of the genericness around the span type
This is commit 67f5ed8. I expect this to be the most controversial change. The motivation for this was to make updating chumsky easier.
Before this change, the parser was generic over the span type. The code base contained two span types that could be used (and the library user could write their own):
SpanandLineSpan.Spanwas basically just aRange.LineSpan, on the other hand, was also storing the start and end position in terms of line and column number. The doc comment forsrc/span.rsclaimed this:I’m guessing this was written at a time where error reporting required specifying line and column numbers. But this isn’t true with
miette.miettejust wants the byte offsets and then does the rest on its own. In fact, after removingLineSpanfrom the code base, I didn’t have to change any test, because it wasn’t actually needed for anything.So, I removed
LineSpanand made the code not be generic anymore over the span type. The#[knus(span)]attribute still works though! And it’s much easier to use now, actually. The user just has to implement the traitDecodeSpanfor their custom span type. And#[knus(span_type=Span)]isn’t required anymore:If anyone wants to know the line and column number, they can get it with this new method I added to
Span:(This needs the original input as an argument, in order to know where the newlines are.)
This is a breaking change, but switching the parser to KDLv2 is a breaking change anyway, so I hope it’s fine. If you really don’t like this change, I can think about how to undo it, but it won’t be easy because there are so many changes on top of this that will become more complicated if the parser is still generic over the span.
Migrating from chumsky 0.9.* to 0.12
This is commit 2defcac.
This was not easy, because there were a lot of subtle breaking changes between chumsky 0.9.* and 0.10.0. There was a migration guide but that still left a lot of trial and error to get it working.
If you look at
Cargo.toml, you’ll see that I’m currently installing chumsky from git. That’s because I sent two PR to chumsky that were necessary to get it working, which have been merged, but have not been released yet:map_err_with()zesterer/chumsky#951Implement the missing features from KDLv2
In commit c4fd14f I added support for multiline strings, which was still missing from the original
kdl-v2branch. The implementation for this ended up being quite verbose. This is the change I’d most like feedback on. Maybe I’m missing a way this could be simpler.And that’s it! Are you interested in these changes @TheLostLambda ? How should we go about merging them?