libyaml
libyaml copied to clipboard
YAML 1.2 support
Hi, I'd like YAML 1.2 support.
The next step is to make a list of the changes needed to get there.
Is "start from scratch" a valid change?
@SoniEx2 you mean, rm libyaml
and start a new?
@sigmavirus24 Yes.
That may be a valid change, but it's not a change that would happen without good reasoning. What reasoning do you have for wanting to start from scratch? Further, if that's your desired first step, why not write a different implementation from scratch and forget this project? That's the easiest way to start from scratch.
Refactoring is good. rm -rf
is only the most extreme form of it.
The next step is to make a list of the changes needed to get there.
https://yaml.readthedocs.io/en/latest/pyyaml.html#defaulting-to-yaml-1-2-support
Just for reference from the 1.2 spec
The primary objective of this revision is to bring YAML into compliance with JSON as an official subset. YAML 1.2 is compatible with 1.1 for most practical applications - this is a minor revision. An expected source of incompatibility with prior versions of YAML, especially the syck implementation, is the change in implicit typing rules. We have removed unique implicit typing rules and have updated these rules to align them with JSON's productions. In this version of YAML, boolean values may be serialized as “true” or “false”; the empty scalar as “null”. Unquoted numeric values are a superset of JSON's numeric production. Other changes in the specification were the removal of the Unicode line breaks and production bug fixes. We also define 3 built-in implicit typing rule sets: untyped, strict JSON, and a more flexible YAML rule set that extends JSON typing.
Looks like most of the changes are dropped features. I would posit that most of the upgrade would be just dropping some tokens from the parse tree. Or course, I've been bitten by things that seem so simple in the past. There is an additional escape added. This upgrade has been lingering for several years and there's even a stale branch that claimed to be the 1.2 upgrade.
If someone submitted a pull request, with tests to upgrade to 1.2 would this push this along?
I think we should make a list of things that need to be changed. I started listing the changes between 1.1 and 1.2 a while ago: https://github.com/yaml/yaml/wiki/YAML-1.2-Changelog
- 1 is not relevant, 3 and 4 are done.
- I think 2 could be complicated. But we could probably allow this for both versions
- For 5 I made a PR to change the output accordingly: #160
- For 6 we need to change behaviour depending on the YAML directive, so we don't break existing YAML.
There are probably more changes, but I think they are mostly removing ambiguity from the 1.1 spec.
Can you think of anything else I should add?
Actually number 6 (Directives are not global anymore) is not implemented correctly in libyaml currently. Directives are not global.
That means we could actually support %YAML 1.2
simply by adding one condition to the relevant if statement.
Fixing global directives for 1.1 would also be possible, but the question is if we want this.
I created #172
#172 was merged. How far is now 1.2 support?
May be it is not my business, but the idea "YAML is a superset of JSON" is a bad idea at very beginning.
As i see inital support for 1.2 already released as 0.2.3 (2020-04-11) but not clear what's left to do
How does one compile the library to get the closest 1.2 support? Are there any configure options?
See https://github.com/yaml/libyaml/wiki/YAML-1.2 for the status on YAML 1.2. There are no configure options regarding that, it is already close to YAML 1.2 by default.
Note that there are other things where libyaml diverges from the spec, that don't have anything to do with the differences of 1.1 and 1.2.
I collected those cases for libyaml and pyyaml together here: https://github.com/yaml/pyyaml/wiki/Testsuite---Failing-cases
edited by @perlpunk and split out to #269
@andry81 that has nothing to do with YAML 1.2 support, so it doesn't belong in this issue.
I recommend to try out libfyaml. It fully supports YAML 1.2. Depending on your use cases it might already have every functionality you need.