yaml / yaml-spec

YAML Specification
http://yaml.org/spec/
346 stars 53 forks source link

Question: what are the disallowed characters in flow sequences? #113

Open am11 opened 3 years ago

am11 commented 3 years ago

[I wanted to open a discussion item, but there seem to be some problem #111]

I am still learning to parse the grammar syntax, but going by YAML 1.2 §7.4.1, I think it does not prohibit consecutive commas or separated by whitespace.

Following are considered ok by reference parser:

but following are not:

this is unique to comma; the flow sequence separator.

So my question; is it implied somehow or did I miss writing on the wall? 🙂

ingydotnet commented 3 years ago

Hi @am11

Thanks for your interest in the YAML spec. I'm glad you're here! I'm also glad you found https://spec.yaml.io/playground/parser

Three important works to help you on this journey are:

Theoretically we can generate correct parsers in all languages, as we make future changes to the grammar.

Note that the suite is not 100% complete, so the ref parser may not be 100% correct. We need lots of help on all fronts.

To your "Question: what are the disallowed characters in flow sequences?" you need to start at https://github.com/yaml/yaml-grammar/blob/master/yaml-spec-1.2.yaml#L2106 and continue down the rabbit hole.

I suggest writing a small program using the grammar yaml to do that, as the hole is somewhat deep.

Feel free to chat with us in our new chat forum https://matrix.to/#/#chat:yaml.io

ingydotnet commented 3 years ago

@am11 I started this program to expand the grammar https://github.com/yaml/yaml-reference-parser/blob/show-grammar/build/show-grammar

$ ./show-grammar all < yaml-spec-1.2-patched.yaml
$ ./show-grammar refs < yaml-spec-1.2-patched.yaml

makes output like https://gist.github.com/ingydotnet/c0209c0a3dc7eb8919536f9ccd469fa6

Next I'll make the program support:

$ ./show-grammar c-flow-sequence < yaml-spec-1.2-patched.yaml

To expand all the rules under c-flow-sequence to help answer your question.