RE: Parsing and lookahead

I returned from a walk with a solution. If I assume 1) each clause starts with "4." (it does) and 2) "4" will not appear anywhere in a definition (it doesn't, save one definition, easily substitutable), a solution is quickly arrived at. I removed the production for notes, as I didn't strictly need it.

New iXML grammar:

 definitions: (-"4.", definition)+. 
  definition: clause,ws,name,ws,description. 
      clause: ["0"-"9"]+. 
        name: ~[":"]+,-":". 
 description: ~["4"]+.        
         -ws: -[Zs]; lf; cr. 
         -lf: -#a. 
         -cr: -#d. 

Produces (fragment):

<definition>
	<clause>61</clause>
	<name>contextually required element</name>
	<description>An element that is not a contextually optional element and 
a) whose generic identifier is the document type name; or 
b) whose currently applicable model token is a contextually required token. 
NOTE - An element could be neither contextually required nor contextually optional; for example, an element whose currently applicable model token is in an or group that has no inherently optional tokens. 
</description>

Regards,

John.

Received on Sunday, 4 May 2025 19:40:50 UTC