Insertions

Some time ago Tom suggested using +"abc" to signal a textual insertion into 
the serialisation, which we put on a backburner. But I ended up thinking 
about it today anyway.

This adds a new mark "+", only applicable to literal terminals (strings and 
hex encodings). Let's call them "insertions".

* When parsing, an insertion is treated as an empty string; in other words, 
it always succeeds.
* On serialisation, an insertion is serialised as its string (just like 
other non-hidden terminals).

Example:

    data: @xmlns, value+",".
    xmlns: +"http://example.com/data".
    value: pos; neg.
    pos: +"+", digit+.
    neg: +"-", -"(", digit+, -")".

With input:

      100,200,(300),400

this would produce

    <data xmlns="http://example.com/data">
       <value>+100</value>
       <value>+200</value>
       <value>-300</value>
       <value>+400</value>
    </data>

It is notable that there is currently no real meaning assigned to "^"
when applied to a terminal: it has no additional effect. So "^" could
be used for this purpose instead of "+", thus leaving the syntax of
ixml untouched, and still looking and feeling reasonable:

    data: @xmlns, value+",".
    xmlns: ^"http://example.com/data".
    value: pos, neg.
    pos: ^"+", digit+.
    neg: ^"-", -"(", digit+, -")".

The nice thing about "+" is that it is the obvious opposite of "-", but has 
the disadvantage is that it is already used for repeats.
The nice thing about "^" is that the syntax doesn't change, and it looks 
like a proof-reader's insert mark.

Steven

Received on Wednesday, 2 March 2022 19:34:42 UTC