-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
KDL 2.0.0 compliance for implementations #372
Comments
please consider pinging tree-sitter-kdl. thanks |
What's the file marker that differentiates v1 from v2? File extension |
There's no file marker, but the data model is exactly the same--it should be very easy to heuristically detect whether you're looking at 1.0 or 2.0 and react accordingly if you're working on a dual parser, and the resulting data will be the same in both cases. |
What is the heuristic in a non-code syntax file to tell apart a syntax error of I'd say that's an oversight of the v2 version, why not have something like |
you detect which one parses and go from there, basically :) So, if you run into Personally, I'm just going to support 2.0 for parsers I maintain going forward instead of trying to support both versions. Folks can use older versions of the parser to use 1.0 until they're ready to migrate. When discussing it, we came to the conclusion that the burden of always having to tag your 2.0 files wasn't worth it when KDL is still relatively low usage and we expect 2.0 to quickly become the dominant format going forward. |
I can't really use that trick since this isn't a parser in a programming lanuage where you have that kind of flexibility also you can have both v1 and v2 errors, so this rule won't help you determine the version
That's fine, put the burden on the v1 users! Or use a file extension. Also, after KDL becomes (world)dominant there might be v3! This future-proofs it. So you'd have a rule like: |
We can't. v1 users are already not tagging their content as v1. And adding something now for users to produce v1 content going forward isn't worth anyone's time; they should be writing v2, as that's what most parsers will be expected to (likely exclusively) accept going forward.
And if there are, we can figure out compat at that point. Note that "make v1 documents tag themselves, v2 can be assumed" is not compatible with a future v3 either; it'll mean that v3 also has required tagging (since a missing tag would indicate v2). So we don't need to worry about it right now; if a v3 ever appears, it'll need to be tagged anyway, so we can introduce the tag then.
This absolutely does not work, fwiw, unless the language is carefully designed to be back/forward-compatible, and losing data is acceptable. (CSS, for example, has this model.) A data format can't really do this. |
And as long as they don't encounter any v2 requiremens, they can continue to do so.
And what about all v1s that have already been written? I don't get it, why should there be no mechanism to differentiate them?
then it'd be much more painful due to higher scale
Well, you could add |
There are also emacs support packages at:
|
This is not possible. There are files valid both in v1 and v2 that produce different data. Example from my app:
If I understand the v2 change correctly, this will change meaning with v2, resulting in the |
No, v2 makes |
The same goes for the other keywords: Likewise, there's the very rare "gotcha" where you might have a node name called Scanning again through the changelog, the vast majority of changes make v2 more strict or use incompatible-with-v1 syntax, so it would be an error in either one. The only change I can think of that could "silently" change the data without being a syntax error in v1 or v2 is the new multiline string indentation stripping, where the following string means two different things whether you're in v1 or v2:
in v1, this yields:
and in v2:
There's no way to distinguish which of these is v1 and v2. |
I see, thanks for the clarification. As long as no v1 document can change meaning in v2 without syntax error, migrations would be much smoother. |
As ckdl is a single-pass streaming parser (and I want to keep it that way), I couldn't do a "if KDLv2 gives a syntax error, retry with the v1 parser" loop. Still, it was pretty straightforward to build a parser that starts out agnostic about the KDL version until the first time it sees a construct that is only valid in one version or the other. The (experimental/draft) hybrid parser in ckdl processes all valid KDLv2 documents correctly and (currently) only compromises on KDLv1 compatibility in a few cases (that I know of), if they occur before any v1-only construct:
I really wouldn't expect other hybrid parser implementations to have a compatibility story worse than this. |
This issue is for tracking full test suite compliance for KDL implementations that support the new KDL 2.0.0 spec.
As of 2024-02-07's 2.0.0-draft.3, the recommendation is now for implementations to start implementing 2.0 and submitting comments for any trouble they might run into while implementing it. Once we have enough satisfied implementors, we will start the process of releasing the final 2.0 spec!
Implementations:
The text was updated successfully, but these errors were encountered: