Chapter 4cs:hygiene-report

Get a hygiene report for a grammar. The hygiene report will contain information about unproductive rules and undefined, unused, or unproductive symbols.

cs:hygiene-report($input)item()
$inputitem()The ixml grammar
cs:hygiene-report($input, $options)item()
$inputitem()The ixml grammar
$optionsmap(xs:string, item())Grammar options

See Chapter 5, Parser options for a description of the available options.

Like cs:make-parser, this function will accept an XML node, an xs:anyURI, or a string.

It returns a report.

Consider the following grammar:


S: A ; B .
A: 'a', X .
B: 'b', Y .
X: 'x' .
Z: 'z' .

It contains unused and undefined nonterminals.

The XML report is in the http://nineml.com/ns/coffeegrinder namespace. This is an example report for this grammar:

<report xmlns="http://nineml.com/ns/coffeegrinder"
        clean="false">
   <undefined>
      <symbol>Y</symbol>
   </undefined>
   <unreachable>
      <symbol>Z</symbol>
   </unreachable>
   <unproductive>
      <symbol>Y</symbol>
      <rule>B ⇒ 'b', Y</rule>
      <rule>S ⇒ B</rule>
   </unproductive>
</report>

In JSON, the report would be:

{
  "report": {
    "unproductive": [
      "B",
      "B ⇒ 'b', Y",
      "S ⇒ B"
    ],
    "unreachable": [
      "Z"
    ],
    "clean": false,
    "undefined": [
      "Y"
    ]
  }
}