Yaml's treatment of single letter values

In yaml, keys appear on the left of a colon and values on the right. Values are generally strings or numbers. However the value of the letter e is supposed to be of type string, but its reproducibly an atom. I would like to determine if the issue is with the way swi-pl is built or whether this is peculiar to yaml’s handling of “e”? Have others experienced this anomoly?

Test cases:
Two separate test files containing yaml to demonstrate the issue with “e”

a.yaml

storage:
- name: a
- name: e

b.yaml

storage:
 device1: a
 device2: e
 device3: f

Issue

?- yaml_read("a.yaml",D).
D = yaml{storage:[yaml{name:"a"}, yaml{name:e}]}.

?- yaml_read("b.yaml",D).
D = yaml{storage:yaml{device1:"a", device2:e, device3:"f"}}.

This is produced on FreeBSD 12.4Stable with swi-pl 8.4.3 and 9.0.4 (built with clang 13); HardenedBSD 13.2S swi-pl 8.4.3 (clang 14).

Workaround
Within the actual project for devices using the MBR scheme, I’m using

( atom(Slice.name) -> atom_string(Slice.name,SliceName) ; SliceName=Slice.name )

I’m hoping that I don’t have to apply the atom test to all input, and that “e” is, for some reason, an anomoly. Unfortunately changing the locale to either default LANG=‘’ or LANG=en_AU.UTF-8, the result is unchanged.

As is,YAML implicit scalars are matched to be a number and, if so, the Prolog parser is called to turn them into a Prolog number. The recogniser recognised “e” as a float :frowning: The Prolog parser turns this into an atom.

Pushed a fix for that. This fixes some more corner cases and documents that we require a digit to follow the decimal “.”. This violates the YAML standard. YAML documents that they consider this a bug anyway as they intend to match JSON which does require a digit after the “.” (as Prolog does).

1 Like

Thank-you very much Jan. Knowing that it was a design decision by YAML developers greatly eases my concerns. I appreciate you sharing the situation with us. :slight_smile:

A roller-coaster ride though: Phew, a known issue. Oh no, please dont violate the standard; oh, the designers want conformity with JSON and see it as a bug, too!

Now you’ve put us ahead of the game. :slight_smile: Impressive changes btw
https://github.com/SWI-Prolog/packages-yaml/commit/9e05c69b5115c637f0bfc13962a2a8990276018a