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, xs:string)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:

1 |S: A ; B .
  |A: 'a', X .
  |B: 'b', Y .
  |X: 'x' .
5 |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:

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

In JSON, the report would be:

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