</xsl:template>
<xsl:template match="terminal">
- <xsl:value-of select="@symbol"/>
+ <xsl:value-of select="@name"/>
<xsl:call-template name="line-wrap">
- <xsl:with-param
- name="first-line-length" select="66 - string-length(@symbol)"
- />
+ <xsl:with-param name="first-line-length">
+ <xsl:choose>
+ <xsl:when test="string-length(@name) > 66">0</xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="66 - string-length(@name)" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
<xsl:with-param name="line-length" select="66" />
<xsl:with-param name="text">
- <xsl:value-of select="concat(' (', @type, ')')"/>
+ <xsl:value-of select="concat(' (', @token-number, ')')"/>
<xsl:apply-templates select="rule" />
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="nonterminal">
- <xsl:value-of select="@symbol"/>
- <xsl:value-of select="concat(' (', @type, ')')"/>
+ <xsl:value-of select="@name"/>
+ <xsl:value-of select="concat(' (', @symbol-number, ')')"/>
<xsl:text> </xsl:text>
<xsl:variable name="output">
<xsl:call-template name="line-wrap">
<xsl:param name="first-line-length" select="$line-length"/>
<xsl:param name="text"/> <!-- required -->
<xsl:choose>
- <xsl:when test="string-length($text) = 0 or normalize-space($text) = ''" />
+ <xsl:when test="normalize-space($text) = ''" />
<xsl:when test="string-length($text) <= $first-line-length">
<xsl:value-of select="concat($text, ' ')" />
</xsl:when>
<xsl:variable name="break-pos">
<xsl:call-template name="ws-search">
<xsl:with-param name="text" select="$text" />
- <xsl:with-param name="pos" select="$first-line-length+1" />
+ <xsl:with-param name="start" select="$first-line-length+1" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="substring($text, 1, $break-pos - 1)" />
<xsl:template name="ws-search">
<xsl:param name="text"/> <!-- required -->
- <xsl:param name="pos"/> <!-- required -->
+ <xsl:param name="start"/> <!-- required -->
+ <xsl:variable name="search-text" select="substring($text, $start)" />
<xsl:choose>
- <xsl:when
- test="$pos > string-length($text) or substring($text, $pos, 1) = ' '"
- >
- <xsl:value-of select="$pos" />
+ <xsl:when test="not(contains($search-text, ' '))">
+ <xsl:value-of select="string-length($text)+1" />
</xsl:when>
<xsl:otherwise>
- <xsl:call-template name="ws-search">
- <xsl:with-param name="text" select="$text" />
- <xsl:with-param name="pos" select="$pos+1" />
- </xsl:call-template>
+ <xsl:value-of
+ select="$start + string-length(substring-before($search-text, ' '))"
+ />
</xsl:otherwise>
</xsl:choose>
</xsl:template>