* data/xslt/xml2dot.xsl (xsl:template match="automaton/state"): After

2007-10-11 change, the child elements here are items not rules.
(<xsl:template match="item"): New.
(xsl:template match="rule"): Update for new reduced itemset.
(xsl:template match="point"): Remove.
(xsl:template match="empty"): For consistency with --graph, don't
output "/* empty */".
* data/xslt/xml2text.xsl (xsl:template match="terminal"): When invoking
line-wrap, don't pass a negative value as first-line-length since this
won't work with the following changes.
(xsl:template name="line-wrap"): Simplify slightly.
(xsl:template name="ws-search"): Eliminate recursion.
* src/print_graph.c (print_core): Don't print a reduction's lookahead
set next to an item whose dot is not at the end of the RHS even if it
happens to be associated with the same rule.
This commit is contained in:
Joel E. Denny
2007-10-21 15:34:08 +00:00
parent 31984206a7
commit 255a6b901a
4 changed files with 60 additions and 27 deletions

View File

@@ -25,8 +25,10 @@
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bison="http://www.gnu.org/software/bison/">
<xsl:import href="bison.xsl"/>
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
@@ -48,7 +50,7 @@
<xsl:with-param name="number" select="@number"/>
<xsl:with-param name="label">
<xsl:value-of select="@number"/>
<xsl:apply-templates select="itemset/rule"/>
<xsl:apply-templates select="itemset/item"/>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates select="actions/transitions"/>
@@ -58,12 +60,27 @@
<xsl:apply-templates select="transition"/>
</xsl:template>
<xsl:template match="item">
<xsl:apply-templates select="key('bison:ruleNumber', @rule-number)">
<xsl:with-param name="point" select="@point"/>
</xsl:apply-templates>
<xsl:apply-templates select="lookaheads"/>
</xsl:template>
<xsl:template match="rule">
<xsl:param name="point"/>
<xsl:text>&#10;</xsl:text>
<xsl:value-of select="lhs"/>
<xsl:text> -&gt;</xsl:text>
<xsl:apply-templates select="rhs/symbol|rhs/point|rhs/empty"/>
<xsl:apply-templates select="lookaheads"/>
<xsl:if test="$point = 0">
<xsl:text> .</xsl:text>
</xsl:if>
<xsl:for-each select="rhs/symbol|rhs/empty">
<xsl:apply-templates select="."/>
<xsl:if test="$point = position()">
<xsl:text> .</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="symbol">
@@ -71,13 +88,7 @@
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="point">
<xsl:text> .</xsl:text>
</xsl:template>
<xsl:template match="empty">
<xsl:text> /* empty */</xsl:text>
</xsl:template>
<xsl:template match="empty"/>
<xsl:template match="lookaheads">
<xsl:text>[</xsl:text>

View File

@@ -117,9 +117,14 @@
<xsl:template match="terminal">
<xsl:value-of select="@name"/>
<xsl:call-template name="line-wrap">
<xsl:with-param
name="first-line-length" select="66 - string-length(@name)"
/>
<xsl:with-param name="first-line-length">
<xsl:choose>
<xsl:when test="string-length(@name) &gt; 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(' (', @number, ')')"/>
@@ -515,7 +520,7 @@
<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) &lt;= $first-line-length">
<xsl:value-of select="concat($text, '&#10;')" />
</xsl:when>
@@ -523,7 +528,7 @@
<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)" />
@@ -540,18 +545,16 @@
<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 &gt; 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>