bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: <reductions>


From: Joel E. Denny
Subject: Re: <reductions>
Date: Tue, 9 Oct 2007 04:48:50 -0400 (EDT)

On Sun, 30 Sep 2007, Joel E. Denny wrote:

> > Similarly, I'm not sure there should be a section about the
> > conflicts, since the states already provide this information.
> >
> > I can be wrong, but I'd feel better if the XML file was
> > without redundancy, even if that requires a bit more work
> > from the XSLT tools.  Work that I guess can be factored with
> > an XLST library tailored to our XML format (I'm using words
> > I understand, but which I never practiced for real, so I
> > might suggest stupid things here :).
> 
> I agree with all this.

... except for the sentence in parentheses, of course.

I committed the following.  Primarily, I'm making --graph/--report and 
xml2dot.xsl/xml2text.xsl produce similar output.  As we refactor the XML 
implementation to remove redundancies, this will make regression testing 
much easier.

Because I needed to reorganize the conflict summary produced by 
xml2text.xsl to make it look like the one from --report, I decided I might 
as well start with new XSLT that derives the conflicts from the automaton.  
That is, as Akim suggested above, the XML no longer contains a conflict 
summary.

xml2xhtml.xsl and xml2text.xsl now share a template for computing 
conflicts.  As Akim suggested, I've started a library.  I named it 
bison.xsl.  I set the namespace URI for its contents as:

  http://www.gnu.org/software/bison/

because I figured it's the most obvious choice.  However, I usually prefer 
something like:

  http://www.gnu.org/software/bison/VERSION/

where VERSION will be 2.3b in the next release.  This cleanly separates 
names that have changed between releases.  What do others think?  Is there 
any GNU convention here?  If not, is there any other convention we should 
consider adopting?

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1734
diff -p -u -r1.1734 ChangeLog
--- ChangeLog   8 Oct 2007 10:09:06 -0000       1.1734
+++ ChangeLog   9 Oct 2007 07:49:51 -0000
@@ -1,3 +1,51 @@
+2007-10-09  Joel E. Denny  <address@hidden>
+
+       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  <address@hidden>
 
        Improve C++ namespace support.  Discussed starting at
Index: data/xslt/bison.xsl
===================================================================
RCS file: data/xslt/bison.xsl
diff -N data/xslt/bison.xsl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/xslt/bison.xsl 9 Oct 2007 07:49:51 -0000
@@ -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/address@hidden'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/address@hidden)"
+        />
+        <xsl:variable
+          name="reduce-count"
+          select="count($reductions/address@hidden)"
+        />
+        <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>
Index: data/xslt/xml2dot.xsl
===================================================================
RCS file: /sources/bison/bison/data/xslt/xml2dot.xsl,v
retrieving revision 1.1
diff -p -u -r1.1 xml2dot.xsl
--- data/xslt/xml2dot.xsl       24 Sep 2007 19:30:17 -0000      1.1
+++ data/xslt/xml2dot.xsl       9 Oct 2007 07:49:51 -0000
@@ -59,7 +59,7 @@
 </xsl:template>
 
 <xsl:template match="rule">
-  <xsl:text>\n</xsl:text>
+  <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"/>
@@ -123,10 +123,8 @@
   <xsl:text>  </xsl:text>
   <xsl:value-of select="$number"/>
   <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="search" select="'&quot;'"/>
-    <xsl:with-param name="replace" select="'\&quot;'"/>
   </xsl:call-template>
   <xsl:text>"]&#10;</xsl:text>
 </xsl:template>
@@ -144,36 +142,55 @@
   <xsl:value-of select="$style"/>
   <xsl:if test="$label and $label != ''">
     <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="search" select="'&quot;'"/>
-      <xsl:with-param name="replace" select="'\&quot;'"/>
     </xsl:call-template>
     <xsl:text>"</xsl:text>
   </xsl:if>
   <xsl:text>]&#10;</xsl:text>
 </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:template name="escape">
