Re: A grammar challange regarding that pesky YAML format

The problem with indentation having meaning is that it is not context-free, so you can only define it to a certain depth. On the other hand "more indented" is hard to define without a specific definition; otherwise you have to have a preprocessor that inserts increase-indent decrease-indent characters. I broach the problem of meaningful indentation in my advanced tutorial, under the heading of Non-context-free languages.


Steven 

On Monday 02 February 2026 14:23:28 (+01:00), Fredrik Öhrström wrote:




- a:
(with no space after the colon).


In YAML this means that we are creating a key->object pair in object in the array.
If the next line is more indented than the character a and you can add properties to this new object.
- a:
    b: 1


will become [ { "a": { "b":1}} ]


Just 
- a:
becomes [ { "a": null } ]


I did not include this in the first example, intentionally to ease in the YAML weirdness over time... :-)


//Fredrik

Received on Monday, 2 February 2026 16:39:41 UTC