mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
In XML output, remove redundant class attribute on symbol element.
* data/xslt/bison.xsl (xsl:key name="bison:symbolByName"): New. * data/xslt/xml2xhtml.xsl (xsl:template match="symbol"): Use it to look up a symbol to determine whether it's a nonterminal or terminal. * src/gram.c (rule_rhs_print_xml): Remove class attribute. * src/state.c (state_rule_lookahead_tokens_print_xml): Likewise. Add prec/assoc information to XML output. * src/gram.c (grammar_rules_print_xml): For each rule that has a %prec, add a percent_prec attribute. * src/print-xml.c (print_grammar): For each terminal that has a precedence or associativity, add a prec or assoc attribute. (xml_indent): New. (xml_puts): Use xml_indent. (xml_printf): Use xml_indent. * src/print-xml.h (xml_indent): Prototype. * tests/existing.at (GNU pic Grammar): Fix a rule miscopied from <http://lists.gnu.org/archive/html/bug-bison/2003-04/msg00026.html>.
This commit is contained in:
24
ChangeLog
24
ChangeLog
@@ -1,3 +1,25 @@
|
||||
2007-12-08 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
In XML output, remove redundant class attribute on symbol element.
|
||||
* data/xslt/bison.xsl (xsl:key name="bison:symbolByName"): New.
|
||||
* data/xslt/xml2xhtml.xsl (xsl:template match="symbol"): Use it to
|
||||
look up a symbol to determine whether it's a nonterminal or terminal.
|
||||
* src/gram.c (rule_rhs_print_xml): Remove class attribute.
|
||||
* src/state.c (state_rule_lookahead_tokens_print_xml): Likewise.
|
||||
|
||||
Add prec/assoc information to XML output.
|
||||
* src/gram.c (grammar_rules_print_xml): For each rule that has a
|
||||
%prec, add a percent_prec attribute.
|
||||
* src/print-xml.c (print_grammar): For each terminal that has a
|
||||
precedence or associativity, add a prec or assoc attribute.
|
||||
(xml_indent): New.
|
||||
(xml_puts): Use xml_indent.
|
||||
(xml_printf): Use xml_indent.
|
||||
* src/print-xml.h (xml_indent): Prototype.
|
||||
|
||||
* tests/existing.at (GNU pic Grammar): Fix a rule miscopied from
|
||||
<http://lists.gnu.org/archive/html/bug-bison/2003-04/msg00026.html>.
|
||||
|
||||
2007-12-08 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
* data/xslt/bison.xsl (bison:ruleNumber): Rename to...
|
||||
@@ -300,7 +322,7 @@
|
||||
|
||||
* 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="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
|
||||
|
||||
@@ -26,6 +26,16 @@
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="http://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:key
|
||||
name="bison:symbolByName"
|
||||
match="/bison-xml-report/grammar/nonterminals/nonterminal"
|
||||
use="@name"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:symbolByName"
|
||||
match="/bison-xml-report/grammar/terminals/terminal"
|
||||
use="@name"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:ruleByNumber"
|
||||
match="/bison-xml-report/grammar/rules/rule"
|
||||
|
||||
@@ -552,7 +552,7 @@
|
||||
<xsl:template match="symbol">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@class = 'nonterminal'">
|
||||
<xsl:when test="name(key('bison:symbolByName', .)) = 'nonterminal'">
|
||||
<span class="i"><xsl:value-of select="."/></span>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
|
||||
11
src/gram.c
11
src/gram.c
@@ -121,8 +121,7 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
|
||||
item_number *rp;
|
||||
xml_puts (out, level, "<rhs>");
|
||||
for (rp = r->rhs; *rp >= 0; rp++)
|
||||
xml_printf (out, level + 1, "<symbol class=\"%s\">%s</symbol>",
|
||||
symbol_class_get_string (symbols[*rp]),
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[*rp]->tag));
|
||||
xml_puts (out, level, "</rhs>");
|
||||
}
|
||||
@@ -221,8 +220,12 @@ grammar_rules_print_xml (FILE *out, int level)
|
||||
usefulness = "useless-in-parser";
|
||||
else
|
||||
usefulness = "useful";
|
||||
xml_printf (out, level + 2, "<rule number=\"%d\" usefulness=\"%s\">",
|
||||
rules[r].number, usefulness);
|
||||
xml_indent (out, level + 2);
|
||||
fprintf (out, "<rule number=\"%d\" usefulness=\"%s\"",
|
||||
rules[r].number, usefulness);
|
||||
if (rules[r].precsym)
|
||||
fprintf (out, " percent_prec=\"%s\"", rules[r].precsym->tag);
|
||||
fputs (">\n", out);
|
||||
}
|
||||
rule_lhs_print_xml (&rules[r], out, level + 3);
|
||||
rule_rhs_print_xml (&rules[r], out, level + 3);
|
||||
|
||||
@@ -392,12 +392,20 @@ print_grammar (FILE *out, int level)
|
||||
if (token_translations[i] != undeftoken->number)
|
||||
{
|
||||
char const *tag = symbols[token_translations[i]]->tag;
|
||||
xml_printf (out, level + 2,
|
||||
"<terminal symbol-number=\"%d\" token-number=\"%d\""
|
||||
" name=\"%s\" usefulness=\"%s\"/>",
|
||||
token_translations[i], i, xml_escape (tag),
|
||||
reduce_token_unused_in_grammar (token_translations[i])
|
||||
? "unused-in-grammar" : "useful");
|
||||
int precedence = symbols[token_translations[i]]->prec;
|
||||
assoc associativity = symbols[token_translations[i]]->assoc;
|
||||
xml_indent (out, level + 2);
|
||||
fprintf (out,
|
||||
"<terminal symbol-number=\"%d\" token-number=\"%d\""
|
||||
" name=\"%s\" usefulness=\"%s\"",
|
||||
token_translations[i], i, xml_escape (tag),
|
||||
reduce_token_unused_in_grammar (token_translations[i])
|
||||
? "unused-in-grammar" : "useful");
|
||||
if (precedence)
|
||||
fprintf (out, " prec=\"%d\"", precedence);
|
||||
if (associativity != undef_assoc)
|
||||
fprintf (out, " assoc=\"%s\"", assoc_to_string (associativity) + 1);
|
||||
fputs ("/>\n", out);
|
||||
}
|
||||
xml_puts (out, level + 1, "</terminals>");
|
||||
|
||||
@@ -418,11 +426,17 @@ print_grammar (FILE *out, int level)
|
||||
}
|
||||
|
||||
void
|
||||
xml_puts (FILE *out, int level, char const *s)
|
||||
xml_indent (FILE *out, int level)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < level; i++)
|
||||
fputs (" ", out);
|
||||
}
|
||||
|
||||
void
|
||||
xml_puts (FILE *out, int level, char const *s)
|
||||
{
|
||||
xml_indent (out, level);
|
||||
fputs (s, out);
|
||||
fputc ('\n', out);
|
||||
}
|
||||
@@ -430,11 +444,9 @@ xml_puts (FILE *out, int level, char const *s)
|
||||
void
|
||||
xml_printf (FILE *out, int level, char const *fmt, ...)
|
||||
{
|
||||
int i;
|
||||
va_list arglist;
|
||||
|
||||
for (i = 0; i < level; i++)
|
||||
fputs (" ", out);
|
||||
xml_indent (out, level);
|
||||
|
||||
va_start (arglist, fmt);
|
||||
vfprintf (out, fmt, arglist);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#ifndef PRINT_XML_H_
|
||||
# define PRINT_XML_H_
|
||||
|
||||
void xml_indent (FILE *out, int level);
|
||||
void xml_puts (FILE *, int, char const *);
|
||||
void xml_printf (FILE *, int, char const *, ...);
|
||||
char const *xml_escape_n (int n, char const *str);
|
||||
|
||||
@@ -262,8 +262,7 @@ state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
||||
xml_puts (out, level, "<lookaheads>");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
||||
{
|
||||
xml_printf (out, level + 1, "<symbol class=\"%s\">%s</symbol>",
|
||||
symbol_class_get_string (symbols[k]),
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[k]->tag));
|
||||
}
|
||||
xml_puts (out, level, "</lookaheads>");
|
||||
|
||||
@@ -1266,7 +1266,7 @@ element:
|
||||
| LABEL ':' optional_separator element
|
||||
| LABEL ':' optional_separator position_not_place
|
||||
| LABEL ':' optional_separator place
|
||||
| '{}'
|
||||
| '{' {} element_list '}'
|
||||
{}
|
||||
optional_element
|
||||
| placeless_element
|
||||
|
||||
Reference in New Issue
Block a user