bison-patches
[Top][All Lists]
Advanced

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

Re: terminal @number vs. @user-number


From: Joel E. Denny
Subject: Re: terminal @number vs. @user-number
Date: Sat, 27 Oct 2007 20:24:27 -0400 (EDT)

On Wed, 24 Oct 2007, Hans Aberg wrote:

> On 24 Oct 2007, at 22:55, Joel E. Denny wrote:
> 
> > > > Currently, Bison puts a terminal's user number (the one returned by
> > > > yylex)
> > > > in its XML "number" attribute.  I think we should rename that to
> > > > "user-number" and add a "number" attribute for Bison's internal symbol
> > > > number.  This would be more consistent with nonterminals.  I'd be happy
> > > > the write the patch.  Is all this agreeable to you, Wojciech?
> > > 
> > > Perhaps giving more sci-tech names :-):
> > > 
> > > The token number variable might be termed "token-number". The set of
> > > terminals
> > > and non-terminals is technically called "vocabulary", so the yytname_[]
> > > values, if that is what you mean, might be called "word-number" or
> > > something.
> > 
> > What about @symbol-number and @token-number?
> 
> I think those are fine:

It seems everyone is in agreement, so I committed the following.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1742
diff -p -u -r1.1742 ChangeLog
--- ChangeLog   21 Oct 2007 15:34:08 -0000      1.1742
+++ ChangeLog   28 Oct 2007 00:17:19 -0000
@@ -1,3 +1,16 @@
+2007-10-27  Joel E. Denny  <address@hidden>
+
+       For the XML output's terminal element, rename @number to @token-number,
+       and add @symbol-number.  In the nonterminal element, rename @number to
+       @symbol-number.  Discussed starting at
+       <http://lists.gnu.org/archive/html/bison-patches/2007-10/msg00040.html>.
+       * data/xslt/xml2text.xsl (xsl:template match="terminal"): Update for
+       renames.
+       (xsl:template match="nonterminal"): Likewise.
+       * data/xslt/xml2xhtml.xsl (xsl:template match="terminal"): Likewise.
+       (xsl:template match="nonterminal"): Likewise.
+       * src/print-xml.c (print_grammar): Implement.
+
 2007-10-21  Joel E. Denny  <address@hidden>
 
        * data/xslt/xml2dot.xsl (xsl:template match="automaton/state"): After
Index: data/xslt/xml2text.xsl
===================================================================
RCS file: /sources/bison/bison/data/xslt/xml2text.xsl,v
retrieving revision 1.5
diff -p -u -r1.5 xml2text.xsl
--- data/xslt/xml2text.xsl      21 Oct 2007 15:34:08 -0000      1.5
+++ data/xslt/xml2text.xsl      28 Oct 2007 00:17:20 -0000
@@ -127,7 +127,7 @@
     </xsl:with-param>
     <xsl:with-param name="line-length" select="66" />
     <xsl:with-param name="text">
-      <xsl:value-of select="concat(' (', @number, ')')"/>
+      <xsl:value-of select="concat(' (', @token-number, ')')"/>
       <xsl:apply-templates select="rule" />
     </xsl:with-param>
   </xsl:call-template>
@@ -140,7 +140,7 @@
 
 <xsl:template match="nonterminal">
   <xsl:value-of select="@name"/>
-  <xsl:value-of select="concat(' (', @number, ')')"/>
+  <xsl:value-of select="concat(' (', @symbol-number, ')')"/>
   <xsl:text>&#10;</xsl:text>
   <xsl:variable name="output">
     <xsl:call-template name="line-wrap">
Index: data/xslt/xml2xhtml.xsl
===================================================================
RCS file: /sources/bison/bison/data/xslt/xml2xhtml.xsl,v
retrieving revision 1.4
diff -p -u -r1.4 xml2xhtml.xsl
--- data/xslt/xml2xhtml.xsl     17 Oct 2007 18:12:20 -0000      1.4
+++ data/xslt/xml2xhtml.xsl     28 Oct 2007 00:17:20 -0000
@@ -298,7 +298,7 @@
 
 <xsl:template match="terminal">
   <b><xsl:value-of select="@name"/></b>
-  <xsl:value-of select="concat(' (', @number, ')')"/>
+  <xsl:value-of select="concat(' (', @token-number, ')')"/>
   <xsl:apply-templates select="rule"/>
   <xsl:text>&#10;</xsl:text>
 </xsl:template>
@@ -315,7 +315,7 @@
 
 <xsl:template match="nonterminal">
   <b><xsl:value-of select="@name"/></b>
-  <xsl:value-of select="concat(' (', @number, ')')"/>
+  <xsl:value-of select="concat(' (', @symbol-number, ')')"/>
   <xsl:text>&#10;    </xsl:text>
   <xsl:if test="left/rule">
     <xsl:text>on left:</xsl:text>
Index: src/print-xml.c
===================================================================
RCS file: /sources/bison/bison/src/print-xml.c,v
retrieving revision 1.8
diff -p -u -r1.8 print-xml.c
--- src/print-xml.c     17 Oct 2007 18:11:03 -0000      1.8
+++ src/print-xml.c     28 Oct 2007 00:17:24 -0000
@@ -429,8 +429,9 @@ print_grammar (FILE *out, int level)
        item_number *rhsp;
 
        xml_printf (out, level + 2,
-                   "<terminal number=\"%d\" name=\"%s\">",
-                   i, xml_escape (tag));
+                   "<terminal symbol-number=\"%d\" token-number=\"%d\""
+                    " name=\"%s\">",
+                   token_translations[i], i, xml_escape (tag));
 
        for (r = 0; r < nrules; r++)
          for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
@@ -465,7 +466,7 @@ print_grammar (FILE *out, int level)
        }
 
       xml_printf (out, level + 2,
-                 "<nonterminal number=\"%d\" name=\"%s\">",
+                 "<nonterminal symbol-number=\"%d\" name=\"%s\">",
                  i, xml_escape (tag));
 
       if (left_count > 0)




reply via email to

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