Re: Alternative syntaxes for the prolog

> This might be easily parsed by a processor or a version control system or a dependency management tool, etc:
>
>   ixml version "1.0" .
>   author given-name: "Norm", surname: "Tovey-Walsh",
>          affiliation: "Saxonica" .
>   date 2024-03-01 .

You know, that’s not bad, if I do say so myself. After ten minutes of noodling about, I have these changes to the ixml grammar:

     -RWS: whitespace+ . 
   prolog: version, RWS, (metadata+ | RS).
  version: -"ixml", RWS, -"version", RWS, string, s, -'.' .
    -msep: whitespace*, -"," .
 metadata: name, (field++msep | RWS, chardata), whitespace*, -".", RS .
    field: RWS, name, whitespace*, -":", whitespace*, chardata .
-chardata: -'"', -dchar+, -'"';
           -"'", -schar+, -"'".

which parse this input:

  ixml version "1.1-nineml" .
  author given-name: "Norman", surname: "Tovey-Walsh" .
  date "2023-03-08" .

  this = "A" .

into:

<ixml>
   <prolog>
      <version string='1.1-nineml'/>
      <metadata name='author'>
         <field name='given-name'>Norman</field>
         <field name='surname'>Tovey-Walsh</field>
      </metadata>
      <metadata name='date'>2023-03-08</metadata>
   </prolog>
   <rule name='this'>
      <alt>
         <literal string='A'/>
      </alt>
   </rule>
</ixml>

I don’t think that’s awful. We’ve talked about a feature to allow content to influence the names of serialized elements so we might get to <author>, <given-name>, etc. Or we could assert by fiat that prolog metadata shall be serialized that way.

                                        Be seeing you,
                                          norm

P.S. The `chardata` production is unnecessary; with a few more grammar changes, I think the standard `string` production can be used. But it was simpler to add another production to keep the scope of the changes small.

--
Norm Tovey-Walsh
Saxonica

Received on Friday, 8 March 2024 10:01:38 UTC