iXML Community Group Test Suite

23 Oct 2023 (22 Nov 2023)

Top-level catalog for tests in the iXML Community Group Test Suite.

Tests have been contributed from several sources, but the core of the test collection are the tests contributed by Steven Pemberton in December 2021.

Misc tests 2

28 Jun 2022

Grammars 21-40.

Test grammars compiled manually in 2018 and 2019, re-packaged in 2022.

Added test cases where needed and moved to ixml test collection, June 2022.

sample.grammar.38

Created 08 Feb 2022 by cmsmcq

Sample grammar from Niklaus Wirth, Grundlagen und Techniken des Compilerbaus (Bonn: Addison-Wesley, 1996, p. 7.

Grammar for BNF as Wirth uses it. Rules for ws added for convenience; Wirth assumes the lexer eats whitespace.

We write 'nil' for Wirth's empty-set symbol.

Invisible XML Grammar


      syntax:  S?, production, syntax; nil.
      production: identifier, S?, -"=", S?, expression, S?, -".", S?.
      expression: term; expression, S?, -"|", S?, term.
      term: factor; term, S, factor.
      factor: identifier; string.

      identifier: letter; identifier, letter; identifier, digit.
      string: stringhead, -'"'.
      stringhead: -'"'; stringhead, character.
      letter: ["A"-"Z"; "a"-"z"].
      digit: ["0"-"9"].

      { Wirth does not define character. }
      character: ~['"'].

      { Wirth does not define empty-set symbol. }
      nil: .

      -S: -[" "; #09; #0A; #0D]+.
    

Test case: Grammar test

Repository URI: …/tests/misc/misc-021-040-catalog.xml

Expected result

<ixml>
   <rule name="syntax">
      <alt>
         <option>
            <nonterminal name="S"/>
         </option>
         <nonterminal name="production"/>
         <nonterminal name="syntax"/>
      </alt>
      <alt>
         <nonterminal name="nil"/>
      </alt>
   </rule>
   <rule name="production">
      <alt>
         <nonterminal name="identifier"/>
         <option>
            <nonterminal name="S"/>
         </option>
         <literal tmark="-" string="="/>
         <option>
            <nonterminal name="S"/>
         </option>
         <nonterminal name="expression"/>
         <option>
            <nonterminal name="S"/>
         </option>
         <literal tmark="-" string="."/>
         <option>
            <nonterminal name="S"/>
         </option>
      </alt>
   </rule>
   <rule name="expression">
      <alt>
         <nonterminal name="term"/>
      </alt>
      <alt>
         <nonterminal name="expression"/>
         <option>
            <nonterminal name="S"/>
         </option>
         <literal tmark="-" string="|"/>
         <option>
            <nonterminal name="S"/>
         </option>
         <nonterminal name="term"/>
      </alt>
   </rule>
   <rule name="term">
      <alt>
         <nonterminal name="factor"/>
      </alt>
      <alt>
         <nonterminal name="term"/>
         <nonterminal name="S"/>
         <nonterminal name="factor"/>
      </alt>
   </rule>
   <rule name="factor">
      <alt>
         <nonterminal name="identifier"/>
      </alt>
      <alt>
         <nonterminal name="string"/>
      </alt>
   </rule>
   <rule name="identifier">
      <alt>
         <nonterminal name="letter"/>
      </alt>
      <alt>
         <nonterminal name="identifier"/>
         <nonterminal name="letter"/>
      </alt>
      <alt>
         <nonterminal name="identifier"/>
         <nonterminal name="digit"/>
      </alt>
   </rule>
   <rule name="string">
      <alt>
         <nonterminal name="stringhead"/>
         <literal tmark="-" string="&#34;"/>
      </alt>
   </rule>
   <rule name="stringhead">
      <alt>
         <literal tmark="-" string="&#34;"/>
      </alt>
      <alt>
         <nonterminal name="stringhead"/>
         <nonterminal name="character"/>
      </alt>
   </rule>
   <rule name="letter">
      <alt>
         <inclusion>
            <member from="A" to="Z"/>
            <member from="a" to="z"/>
         </inclusion>
      </alt>
   </rule>
   <rule name="digit">
      <alt>
         <inclusion>
            <member from="0" to="9"/>
         </inclusion>
      </alt>
   </rule>
   <comment> Wirth does not define character. </comment>
   <rule name="character">
      <alt>
         <exclusion>
            <member string="&#34;"/>
         </exclusion>
      </alt>
   </rule>
   <comment> Wirth does not define empty-set symbol. </comment>
   <rule name="nil">
      <alt/>
   </rule>
   <rule mark="-" name="S">
      <alt>
         <repeat1>
            <inclusion tmark="-">
               <member string=" "/>
               <member hex="09"/>
               <member hex="0A"/>
               <member hex="0D"/>
            </inclusion>
         </repeat1>
      </alt>
   </rule>
</ixml>