X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d4a26c4832ca0ae76c99b98144513dced634280b..aca4ddc75daaf5a9d9ce8f52e15e1f9c0ebab741:/src/print-xml.c
diff --git a/src/print-xml.c b/src/print-xml.c
index 9b1891bd..e37a7414 100644
--- a/src/print-xml.c
+++ b/src/print-xml.c
@@ -1,23 +1,21 @@
/* Print an xml on generated parser, for Bison,
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
- Bison is free software; you can redistribute it and/or modify
+ 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 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bison is distributed in the hope that it will be useful,
+ 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 Bison; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
#include
#include "system.h"
@@ -25,7 +23,6 @@
#include
#include
-#include
#include "LR0.h"
#include "closure.h"
@@ -48,7 +45,7 @@ struct escape_buf
char *ptr;
size_t size;
};
-static struct escape_buf escape_bufs[2];
+static struct escape_buf escape_bufs[3];
/*--------------------------------.
@@ -244,17 +241,18 @@ print_reductions (FILE *out, int level, state *s)
{
transitions *trans = s->transitions;
reductions *reds = s->reductions;
- rule *default_rule = NULL;
+ rule *default_reduction = NULL;
int report = false;
int i, j;
- if (reds->num == 0) {
- xml_puts (out, level, "");
- return;
- }
+ if (reds->num == 0)
+ {
+ xml_puts (out, level, "");
+ return;
+ }
if (yydefact[s->number] != 0)
- default_rule = &rules[yydefact[s->number] - 1];
+ default_reduction = &rules[yydefact[s->number] - 1];
bitset_zero (no_reduce_set);
FOR_EACH_SHIFT (trans, i)
@@ -263,7 +261,7 @@ print_reductions (FILE *out, int level, state *s)
if (s->errs->symbols[i])
bitset_set (no_reduce_set, s->errs->symbols[i]->number);
- if (default_rule)
+ if (default_reduction)
report = true;
if (reds->lookahead_tokens)
@@ -276,7 +274,7 @@ print_reductions (FILE *out, int level, state *s)
{
if (! count)
{
- if (reds->rules[j] != default_rule)
+ if (reds->rules[j] != default_reduction)
report = true;
count = true;
}
@@ -307,7 +305,7 @@ print_reductions (FILE *out, int level, state *s)
{
if (! count)
{
- if (reds->rules[j] != default_rule)
+ if (reds->rules[j] != default_reduction)
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], true);
else
@@ -318,7 +316,7 @@ print_reductions (FILE *out, int level, state *s)
{
if (defaulted)
print_reduction (out, level + 1, symbols[i]->tag,
- default_rule, true);
+ default_reduction, true);
defaulted = false;
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], false);
@@ -326,9 +324,9 @@ print_reductions (FILE *out, int level, state *s)
}
}
- if (default_rule)
+ if (default_reduction)
print_reduction (out, level + 1,
- "$default", default_rule, true);
+ "$default", default_reduction, true);
xml_puts (out, level, "");
}
@@ -392,12 +390,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,
- "",
- 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,
+ "\n", out);
}
xml_puts (out, level + 1, "");
@@ -418,11 +424,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 +442,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);
@@ -492,8 +502,12 @@ print_xml (void)
FILE *out = xfopen (spec_xml_file, "w");
fputs ("\n\n", out);
- xml_printf (out, level, "",
- xml_escape (VERSION));
+ xml_printf (out, level,
+ "",
+ xml_escape_n (0, VERSION),
+ xml_escape_n (1, PACKAGE_BUGREPORT),
+ xml_escape_n (2, PACKAGE_URL));
fputc ('\n', out);
xml_printf (out, level + 1, "%s",