libyaml icon indicating copy to clipboard operation
libyaml copied to clipboard

YAML 1.2 support

Open SoniEx2 opened this issue 8 years ago • 20 comments

Hi, I'd like YAML 1.2 support.

SoniEx2 avatar Oct 08 '16 21:10 SoniEx2

The next step is to make a list of the changes needed to get there.

ingydotnet avatar Oct 10 '16 20:10 ingydotnet

Is "start from scratch" a valid change?

SoniEx2 avatar Oct 11 '16 17:10 SoniEx2

@SoniEx2 you mean, rm libyaml and start a new?

sigmavirus24 avatar Oct 11 '16 18:10 sigmavirus24

@sigmavirus24 Yes.

SoniEx2 avatar Oct 11 '16 18:10 SoniEx2

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.

sigmavirus24 avatar Oct 11 '16 19:10 sigmavirus24

Refactoring is good. rm -rf is only the most extreme form of it.

SoniEx2 avatar Oct 11 '16 19:10 SoniEx2

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

polyzen avatar Mar 26 '17 17:03 polyzen

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.

EvanCarroll avatar Jun 25 '18 18:06 EvanCarroll

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?

spgarbet avatar Feb 03 '20 12:02 spgarbet

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?

perlpunk avatar Feb 03 '20 19:02 perlpunk

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

perlpunk avatar Mar 30 '20 16:03 perlpunk

#172 was merged. How far is now 1.2 support?

rriemann avatar Oct 13 '20 17:10 rriemann

May be it is not my business, but the idea "YAML is a superset of JSON" is a bad idea at very beginning.

andry81 avatar Oct 23 '20 18:10 andry81

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

andypost avatar Mar 24 '21 21:03 andypost

How does one compile the library to get the closest 1.2 support? Are there any configure options?

spgarbet avatar May 29 '23 15:05 spgarbet

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.

perlpunk avatar May 29 '23 15:05 perlpunk

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

perlpunk avatar May 29 '23 15:05 perlpunk

edited by @perlpunk and split out to #269

andry81 avatar May 29 '23 16:05 andry81

@andry81 that has nothing to do with YAML 1.2 support, so it doesn't belong in this issue.

perlpunk avatar May 29 '23 17:05 perlpunk

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.

perlpunk avatar May 29 '23 17:05 perlpunk