+  <xsl:param name="subject" required="yes"/>
+  <xsl:call-template name="string-replace">
+    <xsl:with-param name="subject">
+      <xsl:call-template name="string-replace">
+        <xsl:with-param name="subject">
+          <xsl:call-template name="string-replace">
+            <xsl:with-param name="subject" select="$subject"/>
+            <xsl:with-param name="search" select="'\'"/>
+            <xsl:with-param name="replace" select="'\\'"/>
+          </xsl:call-template>
+        </xsl:with-param>
+        <xsl:with-param name="search" select="'&quot;'"/>
+        <xsl:with-param name="replace" select="'\&quot;'"/>
+      </xsl:call-template>
+    </xsl:with-param>
+    <xsl:with-param name="search" select="'&#10;'"/>
+    <xsl:with-param name="replace" select="'\n'"/>
+  </xsl:call-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>
Index: data/xslt/xml2text.xsl
===================================================================
RCS file: /sources/bison/bison/data/xslt/xml2text.xsl,v
retrieving revision 1.1
diff -p -u -r1.1 xml2text.xsl
--- data/xslt/xml2text.xsl      24 Sep 2007 19:30:49 -0000      1.1
+++ data/xslt/xml2text.xsl      9 Oct 2007 07:49:51 -0000
@@ -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="/">
@@ -36,7 +38,7 @@
 <xsl:template match="bison-xml-report">
   <xsl:apply-templates select="reductions"/>
   <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="automaton"/>
 </xsl:template>
@@ -91,23 +93,6 @@
   </xsl:if>
 </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:text>Grammar&#10;</xsl:text>
   <xsl:apply-templates select="rules/rule">
@@ -131,9 +116,16 @@
 
 <xsl:template match="terminal">
   <xsl:value-of select="@symbol"/>
-  <xsl:value-of select="concat(' (', @type, ')')"/>
-  <xsl:apply-templates select="rule"/>
-  <xsl:text>&#10;</xsl:text>
+  <xsl:call-template name="line-wrap">
+    <xsl:with-param
+      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 match="terminal/rule">
@@ -144,19 +136,27 @@
 <xsl:template match="nonterminal">
   <xsl:value-of select="@symbol"/>
   <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: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>address@hidden:</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>address@hidden:</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 match="nonterminal/left/rule|nonterminal/right/rule">
@@ -164,6 +164,41 @@
   <xsl:value-of select="."/>
 </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:apply-templates select="state">
     <xsl:with-param name="pad" select="'3'"/>
@@ -429,4 +464,50 @@
   </xsl:if>
 </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>
Index: data/xslt/xml2xhtml.xsl
===================================================================
RCS file: /sources/bison/bison/data/xslt/xml2xhtml.xsl,v
retrieving revision 1.1
diff -p -u -r1.1 xml2xhtml.xsl
--- data/xslt/xml2xhtml.xsl     24 Sep 2007 19:31:08 -0000      1.1
+++ data/xslt/xml2xhtml.xsl     9 Oct 2007 07:49:51 -0000
@@ -26,7 +26,10 @@
 
 <xsl:stylesheet version="1.0"
   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"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -123,7 +126,7 @@
   </ul>
   <xsl:apply-templates select="reductions"/>
   <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="automaton"/>
 </xsl:template>
@@ -206,32 +209,52 @@
   </xsl:if>
 </xsl:template>
 
-<xsl:template match="conflicts">
+<xsl:template match="automaton" mode="conflicts">
   <h2>
     <a name="conflicts"/>
     <xsl:text> Conflicts</xsl:text>
   </h2>
   <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">
-      <xsl:apply-templates select="conflict"/>
+      <xsl:copy-of select="$conflict-report"/>
       <xsl:text>&#10;&#10;</xsl:text>
     </p>
   </xsl:if>
 </xsl:template>
 
