Example serialization

I have slightly modified the example serialization in the spec to ensure it 
covers all node types and all serialization rules:



A (necessarily contrived) example grammar that illustrates the 
serialization rules is:

expr: open, -arith, @close, -";".
@open: "(".
close: ")".
arith: left, op, ^right.
left: operand.
-right: operand.
-operand: name; -number.
@name: ["a"-"z"].
@number: ["0"-"9"].
-op: sign.
@sign: "+"; "-".

Applied to the string (a+1); it yields the serialisation

<expr open='(' sign='+' close=')'>
    <left name='a'/>
    <right>1</right>
</expr>

Points to note: how the semicolon is suppressed from the serialization; the 
two ways open and close have been defined as attributes; similarly the two 
ways left and right have been defined as elements; how number appears as 
content and not as an attribute; and how sign being an exposed attribute 
appears on its nearest non-hidden ancestor.

Received on Thursday, 24 February 2022 14:17:37 UTC