Yams icon indicating copy to clipboard operation
Yams copied to clipboard

Clarify version of YAML specification supported.

Open algal opened this issue 5 years ago • 2 comments

I think it would help the README if it added a couple sentences clarifying the degree of YAML spec compliance, if this is known.

I ask because I have what I believe is a valid YAML 1.0 document. It begins with the first line as follows: %YAML:1.0. I think this should be okay because section 3.2.3.3 in the YAML spec says the following:

A version 1.0 processor should accept documents with an explicit “%YAML:1.0” directive, as well as documents lacking a “YAML” directive.

But Yams chokes on it. I don't know if I'm misunderstanding the situation, if this is a fault in the underlying libYAML parser, or if the YAML spec is, like the pirate's code, more what you'd call "guidelines" than actual rules.

(FWIW, At the moment I'm just stripping the first line and everything works after that.)

algal avatar Aug 11 '19 00:08 algal

I see you posted this here too: yaml/libyaml#154

Since Yams uses libyaml for all its heavy lifting, I'm keen to see if anyone clarifies this question for that project first.

The Official YAML Web Site claims that libyaml is a "C" Fast YAML 1.1, I'd guess that YAML 1.1 is the intended supported version.

Also, of 1.0, 1.1 and 1.2, only 1.1 is featured in libyaml's source:

image

jpsim avatar Aug 11 '19 21:08 jpsim

Ah, I had not seen that note on the official website or discovered that evidence in the code itself.

That seems to indicate pretty clearly that LibYAML aims to comply with version 1.1 and that’s that.

What is more, it seems like a “version 1.1 YAML processor” is not required to be able to process YAML 1.0, at least if I am reading section 7.1.1 correctly. The production rule does not allow for a colon after the letters YAML:

[89]  l-yaml-directive  ::= “%” “Y” “A” “M” “L” 
                     s-ignored-space+ ns-yaml-versions
                     s-l-comments
[90]  ns-yaml-version ::= ns-dec-digit+ “.” ns-dec-digit+  

I wonder if the backward incompatibility extends beyond the directive syntax. FWIW, some cursory research pulls up this mailing list thread suggesting there are incompatibilities, but they're not documented anywhere.

algal avatar Aug 12 '19 04:08 algal