]> git.saurik.com Git - bison.git/commitdiff
* data/xslt/xml2dot.xsl (xsl:template match="automaton/state"): After
authorJoel E. Denny <jdenny@ces.clemson.edu>
Sun, 21 Oct 2007 15:34:08 +0000 (15:34 +0000)
committerJoel E. Denny <jdenny@ces.clemson.edu>
Sun, 21 Oct 2007 15:34:08 +0000 (15:34 +0000)
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.

ChangeLog
data/xslt/xml2dot.xsl
data/xslt/xml2text.xsl
src/print_graph.c

index 25a026b7b2918cfb5d179deb595a1492285bfa98..d8e62d845ef420829a3d6912d419076e1ac78c6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-10-21  Joel E. Denny  <jdenny@ces.clemson.edu>
+
+       * 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.
+
 2007-10-19  Joel E. Denny  <jdenny@ces.clemson.edu>
 
        Add %define lr.keep_unreachable_states.
index 1d56ca8d373da04494821b1b039e099e5b50fd8c..d1d2691ac908ea40c6ad0480aa7da9dde7f4d422 100644 (file)
   -->
 
 <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"/>
   <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">
   <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>
index 621599a3267e6eefb0bd27c8cb5356da0b755ae3..291045ad92c55b5fa0dce256ecfeec7718b07a50 100644 (file)
 <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, ')')"/>
   <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>
       <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 &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>
index 2db681510e21bf5925bb3f53490f7a5537988cef..9d7da18a173728f80c335df0a88c2f70673f3da4 100644 (file)
@@ -82,7 +82,8 @@ print_core (struct obstack *oout, state *s)
        obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
 
       /* Experimental feature: display the lookahead tokens. */
-      if (report_flag & report_lookahead_tokens)
+      if (report_flag & report_lookahead_tokens
+          && item_number_is_rule_number (*sp1))
        {
          /* Find the reduction we are handling.  */
          reductions *reds = s->reductions;