Re: A grammar challange regarding that pesky YAML format

Awesome! 

If colon > following space > newline and colon > newline should be treated the same, your original grammar has an error: it treats key > colon > newline as a valonly, not as a kvp.

My initial attempt also fails, but I think the following updated grammar will work and will handle the colon without a following value on the same line correctly.

**********************************
**********************************

doc = arrayline+.
arrayline = -'- ', (valonly | kvp).

valonly = (-key, not_val | not_key, val), -#a.
-not_val = ':', ~[' ';#a], val | ~[':_';L], val.
-not_key = ~[L;'_'].

kvp = kcs, val, -#a | @key, -":", -#a.
-val = ~[#a]*.
-kcs = @key, -': '.
key = [L;'_']+.

**********************************
**********************************


___________________________________________________ 
Dr. Bethan Tovey-Walsh 

linguacelta.com

Golygydd | Editor geirfan.cymru

Croeso i chi ysgrifennu ataf yn y Gymraeg.

> On 2 Feb 2026, at 13:36, Fredrik Öhrström <oehrstroem@gmail.com> wrote:
> 
> I think the space after colon before newline is optional when declaring a new object.
> 
> > I hate YAML more and more passionately, the more you tell me about its weirdness!
> 
> Yes, lets focus that feeling into crafting an ixml grammar. Remember with a yaml.ixml then we can work on yaml without having to see it. :-)
> YAML is unfortunately rather common.
> 
> //Fredrik

Received on Monday, 2 February 2026 13:48:35 UTC