+<xsl:template match="grammar" mode="useless-in-parser">
+ <xsl:variable
+ name="set" select="rules/rule[@usefulness='useless-in-parser']"
+ />
+ <xsl:if test="$set">
+ <h2>
+ <a name="rules_useless_in_parser"/>
+ <xsl:text> Rules useless in parser due to conflicts</xsl:text>
+ </h2>
+ <xsl:text> </xsl:text>
+ <p class="pre">
+ <xsl:call-template name="style-rule-set">
+ <xsl:with-param name="rule-set" select="$set"/>
+ </xsl:call-template>
+ </p>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="grammar">
+ <h2>
+ <a name="grammar"/>
+ <xsl:text> Grammar</xsl:text>
+ </h2>
+ <xsl:text> </xsl:text>
+ <p class="pre">
+ <xsl:call-template name="style-rule-set">
+ <xsl:with-param
+ name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
+ />
+ </xsl:call-template>
+ </p>
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates select="terminals"/>
+ <xsl:apply-templates select="nonterminals"/>
+</xsl:template>
+
+<xsl:template name="style-rule-set">
+ <xsl:param name="rule-set"/>
+ <xsl:for-each select="$rule-set">
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="pad" select="'3'"/>
+ <xsl:with-param name="prev-lhs">
+ <xsl:if test="position()>1">
+ <xsl:variable name="position" select="position()"/>
+ <xsl:value-of select="$rule-set[$position - 1]/lhs"/>
+ </xsl:if>
+ </xsl:with-param>
+ </xsl:apply-templates>
+ </xsl:for-each>
+</xsl:template>
+