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:

cache

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.

format

Identifies the format of the result:

xml

Returns an XML node.

json

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"
        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  }
}