Re: A grammar challange regarding that pesky YAML format

> I'm not understanding something here.
> Could you show your iXML grammar and an example of an input that gives an
ambiguous result (and indicate which result is the desired one)?

Hi Bethan!

Here is a greatly simplified grammar that shows the problem:
======= File ex.ixml =======
doc = arrayline+.
arrayline = -'- ', (valonly | kvp).
valonly = ~[#a]*, -#a.

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

======== File in.yaml ======
- a: 1
- b: 2
- c: 3

And you get with: xmq ex.ixml in.yaml

doc(ixml:state = ambiguous
       xmlns:ixml = http://invisiblexml.org/NS)
{
    arrayline {
        valonly = 'a: 1'
    }
    arrayline {
        valonly = 'b: 2'
    }
    arrayline {
        valonly = 'c: 3'
    }
}


And with: markup-blitz ex.ixml in.yaml | xmq

doc(ixml:state = ambiguous
    xmlns:ixml = http://invisiblexml.org/NS)
{
    arrayline {
        kvp(key = a) = 1
    }
    arrayline {
        kvp(key = b) = 2
    }
    arrayline {
        kvp(key = c) = 3
    }
}

So the output is ambiguous and xmq and markup-blitz picks different choices
which is fine.

The challenge is to rewrite the valonly rule, to reject the kvp matches so
that the output is
like the markup-blitz output and un-ambiguous.

//Fredrik

Received on Monday, 2 February 2026 09:17:48 UTC