ebnf-convert-006

Tests that cx:ebnf-convert supports inline-terminals.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/ebnf-convert.xpl"/>
   <p:output port="result" sequence="true"/>
   <cx:ebnf-convert notation="ixml" xml="true"
                    epsilon-references="true" inline-terminals="false">
      <p:with-input port="source">
         <p:inline content-type="text/plain">
        S: A | B | C.
        A: "a".
        B: "b".
        C: ().
      </p:inline>
      </p:with-input>
   </cx:ebnf-convert>
</p:declare-step>

Result

<g:grammar xmlns:g="http://www.w3.org/2001/03/XPath/grammar"
           xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <g:production name="S">
      <g:choice>
         <g:ref name="A"/>
         <g:ref name="B"/>
         <g:ref name="C"/>
      </g:choice>
   </g:production>
   <g:production name="A">
      <g:string>a</g:string>
   </g:production>
   <g:production name="B">
      <g:string>b</g:string>
   </g:production>
   <g:production name="C"/>
</g:grammar>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:ns prefix="g"
         uri="http://www.w3.org/2001/03/XPath/grammar"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="g:grammar">The root is wrong.</s:assert>
         <s:assert test="//g:production[@name='A']">There should be a A production.</s:assert>
         <s:assert test="//g:production[@name='C']">There should be a C production.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

24 Feb 2025, Norm Tovey-Walsh
Created test.