From 44ad466a325274a787dd400be9ab40338822235e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 11 Jul 2020 08:41:37 +0200 Subject: [PATCH] reports: let xml reports catch up with --report and --graph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The text and Dot reports are expected to be identical when generated directly (--report, --graph) or indirectly (via XML). The xml testsuite had not be run for ages, let it catch up a bit. * src/print-xml.c: Pass the type of the symbols. * data/xslt/xml2text.xsl Catch up with the new layout. Display the symbol types. Use '•', not '.' * tests/local.at: Smash '•' to '.' when matching against the direct text report. * tests/report.at: Adjust XML expectations. --- data/xslt/xml2text.xsl | 20 ++++++++++++------ src/print-xml.c | 13 ++++++++---- tests/local.at | 9 ++++++-- tests/report.at | 48 +++++++++++++++++++++--------------------- 4 files changed, 54 insertions(+), 36 deletions(-) diff --git a/data/xslt/xml2text.xsl b/data/xslt/xml2text.xsl index 3d0550dd..6aad1526 100644 --- a/data/xslt/xml2text.xsl +++ b/data/xslt/xml2text.xsl @@ -52,7 +52,7 @@ Nonterminals useless in grammar - + @@ -65,7 +65,7 @@ Terminals unused in grammar - + @@ -136,6 +136,7 @@ + @@ -148,6 +149,9 @@ + + + @@ -157,14 +161,18 @@ + + + + - + on@left: @@ -173,7 +181,7 @@ - , + on@right: @@ -348,11 +356,11 @@ - . + - . + diff --git a/src/print-xml.c b/src/print-xml.c index de4bf141..bd231045 100644 --- a/src/print-xml.c +++ b/src/print-xml.c @@ -384,13 +384,15 @@ print_grammar (FILE *out, int level) { symbol const *sym = symbols[token_translations[i]]; char const *tag = sym->tag; + char const *type = sym->content->type_name; int precedence = sym->content->prec; assoc associativity = sym->content->assoc; xml_indent (out, level + 2); fprintf (out, "tag; + char const *type = sym->content->type_name; xml_printf (out, level + 2, "", - i, xml_escape (tag), - reduce_nonterminal_useless_in_grammar (symbols[i]->content) + i, xml_escape_n (0, tag), + type ? xml_escape_n (1, type) : "", + reduce_nonterminal_useless_in_grammar (sym->content) ? "useless-in-grammar" : "useful"); } xml_puts (out, level + 1, ""); diff --git a/tests/local.at b/tests/local.at index 863f75e9..b94dd407 100644 --- a/tests/local.at +++ b/tests/local.at @@ -1169,11 +1169,16 @@ m4_define([AT_BISON_CHECK_XML], [cp xml-tests/test.output expout] AT_CHECK([[$XSLTPROC \ `]]AT_SET_ENV[[ bison --print-datadir`/xslt/xml2text.xsl \ - xml-tests/test.xml]], [[0]], [expout]) + xml-tests/test.xml]], [[0]], [stdout]) + # xml2text and xml2dot always use '•', while --report uses '•' or '.' + # depending on the locale, and the test suite is run with the plain + # C locale. + AT_CHECK([[sed -e 's/•/./g' stdout]], [], [expout]) [sort xml-tests/test.gv > expout] AT_CHECK([[$XSLTPROC \ `]]AT_SET_ENV[[ bison --print-datadir`/xslt/xml2dot.xsl \ - xml-tests/test.xml | sort]], [[0]], [expout]) + xml-tests/test.xml | sort | sed -e 's/•/./g']], + [[0]], [stdout]) [rm -rf xml-tests expout] AT_RESTORE_SPECIAL_FILES [fi]]) diff --git a/tests/report.at b/tests/report.at index cc2aa34b..9f6d6701 100644 --- a/tests/report.at +++ b/tests/report.at @@ -764,24 +764,24 @@ AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version=" - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + @@ -1881,16 +1881,16 @@ AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version=" - - - - - - + + + + + + - - + +