5. cs: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($grammar, $options)node()
$grammarnodeThe ixml grammar
$optionsmap(xs:string, xs:string)Grammar options

The following options are recognized:


If unspecified or specified with the value “true” or “yes”, the grammar will be cached. If any other value is specified, the grammar will not be cached.

Caching at this level saves the mapping between the XML representation of the grammar and the underlying Invisible XML parser object.


Identifies the format of the result:


Returns an XML node.


Returns a map.

It is an error to specify any other value.

It returns a report.

Consider the following grammar:

1S: A ; B .
A: 'a', X .
B: 'b', Y .
X: 'x' .
5Z: '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"
5   </undefined>
10      <symbol>Y</symbol>
      <rule>B ⇒ 'b', Y</rule>
      <rule>S ⇒ B</rule>

In JSON, the report would be:

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