Make xml2dot.xsl and --graph produce the same output.

* data/xslt/xml2dot.xsl (xsl:template match="rule"): Use a `
'
instead of a `\n'.  That is, don't add escapes yet or they'll be doubly
escaped later.
(xsl:template name="output-node"): Use the new escape template instead
of the string-replace template directly.
(xsl:template name="output-edge"): Likewise.
(xsl:template name="escape"): New, escapes backslashes and newlines in
addition to quotation marks.
* src/graphviz.c (start_graph, output_node, output_edge): Add
whitespace to output for legibility.

Make xml2text.xsl and --report produce the same output, and remove the
XML "conflicts" element since a conflict summary is easily extracted
from the automaton.
* data/xslt/bison.xsl: New.
(xsl:template match="state" mode="bison:count-conflicts): New.
* data/xslt/xml2text.xsl: Import bison.xsl.
(xsl:template match="bison-xml-report"): Instead of styling the
"conflicts" element, style the "automaton" element with mode
"conflicts".  Unlike the former, the latter lists S/R and R/R
conflicts for a state on the same line.
(xsl:template match="conflicts"): Remove.
(xsl:template match="conflict"): Remove.
(xsl:template match="terminal"): Line-wrap the list of rules in which
the terminal is used.
(xsl:template match="nonterminal"): Likewise for nonterminals.
(xsl:template match="automaton" mode="conflicts"): New.
(xsl:template match="state" mode="conflicts"): New.
(xsl:template name="line-wrap"): New.
(xsl:template name="ws-search"): New.
* data/xslt/xml2xhtml.xsl: Import bison.xsl.
(xsl:template match="bison-xml-report"): Instead of styling the
"conflicts" element, style the "automaton" element with mode
"conflicts."
(xsl:template match="conflicts"): Remove.
(xsl:template match="conflict"): Remove.
(xsl:template match="automaton" mode="conflicts"): New.
(xsl:template match="state" mode="conflicts): New.
* src/conflicts.c (conflicts_output_xml): Remove.
* src/conflicts.h (conflicts_output_xml): Remove prototype.
* src/print-xml.c (print_xml): Don't invoke conflicts_output_xml.
* src/print.c (print_grammar): Consistently wrap at the 66th column so
the corresponding XSLT is easier.  Also, never wrap between a word and
the comma that follows it.
This commit is contained in:
Joel E. Denny
2007-10-09 08:48:43 +00:00
parent 793fbca50a
commit 21f1b063d8
10 changed files with 324 additions and 134 deletions

View File

@@ -1,3 +1,51 @@
2007-10-09 Joel E. Denny <jdenny@ces.clemson.edu>
Make xml2dot.xsl and --graph produce the same output.
* data/xslt/xml2dot.xsl (xsl:template match="rule"): Use a `&#10;'
instead of a `\n'. That is, don't add escapes yet or they'll be doubly
escaped later.
(xsl:template name="output-node"): Use the new escape template instead
of the string-replace template directly.
(xsl:template name="output-edge"): Likewise.
(xsl:template name="escape"): New, escapes backslashes and newlines in
addition to quotation marks.
* src/graphviz.c (start_graph, output_node, output_edge): Add
whitespace to output for legibility.
Make xml2text.xsl and --report produce the same output, and remove the
XML "conflicts" element since a conflict summary is easily extracted
from the automaton.
* data/xslt/bison.xsl: New.
(xsl:template match="state" mode="bison:count-conflicts): New.
* data/xslt/xml2text.xsl: Import bison.xsl.
(xsl:template match="bison-xml-report"): Instead of styling the
"conflicts" element, style the "automaton" element with mode
"conflicts". Unlike the former, the latter lists S/R and R/R
conflicts for a state on the same line.
(xsl:template match="conflicts"): Remove.
(xsl:template match="conflict"): Remove.
(xsl:template match="terminal"): Line-wrap the list of rules in which
the terminal is used.
(xsl:template match="nonterminal"): Likewise for nonterminals.
(xsl:template match="automaton" mode="conflicts"): New.
(xsl:template match="state" mode="conflicts"): New.
(xsl:template name="line-wrap"): New.
(xsl:template name="ws-search"): New.
* data/xslt/xml2xhtml.xsl: Import bison.xsl.
(xsl:template match="bison-xml-report"): Instead of styling the
"conflicts" element, style the "automaton" element with mode
"conflicts."
(xsl:template match="conflicts"): Remove.
(xsl:template match="conflict"): Remove.
(xsl:template match="automaton" mode="conflicts"): New.
(xsl:template match="state" mode="conflicts): New.
* src/conflicts.c (conflicts_output_xml): Remove.
* src/conflicts.h (conflicts_output_xml): Remove prototype.
* src/print-xml.c (print_xml): Don't invoke conflicts_output_xml.
* src/print.c (print_grammar): Consistently wrap at the 66th column so
the corresponding XSLT is easier. Also, never wrap between a word and
the comma that follows it.
2007-10-08 Joel E. Denny <jdenny@ces.clemson.edu> 2007-10-08 Joel E. Denny <jdenny@ces.clemson.edu>
Improve C++ namespace support. Discussed starting at Improve C++ namespace support. Discussed starting at

64
data/xslt/bison.xsl Normal file
View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
bison.xsl - common templates for Bison XSLT.
Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bison="http://www.gnu.org/software/bison/">
<!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->
<xsl:template match="state" mode="bison:count-conflicts">
<xsl:variable name="transitions" select="actions/transitions"/>
<xsl:variable name="reductions" select="actions/reductions"/>
<xsl:variable
name="terminals"
select="
$transitions/transition[@type='shift']/@symbol
| $reductions/reduction/@symbol
"
/>
<xsl:variable name="conflict-data">
<xsl:for-each select="$terminals">
<xsl:variable name="name" select="."/>
<xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">
<xsl:variable
name="shift-count"
select="count($transitions/transition[@symbol=$name])"
/>
<xsl:variable
name="reduce-count"
select="count($reductions/reduction[@symbol=$name])"
/>
<xsl:if test="$shift-count > 0 and $reduce-count > 0">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:if test="$reduce-count > 1">
<xsl:text>r</xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -59,7 +59,7 @@
</xsl:template> </xsl:template>
<xsl:template match="rule"> <xsl:template match="rule">
<xsl:text>\n</xsl:text> <xsl:text>&#10;</xsl:text>
<xsl:value-of select="lhs"/> <xsl:value-of select="lhs"/>
<xsl:text> -&gt;</xsl:text> <xsl:text> -&gt;</xsl:text>
<xsl:apply-templates select="rhs/symbol|rhs/point|rhs/empty"/> <xsl:apply-templates select="rhs/symbol|rhs/point|rhs/empty"/>
@@ -123,10 +123,8 @@
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<xsl:value-of select="$number"/> <xsl:value-of select="$number"/>
<xsl:text> [label="</xsl:text> <xsl:text> [label="</xsl:text>
<xsl:call-template name="string-replace"> <xsl:call-template name="escape">
<xsl:with-param name="subject" select="$label"/> <xsl:with-param name="subject" select="$label"/>
<xsl:with-param name="search" select="'&quot;'"/>
<xsl:with-param name="replace" select="'\&quot;'"/>
</xsl:call-template> </xsl:call-template>
<xsl:text>"]&#10;</xsl:text> <xsl:text>"]&#10;</xsl:text>
</xsl:template> </xsl:template>
@@ -144,36 +142,55 @@
<xsl:value-of select="$style"/> <xsl:value-of select="$style"/>
<xsl:if test="$label and $label != ''"> <xsl:if test="$label and $label != ''">
<xsl:text> label="</xsl:text> <xsl:text> label="</xsl:text>
<xsl:call-template name="string-replace"> <xsl:call-template name="escape">
<xsl:with-param name="subject" select="$label"/> <xsl:with-param name="subject" select="$label"/>
<xsl:with-param name="search" select="'&quot;'"/>
<xsl:with-param name="replace" select="'\&quot;'"/>
</xsl:call-template> </xsl:call-template>
<xsl:text>"</xsl:text> <xsl:text>"</xsl:text>
</xsl:if> </xsl:if>
<xsl:text>]&#10;</xsl:text> <xsl:text>]&#10;</xsl:text>
</xsl:template> </xsl:template>
<xsl:template name="string-replace"> <xsl:template name="escape">
<xsl:param name="subject"/> <xsl:param name="subject" required="yes"/>
<xsl:param name="search"/> <xsl:call-template name="string-replace">
<xsl:param name="replace"/> <xsl:with-param name="subject">
<xsl:choose> <xsl:call-template name="string-replace">
<xsl:when test="contains($subject, $search)"> <xsl:with-param name="subject">
<xsl:variable name="before" select="substring-before($subject, $search)"/> <xsl:call-template name="string-replace">
<xsl:variable name="after" select="substring-after($subject, $search)"/> <xsl:with-param name="subject" select="$subject"/>
<xsl:value-of select="$before"/> <xsl:with-param name="search" select="'\'"/>
<xsl:value-of select="$replace"/> <xsl:with-param name="replace" select="'\\'"/>
<xsl:call-template name="string-replace"> </xsl:call-template>
<xsl:with-param name="subject" select="$after"/> </xsl:with-param>
<xsl:with-param name="search" select="$search"/> <xsl:with-param name="search" select="'&quot;'"/>
<xsl:with-param name="replace" select="$replace"/> <xsl:with-param name="replace" select="'\&quot;'"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:with-param>
<xsl:otherwise> <xsl:with-param name="search" select="'&#10;'"/>
<xsl:value-of select="$subject"/> <xsl:with-param name="replace" select="'\n'"/>
</xsl:otherwise> </xsl:call-template>
</xsl:choose> </xsl:template>
</xsl:template>
<xsl:template name="string-replace">
<xsl:param name="subject"/>
<xsl:param name="search"/>
<xsl:param name="replace"/>
<xsl:choose>
<xsl:when test="contains($subject, $search)">
<xsl:variable name="before" select="substring-before($subject, $search)"/>
<xsl:variable name="after" select="substring-after($subject, $search)"/>
<xsl:value-of select="$before"/>
<xsl:value-of select="$replace"/>
<xsl:call-template name="string-replace">
<xsl:with-param name="subject" select="$after"/>
<xsl:with-param name="search" select="$search"/>
<xsl:with-param name="replace" select="$replace"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$subject"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@@ -25,8 +25,10 @@
--> -->
<xsl:stylesheet version="1.0" <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:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/"> <xsl:template match="/">
@@ -36,7 +38,7 @@
<xsl:template match="bison-xml-report"> <xsl:template match="bison-xml-report">
<xsl:apply-templates select="reductions"/> <xsl:apply-templates select="reductions"/>
<xsl:apply-templates select="rules-never-reduced"/> <xsl:apply-templates select="rules-never-reduced"/>
<xsl:apply-templates select="conflicts"/> <xsl:apply-templates select="automaton" mode="conflicts"/>
<xsl:apply-templates select="grammar"/> <xsl:apply-templates select="grammar"/>
<xsl:apply-templates select="automaton"/> <xsl:apply-templates select="automaton"/>
</xsl:template> </xsl:template>
@@ -91,23 +93,6 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="conflicts">
<xsl:if test="conflict">
<xsl:apply-templates select="conflict"/>
<xsl:text>&#10;&#10;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="conflict">
<xsl:text>State </xsl:text>
<xsl:value-of select="@state"/>
<xsl:text> conflicts: </xsl:text>
<xsl:value-of select="@num"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@type"/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
<xsl:template match="grammar"> <xsl:template match="grammar">
<xsl:text>Grammar&#10;</xsl:text> <xsl:text>Grammar&#10;</xsl:text>
<xsl:apply-templates select="rules/rule"> <xsl:apply-templates select="rules/rule">
@@ -131,9 +116,16 @@
<xsl:template match="terminal"> <xsl:template match="terminal">
<xsl:value-of select="@symbol"/> <xsl:value-of select="@symbol"/>
<xsl:value-of select="concat(' (', @type, ')')"/> <xsl:call-template name="line-wrap">
<xsl:apply-templates select="rule"/> <xsl:with-param
<xsl:text>&#10;</xsl:text> name="first-line-length" select="66 - string-length(@symbol)"
/>
<xsl:with-param name="line-length" select="66" />
<xsl:with-param name="text">
<xsl:value-of select="concat(' (', @type, ')')"/>
<xsl:apply-templates select="rule" />
</xsl:with-param>
</xsl:call-template>
</xsl:template> </xsl:template>
<xsl:template match="terminal/rule"> <xsl:template match="terminal/rule">
@@ -144,19 +136,27 @@
<xsl:template match="nonterminal"> <xsl:template match="nonterminal">
<xsl:value-of select="@symbol"/> <xsl:value-of select="@symbol"/>
<xsl:value-of select="concat(' (', @type, ')')"/> <xsl:value-of select="concat(' (', @type, ')')"/>
<xsl:text>&#10; </xsl:text>
<xsl:if test="left/rule">
<xsl:text>on left:</xsl:text>
</xsl:if>
<xsl:apply-templates select="left/rule"/>
<xsl:if test="left/rule and right/rule">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="right/rule">
<xsl:text>on right:</xsl:text>
</xsl:if>
<xsl:apply-templates select="right/rule"/>
<xsl:text>&#10;</xsl:text> <xsl:text>&#10;</xsl:text>
<xsl:variable name="output">
<xsl:call-template name="line-wrap">
<xsl:with-param name="line-length" select="66" />
<xsl:with-param name="text">
<xsl:text> </xsl:text>
<xsl:if test="left/rule">
<xsl:text>on@left:</xsl:text>
</xsl:if>
<xsl:apply-templates select="left/rule"/>
<xsl:if test="left/rule and right/rule">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="right/rule">
<xsl:text>on@right:</xsl:text>
</xsl:if>
<xsl:apply-templates select="right/rule"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="translate($output, '@', ' ')" />
</xsl:template> </xsl:template>
<xsl:template match="nonterminal/left/rule|nonterminal/right/rule"> <xsl:template match="nonterminal/left/rule|nonterminal/right/rule">
@@ -164,6 +164,41 @@
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:template> </xsl:template>
<xsl:template match="automaton" mode="conflicts">
<xsl:variable name="conflict-report">
<xsl:apply-templates select="state" mode="conflicts"/>
</xsl:variable>
<xsl:if test="string-length($conflict-report) != 0">
<xsl:value-of select="$conflict-report"/>
<xsl:text>&#10;&#10;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="state" mode="conflicts">
<xsl:variable name="conflict-counts">
<xsl:apply-templates select="." mode="bison:count-conflicts" />
</xsl:variable>
<xsl:variable
name="sr-count" select="substring-before($conflict-counts, ',')"
/>
<xsl:variable
name="rr-count" select="substring-after($conflict-counts, ',')"
/>
<xsl:if test="$sr-count > 0 or $rr-count > 0">
<xsl:value-of select="concat('State ', @number, ' conflicts:')"/>
<xsl:if test="$sr-count > 0">
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
<xsl:if test="$rr-count > 0">
<xsl:value-of select="(',')"/>
</xsl:if>
</xsl:if>
<xsl:if test="$rr-count > 0">
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
</xsl:if>
<xsl:value-of select="'&#10;'"/>
</xsl:if>
</xsl:template>
<xsl:template match="automaton"> <xsl:template match="automaton">
<xsl:apply-templates select="state"> <xsl:apply-templates select="state">
<xsl:with-param name="pad" select="'3'"/> <xsl:with-param name="pad" select="'3'"/>
@@ -429,4 +464,50 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="line-wrap">
<xsl:param name="line-length" required="yes" />
<xsl:param name="first-line-length" select="$line-length" />
<xsl:param name="text" required="yes" />
<xsl:choose>
<xsl:when test="string-length($text) = 0 or normalize-space($text) = ''" />
<xsl:when test="string-length($text) &lt;= $first-line-length">
<xsl:value-of select="concat($text, '&#10;')" />
</xsl:when>
<xsl:otherwise>
<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:call-template>
</xsl:variable>
<xsl:value-of select="substring($text, 1, $break-pos - 1)" />
<xsl:text>&#10;</xsl:text>
<xsl:call-template name="line-wrap">
<xsl:with-param name="line-length" select="$line-length" />
<xsl:with-param
name="text" select="concat(' ', substring($text, $break-pos+1))"
/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ws-search">
<xsl:param name="text" required="yes" />
<xsl:param name="pos" required="yes" />
<xsl:choose>
<xsl:when
test="$pos &gt; string-length($text) or substring($text, $pos, 1) = ' '"
>
<xsl:value-of select="$pos" />
</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:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@@ -26,7 +26,10 @@
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"> xmlns="http://www.w3.org/1999/xhtml"
xmlns:bison="http://www.gnu.org/software/bison/">
<xsl:import href="bison.xsl"/>
<xsl:output method="xml" encoding="UTF-8" <xsl:output method="xml" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -123,7 +126,7 @@
</ul> </ul>
<xsl:apply-templates select="reductions"/> <xsl:apply-templates select="reductions"/>
<xsl:apply-templates select="rules-never-reduced"/> <xsl:apply-templates select="rules-never-reduced"/>
<xsl:apply-templates select="conflicts"/> <xsl:apply-templates select="automaton" mode="conflicts"/>
<xsl:apply-templates select="grammar"/> <xsl:apply-templates select="grammar"/>
<xsl:apply-templates select="automaton"/> <xsl:apply-templates select="automaton"/>
</xsl:template> </xsl:template>
@@ -206,32 +209,52 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="conflicts"> <xsl:template match="automaton" mode="conflicts">
<h2> <h2>
<a name="conflicts"/> <a name="conflicts"/>
<xsl:text> Conflicts</xsl:text> <xsl:text> Conflicts</xsl:text>
</h2> </h2>
<xsl:text>&#10;&#10;</xsl:text> <xsl:text>&#10;&#10;</xsl:text>
<xsl:if test="conflict"> <xsl:variable name="conflict-report">
<xsl:apply-templates select="state" mode="conflicts"/>
</xsl:variable>
<xsl:if test="string-length($conflict-report) != 0">
<p class="pre"> <p class="pre">
<xsl:apply-templates select="conflict"/> <xsl:copy-of select="$conflict-report"/>
<xsl:text>&#10;&#10;</xsl:text> <xsl:text>&#10;&#10;</xsl:text>
</p> </p>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="conflict"> <xsl:template match="state" mode="conflicts">
<a> <xsl:variable name="conflict-counts">
<xsl:attribute name="href"> <xsl:apply-templates select="." mode="bison:count-conflicts" />
<xsl:value-of select="concat('#state_', @state)"/> </xsl:variable>
</xsl:attribute> <xsl:variable
<xsl:value-of select="concat('State ', @state)"/> name="sr-count" select="substring-before($conflict-counts, ',')"
</a> />
<xsl:text> conflicts: </xsl:text> <xsl:variable
<xsl:value-of select="@num"/> name="rr-count" select="substring-after($conflict-counts, ',')"
<xsl:text> </xsl:text> />
<xsl:value-of select="@type"/> <xsl:if test="$sr-count > 0 or $rr-count > 0">
<xsl:text>&#10;</xsl:text> <a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#state_', @number)"/>
</xsl:attribute>
<xsl:value-of select="concat('State ', @number)"/>
</a>
<xsl:text> conflicts:</xsl:text>
<xsl:if test="$sr-count > 0">
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
<xsl:if test="$rr-count > 0">
<xsl:value-of select="(',')"/>
</xsl:if>
</xsl:if>
<xsl:if test="$rr-count > 0">
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
</xsl:if>
<xsl:value-of select="'&#10;'"/>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="grammar"> <xsl:template match="grammar">

View File

@@ -522,47 +522,6 @@ conflicts_output (FILE *out)
fputs ("\n\n", out); fputs ("\n\n", out);
} }
void
conflicts_output_xml (FILE *out, int level)
{
bool printed_sth = false;
state_number i;
int src_num;
int rrc_num;
for (i = 0; i < nstates; i++)
{
state *s = states[i];
if (conflicts[i])
{
if (!printed_sth) {
fputc ('\n', out);
xml_puts (out, level, "<conflicts>");
}
src_num = count_sr_conflicts (s);
rrc_num = count_rr_conflicts (s, true);
if (src_num)
xml_printf (out, level + 1,
"<conflict state=\"%d\" num=\"%d\""
" type=\"shift/reduce\"/>",
i, src_num);
if (rrc_num)
xml_printf (out, level + 1,
"<conflict state=\"%d\" num=\"%d\""
" type=\"reduce/reduce\"/>",
i, rrc_num);
printed_sth = true;
}
}
if (printed_sth)
xml_puts (out, level, "</conflicts>");
else
xml_puts (out, level, "<conflicts/>");
}
/*--------------------------------------------------------. /*--------------------------------------------------------.
| Total the number of S/R and R/R conflicts. Unlike the | | Total the number of S/R and R/R conflicts. Unlike the |
| code in conflicts_output, however, count EACH pair of | | code in conflicts_output, however, count EACH pair of |

View File

@@ -37,7 +37,6 @@ void conflicts_update_state_numbers (state_number old_to_new[],
void conflicts_print (void); void conflicts_print (void);
int conflicts_total_count (void); int conflicts_total_count (void);
void conflicts_output (FILE *out); void conflicts_output (FILE *out);
void conflicts_output_xml (FILE *out, int level);
void conflicts_free (void); void conflicts_free (void);
/* Were there conflicts? */ /* Were there conflicts? */

View File

@@ -1,6 +1,6 @@
/* Output Graphviz specification of a state machine generated by Bison. /* Output Graphviz specification of a state machine generated by Bison.
Copyright (C) 2006 Free Software Foundation, Inc. Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -38,20 +38,20 @@ quote (char const *name)
void void
start_graph (FILE *fout) start_graph (FILE *fout)
{ {
fputs ("digraph Automaton{\n", fout); fputs ("digraph Automaton {\n", fout);
} }
void void
output_node (int id, char const *label, FILE *fout) output_node (int id, char const *label, FILE *fout)
{ {
fprintf (fout, "%d[label=%s]\n", id, quote (label)); fprintf (fout, " %d [label=%s]\n", id, quote (label));
} }
void void
output_edge (int source, int destination, char const *label, output_edge (int source, int destination, char const *label,
char const *style, FILE *fout) char const *style, FILE *fout)
{ {
fprintf (fout, "%d->%d[style=%s", source, destination, style); fprintf (fout, " %d -> %d [style=%s", source, destination, style);
if (label) if (label)
fprintf (fout, " label=%s", quote (label)); fprintf (fout, " label=%s", quote (label));
fputs ("]\n", fout); fputs ("]\n", fout);

View File

@@ -584,9 +584,6 @@ print_xml (void)
/* print rules never reduced */ /* print rules never reduced */
print_rules_never_reduced (out, level + 1); print_rules_never_reduced (out, level + 1);
/* print conflicts */
conflicts_output_xml (out, level + 1);
/* print grammar */ /* print grammar */
print_grammar (out, level + 1); print_grammar (out, level + 1);

View File

@@ -401,7 +401,7 @@ print_grammar (FILE *out)
buffer[0] = 0; buffer[0] = 0;
column = strlen (tag); column = strlen (tag);
fputs (tag, out); fputs (tag, out);
END_TEST (50); END_TEST (65);
sprintf (buffer, " (%d)", i); sprintf (buffer, " (%d)", i);
for (r = 0; r < nrules; r++) for (r = 0; r < nrules; r++)
@@ -445,14 +445,16 @@ print_grammar (FILE *out)
if (left_count > 0) if (left_count > 0)
{ {
END_TEST (50); END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on left:")); sprintf (buffer + strlen (buffer), _(" on left:"));
for (r = 0; r < nrules; r++) for (r = 0; r < nrules; r++)
{ {
END_TEST (65);
if (rules[r].lhs->number == i) if (rules[r].lhs->number == i)
sprintf (buffer + strlen (buffer), " %d", r); {
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
}
} }
} }
@@ -460,7 +462,7 @@ print_grammar (FILE *out)
{ {
if (left_count > 0) if (left_count > 0)
sprintf (buffer + strlen (buffer), ","); sprintf (buffer + strlen (buffer), ",");
END_TEST (50); END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on right:")); sprintf (buffer + strlen (buffer), _(" on right:"));
for (r = 0; r < nrules; r++) for (r = 0; r < nrules; r++)
{ {