-<xsl:template match="conflict">
-  <a>
-    <xsl:attribute name="href">
-      <xsl:value-of select="concat('#state_', @state)"/>
-    </xsl:attribute>
-    <xsl:value-of select="concat('State ', @state)"/>
-  </a>
-  <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 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">
+    <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 match="grammar">
Index: src/conflicts.c
===================================================================
RCS file: /sources/bison/bison/src/conflicts.c,v
retrieving revision 1.123
diff -p -u -r1.123 conflicts.c
--- src/conflicts.c     24 Sep 2007 06:34:44 -0000      1.123
+++ src/conflicts.c     9 Oct 2007 07:49:51 -0000
@@ -522,47 +522,6 @@ conflicts_output (FILE *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  |
 | code in conflicts_output, however, count EACH pair of   |
Index: src/conflicts.h
===================================================================
RCS file: /sources/bison/bison/src/conflicts.h,v
retrieving revision 1.20
diff -p -u -r1.20 conflicts.h
--- src/conflicts.h     21 Sep 2007 22:53:57 -0000      1.20
+++ src/conflicts.h     9 Oct 2007 07:49:51 -0000
@@ -37,7 +37,6 @@ void conflicts_update_state_numbers (sta
 void conflicts_print (void);
 int conflicts_total_count (void);
 void conflicts_output (FILE *out);
-void conflicts_output_xml (FILE *out, int level);
 void conflicts_free (void);
 
 /* Were there conflicts? */
Index: src/graphviz.c
===================================================================
RCS file: /sources/bison/bison/src/graphviz.c,v
retrieving revision 1.2
diff -p -u -r1.2 graphviz.c
--- src/graphviz.c      15 Aug 2007 20:21:30 -0000      1.2
+++ src/graphviz.c      9 Oct 2007 07:49:51 -0000
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -38,20 +38,20 @@ quote (char const *name)
 void
 start_graph (FILE *fout)
 {
-  fputs ("digraph Automaton{\n", fout);
+  fputs ("digraph Automaton {\n", fout);
 }
 
 void
 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
 output_edge (int source, int destination, char const *label,
             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)
     fprintf (fout, " label=%s", quote (label));
   fputs ("]\n", fout);
Index: src/print-xml.c
===================================================================
RCS file: /sources/bison/bison/src/print-xml.c,v
retrieving revision 1.4
diff -p -u -r1.4 print-xml.c
--- src/print-xml.c     29 Sep 2007 22:36:37 -0000      1.4
+++ src/print-xml.c     9 Oct 2007 07:49:51 -0000
@@ -584,9 +584,6 @@ print_xml (void)
   /* print rules never reduced */
   print_rules_never_reduced (out, level + 1);
 
-  /* print conflicts */
-  conflicts_output_xml (out, level + 1);
-
   /* print grammar */
   print_grammar (out, level + 1);
 
Index: src/print.c
===================================================================
RCS file: /sources/bison/bison/src/print.c,v
retrieving revision 1.104
diff -p -u -r1.104 print.c
--- src/print.c 15 Aug 2007 20:21:31 -0000      1.104
+++ src/print.c 9 Oct 2007 07:49:51 -0000
@@ -401,7 +401,7 @@ print_grammar (FILE *out)
        buffer[0] = 0;
        column = strlen (tag);
        fputs (tag, out);
-       END_TEST (50);
+       END_TEST (65);
        sprintf (buffer, " (%d)", i);
 
        for (r = 0; r < nrules; r++)
@@ -445,14 +445,16 @@ print_grammar (FILE *out)
 
       if (left_count > 0)
        {
-         END_TEST (50);
+         END_TEST (65);
          sprintf (buffer + strlen (buffer), _(" on left:"));
 
          for (r = 0; r < nrules; r++)
            {
-             END_TEST (65);
              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)
            sprintf (buffer + strlen (buffer), ",");
-         END_TEST (50);
+         END_TEST (65);
          sprintf (buffer + strlen (buffer), _(" on right:"));
          for (r = 0; r < nrules; r++)
            {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]