From 715978d726bb2100b124d94e6cf00ec2055a9f78 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 16 Oct 2012 11:04:03 +0200 Subject: [PATCH 01/46] java: fixes * data/java.m4: Remove stray M4 characters. --- data/java.m4 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/java.m4 b/data/java.m4 index 4e809680..627028b3 100644 --- a/data/java.m4 +++ b/data/java.m4 @@ -155,24 +155,24 @@ m4_define([b4_case], [ case $1: ## ---------------- ## m4_define([b4_yystype], [b4_percent_define_get([[stype]])]) -b4_percent_define_default([[stype]], [[Object]])]) +b4_percent_define_default([[stype]], [[Object]]) # %name-prefix m4_define_default([b4_prefix], [[YY]]) -b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])]) +b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser]) m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])]) -b4_percent_define_default([[lex_throws]], [[java.io.IOException]])]) +b4_percent_define_default([[lex_throws]], [[java.io.IOException]]) m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])]) -b4_percent_define_default([[throws]], [])]) +b4_percent_define_default([[throws]], []) m4_define([b4_throws], [b4_percent_define_get([[throws]])]) -b4_percent_define_default([[api.location.type]], [Location])]) +b4_percent_define_default([[api.location.type]], [Location]) m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])]) -b4_percent_define_default([[api.position.type]], [Position])]) +b4_percent_define_default([[api.position.type]], [Position]) m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])]) @@ -219,9 +219,9 @@ m4_define([b4_rhs_location], # it to be single quoted. Same for b4_parse_param. # TODO: should be in bison.m4 -m4_define_default([b4_lex_param], [[]])) -m4_define([b4_lex_param], b4_lex_param)) -m4_define([b4_parse_param], b4_parse_param)) +m4_define_default([b4_lex_param], [[]]) +m4_define([b4_lex_param], b4_lex_param) +m4_define([b4_parse_param], b4_parse_param) # b4_lex_param_decl # ------------------- From 85935600ad544bfe16ede35621f0b96b5d3dce81 Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Thu, 18 Oct 2012 15:38:29 +0000 Subject: [PATCH 02/46] graphs: address an issue with R/R conflicts All disabled reductions should now be shown as such. * src/graphviz.c (output_red): Here. (conclude_red): New. Signed-off-by: Akim Demaille --- src/graphviz.c | 88 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/src/graphviz.c b/src/graphviz.c index e62ee1d4..a7a42d60 100644 --- a/src/graphviz.c +++ b/src/graphviz.c @@ -93,6 +93,40 @@ no_reduce_bitset_init (state const *s, bitset *no_reduce_set) bitset_set (*no_reduce_set, s->errs->symbols[n]->number); } +static void +conclude_red (struct obstack *out, int source, int ruleno, bool enabled, + bool first, FILE *fout) +{ + /* If no lookahead tokens were valid transitions, this reduction is + actually hidden, so cancel everything. */ + if (first) + return (void) obstack_finish0 (out); + else + { + char const *ed = enabled ? "e" : "d"; + + /* First, build the edge's head. */ + if (! first) + fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [label = \"", + source, ruleno, ed); + + /* (The lookahead tokens have been added to the beginning of the + obstack, in the caller function.) */ + + /* Then, the edge's tail. */ + obstack_sgrow (out, "\" style = solid]\n"); + + /* Build the associated diamond representation or the target rule. */ + obstack_printf (out, " \"%dR%d%s\" " + "[style = filled shape = diamond fillcolor = %s " + "label = \"R%d\"]\n", + source, ruleno, ed, + enabled ? "yellowgreen" : "firebrick1", + ruleno); + fprintf (fout, obstack_finish0 (out)); + } +} + static bool print_token (struct obstack *out, bool first, char const *tok) { @@ -110,58 +144,52 @@ output_red (state const *s, reductions const *reds, FILE *fout) bitset no_reduce_set; int j; int source = s->number; - struct obstack oout; + struct obstack dout, eout; no_reduce_bitset_init (s, &no_reduce_set); - obstack_init (&oout); + obstack_init (&dout); + obstack_init (&eout); for (j = 0; j < reds->num; ++j) { - bool disabled = false; - bool first = true; + bool defaulted = false; + bool firstd = true, firste = true; // first{en,dis}abled int ruleno = reds->rules[j]->user_number; rule *default_reduction = NULL; if (yydefact[s->number] != 0) default_reduction = &rules[yydefact[s->number] - 1]; - /* First, print the edges that represent each possible reduction for - the given state. */ - obstack_printf (&oout, " %1$d -> \"%1$dR%2$d\" [label=\"", - source, ruleno); + /* Build the lookahead tokens lists, one for enabled transitions and one + for disabled transistions. */ if (default_reduction && default_reduction == reds->rules[j]) - first = print_token (&oout, true, "$default"); - else + { + firste = print_token (&eout, true, "$default"); + defaulted = true; + } + if (reds->lookahead_tokens) { int i; for (i = 0; i < ntokens; i++) if (bitset_test (reds->lookahead_tokens[j], i)) { - first = print_token (&oout, first, symbols[i]->tag); if (bitset_test (no_reduce_set, i)) - disabled = true; + firstd = print_token (&dout, firstd, symbols[i]->tag); + else + { + if (! defaulted) + firste = print_token (&eout, firste, symbols[i]->tag); + bitset_set (no_reduce_set, i); + } } } - obstack_sgrow (&oout, "\" style=solid]\n"); - /* Then, print the reduction's representation. Done later since - we need to know whether this reduction is disabled. */ - obstack_printf (&oout, - " \"%dR%d\" " - "[style=filled shape=diamond fillcolor=%s " - "label=\"R%d\"]\n", - source, ruleno, - disabled ? "firebrick1" : "yellowgreen", - ruleno); - - /* If no lookahead tokens were valid transitions, this reduction is - actually disabled, so don't print it. */ - if (first) - (void) obstack_finish0 (&oout); - else - fprintf (fout, obstack_finish0 (&oout)); + /* Do the actual output. */ + conclude_red (&eout, source, ruleno, true, firste, fout); + conclude_red (&dout, source, ruleno, false, firstd, fout); } - obstack_free (&oout, 0); + obstack_free (&eout, 0); + obstack_free (&dout, 0); } void From 8048226f50f62fb64044625bf0ebbdc403a6776e Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Thu, 18 Oct 2012 15:38:30 +0000 Subject: [PATCH 03/46] graphs: style changes * src/graphviz.c (start_graph): Use courier font. (conclude_red): Use commas to separate attributes. Show the acceptation as a special reduction, with a blue color and an "Acc" label. Show the lookahead tokens between square brackets. (output_red): No longer label default reductions. * src/print_graph.c (print_core): Refactor spacing, and print an additional space between a rule's rhs and its lookahead tokens. Also, capitalize "State". (print_actions): Style, move a declaration. Signed-off-by: Akim Demaille --- src/graphviz.c | 68 ++++++++++++++++++++++++++++------------------- src/print_graph.c | 14 +++++----- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/graphviz.c b/src/graphviz.c index a7a42d60..3ae0b546 100644 --- a/src/graphviz.c +++ b/src/graphviz.c @@ -53,7 +53,10 @@ start_graph (FILE *fout) "digraph %s\n" "{\n", quote (grammar_file)); - fprintf (fout, "node [shape=box]\n"); + fprintf (fout, + " node [fontname = courier, shape = box, colorscheme = paired6]\n" + " edge [fontname = courier]\n" + "\n"); } void @@ -94,8 +97,8 @@ no_reduce_bitset_init (state const *s, bitset *no_reduce_set) } static void -conclude_red (struct obstack *out, int source, int ruleno, bool enabled, - bool first, FILE *fout) +conclude_red (struct obstack *out, int source, rule_number ruleno, + bool enabled, bool first, FILE *fout) { /* If no lookahead tokens were valid transitions, this reduction is actually hidden, so cancel everything. */ @@ -104,26 +107,33 @@ conclude_red (struct obstack *out, int source, int ruleno, bool enabled, else { char const *ed = enabled ? "e" : "d"; + char const *color = enabled ? ruleno ? "3" : "1" : "5"; - /* First, build the edge's head. */ - if (! first) - fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [label = \"", - source, ruleno, ed); + /* First, build the edge's head. The name of reduction nodes is "nRm", + with n the source state and m the rule number. This is because we + don't want all the reductions bearing a same rule number to point to + the same state, since that is not the desired format. */ + fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [", + source, ruleno, ed); - /* (The lookahead tokens have been added to the beginning of the - obstack, in the caller function.) */ + if (! obstack_empty_p (out)) + /* (The lookahead tokens have been added to the beginning of the + obstack, in the caller function.) */ + fprintf (fout, "label = \"[%s]\" ", obstack_finish0 (out)); /* Then, the edge's tail. */ - obstack_sgrow (out, "\" style = solid]\n"); + fprintf (fout, "style = solid]\n"); + + /* Build the associated diamond representation of the target rule. */ + fprintf (fout, " \"%dR%d%s\" [style = filled, " + "shape = diamond, fillcolor = %s, ", + source, ruleno, ed, color); + + if (ruleno) + fprintf (fout, "label = \"R%d\"]\n", ruleno); + else + fprintf (fout, "label = \"Acc\"]\n"); - /* Build the associated diamond representation or the target rule. */ - obstack_printf (out, " \"%dR%d%s\" " - "[style = filled shape = diamond fillcolor = %s " - "label = \"R%d\"]\n", - source, ruleno, ed, - enabled ? "yellowgreen" : "firebrick1", - ruleno); - fprintf (fout, obstack_finish0 (out)); } } @@ -133,7 +143,7 @@ print_token (struct obstack *out, bool first, char const *tok) char const *q = escape (tok); if (! first) - obstack_sgrow (out, ","); + obstack_sgrow (out, ", "); obstack_sgrow (out, q); return false; } @@ -144,7 +154,13 @@ output_red (state const *s, reductions const *reds, FILE *fout) bitset no_reduce_set; int j; int source = s->number; - struct obstack dout, eout; + + /* Two obstacks are needed: one for the enabled reductions, and one + for the disabled reductions, because in the end we want two + separate edges, even though in most cases only one will actually + be printed. */ + struct obstack dout; + struct obstack eout; no_reduce_bitset_init (s, &no_reduce_set); obstack_init (&dout); @@ -153,8 +169,9 @@ output_red (state const *s, reductions const *reds, FILE *fout) for (j = 0; j < reds->num; ++j) { bool defaulted = false; - bool firstd = true, firste = true; // first{en,dis}abled - int ruleno = reds->rules[j]->user_number; + bool firstd = true; + bool firste = true; + rule_number ruleno = reds->rules[j]->user_number; rule *default_reduction = NULL; if (yydefact[s->number] != 0) @@ -163,10 +180,7 @@ output_red (state const *s, reductions const *reds, FILE *fout) /* Build the lookahead tokens lists, one for enabled transitions and one for disabled transistions. */ if (default_reduction && default_reduction == reds->rules[j]) - { - firste = print_token (&eout, true, "$default"); - defaulted = true; - } + defaulted = true; if (reds->lookahead_tokens) { int i; @@ -185,7 +199,7 @@ output_red (state const *s, reductions const *reds, FILE *fout) } /* Do the actual output. */ - conclude_red (&eout, source, ruleno, true, firste, fout); + conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout); conclude_red (&dout, source, ruleno, false, firstd, fout); } obstack_free (&eout, 0); diff --git a/src/print_graph.c b/src/print_graph.c index b9021014..61aa1e3c 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -55,7 +55,8 @@ print_core (struct obstack *oout, state *s) snritems = nitemset; } - obstack_printf (oout, "state %d\\n", s->number); + obstack_printf (oout, _("State %d"), s->number); + obstack_sgrow (oout, "\\n"); for (i = 0; i < snritems; i++) { item_number *sp; @@ -69,12 +70,12 @@ print_core (struct obstack *oout, state *s) r = item_number_as_rule_number (*sp); - obstack_printf (oout, "%d: %s -> ", r, escape (rules[r].lhs->tag)); + obstack_printf (oout, "%d: %s ->", r, escape (rules[r].lhs->tag)); for (sp = rules[r].rhs; sp < sp1; sp++) - obstack_printf (oout, "%s ", escape (symbols[*sp]->tag)); + obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); - obstack_1grow (oout, '.'); + obstack_sgrow (oout, " ."); for (/* Nothing */; *sp >= 0; ++sp) obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); @@ -93,7 +94,7 @@ print_core (struct obstack *oout, state *s) bitset_iterator biter; int k; char const *sep = ""; - obstack_1grow (oout, '['); + obstack_sgrow (oout, " ["); BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0) { obstack_sgrow (oout, sep); @@ -116,9 +117,8 @@ print_core (struct obstack *oout, state *s) static void print_actions (state const *s, FILE *fgraph) { - int i; - transitions const *trans = s->transitions; + int i; /* Display reductions. */ output_red (s, s->reductions, fgraph); From ce6cf10f73b2eabdb460ade6e4813254459f442a Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Thu, 18 Oct 2012 15:38:31 +0000 Subject: [PATCH 04/46] graphs: change the output format of the rules Use something similar to the report file. * src/print_graph.c (print_lhs): New, obstack equivalent of rule_lhs_print. (print_core): Use here. Signed-off-by: Akim Demaille --- src/print_graph.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/print_graph.c b/src/print_graph.c index 61aa1e3c..d5ec5fb4 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -40,11 +40,32 @@ | Construct the node labels. | `----------------------------*/ +/* Print the lhs of a rule in such a manner that there is no vertical + repetition, like in *.output files. */ + +static void +print_lhs (struct obstack *oout, rule *previous_rule, rule *r) +{ + if (previous_rule && STREQ (previous_rule->lhs->tag, r->lhs->tag)) + { + int i; + for (i = 0; i < strlen (r->lhs->tag); ++i) + obstack_1grow (oout, ' '); + obstack_1grow (oout, '|'); + } + else + { + obstack_sgrow (oout, escape (r->lhs->tag)); + obstack_1grow (oout, ':'); + } +} + static void print_core (struct obstack *oout, state *s) { - size_t i; item_number *sitems = s->items; + rule *previous_rule = NULL; + size_t i; size_t snritems = s->nitems; /* Output all the items of a state, not only its kernel. */ @@ -70,7 +91,9 @@ print_core (struct obstack *oout, state *s) r = item_number_as_rule_number (*sp); - obstack_printf (oout, "%d: %s ->", r, escape (rules[r].lhs->tag)); + obstack_printf (oout, "%3d ", r); + print_lhs (oout, previous_rule, &rules[r]); + previous_rule = &rules[r]; for (sp = rules[r].rhs; sp < sp1; sp++) obstack_printf (oout, " %s", escape (symbols[*sp]->tag)); From dd47b5220cb0346e3dd8d873f09b606733adf836 Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Thu, 18 Oct 2012 15:38:33 +0000 Subject: [PATCH 05/46] graphs: add tests, introducing -k graph * tests/output.at (AT_TEST): New. Use it to add 6 --graph tests. Signed-off-by: Akim Demaille --- tests/output.at | 365 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 365 insertions(+) diff --git a/tests/output.at b/tests/output.at index 9f1bd115..37d2c3da 100644 --- a/tests/output.at +++ b/tests/output.at @@ -231,3 +231,368 @@ AT_CHECK_OUTPUT_FILE_NAME([[@{]]) AT_CHECK_OUTPUT_FILE_NAME([[@}]]) AT_CHECK_OUTPUT_FILE_NAME([[@<:@]]) AT_CHECK_OUTPUT_FILE_NAME([[@:>@]]) + + +# AT_TEST(SETUP-NAME, GRAMMAR, DOT-BODY) +# -------------------------------------- +# Check that the DOT graph for GRAMMAR is DOT-BODY. +m4_pushdef([AT_TEST], +[AT_SETUP([$1]) +AT_KEYWORDS([[graph]]) +AT_DATA([[input.y]], [$2]) +AT_BISON_CHECK([[-rall --graph input.y]], [0], [[]], [[ignore]]) +AT_CHECK([[grep -v // input.dot]], [0], +[[ +digraph "input.y" +{ + node [fontname = courier, shape = box, colorscheme = paired6] + edge [fontname = courier] + ]$3[} +]]) +AT_CLEANUP +]) + + +## ------------------------ ## +## Graph with no conflicts. ## +## ------------------------ ## + +AT_TEST([Graph with no conflicts], +[[%% +exp: a '?' b; +a: ; +b: 'b'; +]], +[[ + 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"] + 0 -> "0R2e" [style = solid] + "0R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 0 -> 1 [style=dashed label="exp"] + 0 -> 2 [style=dashed label="a"] + 1 [label="State 1\n 0 $accept: exp . $end\l"] + 1 -> 3 [style=solid label="$end"] + 2 [label="State 2\n 1 exp: a . '?' b\l"] + 2 -> 4 [style=solid label="'?'"] + 3 [label="State 3\n 0 $accept: exp $end .\l"] + 3 -> "3R0e" [style = solid] + "3R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 4 [label="State 4\n 1 exp: a '?' . b\l 3 b: . 'b'\l"] + 4 -> 5 [style=solid label="'b'"] + 4 -> 6 [style=dashed label="b"] + 5 [label="State 5\n 3 b: 'b' .\l"] + 5 -> "5R3e" [style = solid] + "5R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 6 [label="State 6\n 1 exp: a '?' b .\l"] + 6 -> "6R1e" [style = solid] + "6R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] +]]) + +## ------------------------ ## +## Graph with unsolved S/R. ## +## ------------------------ ## + +AT_TEST([Graph with unsolved S/R], +[[%% +start: + 'a' + | empty_a 'a' + | 'b' + | empty_b 'b' + | 'c' + | empty_c 'c' + ; +empty_a: %prec 'a'; +empty_b: %prec 'b'; +empty_c: %prec 'c'; +]], +[[ + 0 [label="State 0\n 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"] + 0 -> "0R7d" [label = "['a']" style = solid] + "0R7d" [style = filled, shape = diamond, fillcolor = 5, label = "R7"] + 0 -> "0R8d" [label = "['b']" style = solid] + "0R8d" [style = filled, shape = diamond, fillcolor = 5, label = "R8"] + 0 -> "0R9d" [label = "['c']" style = solid] + "0R9d" [style = filled, shape = diamond, fillcolor = 5, label = "R9"] + 0 -> 1 [style=solid label="'a'"] + 0 -> 2 [style=solid label="'b'"] + 0 -> 3 [style=solid label="'c'"] + 0 -> 4 [style=dashed label="start"] + 0 -> 5 [style=dashed label="empty_a"] + 0 -> 6 [style=dashed label="empty_b"] + 0 -> 7 [style=dashed label="empty_c"] + 1 [label="State 1\n 1 start: 'a' .\l"] + 1 -> "1R1e" [style = solid] + "1R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] + 2 [label="State 2\n 3 start: 'b' .\l"] + 2 -> "2R3e" [style = solid] + "2R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 3 [label="State 3\n 5 start: 'c' .\l"] + 3 -> "3R5e" [style = solid] + "3R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] + 4 [label="State 4\n 0 $accept: start . $end\l"] + 4 -> 8 [style=solid label="$end"] + 5 [label="State 5\n 2 start: empty_a . 'a'\l"] + 5 -> 9 [style=solid label="'a'"] + 6 [label="State 6\n 4 start: empty_b . 'b'\l"] + 6 -> 10 [style=solid label="'b'"] + 7 [label="State 7\n 6 start: empty_c . 'c'\l"] + 7 -> 11 [style=solid label="'c'"] + 8 [label="State 8\n 0 $accept: start $end .\l"] + 8 -> "8R0e" [style = solid] + "8R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 9 [label="State 9\n 2 start: empty_a 'a' .\l"] + 9 -> "9R2e" [style = solid] + "9R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 10 [label="State 10\n 4 start: empty_b 'b' .\l"] + 10 -> "10R4e" [style = solid] + "10R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] + 11 [label="State 11\n 6 start: empty_c 'c' .\l"] + 11 -> "11R6e" [style = solid] + "11R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] +]]) + +## ---------------------- ## +## Graph with solved S/R. ## +## ---------------------- ## + +AT_TEST([Graph with solved S/R], +[[%left 'a' +%right 'b' +%right 'c' +%% +start: + 'a' + | empty_a 'a' + | 'b' + | empty_b 'b' + | 'c' + | empty_c 'c' + ; +empty_a: %prec 'a'; +empty_b: %prec 'b'; +empty_c: %prec 'c'; +]], +[[ + 0 [label="State 0\n 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"] + 0 -> "0R7e" [style = solid] + "0R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] + 0 -> 1 [style=solid label="'b'"] + 0 -> 2 [style=solid label="'c'"] + 0 -> 3 [style=dashed label="start"] + 0 -> 4 [style=dashed label="empty_a"] + 0 -> 5 [style=dashed label="empty_b"] + 0 -> 6 [style=dashed label="empty_c"] + 1 [label="State 1\n 3 start: 'b' .\l"] + 1 -> "1R3e" [style = solid] + "1R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 2 [label="State 2\n 5 start: 'c' .\l"] + 2 -> "2R5e" [style = solid] + "2R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] + 3 [label="State 3\n 0 $accept: start . $end\l"] + 3 -> 7 [style=solid label="$end"] + 4 [label="State 4\n 2 start: empty_a . 'a'\l"] + 4 -> 8 [style=solid label="'a'"] + 5 [label="State 5\n 4 start: empty_b . 'b'\l"] + 5 -> 9 [style=solid label="'b'"] + 6 [label="State 6\n 6 start: empty_c . 'c'\l"] + 6 -> 10 [style=solid label="'c'"] + 7 [label="State 7\n 0 $accept: start $end .\l"] + 7 -> "7R0e" [style = solid] + "7R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 8 [label="State 8\n 2 start: empty_a 'a' .\l"] + 8 -> "8R2e" [style = solid] + "8R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 9 [label="State 9\n 4 start: empty_b 'b' .\l"] + 9 -> "9R4e" [style = solid] + "9R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] + 10 [label="State 10\n 6 start: empty_c 'c' .\l"] + 10 -> "10R6e" [style = solid] + "10R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] +]]) + +## ---------------- ## +## Graph with R/R. ## +## ---------------- ## + +AT_TEST([Graph with R/R], +[[%% +exp: a | b; +a: ; +b: ; +]], +[[ + 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"] + 0 -> "0R3e" [style = solid] + "0R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 0 -> "0R4d" [label = "[$end]" style = solid] + "0R4d" [style = filled, shape = diamond, fillcolor = 5, label = "R4"] + 0 -> 1 [style=dashed label="exp"] + 0 -> 2 [style=dashed label="a"] + 0 -> 3 [style=dashed label="b"] + 1 [label="State 1\n 0 $accept: exp . $end\l"] + 1 -> 4 [style=solid label="$end"] + 2 [label="State 2\n 1 exp: a .\l"] + 2 -> "2R1e" [style = solid] + "2R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] + 3 [label="State 3\n 2 exp: b .\l"] + 3 -> "3R2e" [style = solid] + "3R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 4 [label="State 4\n 0 $accept: exp $end .\l"] + 4 -> "4R0e" [style = solid] + "4R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] +]]) + +## ---------------------------------------- ## +## Graph with reductions with multiple LAT. ## +## ---------------------------------------- ## + +AT_TEST([Graph with reductions with multiple LAT], +[[%% +exp: a ';' | a ';' | a '.' | b '?' | b '!' | c '?' | c ';'; +a: ; +b: ; +c: ; +]], +[[ + 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"] + 0 -> "0R8e" [style = solid] + "0R8e" [style = filled, shape = diamond, fillcolor = 3, label = "R8"] + 0 -> "0R9e" [label = "['?', '!']" style = solid] + "0R9e" [style = filled, shape = diamond, fillcolor = 3, label = "R9"] + 0 -> "0R10d" [label = "[';', '?']" style = solid] + "0R10d" [style = filled, shape = diamond, fillcolor = 5, label = "R10"] + 0 -> 1 [style=dashed label="exp"] + 0 -> 2 [style=dashed label="a"] + 0 -> 3 [style=dashed label="b"] + 0 -> 4 [style=dashed label="c"] + 1 [label="State 1\n 0 $accept: exp . $end\l"] + 1 -> 5 [style=solid label="$end"] + 2 [label="State 2\n 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"] + 2 -> 6 [style=solid label="';'"] + 2 -> 7 [style=solid label="'.'"] + 3 [label="State 3\n 4 exp: b . '?'\l 5 | b . '!'\l"] + 3 -> 8 [style=solid label="'?'"] + 3 -> 9 [style=solid label="'!'"] + 4 [label="State 4\n 6 exp: c . '?'\l 7 | c . ';'\l"] + 4 -> 10 [style=solid label="';'"] + 4 -> 11 [style=solid label="'?'"] + 5 [label="State 5\n 0 $accept: exp $end .\l"] + 5 -> "5R0e" [style = solid] + "5R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 6 [label="State 6\n 1 exp: a ';' . [$end]\l 2 | a ';' . [$end]\l"] + 6 -> "6R1e" [style = solid] + "6R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] + 6 -> "6R2d" [label = "[$end]" style = solid] + "6R2d" [style = filled, shape = diamond, fillcolor = 5, label = "R2"] + 7 [label="State 7\n 3 exp: a '.' .\l"] + 7 -> "7R3e" [style = solid] + "7R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 8 [label="State 8\n 4 exp: b '?' .\l"] + 8 -> "8R4e" [style = solid] + "8R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] + 9 [label="State 9\n 5 exp: b '!' .\l"] + 9 -> "9R5e" [style = solid] + "9R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] + 10 [label="State 10\n 7 exp: c ';' .\l"] + 10 -> "10R7e" [style = solid] + "10R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] + 11 [label="State 11\n 6 exp: c '?' .\l"] + 11 -> "11R6e" [style = solid] + "11R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] +]]) + +## ------------------------------------------------------ ## +## Graph with a reduction rule both enabled and disabled. ## +## ------------------------------------------------------ ## + +AT_TEST([Graph with a reduction rule both enabled and disabled], +[[%% +exp: ifexp | opexp | imm; +ifexp: "if" exp "then" exp elseexp; +elseexp: "else" exp | ; +opexp: exp '+' exp; +imm: '0'; +]], +[[ + 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 0 -> 1 [style=solid label="\"if\""] + 0 -> 2 [style=solid label="'0'"] + 0 -> 3 [style=dashed label="exp"] + 0 -> 4 [style=dashed label="ifexp"] + 0 -> 5 [style=dashed label="opexp"] + 0 -> 6 [style=dashed label="imm"] + 1 [label="State 1\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" . exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 1 -> 1 [style=solid label="\"if\""] + 1 -> 2 [style=solid label="'0'"] + 1 -> 7 [style=dashed label="exp"] + 1 -> 4 [style=dashed label="ifexp"] + 1 -> 5 [style=dashed label="opexp"] + 1 -> 6 [style=dashed label="imm"] + 2 [label="State 2\n 8 imm: '0' .\l"] + 2 -> "2R8e" [style = solid] + "2R8e" [style = filled, shape = diamond, fillcolor = 3, label = "R8"] + 3 [label="State 3\n 0 $accept: exp . $end\l 7 opexp: exp . '+' exp\l"] + 3 -> 8 [style=solid label="$end"] + 3 -> 9 [style=solid label="'+'"] + 4 [label="State 4\n 1 exp: ifexp .\l"] + 4 -> "4R1e" [style = solid] + "4R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] + 5 [label="State 5\n 2 exp: opexp .\l"] + 5 -> "5R2e" [style = solid] + "5R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 6 [label="State 6\n 3 exp: imm .\l"] + 6 -> "6R3e" [style = solid] + "6R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] + 7 [label="State 7\n 4 ifexp: \"if\" exp . \"then\" exp elseexp\l 7 opexp: exp . '+' exp\l"] + 7 -> 10 [style=solid label="\"then\""] + 7 -> 9 [style=solid label="'+'"] + 8 [label="State 8\n 0 $accept: exp $end .\l"] + 8 -> "8R0e" [style = solid] + "8R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 9 [label="State 9\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 7 | exp '+' . exp\l 8 imm: . '0'\l"] + 9 -> 1 [style=solid label="\"if\""] + 9 -> 2 [style=solid label="'0'"] + 9 -> 11 [style=dashed label="exp"] + 9 -> 4 [style=dashed label="ifexp"] + 9 -> 5 [style=dashed label="opexp"] + 9 -> 6 [style=dashed label="imm"] + 10 [label="State 10\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" exp \"then\" . exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 10 -> 1 [style=solid label="\"if\""] + 10 -> 2 [style=solid label="'0'"] + 10 -> 12 [style=dashed label="exp"] + 10 -> 4 [style=dashed label="ifexp"] + 10 -> 5 [style=dashed label="opexp"] + 10 -> 6 [style=dashed label="imm"] + 11 [label="State 11\n 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"] + 11 -> "11R7e" [style = solid] + "11R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] + 11 -> "11R7d" [label = "['+']" style = solid] + "11R7d" [style = filled, shape = diamond, fillcolor = 5, label = "R7"] + 11 -> 9 [style=solid label="'+'"] + 12 [label="State 12\n 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] + 12 -> "12R6e" [style = solid] + "12R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] + 12 -> "12R6d" [label = "[\"else\", '+']" style = solid] + "12R6d" [style = filled, shape = diamond, fillcolor = 5, label = "R6"] + 12 -> 13 [style=solid label="\"else\""] + 12 -> 9 [style=solid label="'+'"] + 12 -> 14 [style=dashed label="elseexp"] + 13 [label="State 13\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 5 elseexp: \"else\" . exp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 13 -> 1 [style=solid label="\"if\""] + 13 -> 2 [style=solid label="'0'"] + 13 -> 15 [style=dashed label="exp"] + 13 -> 4 [style=dashed label="ifexp"] + 13 -> 5 [style=dashed label="opexp"] + 13 -> 6 [style=dashed label="imm"] + 14 [label="State 14\n 4 ifexp: \"if\" exp \"then\" exp elseexp .\l"] + 14 -> "14R4e" [style = solid] + "14R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] + 15 [label="State 15\n 5 elseexp: \"else\" exp . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] + 15 -> "15R5e" [style = solid] + "15R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] + 15 -> "15R5d" [label = "['+']" style = solid] + "15R5d" [style = filled, shape = diamond, fillcolor = 5, label = "R5"] + 15 -> 9 [style=solid label="'+'"] +]]) + +m4_popdef([AT_TEST]) From fc4fdd623e7613c002f7c7d6cb73b4ab4bb5b494 Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Thu, 18 Oct 2012 15:38:32 +0000 Subject: [PATCH 06/46] graphs: documentation Note that 'make web-manual' fails. * NEWS: Document these changes. * doc/Makefile.am: Adjust to generate example files. * doc/bison.texi: Add a Graphviz section after "Understanding::", the section describing the .output file, because these are similar. * doc/figs/example-reduce.dot, doc/figs/example-reduce.txt, doc/figs/example-shift.dot, doc/figs/example-shift.txt: New, minimal examples to illustrate the documentation. Signed-off-by: Akim Demaille --- NEWS | 9 +++ TODO | 13 +++++ doc/Makefile.am | 27 +++++++++ doc/bison.texi | 110 ++++++++++++++++++++++++++++++++++++ doc/figs/example-reduce.dot | 11 ++++ doc/figs/example-reduce.txt | 15 +++++ doc/figs/example-shift.dot | 9 +++ doc/figs/example-shift.txt | 12 ++++ 8 files changed, 206 insertions(+) create mode 100644 doc/figs/example-reduce.dot create mode 100644 doc/figs/example-reduce.txt create mode 100644 doc/figs/example-shift.dot create mode 100644 doc/figs/example-shift.txt diff --git a/NEWS b/NEWS index 9476819e..d1b66564 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,15 @@ GNU Bison NEWS position_type are deprecated in favor of api.location.type and api.position.type. +** Graphviz improvements + + The graphical presentation of the states is more readable: their shape is + now rectangular, the state number is clearly displayed, and the items are + numbered and left-justified. + + The reductions are now explicitly represented as transitions to other + diamond shaped nodes. + * Noteworthy changes in release 2.6.2 (2012-08-03) [stable] ** Bug fixes diff --git a/TODO b/TODO index 4f628a20..978b5c6f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,17 @@ * Short term +** Graphviz display code thoughts +The code for the --graph option is over two files: print_graph, and +graphviz. I believe this is because Bison used to also produce VCG graphs, +but since this is no longer true, maybe we could consider these files for +fusion. + +Little effort factoring seems to have been given to factoring in these files, +and their print-xml and print counterpart. We would very much like to re-use +the pretty format of states from .output in the .dot + +Also, the underscore in print_graph.[ch] isn't very fitting considering +the dashes in the other filenames. + ** Variable names. What should we name `variant' and `lex_symbol'? diff --git a/doc/Makefile.am b/doc/Makefile.am index f695e22d..9c650bf3 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -96,6 +96,33 @@ PREPATH = $(top_builddir)/src nodist_man_MANS = yacc.1 +## ----------------------------- ## +## Graphviz examples generation. ## +## ----------------------------- ## + +CLEANDIRS += figs +EXTRA_DIST += figs/example-reduce.dot figs/example-shift.dot +SUFFIXES += .dot .eps .pdf .png + +bison.dvi: figs/example-reduce.eps figs/example-shift.eps +bison.html: figs/example-reduce.png figs/example-shift.png +bison.pdf: figs/example-reduce.pdf figs/example-shift.pdf + +.dot.eps: + $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` + $(AM_V_at) dot -Teps $< >$@.tmp + $(AM_V_at) mv $@.tmp $@ + +.dot.pdf: + $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` + $(AM_V_at) dot -Tpdf -Gmargin=0 $< >$@.tmp + $(AM_V_at) mv $@.tmp $@ + +.dot.png: + $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` + $(AM_V_at) dot -Tpng $< >$@.tmp + $(AM_V_at) mv $@.tmp $@ + ## -------------- ## ## Doxygenation. ## ## -------------- ## diff --git a/doc/bison.texi b/doc/bison.texi index 8e8e9bb6..4cca4636 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -294,6 +294,7 @@ Handling Context Dependencies Debugging Your Parser * Understanding:: Understanding the structure of your parser. +* Graphviz:: Getting a visual representation of the parser. * Tracing:: Tracing the execution of your parser. Tracing Your Parser @@ -8093,6 +8094,7 @@ automaton, and how to enable and understand the parser run-time traces. @menu * Understanding:: Understanding the structure of your parser. +* Graphviz:: Getting a visual representation of the parser. * Tracing:: Tracing the execution of your parser. @end menu @@ -8509,6 +8511,114 @@ precedence of @samp{/} with respect to @samp{+}, @samp{-}, and @samp{*}, but also because the associativity of @samp{/} is not specified. +@c ================================================= Graphical Representation + +@node Graphviz +@section Visualizing Your Parser +@cindex dot + +As another means to gain better understanding of the shift/reduce +automaton corresponding to the Bison parser, a DOT file can be generated. Note +that debugging a real grammar with this is tedious at best, and impractical +most of the times, because the generated files are huge (the generation of +a PDF or PNG file from it will take very long, and more often than not it will +fail due to memory exhaustion). This option was rather designed for beginners, +to help them understand LR parsers. + +This file is generated when the @option{--graph} option is specified (see +@pxref{Invocation, , Invoking Bison}). Its name is made by removing +@samp{.tab.c} or @samp{.c} from the parser implementation file name, and +adding @samp{.dot} instead. If the grammar file is @file{foo.y}, the +Graphviz output file is called @file{foo.dot}. + +The following grammar file, @file{rr.y}, will be used in the sequel: + +@example +%% +@group +exp: a ";" | b "."; +a: "0"; +b: "0"; +@end group +@end example + +The graphical output is very similar to the textual one, and as such it is +easier understood by making direct comparisons between them. See +@ref{Debugging, , Debugging Your Parser} for a detailled analysis of the +textual report. + +@subheading Graphical Representation of States + +The items (pointed rules) for each state are grouped together in graph nodes. +Their numbering is the same as in the verbose file. See the following points, +about transitions, for examples + +When invoked with @option{--report=lookaheads}, the lookahead tokens, when +needed, are shown next to the relevant rule between square brackets as a +comma separated list. This is the case in the figure for the representation of +reductions, below. + +@sp 1 + +The transitions are represented as directed edges between the current and +the target states. + +@subheading Graphical Representation of Shifts + +Shifts are shown as solid arrows, labelled with the lookahead token for that +shift. The following describes a reduction in the @file{rr.output} file: + +@example +@group +state 3 + + 1 exp: a . ";" + + ";" shift, and go to state 6 +@end group +@end example + +A Graphviz rendering of this portion of the graph could be: + +@center @image{figs/example-shift, 100pt} + +@subheading Graphical Representation of Reductions + +Reductions are shown as solid arrows, leading to a diamond-shaped node +bearing the number of the reduction rule. The arrow is labelled with the +appropriate comma separated lookahead tokens. If the reduction is the default +action for the given state, there is no such label. + +This is how reductions are represented in the verbose file @file{rr.output}: +@example +state 1 + + 3 a: "0" . [";"] + 4 b: "0" . ["."] + + "." reduce using rule 4 (b) + $default reduce using rule 3 (a) +@end example + +A Graphviz rendering of this portion of the graph could be: + +@center @image{figs/example-reduce, 120pt} + +When unresolved conflicts are present, because in deterministic parsing +a single decision can be made, Bison can arbitrarily choose to disable a +reduction, see @ref{Shift/Reduce, , Shift/Reduce Conflicts}. Discarded actions +are distinguished by a red filling color on these nodes, just like how they are +reported between square brackets in the verbose file. + +The reduction corresponding to the rule number 0 is the acceptation state. It +is shown as a blue diamond, labelled "Acc". + +@subheading Graphical representation of go tos + +The @samp{go to} jump transitions are represented as dotted lines bearing +the name of the rule being jumped to. + +@c ================================================= Tracing @node Tracing @section Tracing Your Parser diff --git a/doc/figs/example-reduce.dot b/doc/figs/example-reduce.dot new file mode 100644 index 00000000..fdd99c5d --- /dev/null +++ b/doc/figs/example-reduce.dot @@ -0,0 +1,11 @@ +digraph "reduce.y" +{ + node [fontname=courier shape=box] + edge [fontname=courier] + + 1 [label="State 1\n 3 a: \"0\" . [\".\"]\l 4 b: \"0\" . [\";\"]\l"] + 1 -> "1R3" [label="" style=solid] + "1R3" [style=filled shape=diamond fillcolor=yellowgreen label="R3"] + 1 -> "1R4" [label="[\";\"]" style=solid] + "1R4" [style=filled shape=diamond fillcolor=yellowgreen label="R4"] +} diff --git a/doc/figs/example-reduce.txt b/doc/figs/example-reduce.txt new file mode 100644 index 00000000..19df1564 --- /dev/null +++ b/doc/figs/example-reduce.txt @@ -0,0 +1,15 @@ + .------------------. + | State 1 | + | 3 a: "0" . [";"] | + | 4 b: "0" . ["."] | + `------------------' + / \ + / \ ["."] + / \ + v v + . . + / \ / \ + / R \ / R \ +(green) \ 3 / \ 4 / (green) + \ / \ / + . . diff --git a/doc/figs/example-shift.dot b/doc/figs/example-shift.dot new file mode 100644 index 00000000..995ba0e4 --- /dev/null +++ b/doc/figs/example-shift.dot @@ -0,0 +1,9 @@ +digraph "shift.y" +{ + node [fontname=courier shape=box] + edge [fontname=courier] + + 3 [label="State 3\n 1 exp: a . \".\"\l"] + 3 -> 6 [style=solid label="\".\""] + 6 [label="State 6\n 1 exp: a \".\" .\l"] +} diff --git a/doc/figs/example-shift.txt b/doc/figs/example-shift.txt new file mode 100644 index 00000000..43b14122 --- /dev/null +++ b/doc/figs/example-shift.txt @@ -0,0 +1,12 @@ +.----------------. +| State 3 | +| 1 exp: a . ";" | +`----------------' + | + | ";" + | + v +.----------------. +| State 6 | +| 1 exp: a ";" . | +`----------------' From a029e56f5cf707378aa48cd783001d814dda6c9d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 19 Oct 2012 11:28:01 +0200 Subject: [PATCH 07/46] maint: check for dot before using it * configure.ac: here. * doc/Makefile.am: Use $(DOT). Ship the generated files, to spare the user the need for Graphviz. --- README-hacking | 25 +++++++++++++------------ configure.ac | 1 + doc/Makefile.am | 17 ++++++++++------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README-hacking b/README-hacking index 26391e98..11b9f82a 100644 --- a/README-hacking +++ b/README-hacking @@ -43,16 +43,17 @@ These requirements do not apply when building from a distribution tarball. ** Requirements -We've opted to keep only the highest-level sources in the repository. -This eases our maintenance burden, (fewer merges etc.), but imposes more +We've opted to keep only the highest-level sources in the repository. This +eases our maintenance burden, (fewer merges etc.), but imposes more requirements on anyone wishing to build from the just-checked-out sources. For example, you have to use the latest stable versions of the maintainer tools we depend upon, including: -- Automake - Autoconf +- Automake - Flex - Gettext +- Graphviz - Gzip - Perl - Rsync @@ -61,16 +62,16 @@ tools we depend upon, including: Valgrind is also highly recommended, if it supports your architecture. -Bison is written using Bison grammars, so there are bootstrapping -issues. The bootstrap script attempts to discover when the C code -generated from the grammars is out of date, and to bootstrap with an -out-of-date version of the C code, but the process is not foolproof. -Also, you may run into similar problems yourself if you modify Bison. +Bison is written using Bison grammars, so there are bootstrapping issues. +The bootstrap script attempts to discover when the C code generated from the +grammars is out of date, and to bootstrap with an out-of-date version of the +C code, but the process is not foolproof. Also, you may run into similar +problems yourself if you modify Bison. -Only building the initial full source tree will be a bit painful. -Later, after synchronizing from the repository a plain 'make' should -be sufficient. Note, however, that when gnulib is updated, running -'./bootstrap' again might be needed. +Only building the initial full source tree will be a bit painful. Later, +after synchronizing from the repository a plain 'make' should be sufficient. +Note, however, that when gnulib is updated, running './bootstrap' again +might be needed. ** First checkout diff --git a/configure.ac b/configure.ac index 4cc9ef91..6a0e9c45 100644 --- a/configure.ac +++ b/configure.ac @@ -115,6 +115,7 @@ AC_SUBST([YACC_SCRIPT]) AC_SUBST([YACC_LIBRARY]) # Checks for programs. +AM_MISSING_PROG([DOT], [dot]) AC_PROG_LEX $LEX_IS_FLEX || AC_MSG_ERROR([Flex is required]) AC_PROG_YACC diff --git a/doc/Makefile.am b/doc/Makefile.am index 9c650bf3..9c9c24ca 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -101,26 +101,29 @@ nodist_man_MANS = yacc.1 ## ----------------------------- ## CLEANDIRS += figs -EXTRA_DIST += figs/example-reduce.dot figs/example-shift.dot +FIGS_DOT = figs/example-reduce.dot figs/example-shift.dot +EXTRA_DIST += \ + $(FIGS_DOT) \ + $(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png) SUFFIXES += .dot .eps .pdf .png -bison.dvi: figs/example-reduce.eps figs/example-shift.eps -bison.html: figs/example-reduce.png figs/example-shift.png -bison.pdf: figs/example-reduce.pdf figs/example-shift.pdf +bison.dvi: $(FIGS_DOT:.dot=.eps) +bison.html: $(FIGS_DOT:.dot=.png) +bison.pdf: $(FIGS_DOT:.dot=.pdf) .dot.eps: $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` - $(AM_V_at) dot -Teps $< >$@.tmp + $(AM_V_at) $(DOT) -Gmargin=0 -Teps $< >$@.tmp $(AM_V_at) mv $@.tmp $@ .dot.pdf: $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` - $(AM_V_at) dot -Tpdf -Gmargin=0 $< >$@.tmp + $(AM_V_at) $(DOT) -Gmargin=0 -Tpdf $< >$@.tmp $(AM_V_at) mv $@.tmp $@ .dot.png: $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` - $(AM_V_at) dot -Tpng $< >$@.tmp + $(AM_V_at) $(DOT) -Gmargin=0 -Tpng $< >$@.tmp $(AM_V_at) mv $@.tmp $@ ## -------------- ## From a8ad0481429ae03239cddc9ec31930b32de41830 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 19 Oct 2012 11:28:59 +0200 Subject: [PATCH 08/46] xml: slight improvement of the DOT output This was completely forgotten... Nothing about XML is actually documented... * data/xslt/xml2dot.xsl: Use boxes, and Courier font. --- data/xslt/xml2dot.xsl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/xslt/xml2dot.xsl b/data/xslt/xml2dot.xsl index 219faa2f..111613ce 100644 --- a/data/xslt/xml2dot.xsl +++ b/data/xslt/xml2dot.xsl @@ -55,7 +55,11 @@ - " { + { + node [fontname = courier, shape = box, colorscheme = paired6] + edge [fontname = courier] + + } From 73c2a97540abb81b508c0fc5f3fef46a1b3ee799 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 19 Oct 2012 11:36:18 +0200 Subject: [PATCH 09/46] gnulib: update --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index dcf27bef..d245e6dd 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit dcf27bef48c9800d5a2be8349226f73f1b8ff2e5 +Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f From 36cdaaac539f05decd282d6b36447a2804ff0374 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 28 Sep 2012 15:04:57 +0200 Subject: [PATCH 10/46] gnulib: update --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index 4430dd02..dcf27bef 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 4430dd023d6c2b7b63a87fa62dcc2360c5a34a12 +Subproject commit dcf27bef48c9800d5a2be8349226f73f1b8ff2e5 From 3746fc33c47a8c76232a49d7116a3fba8bfe44c5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 27 Sep 2012 09:42:57 +0200 Subject: [PATCH 11/46] minor changes. * NEWS: Word changes. * doc/bison.texi: Spell check. Fix minor issues. * tests/headers.at: Comment and formatting changes. --- doc/bison.texi | 13 +++++++------ tests/headers.at | 8 +++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index ad605054..b8a1aa6d 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -5076,7 +5076,7 @@ default location or at the location specified by @var{qualifier}. @deffn {Directive} %debug In the parser implementation file, define the macro @code{YYDEBUG} (or -@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}), see +@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}, see @ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is not already defined, so that the debugging facilities are compiled. @xref{Tracing, ,Tracing Your Parser}. @@ -8502,8 +8502,8 @@ Prologue}). If the @code{%define} variable @code{api.prefix} is used (@pxref{Multiple Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define api.prefix x}, then if @code{CDEBUG} is defined, its value controls the -tracing feature (enabled iff nonzero); otherwise tracing is enabled iff -@code{YYDEBUG} is nonzero. +tracing feature (enabled if and only if nonzero); otherwise tracing is +enabled if and only if @code{YYDEBUG} is nonzero. @item the option @option{-t} (POSIX Yacc compliant) @itemx the option @option{--debug} (Bison extension) @@ -11761,10 +11761,11 @@ London, Department of Computer Science, TR-00-12 (December 2000). @c LocalWords: toString deftypeivar deftypeivarx deftypeop YYParser strictfp @c LocalWords: superclasses boolean getErrorVerbose setErrorVerbose deftypecv @c LocalWords: getDebugStream setDebugStream getDebugLevel setDebugLevel url -@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos +@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos uint @c LocalWords: getLVal defvar deftypefn deftypefnx gotos msgfmt Corbett LALR's -@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy -@c LocalWords: Scannerless ispell american +@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy ints +@c LocalWords: Scannerless ispell american ChangeLog smallexample CSTYPE CLTYPE +@c LocalWords: clval CDEBUG cdebug deftypeopx yyterminate @c Local Variables: @c ispell-dictionary: "american" diff --git a/tests/headers.at b/tests/headers.at index cac7fe5f..aea0bc9b 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -126,8 +126,8 @@ AT_SETUP([Several parsers]) # AT_TEST([PREFIX], [DIRECTIVES]) # ------------------------------- -# Generate and compile to *.o. Make sure there is no YY* nor yy* in -# the header (but YYDEBUG and YYPARSE_PARAM). +# Generate and compile to *.o. Make sure there is no (allowed) YY* +# nor yy* identifiers in the header. m4_pushdef([AT_TEST], [AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2]) AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])], @@ -161,6 +161,8 @@ exp: ]]) AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])]) + +# Check there is no 'yy' left. # C++ output relies on namespaces and still uses yy a lot. AT_SKEL_CC_IF([], [AT_CHECK([$EGREP yy $1.h], [1])]) @@ -173,8 +175,8 @@ AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \ -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ | $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']], [1]) -AT_LANG_COMPILE([$1.o]) +AT_LANG_COMPILE([$1.o]) AT_CHECK([[echo "$1" >>expout]]) AT_BISON_OPTION_POPDEFS From 6192d2c6de859990f8e90c128de9733c1315db7a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 27 Sep 2012 09:43:49 +0200 Subject: [PATCH 12/46] headers: move CPP guards into YY_*_INCLUDED to avoid collisions See . * data/c.m4 (b4_cpp_guard): Prepend YY_ and append _INCLUDED. * tests/headers.at: Adjust. * NEWS, doc/bison.texi: Document. --- NEWS | 11 +++++++++++ data/c.m4 | 2 +- doc/bison.texi | 17 +++++++++++++++++ tests/headers.at | 7 ++++--- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 75a11bf0..090253d4 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,17 @@ GNU Bison NEWS Incorrect definitions of YY_, issued by yacc.c when no parser header is generated, are removed. +** Header guards (yacc.c, glr.c, glr.cc) + + In order to avoid collisions, the header guards are now + YY___INCLUDED, instead of merely _. + For instance the header generated from + + %define api.prefix "calc" + %defines "lib/parse.h" + + will use YY_CALC_LIB_PARSE_H_INCLUDED as guard. + * Noteworthy changes in release 2.6.2 (2012-08-03) [stable] ** Bug fixes diff --git a/data/c.m4 b/data/c.m4 index ccb4969e..fd2203eb 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -30,7 +30,7 @@ m4_define([b4_tocpp], # ------------------ # A valid C macro name to use as a CPP header guard for FILE. m4_define([b4_cpp_guard], -[b4_tocpp(m4_defn([b4_prefix])/[$1])]) +[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]]) # b4_cpp_guard_open(FILE) diff --git a/doc/bison.texi b/doc/bison.texi index b8a1aa6d..69836112 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -5124,6 +5124,23 @@ Values, ,Semantic Values of Tokens}. If you have declared @code{%code requires} or @code{%code provides}, the output header also contains their code. @xref{%code Summary}. + +@cindex Header guard +The generated header is protected against multiple inclusions with a C +preprocessor guard: @samp{YY_@var{PREFIX}_@var{FILE}_INCLUDED}, where +@var{PREFIX} and @var{FILE} are the prefix (@pxref{Multiple Parsers, +,Multiple Parsers in the Same Program}) and generated file name turned +uppercase, with each series of non alphanumerical characters converted to a +single underscore. + +For instance with @samp{%define api.prefix "calc"} and @samp{%defines +"lib/parse.h"}, the header will be guarded as follows. +@example +#ifndef YY_CALC_LIB_PARSE_H_INCLUDED +# define YY_CALC_LIB_PARSE_H_INCLUDED +... +#endif /* ! YY_CALC_LIB_PARSE_H_INCLUDED */ +@end example @end deffn @deffn {Directive} %defines @var{defines-file} diff --git a/tests/headers.at b/tests/headers.at index aea0bc9b..0524340e 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -167,13 +167,14 @@ AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])]) AT_SKEL_CC_IF([], [AT_CHECK([$EGREP yy $1.h], [1])]) -# Ignore comments. Ignore YYPARSE_PARAM (obsolete) and -# YYPUSH_MORE(_DEFINED)? (whose definition is constant). +# Check there is not 'YY' left. +# Ignore comments, YYPARSE_PARAM (obsolete), YYPUSH_MORE(_DEFINED)? +# (constant definition), YY_\w+_INCLUDED (header guards). # # YYDEBUG (not renamed) can be read, but not changed. AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \ -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ | - $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']], + $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?|_[0-9A-Z_]+_INCLUDED)|(defined|if) YYDEBUG']], [1]) AT_LANG_COMPILE([$1.o]) From c473e022d9865ba35101de1b9045458f9be45057 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 3 Oct 2012 08:43:10 +0200 Subject: [PATCH 13/46] doc: add missing documentation for --report * doc/bison.texi (Bison Options): Document --report's "solved", "all", and "none". --- doc/bison.texi | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index 69836112..ba18d9a9 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -9072,13 +9072,23 @@ separated list of @var{things} among: Description of the grammar, conflicts (resolved and unresolved), and parser's automaton. +@item itemset +Implies @code{state} and augments the description of the automaton with +the full set of items for each state, instead of its core only. + @item lookahead Implies @code{state} and augments the description of the automaton with each rule's lookahead set. -@item itemset -Implies @code{state} and augments the description of the automaton with -the full set of items for each state, instead of its core only. +@item solved +Implies @code{state}. Explain how conflicts were solved thanks to +precedence and associativity directives. + +@item all +Enable all the items. + +@item none +Do not generate the report. @end table @item --report-file=@var{file} From ddbd0c40dc1c2399d2a0c961d8ecf07c8a698024 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 3 Oct 2012 09:17:58 +0200 Subject: [PATCH 14/46] tests: check that headers are self contained Reported by Alexandre Duret-Lutz. * tests/headers.at (Several parsers): here. --- THANKS | 2 +- tests/headers.at | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 95acb1e2..170b0569 100644 --- a/THANKS +++ b/THANKS @@ -5,7 +5,7 @@ Airy Andre Airy.Andre@edf.fr Akim Demaille akim@freefriends.org Albert Chin-A-Young china@thewrittenword.com Alexander Belopolsky alexb@rentec.com -Alexandre Duret-Lutz adl@src.lip6.fr +Alexandre Duret-Lutz adl@lrde.epita.fr Andreas Schwab schwab@suse.de Andrew Suffield asuffield@users.sourceforge.net Angelo Borsotti angelo.borsotti@gmail.com diff --git a/tests/headers.at b/tests/headers.at index 0524340e..91fdb950 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -127,7 +127,8 @@ AT_SETUP([Several parsers]) # AT_TEST([PREFIX], [DIRECTIVES]) # ------------------------------- # Generate and compile to *.o. Make sure there is no (allowed) YY* -# nor yy* identifiers in the header. +# nor yy* identifiers in the header. Check that headers are +# self-contained, and can be compiled by a C++ compiler. m4_pushdef([AT_TEST], [AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2]) AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])], @@ -242,6 +243,18 @@ AT_TEST([x8], [%define api.pure %define api.push-pull both]) AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]]) AT_CHECK([./parser], [0], [[expout]]) +# Check that the headers are self-contained, and protected against +# multiple inclusions. While at it, check they are sane for C++. +for h in *.h *.hh +do + # No shell expansion with AT_DATA. + cat >$h.cc < Date: Wed, 3 Oct 2012 15:26:56 +0000 Subject: [PATCH 15/46] maint: fix an erroneous include This fixes test 130 (Several parsers). * data/location.cc: Include rather than since we really need << on strings for instance. * NEWS: Document this. Signed-off-by: Akim Demaille --- NEWS | 4 +++- data/location.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 090253d4..90b5d9d8 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ GNU Bison NEWS Incorrect definitions of YY_, issued by yacc.c when no parser header is generated, are removed. + All the generated headers are self-contained. + ** Header guards (yacc.c, glr.c, glr.cc) In order to avoid collisions, the header guards are now @@ -1882,7 +1884,7 @@ along with this program. If not, see . LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf - LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp + LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval Local Variables: mode: outline diff --git a/data/location.cc b/data/location.cc index b7383d65..0673f4c2 100644 --- a/data/location.cc +++ b/data/location.cc @@ -30,7 +30,7 @@ b4_copyright([Positions for Bison parsers in C++], ]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[ # include // std::max -# include +# include # include ]b4_null_define[ From 7aa15a002657765f171865c11e368782f6109f7d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 4 Oct 2012 09:07:42 +0200 Subject: [PATCH 16/46] lalr1.cc: fix test suite portability Reported by Rob Vermaas' Hydra build farm on x86_64-darwin 10.2.0 with G++ 4.6.3. * tests/headers.at (Several parsers): Include AT_DATA_SOURCE_PROLOGUE in the files to compile. * data/location.cc: Do not include twice string and iostream (once by position.hh, and then by location.hh). * README-hacking (Typical errors): Some hints for other maintainers. --- README-hacking | 13 +++++++++++++ THANKS | 1 + data/location.cc | 2 -- tests/headers.at | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README-hacking b/README-hacking index bb91ac06..50669568 100644 --- a/README-hacking +++ b/README-hacking @@ -168,6 +168,19 @@ decide whether to update. ** make check Use liberally. +** Typical errors +If the test suite shows failures such as the following one + + .../bison/lib/getopt.h:196:8: error: redefinition of 'struct option' + /usr/include/getopt.h:54:8: error: previous definition of 'struct option' + +it probably means that some file was compiled without +AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I pick up +gnulib's replacement headers, such as getopt.h, which will go if config.h +was not included first. + +See tests/local.at for details. + ** make maintainer-check-valgrind This target uses valgrind both to check bison, and the generated parsers. diff --git a/THANKS b/THANKS index 170b0569..b6a2b2d8 100644 --- a/THANKS +++ b/THANKS @@ -93,6 +93,7 @@ R Blake blakers@mac.com Raja R Harinath harinath@cs.umn.edu Ralf Wildenhues Ralf.Wildenhues@gmx.de Richard Stallman rms@gnu.org +Rob Vermaas rob.vermaas@gmail.com Robert Anisko anisko_r@epita.fr Satya Kiran Popuri satyakiran@gmail.com Sebastian Setzer sebastian.setzer.ext@siemens.com diff --git a/data/location.cc b/data/location.cc index 0673f4c2..92b6d096 100644 --- a/data/location.cc +++ b/data/location.cc @@ -159,8 +159,6 @@ b4_copyright([Locations for Bison parsers in C++], ]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[ -# include -# include # include "position.hh" ]b4_namespace_open[ diff --git a/tests/headers.at b/tests/headers.at index 91fdb950..8e70a7eb 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -249,6 +249,7 @@ for h in *.h *.hh do # No shell expansion with AT_DATA. cat >$h.cc < Date: Thu, 4 Oct 2012 11:45:09 +0200 Subject: [PATCH 17/46] maint: word changes * README-hacking (Typical errors): Improve wording. --- README-hacking | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-hacking b/README-hacking index 50669568..26391e98 100644 --- a/README-hacking +++ b/README-hacking @@ -175,9 +175,9 @@ If the test suite shows failures such as the following one /usr/include/getopt.h:54:8: error: previous definition of 'struct option' it probably means that some file was compiled without -AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I pick up -gnulib's replacement headers, such as getopt.h, which will go if config.h -was not included first. +AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options +pick up gnulib's replacement headers, such as getopt.h, and this will go +wrong if config.h was not included first. See tests/local.at for details. From 9a50c55af79520cb103ea7941e84bd554de16a98 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 5 Oct 2012 08:54:15 +0200 Subject: [PATCH 18/46] tests: diff -u is not portable Reported by Didier Godefroy . * tests/existing.at (AT_LALR1_DIFF_CHECK): Skip if diff -u does not work. --- NEWS | 2 +- tests/existing.at | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 90b5d9d8..b5c89040 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ GNU Bison NEWS ** Bug fixes - Bugs in the test suite have been fixed. + Bugs and portability issues in the test suite have been fixed. Some errors in translations have been addressed, and --help now directs users to the appropriate place to report them. diff --git a/tests/existing.at b/tests/existing.at index 582f6b3d..149499d4 100644 --- a/tests/existing.at +++ b/tests/existing.at @@ -35,7 +35,10 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1) dnl support is rapidly evolving, let's keep that information to be careful. dnl However, we don't do diffs for canonical LR(1) because the diff is huge. m4_pushdef([AT_LALR1_DIFF_CHECK], -[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]]) +[dnl We need diff -u, which is not portable. +AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore]) + +AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]]) AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore]) AT_CHECK([[diff -u input-lalr.output input.output \ | sed -n '/^@@/,$p' | sed 's/^ $//']], From e272d9dc80291b22a3a80675e2cefafdd40a8581 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 5 Oct 2012 09:20:30 +0200 Subject: [PATCH 19/46] tests: fix sed portability issues Reported by Didier Godefroy, . * tests/calc.at (AT_CHECK_SPACES): Use Perl. --- tests/calc.at | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/calc.at b/tests/calc.at index 3aab8681..a1c11e5f 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -503,12 +503,15 @@ AT_CHECK([cat stderr], 0, [expout]) # Make sure we did not introduce bad spaces. Checked here because all # the skeletons are (or should be) exercized here. m4_define([AT_CHECK_SPACES], -[# No initial empty lines. -AT_CHECK([sed -ne '/./q;=;p;' $1]) -# No trailing spaces. -# FIXME: For 2.7: AT_CHECK([sed -ne '/[ ]$/{=;p;}' $1]) -# No final empty lines. -AT_CHECK([sed -ne '${/^$/{=;p;};}' $1]) +[AT_CHECK([perl -ne ' + chomp; + print "$.: {$_}\n" + if (# No starting/ending empty lines. + (eof || $. == 1) && /^\s*$/ + # No trailing space. FIXME: not ready for "maint". + # || /\s$/ + )' $1 +])dnl ]) From 82443642d255cc2fd61644cf3fef2c9622bed245 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 8 Apr 2012 08:58:43 +0200 Subject: [PATCH 20/46] build: look for Perl in configure. Bison uses "/usr/bin/perl" or "perl" in several places, and it does not appear to be a problem. But, at least to make it simpler to change PERL on the make command line, check for perl in configure. * configure.ac (PERL): New. * doc/Doxyfile.in, doc/Makefile.am, tests/bison.in: Use it. --- configure.ac | 4 ++++ doc/Doxyfile.in | 2 +- doc/Makefile.am | 2 +- tests/bison.in | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b9d2ea69..4cc9ef91 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,10 @@ AC_PROG_GNU_M4 AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.]) AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4 supports -g, otherwise to "".]) +AC_PATH_PROG([PERL], [perl]) +if test -z "$PERL"; then + AC_MSG_ERROR([perl not found]) +fi AM_MISSING_PROG([HELP2MAN], [help2man]) AC_PATH_PROG([XSLTPROC], [xsltproc]) AC_SUBST([XSLTPROC]) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index b5557518..e36a1cee 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -940,7 +940,7 @@ EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +PERL_PATH = @PERL@ #--------------------------------------------------------------------------- # Configuration options related to the dot tool diff --git a/doc/Makefile.am b/doc/Makefile.am index d87f00f0..f695e22d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -30,7 +30,7 @@ $(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL) $(AM_V_at)rm -f $@.tmp $(AM_V_at)cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison $(AM_V_at)$(top_builddir)/src/bison --help \ - | perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp + | $(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp $(AM_V_at)diff -u $@~ $@.tmp || true $(AM_V_at)mv $@.tmp $@ MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi diff --git a/tests/bison.in b/tests/bison.in index 4dfeb791..f21b2bcd 100644 --- a/tests/bison.in +++ b/tests/bison.in @@ -19,7 +19,7 @@ abs_top_srcdir='@abs_top_srcdir@' abs_top_builddir='@abs_top_builddir@' -: ${PERL=perl} +: ${PERL='@PERL@'} # Use the shipped files, not those installed. BISON_PKGDATADIR=$abs_top_srcdir/data From c955769a75197c3afddc9ea674439f3a49b82059 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 5 Oct 2012 09:24:59 +0200 Subject: [PATCH 21/46] tests: use $PERL instead of perl * tests/atlocal.in (PERL): New. Sort. * tests/calc.at, tests/input.at, tests/local.at, tests/regression.at, * tests/skeletons.at, tests/synclines.at, tests/torture.at: here. --- tests/atlocal.in | 20 +++++++++++--------- tests/calc.at | 2 +- tests/input.at | 8 ++++---- tests/local.at | 2 +- tests/regression.at | 6 +++--- tests/skeletons.at | 2 +- tests/synclines.at | 2 +- tests/torture.at | 6 +++--- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/atlocal.in b/tests/atlocal.in index d059d630..9a2d19f0 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -63,24 +63,26 @@ fi ## Other. ## ## ------- ## -# Are special link options needed? -LDFLAGS='@LDFLAGS@' - -# Are special libraries needed? -LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@" - # Empty if no javac was found CONF_JAVAC='@CONF_JAVAC@' # Empty if no Java VM was found CONF_JAVA='@CONF_JAVA@' -# Empty if no xsltproc was found -: ${XSLTPROC='@XSLTPROC@'} - # We need egrep. : ${EGREP='@EGREP@'} # Use simple quotes (lib/quote.c). LC_CTYPE=C export LC_CTYPE + +# Are special link options needed? +LDFLAGS='@LDFLAGS@' + +# Are special libraries needed? +LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@" + +# Empty if no xsltproc was found +: ${XSLTPROC='@XSLTPROC@'} + +: ${PERL='@PERL@'} diff --git a/tests/calc.at b/tests/calc.at index a1c11e5f..9518c3c3 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -503,7 +503,7 @@ AT_CHECK([cat stderr], 0, [expout]) # Make sure we did not introduce bad spaces. Checked here because all # the skeletons are (or should be) exercized here. m4_define([AT_CHECK_SPACES], -[AT_CHECK([perl -ne ' +[AT_CHECK([$PERL -ne ' chomp; print "$.: {$_}\n" if (# No starting/ending empty lines. diff --git a/tests/input.at b/tests/input.at index ff1d3924..07c3e873 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1194,7 +1194,7 @@ AT_DATA([empty.y], start: ''; start: ' ]]) -AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]]) +AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]]) AT_BISON_CHECK([empty.y], [1], [], [[empty.y:2.8-9: warning: empty character literal @@ -1209,7 +1209,7 @@ AT_DATA([two.y], start: 'ab'; start: 'ab ]]) -AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]]) +AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]]) AT_BISON_CHECK([two.y], [1], [], [[two.y:2.8-11: warning: extra characters in character literal @@ -1224,7 +1224,7 @@ AT_DATA([three.y], start: 'abc'; start: 'abc ]]) -AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]]) +AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]]) AT_BISON_CHECK([three.y], [1], [], [[three.y:2.8-12: warning: extra characters in character literal @@ -1253,7 +1253,7 @@ start: '\777' '\0' '\xfff' '\x0' # Beside we cannot even expect "echo '\0'" to output two characters # (well three with \n): at least Bash 3.2 converts the two-character # sequence "\0" into a single NUL character. -AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \ +AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \ || exit 77]]) AT_BISON_CHECK([input.y], [1], [], diff --git a/tests/local.at b/tests/local.at index 5c9b865e..2362e766 100644 --- a/tests/local.at +++ b/tests/local.at @@ -38,7 +38,7 @@ m4_define([m4_null_if], # Expect COUNT matches of the PERL-REGEXP in FILE. The file is # taken in "slurp" mode, i.e., one can match end-of-lines. m4_define([AT_MATCHES_CHECK], -[AT_CHECK([perl -0777 -ne ' +[AT_CHECK([$PERL -0777 -ne ' my $count = 0; s{$2}{ ++$count; "" }gem; printf "$count\n";' $1], [0], [$3 diff --git a/tests/regression.at b/tests/regression.at index 2f029939..758825c7 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -1481,17 +1481,17 @@ AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]], # Check number of default reductions in inconsistent states to be sure # syntax error is detected before unnecessary reductions are performed. -AT_CHECK([[perl -0777 -ne 'print s/inconsistent default reduction//g;' \ +AT_CHECK([[$PERL -0777 -ne 'print s/inconsistent default reduction//g;' \ < stdout.txt || exit 77]], [[0]], [[14]]) # Check number of default reductions in consistent states to be sure # it is performed before the syntax error is detected. -AT_CHECK([[perl -0777 -ne 'print s/\bconsistent default reduction//g;' \ +AT_CHECK([[$PERL -0777 -ne 'print s/\bconsistent default reduction//g;' \ < stdout.txt || exit 77]], [[0]], [[2]]) # Check number of reallocs to be sure reallocated memory isn't somehow # lost between LAC invocations. -AT_CHECK([[perl -0777 -ne 'print s/\(realloc//g;' < stderr.txt \ +AT_CHECK([[$PERL -0777 -ne 'print s/\(realloc//g;' < stderr.txt \ || exit 77]], [[0]], [[3]]) AT_BISON_OPTION_POPDEFS diff --git a/tests/skeletons.at b/tests/skeletons.at index 76cf0662..e23c3bb0 100644 --- a/tests/skeletons.at +++ b/tests/skeletons.at @@ -315,7 +315,7 @@ print '@output(@,@)', "\n"; (print "garbage"x10, "\n") for (1..1000); print "${M4}_divert_pop(0)\n"; ]]) -AT_CHECK([[perl gen-skel.pl > skel.c || exit 77]]) +AT_CHECK([[$PERL gen-skel.pl > skel.c || exit 77]]) AT_DATA([[input.y]], [[%skeleton "./skel.c" diff --git a/tests/synclines.at b/tests/synclines.at index e2b7005d..041ae194 100644 --- a/tests/synclines.at +++ b/tests/synclines.at @@ -64,7 +64,7 @@ m4_define([AT_SYNCLINES_COMPILE], # distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host # distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead -AT_CHECK([[perl -p -0777 - stderr <<\EOF +AT_CHECK([[$PERL -p -0777 - stderr <<\EOF s/^distcc\[\d+\] .*\n//gm; s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm; s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm; diff --git a/tests/torture.at b/tests/torture.at index 705e131e..a5e244b6 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -125,7 +125,7 @@ EOF ]]) AT_BISON_OPTION_POPDEFS -AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout]) +AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout]) mv stdout $1 ]) @@ -214,7 +214,7 @@ main (void) EOF ]]) -AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout]) +AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout]) mv stdout $1 AT_BISON_OPTION_POPDEFS ]) @@ -350,7 +350,7 @@ main (void) EOF ]]) -AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout]) +AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout]) mv stdout $1 AT_BISON_OPTION_POPDEFS ]) From 5b34bb31100247acddd4d0d3147bf25ad5be0ff7 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 20 Sep 2012 11:42:06 +0200 Subject: [PATCH 22/46] tests: minor improvements * tests/c++.at: Space changes. Use AT_YYERROR_DEFINE. * tests/local.at (AT_YYERROR_DEFINE): Issue errors on unknown languages. --- tests/c++.at | 9 ++++----- tests/local.at | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/c++.at b/tests/c++.at index 93675d4d..c44a2a59 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -1,4 +1,4 @@ -# Checking the output filenames. -*- Autotest -*- +# Checking the C++ Features. -*- Autotest -*- # Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation, # Inc. @@ -30,6 +30,7 @@ m4_define([AT_CHECK_DOXYGEN], [m4_fatal([invalid argument: $1])]) AT_SETUP([Doxygen $1 Documentation]) +AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"]) AT_DATA([input.yy], [[%skeleton "lalr1.cc" %locations @@ -38,10 +39,7 @@ AT_DATA([input.yy], %% exp:; %% -yy::parser::error (const location& l, const std::string& m) -{ - std::cerr << l << s << std::endl; -} +]AT_YYERROR_DEFINE[ ]]) AT_BISON_CHECK([-o input.cc input.yy], 0) @@ -94,6 +92,7 @@ EXTRACT_STATIC = AT_DOXYGEN_PRIVATE AT_CHECK([doxygen --version || exit 77], 0, ignore) AT_CHECK([doxygen], 0, [], [ignore]) +AT_BISON_OPTION_POPDEFS AT_CLEANUP m4_popdef([AT_DOXYGEN_PRIVATE]) diff --git a/tests/local.at b/tests/local.at index 2362e766..036b0a1d 100644 --- a/tests/local.at +++ b/tests/local.at @@ -405,7 +405,8 @@ void public void yyerror (String s) { System.err.println (s); - }]])])dnl + }]])], +[m4_fatal([$0: invalid language: ]AT_LANG)])dnl ]) From 39845e8e405f4aa74e93d04481c2c5d8004833fc Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 8 Oct 2012 09:12:10 +0200 Subject: [PATCH 23/46] skeletons: style changes * data/yacc.c, data/glr.c: Prefer Title case for (CPP) macro arguments. --- data/glr.c | 24 ++++++++++++------------ data/yacc.c | 18 +++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/data/glr.c b/data/glr.c index 97efe894..9b8ff67c 100644 --- a/data/glr.c +++ b/data/glr.c @@ -241,24 +241,24 @@ b4_percent_code_get[]dnl # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else ]b4_c_function_def([YYID], [static int], [[int i], [i]])[ { @@ -289,8 +289,8 @@ b4_percent_code_get[]dnl #ifndef YYSETJMP # include # define YYJMP_BUF jmp_buf -# define YYSETJMP(env) setjmp (env) -# define YYLONGJMP(env, val) longjmp (env, val) +# define YYSETJMP(Env) setjmp (Env) +# define YYLONGJMP(Env, Val) longjmp (Env, Val) #endif /*-----------------. @@ -313,7 +313,7 @@ b4_percent_code_get[]dnl #endif])[ #ifndef YYASSERT -# define YYASSERT(condition) ((void) ((condition) || (abort (), 0))) +# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0))) #endif /* YYFINAL -- State number of the termination state. */ @@ -972,8 +972,8 @@ yylhsNonterm (yyRuleNum yyrule) return yyr1[yyrule]; } -#define yypact_value_is_default(yystate) \ - ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ +#define yypact_value_is_default(Yystate) \ + ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[ /** True iff LR state STATE has only a default reduction (regardless * of token). */ @@ -990,8 +990,8 @@ yydefaultAction (yyStateNum yystate) return yydefact[yystate]; } -#define yytable_value_is_error(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(Yytable_value) \ + ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[ /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. * Result R means diff --git a/data/yacc.c b/data/yacc.c index 7bcbd7ca..736a9b20 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -404,24 +404,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else ]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[ { @@ -680,11 +680,11 @@ static const ]b4_int_type_for([b4_table])[ yytable[] = ]b4_table[ }; -#define yypact_value_is_default(yystate) \ - ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ +#define yypact_value_is_default(Yystate) \ + ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[ -#define yytable_value_is_error(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(Yytable_value) \ + ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[ static const ]b4_int_type_for([b4_check])[ yycheck[] = { From fa5303b8ff748b8feab0b2613773056ce9f3ff54 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 5 Oct 2012 10:55:11 -0700 Subject: [PATCH 24/46] yacc.c: initialize yylval in pure-parser mode See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html (spreading over September and October). * data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN) (YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE): New macros. Use them to suppress an unwanted GCC diagnostic. --- data/yacc.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/data/yacc.c b/data/yacc.c index 736a9b20..faf1d786 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -170,6 +170,28 @@ m4_define([b4_declare_scanner_communication_variables], [[ /* The lookahead symbol. */ int yychar; +]b4_pure_if([[ +#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__)) +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YYLVAL_INITIALIZE() (yylval = yyval_default) +#endif]])[ +#ifndef YYLVAL_INITIALIZE +# define YYLVAL_INITIALIZE() +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif + /* The semantic value of the lookahead symbol. */ YYSTYPE yylval;]b4_locations_if([[ @@ -1563,8 +1585,9 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs;]b4_locations_if([[ - yylsp = yyls; + yylsp = yyls;]])[ + YYLVAL_INITIALIZE ();]b4_locations_if([[ #if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; @@ -1750,7 +1773,9 @@ yyread_pushed_token:]])[ YY_LAC_DISCARD ("shift");]])[ yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END ]b4_locations_if([ *++yylsp = yylloc;])[ goto yynewstate; @@ -1970,7 +1995,9 @@ yyerrlab1: current lookahead token, the shift below will for sure. */ YY_LAC_DISCARD ("error recovery");]])[ + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END ]b4_locations_if([[ yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of From 8f8439cee10db2ba526f3797e163b16c1d4f0c9d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 8 Oct 2012 09:02:09 +0200 Subject: [PATCH 25/46] tests: no longer disable -O compiler options Tests are running without -O since f377f69fec28013c79db4efe12bbb9d48987fb2c because some warnings (about yylval not being initialized) show only when GCC is given -O2. The previous patch fixes the warnings. Run the test suite with compiler options unmodified. * tests/atlocal.in (O0CFLAGS, O0CXXFLAGS): Remove, use CFLAGS and CXXFLAGS. --- NEWS | 13 +++++++++++++ tests/atlocal.in | 11 ++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index b5c89040..b06a1112 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,19 @@ GNU Bison NEWS will use YY_CALC_LIB_PARSE_H_INCLUDED as guard. +** Fix compiler warnings in the generated parser (yacc.c) + + The compilation of pure parsers (%define api.pure) can trigger GCC + warnings such as: + + input.c: In function 'yyparse': + input.c:1503:12: warning: 'yylval' may be used uninitialized in this + function [-Wmaybe-uninitialized] + *++yyvsp = yylval; + ^ + + This is now fixed; pragmas to avoid these warnings are no longer needed. + * Noteworthy changes in release 2.6.2 (2012-08-03) [stable] ** Bug fixes diff --git a/tests/atlocal.in b/tests/atlocal.in index 9a2d19f0..2f682592 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -29,16 +29,10 @@ CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@" # Is the compiler GCC? GCC='@GCC@' -# We want no optimization, as they uncover warnings (therefore, -# failures) about uninitialized variables in the test suite. FIXME: -# fix the warnings, not the flags. - O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9s] *//g'` -O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9s] *//g'` - # Sometimes a test group needs to ignore gcc warnings, so it locally # sets CFLAGS to this. - NO_WERROR_CFLAGS="$O0CFLAGS @WARN_CFLAGS@ @WARN_CFLAGS_TEST@" -NO_WERROR_CXXFLAGS="$O0CXXFLAGS @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@" + NO_WERROR_CFLAGS='@CFLAGS@ @WARN_CFLAGS@ @WARN_CFLAGS_TEST@' +NO_WERROR_CXXFLAGS='@CXXFLAGS@ @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@' # But most of the time, we want -Werror. CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@" @@ -51,7 +45,6 @@ BISON_CXX_WORKS='@BISON_CXX_WORKS@' if "$at_arg_compile_c_with_cxx"; then CC_IS_CXX=1 CC=$CXX - O0CFLAGS=$O0CXXFLAGS NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS CFLAGS=$CXXFLAGS else From 19d9b60787a5b9340b8adf4b3e918c356bb2bd90 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 8 Oct 2012 09:17:20 +0200 Subject: [PATCH 26/46] warnings: avoid warnings from clang Fix the following warning parse-gram.c:2078:14: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if (((yyn) == (-91))) ~~~~~~^~~~~~~~ parse-gram.c:2078:14: note: remove extraneous parentheses around the comparison to silence this warning if (((yyn) == (-91))) ~ ^ ~ parse-gram.c:2078:14: note: use '=' to turn this equality comparison into an assignment if (((yyn) == (-91))) ^~ = 1 error generated. and the following one: input.cc:740:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn] static void yyMemoryExhausted (yyGLRStack* yystackp) __attribute__ ((__noreturn__)); static void yyMemoryExhausted (yyGLRStack* yystackp) { YYLONGJMP (yystackp->yyexception_buffer, 2); } ^ 1 warning and 1 error generated. This is Apple clang version 3.1 (tags/Apple/clang-318.0.61). * data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B) to avoid this warning. Any reasonable compiler should generate the same code. * src/uniqstr.h (UNIQSTR_EQ): Likewise. * data/glr.c (LONGJMP): abort after longjmp to pacify clang. --- data/c.m4 | 2 +- data/glr.c | 3 ++- src/uniqstr.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/c.m4 b/data/c.m4 index fd2203eb..994d2964 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -184,7 +184,7 @@ m4_define([b4_table_value_equals], [m4_if(m4_eval($3 < m4_indir([b4_]$1[_min]) || m4_indir([b4_]$1[_max]) < $3), [1], [[YYID (0)]], - [[((]$2[) == (]$3[))]])]) + [(!!(($2) == ($3)))])]) ## ---------## diff --git a/data/glr.c b/data/glr.c index 9b8ff67c..79d6ffd0 100644 --- a/data/glr.c +++ b/data/glr.c @@ -290,7 +290,8 @@ b4_percent_code_get[]dnl # include # define YYJMP_BUF jmp_buf # define YYSETJMP(Env) setjmp (Env) -# define YYLONGJMP(Env, Val) longjmp (Env, Val) +// Pacify clang. +# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0)) #endif /*-----------------. diff --git a/src/uniqstr.h b/src/uniqstr.h index 913da39f..677ecc42 100644 --- a/src/uniqstr.h +++ b/src/uniqstr.h @@ -36,7 +36,7 @@ uniqstr uniqstr_vsprintf (char const *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); /* Two uniqstr values have the same value iff they are the same. */ -#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2)) +#define UNIQSTR_EQ(USTR1, USTR2) (!!((USTR1) == (USTR2))) /* Compare two uniqstr a la strcmp: negative for <, nul for =, and positive for >. Undefined order, relies on addresses. */ From 7b70847e5834fdb3265db8629167353b86b43173 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 8 Oct 2012 13:46:50 +0200 Subject: [PATCH 27/46] NEWS: warnings with clang * NEWS: here. --- NEWS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b06a1112..220d9ed1 100644 --- a/NEWS +++ b/NEWS @@ -27,7 +27,7 @@ GNU Bison NEWS will use YY_CALC_LIB_PARSE_H_INCLUDED as guard. -** Fix compiler warnings in the generated parser (yacc.c) +** Fix compiler warnings in the generated parser (yacc.c, glr.c) The compilation of pure parsers (%define api.pure) can trigger GCC warnings such as: @@ -40,6 +40,10 @@ GNU Bison NEWS This is now fixed; pragmas to avoid these warnings are no longer needed. + Warnings from clang ("equality comparison with extraneous parentheses" and + "function declared 'noreturn' should not return") have also been + addressed. + * Noteworthy changes in release 2.6.2 (2012-08-03) [stable] ** Bug fixes From ae2199381ee5eef2379e34376b77a36d99739cb6 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 12 Oct 2012 10:10:18 +0200 Subject: [PATCH 28/46] tests: check %no-lines * tests/synclines.at: here. --- tests/synclines.at | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/synclines.at b/tests/synclines.at index 041ae194..63ae6858 100644 --- a/tests/synclines.at +++ b/tests/synclines.at @@ -216,4 +216,54 @@ exp: '0'; [input.y:8: #error "8" ]) +## -------------------- ## +## %code top syncline. ## +## -------------------- ## + +AT_TEST([%code top syncline], +[[%code top { +#error "2" +} +%{ +]AT_YYERROR_DECLARE_EXTERN[ +]AT_YYLEX_DECLARE_EXTERN[ +%} +%% +exp: '0'; +%% +]], +[input.y:2: #error "2" +]) + +m4_popdef([AT_TEST]) + +## ----------- ## +## %no-lines. ## +## ----------- ## + +m4_pushdef([AT_TEST], +[AT_SETUP([%no-lines]) + +AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %defines]) +AT_DATA_GRAMMAR([input.y], +[%skeleton "$1" %defines +%{ +]AT_YYERROR_DECLARE_EXTERN[ +]AT_YYLEX_DECLARE_EXTERN[ +%} +%% +exp: '0' +]) +AT_BISON_CHECK([--no-lines -o input.AT_SKEL_CC_IF([cc], [c]) -d input.y]) +AT_CHECK([[grep '#line' ]AT_SKEL_CC_IF([*.cc *.hh], [*.c *.h])], 1) +AT_BISON_OPTION_POPDEFS + +AT_CLEANUP +]) + +AT_TEST([yacc.c]) +AT_TEST([glr.c]) +AT_TEST([lalr1.cc]) +AT_TEST([glr.cc]) + m4_popdef([AT_TEST]) From cc5a986ce43372e5349b0e86718fd808a633a404 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 19 Oct 2012 11:36:18 +0200 Subject: [PATCH 29/46] gnulib: update --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index dcf27bef..d245e6dd 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit dcf27bef48c9800d5a2be8349226f73f1b8ff2e5 +Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f From 6eb8f74f8fa3cea393c0de27599f0e70bb1e106c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 22 Oct 2012 15:16:12 +0200 Subject: [PATCH 30/46] version 2.6.3 * NEWS: Record release date. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 220d9ed1..2cdb4987 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU Bison NEWS -* Noteworthy changes in release ?.? (????-??-??) [?] +* Noteworthy changes in release 2.6.3 (2012-10-22) [stable] ** Bug fixes From a4eb820f17de135bb4b0f6503ab22ea7b0595999 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 22 Oct 2012 15:28:10 +0200 Subject: [PATCH 31/46] maint: post-release administrivia * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update. --- .prev-version | 2 +- NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.prev-version b/.prev-version index 097a15a2..ec1cf33c 100644 --- a/.prev-version +++ b/.prev-version @@ -1 +1 @@ -2.6.2 +2.6.3 diff --git a/NEWS b/NEWS index 2cdb4987..083d90a9 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ GNU Bison NEWS +* Noteworthy changes in release ?.? (????-??-??) [?] + + * Noteworthy changes in release 2.6.3 (2012-10-22) [stable] ** Bug fixes From 468455e12b995d4b44a648cb47b749ead4453bae Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 22 Oct 2012 18:13:15 +0200 Subject: [PATCH 32/46] 2.6.4: botched 2.6.3 * NEWS: here. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 083d90a9..9dd51415 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ GNU Bison NEWS * Noteworthy changes in release ?.? (????-??-??) [?] + Bison 2.6.3's --version was incorrect. This release fixes this issue. * Noteworthy changes in release 2.6.3 (2012-10-22) [stable] From 40a1cd37f31500bec5ddd05692141afca31b176a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 22 Oct 2012 18:14:54 +0200 Subject: [PATCH 33/46] regen --- src/parse-gram.c | 323 +++++++++++++++++++++++++---------------------- src/parse-gram.h | 12 +- 2 files changed, 181 insertions(+), 154 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index da95d53b..148ef761 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.2.13-429e. */ +/* A Bison parser, made by GNU Bison 2.6.3.3-b10d3. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.2.13-429e" +#define YYBISON_VERSION "2.6.3.3-b10d3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -70,7 +70,7 @@ #define yylloc gram_lloc /* Copy the first part of user declarations. */ -/* Line 336 of yacc.c */ +/* Line 358 of yacc.c */ #line 1 "parse-gram.y" /* Bison Grammar Parser -*- C -*- @@ -166,7 +166,7 @@ current_lhs(symbol *sym, location loc, named_ref *ref) #define YYTYPE_UINT16 uint_fast16_t #define YYTYPE_UINT8 uint_fast8_t -/* Line 336 of yacc.c */ +/* Line 358 of yacc.c */ #line 171 "parse-gram.c" # ifndef YY_NULL @@ -187,8 +187,8 @@ current_lhs(symbol *sym, location loc, named_ref *ref) /* In a future release of Bison, this section will be replaced by #include "parse-gram.h". */ -#ifndef GRAM_Y_TAB_H -# define GRAM_Y_TAB_H +#ifndef YY_GRAM_Y_TAB_H_INCLUDED +# define YY_GRAM_Y_TAB_H_INCLUDED /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -324,7 +324,7 @@ extern int gram_debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 352 of yacc.c */ +/* Line 374 of yacc.c */ #line 115 "parse-gram.y" symbol *symbol; @@ -338,7 +338,7 @@ typedef union YYSTYPE named_ref *named_ref; -/* Line 352 of yacc.c */ +/* Line 374 of yacc.c */ #line 343 "parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -374,11 +374,11 @@ int gram_parse (); #endif #endif /* ! YYPARSE_PARAM */ -#endif /* !GRAM_Y_TAB_H */ +#endif /* !YY_GRAM_Y_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ -/* Line 355 of yacc.c */ +/* Line 377 of yacc.c */ #line 383 "parse-gram.c" #ifdef short @@ -432,24 +432,24 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +# define YYID(N) (N) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) @@ -863,10 +863,10 @@ static const yytype_int16 yytable[] = 42 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-91)) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-91))) -#define yytable_value_is_error(yytable_value) \ +#define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_uint8 yycheck[] = @@ -1070,129 +1070,129 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) switch (yytype) { case 3: /* "string" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 205 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1078 "parse-gram.c" break; case 4: /* "integer" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 217 "parse-gram.y" { fprintf (stderr, "%d", ((*yyvaluep).integer)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1085 "parse-gram.c" break; case 43: /* "{...}" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1092 "parse-gram.c" break; case 44: /* "[identifier]" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 212 "parse-gram.y" { fprintf (stderr, "[%s]", ((*yyvaluep).uniqstr)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1099 "parse-gram.c" break; case 45: /* "char" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 199 "parse-gram.y" { fputs (char_name (((*yyvaluep).character)), stderr); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1106 "parse-gram.c" break; case 46: /* "epilogue" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1113 "parse-gram.c" break; case 48: /* "identifier" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1120 "parse-gram.c" break; case 49: /* "identifier:" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 213 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1127 "parse-gram.c" break; case 52: /* "%{...%}" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1134 "parse-gram.c" break; case 54: /* "type" */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 214 "parse-gram.y" { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1141 "parse-gram.c" break; case 71: /* symbol.prec */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1148 "parse-gram.c" break; case 84: /* variable */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1155 "parse-gram.c" break; case 85: /* content.opt */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1162 "parse-gram.c" break; case 86: /* braceless */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1169 "parse-gram.c" break; case 87: /* id */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1176 "parse-gram.c" break; case 88: /* id_colon */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 221 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1183 "parse-gram.c" break; case 89: /* symbol */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1190 "parse-gram.c" break; case 90: /* string_as_id */ -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 811 of yacc.c */ +/* Line 833 of yacc.c */ #line 1197 "parse-gram.c" break; default: @@ -1868,6 +1868,28 @@ yyparse () /* The lookahead symbol. */ int yychar; + +#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__)) +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YYLVAL_INITIALIZE() (yylval = yyval_default) +#endif +#ifndef YYLVAL_INITIALIZE +# define YYLVAL_INITIALIZE() +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif + /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; @@ -1961,6 +1983,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; + YYLVAL_INITIALIZE (); #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; @@ -1968,7 +1991,7 @@ YYLTYPE yylloc; #endif /* User initialization code. */ -/* Line 1573 of yacc.c */ +/* Line 1596 of yacc.c */ #line 107 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -1976,8 +1999,8 @@ YYLTYPE yylloc; boundary_set (&yylloc.start, current_file, 1, 1); boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1573 of yacc.c */ -#line 1981 "parse-gram.c" +/* Line 1596 of yacc.c */ +#line 2004 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2129,7 +2152,9 @@ yybackup: YY_LAC_DISCARD ("shift"); yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END *++yylsp = yylloc; goto yynewstate; @@ -2169,7 +2194,7 @@ yyreduce: switch (yyn) { case 6: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 246 "parse-gram.y" { code_props plain_code; @@ -2183,13 +2208,13 @@ yyreduce: break; case 7: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 255 "parse-gram.y" { debug_flag = true; } break; case 8: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 257 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), @@ -2198,13 +2223,13 @@ yyreduce: break; case 9: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 261 "parse-gram.y" { defines_flag = true; } break; case 10: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 263 "parse-gram.y" { defines_flag = true; @@ -2213,37 +2238,37 @@ yyreduce: break; case 11: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 267 "parse-gram.y" { error_verbose = true; } break; case 12: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 268 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 269 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 270 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 271 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 273 "parse-gram.y" { nondeterministic_parser = true; @@ -2252,7 +2277,7 @@ yyreduce: break; case 17: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 278 "parse-gram.y" { code_props action; @@ -2265,67 +2290,67 @@ yyreduce: break; case 18: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 286 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 287 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 288 "parse-gram.y" { locations_flag = true; } break; case 21: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 289 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 290 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 291 "parse-gram.y" { no_lines_flag = true; } break; case 24: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 292 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 293 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 294 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 295 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 297 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use @@ -2344,13 +2369,13 @@ yyreduce: break; case 29: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 311 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 313 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); @@ -2378,25 +2403,25 @@ yyreduce: break; case 31: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 336 "parse-gram.y" { token_table_flag = true; } break; case 32: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 337 "parse-gram.y" { report_flag |= report_states; } break; case 33: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 338 "parse-gram.y" { yacc_flag = true; } break; case 37: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 346 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); @@ -2404,7 +2429,7 @@ yyreduce: break; case 38: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 350 "parse-gram.y" { code_props code; @@ -2420,7 +2445,7 @@ yyreduce: break; case 39: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 362 "parse-gram.y" { code_props code; @@ -2436,7 +2461,7 @@ yyreduce: break; case 40: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 374 "parse-gram.y" { default_prec = true; @@ -2444,7 +2469,7 @@ yyreduce: break; case 41: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 378 "parse-gram.y" { default_prec = false; @@ -2452,7 +2477,7 @@ yyreduce: break; case 42: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 382 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes @@ -2463,7 +2488,7 @@ yyreduce: break; case 43: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 389 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2472,19 +2497,19 @@ yyreduce: break; case 44: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 403 "parse-gram.y" {} break; case 45: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 404 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 409 "parse-gram.y" { union_seen = true; @@ -2494,13 +2519,13 @@ yyreduce: break; case 47: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 420 "parse-gram.y" { current_class = nterm_sym; } break; case 48: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 421 "parse-gram.y" { current_class = unknown_sym; @@ -2509,13 +2534,13 @@ yyreduce: break; case 49: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 425 "parse-gram.y" { current_class = token_sym; } break; case 50: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 426 "parse-gram.y" { current_class = unknown_sym; @@ -2524,7 +2549,7 @@ yyreduce: break; case 51: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 431 "parse-gram.y" { symbol_list *list; @@ -2536,7 +2561,7 @@ yyreduce: break; case 52: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 442 "parse-gram.y" { symbol_list *list; @@ -2552,109 +2577,109 @@ yyreduce: break; case 53: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 456 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 457 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 458 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 462 "parse-gram.y" { current_type = NULL; } break; case 57: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 463 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 469 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 471 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 60: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 475 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 476 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } break; case 62: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 482 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 484 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 64: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 488 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 489 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 66: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 493 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 67: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 494 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 68: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 495 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 496 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 502 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); @@ -2663,7 +2688,7 @@ yyreduce: break; case 71: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 507 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); @@ -2672,7 +2697,7 @@ yyreduce: break; case 72: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 512 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2682,7 +2707,7 @@ yyreduce: break; case 73: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 518 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2692,7 +2717,7 @@ yyreduce: break; case 74: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 524 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); @@ -2703,7 +2728,7 @@ yyreduce: break; case 81: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 554 "parse-gram.y" { yyerrok; @@ -2711,13 +2736,13 @@ yyreduce: break; case 82: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 560 "parse-gram.y" { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); } break; case 83: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 561 "parse-gram.y" { /* Free the current lhs. */ @@ -2726,86 +2751,86 @@ yyreduce: break; case 84: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 568 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 569 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 575 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } break; case 88: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 578 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 89: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 580 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 90: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 582 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 584 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 586 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 590 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 592 "parse-gram.y" { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 96: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 604 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 609 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 610 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 621 "parse-gram.y" { code_props plain_code; @@ -2818,13 +2843,13 @@ yyreduce: break; case 101: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 641 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 643 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); @@ -2834,13 +2859,13 @@ yyreduce: break; case 103: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 651 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 663 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); @@ -2849,7 +2874,7 @@ yyreduce: break; case 108: -/* Line 1788 of yacc.c */ +/* Line 1813 of yacc.c */ #line 672 "parse-gram.y" { code_props plain_code; @@ -2862,8 +2887,8 @@ yyreduce: break; -/* Line 1788 of yacc.c */ -#line 2867 "parse-gram.c" +/* Line 1813 of yacc.c */ +#line 2892 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3038,7 +3063,9 @@ yyerrlab1: current lookahead token, the shift below will for sure. */ YY_LAC_DISCARD ("error recovery"); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of @@ -3111,7 +3138,7 @@ yyreturn: } -/* Line 2049 of yacc.c */ +/* Line 2076 of yacc.c */ #line 682 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index f1dacd16..455a7683 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.2.13-429e. */ +/* A Bison parser, made by GNU Bison 2.6.3.3-b10d3. */ /* Bison interface for Yacc-like parsers in C @@ -30,8 +30,8 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef GRAM__________SRC_PARSE_GRAM_H -# define GRAM__________SRC_PARSE_GRAM_H +#ifndef YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED +# define YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -167,7 +167,7 @@ extern int gram_debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 2050 of yacc.c */ +/* Line 2077 of yacc.c */ #line 115 "parse-gram.y" symbol *symbol; @@ -181,7 +181,7 @@ typedef union YYSTYPE named_ref *named_ref; -/* Line 2050 of yacc.c */ +/* Line 2077 of yacc.c */ #line 186 "parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -217,4 +217,4 @@ int gram_parse (); #endif #endif /* ! YYPARSE_PARAM */ -#endif /* !GRAM__________SRC_PARSE_GRAM_H */ +#endif /* !YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED */ From 0ac1584946d1c00d687f53b012ef28d6397602ce Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 23 Oct 2012 13:46:28 +0200 Subject: [PATCH 34/46] version 2.6.4 * NEWS: Record release date. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9dd51415..87d4173e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU Bison NEWS -* Noteworthy changes in release ?.? (????-??-??) [?] +* Noteworthy changes in release 2.6.4 (2012-10-23) [stable] Bison 2.6.3's --version was incorrect. This release fixes this issue. From 6f1360bd893f202ea621dad1d4993488a7af48bd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 23 Oct 2012 13:58:51 +0200 Subject: [PATCH 35/46] maint: post-release administrivia * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update. --- .prev-version | 2 +- NEWS | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.prev-version b/.prev-version index ec1cf33c..2714f531 100644 --- a/.prev-version +++ b/.prev-version @@ -1 +1 @@ -2.6.3 +2.6.4 diff --git a/NEWS b/NEWS index 87d4173e..895f55db 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ GNU Bison NEWS +* Noteworthy changes in release ?.? (????-??-??) [?] + + * Noteworthy changes in release 2.6.4 (2012-10-23) [stable] Bison 2.6.3's --version was incorrect. This release fixes this issue. From 851e3f846852bf960587e54156dbbb5115d25f42 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 09:40:20 +0200 Subject: [PATCH 36/46] fix comment * data/c.m4 (b4_YYDEBUG_define): here. --- data/c.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/c.m4 b/data/c.m4 index 994d2964..561900af 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -602,7 +602,7 @@ m4_define([b4_YYDEBUG_define], # endif # else /* ! defined YYDEBUG */ # define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[ -# endif /* ! defined ]b4_api_PREFIX[DEBUG */ +# endif /* ! defined YYDEBUG */ #endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl ]) From e73ac5a09b54ad2c1e4169d7a5e309f7cf32633f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 09:34:00 +0200 Subject: [PATCH 37/46] parse-gram: update the Bison interface * src/parse-gram.y (%pure-parser, %name-prefix): Replace with... (%define api.pure, %define api.prefix) * src/location.h, src/scan-gram.h: Adjust to api.prefix. --- src/location.h | 2 +- src/parse-gram.y | 12 ++++++------ src/scan-gram.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/location.h b/src/location.h index 4c2b410d..5ebb92e3 100644 --- a/src/location.h +++ b/src/location.h @@ -88,7 +88,7 @@ typedef struct } location; -#define YYLTYPE location +#define GRAM_LTYPE location #define EMPTY_LOCATION_INIT {{NULL, 0, 0}, {NULL, 0, 0}} extern location const empty_location; diff --git a/src/parse-gram.y b/src/parse-gram.y index 3120bfc2..6a49923c 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -94,14 +94,14 @@ current_lhs(symbol *sym, location loc, named_ref *ref) %} %debug -%verbose -%defines -%locations -%pure-parser -%error-verbose +%define api.prefix "gram_" +%define api.pure %define parse.lac full -%name-prefix="gram_" +%defines +%error-verbose %expect 0 +%locations +%verbose %initial-action { diff --git a/src/scan-gram.h b/src/scan-gram.h index ed973c78..72138a27 100644 --- a/src/scan-gram.h +++ b/src/scan-gram.h @@ -32,7 +32,7 @@ void gram_scanner_last_string_free (void); extern FILE *gram_out; extern int gram_lineno; -# define GRAM_LEX_DECL int gram_lex (YYSTYPE *val, location *loc) +# define GRAM_LEX_DECL int gram_lex (GRAM_STYPE *val, location *loc) GRAM_LEX_DECL; #endif /* !SCAN_GRAM_H_ */ From 20df0160bc32607758065361f3444cfb591b19a6 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 09:42:03 +0200 Subject: [PATCH 38/46] regen --- src/parse-gram.c | 126 +++++++++++++++++++++++++---------------------- src/parse-gram.h | 50 +++++++++++-------- 2 files changed, 97 insertions(+), 79 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 148ef761..56139fd6 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.3.3-b10d3. */ +/* A Bison parser, made by GNU Bison 2.6.4.4-8c79c-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.3.3-b10d3" +#define YYBISON_VERSION "2.6.4.4-8c79c-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,7 +58,9 @@ /* Pull parsers. */ #define YYPULL 1 - +/* Substitute the type names. */ +#define YYSTYPE GRAM_STYPE +#define YYLTYPE GRAM_LTYPE /* Substitute the variable and function names. */ #define yyparse gram_parse #define yylex gram_lex @@ -167,7 +169,7 @@ current_lhs(symbol *sym, location loc, named_ref *ref) #define YYTYPE_UINT8 uint_fast8_t /* Line 358 of yacc.c */ -#line 171 "parse-gram.c" +#line 173 "parse-gram.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -190,19 +192,27 @@ current_lhs(symbol *sym, location loc, named_ref *ref) #ifndef YY_GRAM_Y_TAB_H_INCLUDED # define YY_GRAM_Y_TAB_H_INCLUDED /* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG +#ifndef GRAM_DEBUG +# if defined YYDEBUG +# if YYDEBUG +# define GRAM_DEBUG 1 +# else +# define GRAM_DEBUG 0 +# endif +# else /* ! defined YYDEBUG */ +# define GRAM_DEBUG 1 +# endif /* ! defined YYDEBUG */ +#endif /* ! defined GRAM_DEBUG */ +#if GRAM_DEBUG extern int gram_debug; #endif /* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE +#ifndef GRAM_TOKENTYPE +# define GRAM_TOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ - enum yytokentype { + enum gram_tokentype { GRAM_EOF = 0, STRING = 258, INT = 259, @@ -321,8 +331,8 @@ extern int gram_debug; -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE +#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED +typedef union GRAM_STYPE { /* Line 374 of yacc.c */ #line 115 "parse-gram.y" @@ -339,24 +349,24 @@ typedef union YYSTYPE /* Line 374 of yacc.c */ -#line 343 "parse-gram.c" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 +#line 353 "parse-gram.c" +} GRAM_STYPE; +# define GRAM_STYPE_IS_TRIVIAL 1 +# define gram_stype GRAM_STYPE /* obsolescent; will be withdrawn */ +# define GRAM_STYPE_IS_DECLARED 1 #endif -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE +#if ! defined GRAM_LTYPE && ! defined GRAM_LTYPE_IS_DECLARED +typedef struct GRAM_LTYPE { int first_line; int first_column; int last_line; int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 +} GRAM_LTYPE; +# define gram_ltype GRAM_LTYPE /* obsolescent; will be withdrawn */ +# define GRAM_LTYPE_IS_DECLARED 1 +# define GRAM_LTYPE_IS_TRIVIAL 1 #endif @@ -379,7 +389,7 @@ int gram_parse (); /* Copy the second part of user declarations. */ /* Line 377 of yacc.c */ -#line 383 "parse-gram.c" +#line 393 "parse-gram.c" #ifdef short # undef short @@ -514,8 +524,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \ + && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -632,7 +642,7 @@ static const yytype_uint8 yytranslate[] = 55, 56, 57 }; -#if YYDEBUG +#if GRAM_DEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint16 yyprhs[] = @@ -700,7 +710,7 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 1 +#if GRAM_DEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -993,7 +1003,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1013,7 +1023,7 @@ while (YYID (0)) #endif /* Enable debugging if requested. */ -#if YYDEBUG +#if GRAM_DEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ @@ -1074,126 +1084,126 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 205 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); }; /* Line 833 of yacc.c */ -#line 1078 "parse-gram.c" +#line 1088 "parse-gram.c" break; case 4: /* "integer" */ /* Line 833 of yacc.c */ #line 217 "parse-gram.y" { fprintf (stderr, "%d", ((*yyvaluep).integer)); }; /* Line 833 of yacc.c */ -#line 1085 "parse-gram.c" +#line 1095 "parse-gram.c" break; case 43: /* "{...}" */ /* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); }; /* Line 833 of yacc.c */ -#line 1092 "parse-gram.c" +#line 1102 "parse-gram.c" break; case 44: /* "[identifier]" */ /* Line 833 of yacc.c */ #line 212 "parse-gram.y" { fprintf (stderr, "[%s]", ((*yyvaluep).uniqstr)); }; /* Line 833 of yacc.c */ -#line 1099 "parse-gram.c" +#line 1109 "parse-gram.c" break; case 45: /* "char" */ /* Line 833 of yacc.c */ #line 199 "parse-gram.y" { fputs (char_name (((*yyvaluep).character)), stderr); }; /* Line 833 of yacc.c */ -#line 1106 "parse-gram.c" +#line 1116 "parse-gram.c" break; case 46: /* "epilogue" */ /* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 833 of yacc.c */ -#line 1113 "parse-gram.c" +#line 1123 "parse-gram.c" break; case 48: /* "identifier" */ /* Line 833 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; /* Line 833 of yacc.c */ -#line 1120 "parse-gram.c" +#line 1130 "parse-gram.c" break; case 49: /* "identifier:" */ /* Line 833 of yacc.c */ #line 213 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); }; /* Line 833 of yacc.c */ -#line 1127 "parse-gram.c" +#line 1137 "parse-gram.c" break; case 52: /* "%{...%}" */ /* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 833 of yacc.c */ -#line 1134 "parse-gram.c" +#line 1144 "parse-gram.c" break; case 54: /* "type" */ /* Line 833 of yacc.c */ #line 214 "parse-gram.y" { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); }; /* Line 833 of yacc.c */ -#line 1141 "parse-gram.c" +#line 1151 "parse-gram.c" break; case 71: /* symbol.prec */ /* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 833 of yacc.c */ -#line 1148 "parse-gram.c" +#line 1158 "parse-gram.c" break; case 84: /* variable */ /* Line 833 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; /* Line 833 of yacc.c */ -#line 1155 "parse-gram.c" +#line 1165 "parse-gram.c" break; case 85: /* content.opt */ /* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 833 of yacc.c */ -#line 1162 "parse-gram.c" +#line 1172 "parse-gram.c" break; case 86: /* braceless */ /* Line 833 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 833 of yacc.c */ -#line 1169 "parse-gram.c" +#line 1179 "parse-gram.c" break; case 87: /* id */ /* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 833 of yacc.c */ -#line 1176 "parse-gram.c" +#line 1186 "parse-gram.c" break; case 88: /* id_colon */ /* Line 833 of yacc.c */ #line 221 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); }; /* Line 833 of yacc.c */ -#line 1183 "parse-gram.c" +#line 1193 "parse-gram.c" break; case 89: /* symbol */ /* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 833 of yacc.c */ -#line 1190 "parse-gram.c" +#line 1200 "parse-gram.c" break; case 90: /* string_as_id */ /* Line 833 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 833 of yacc.c */ -#line 1197 "parse-gram.c" +#line 1207 "parse-gram.c" break; default: break; @@ -1302,12 +1312,12 @@ do { \ /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; -#else /* !YYDEBUG */ +#else /* !GRAM_DEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ +#endif /* !GRAM_DEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ @@ -1338,7 +1348,7 @@ int yydebug; required. Return 1 if memory is exhausted. */ static int yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, -#if YYDEBUG +#if GRAM_DEBUG char const *yydebug_prefix, char const *yydebug_suffix, #endif @@ -1441,7 +1451,7 @@ do { \ the parser stacks to try to find a new initial context in which the current lookahead is syntactically acceptable. If it fails to find such a context, it discards the lookahead. */ -#if YYDEBUG +#if GRAM_DEBUG # define YY_LAC_DISCARD(Event) \ do { \ if (yy_lac_established) \ @@ -1544,7 +1554,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, else { if (yy_lac_stack_realloc (yyes_capacity, 1, -#if YYDEBUG +#if GRAM_DEBUG " (", ")", #endif yyes, yyesa, &yyesp, yyes_prev)) @@ -1746,7 +1756,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yysize = yysize1; } } -# if YYDEBUG +# if GRAM_DEBUG else if (yydebug) YYFPRINTF (stderr, "No expected tokens.\n"); # endif @@ -1984,7 +1994,7 @@ YYLTYPE yylloc; yylsp = yyls; YYLVAL_INITIALIZE (); -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -2000,7 +2010,7 @@ YYLTYPE yylloc; boundary_set (&yylloc.end, current_file, 1, 1); } /* Line 1596 of yacc.c */ -#line 2004 "parse-gram.c" +#line 2014 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2888,7 +2898,7 @@ yyreduce: /* Line 1813 of yacc.c */ -#line 2892 "parse-gram.c" +#line 2902 "parse-gram.c" default: break; } if (yychar_backup != yychar) diff --git a/src/parse-gram.h b/src/parse-gram.h index 455a7683..a2c9934b 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.3.3-b10d3. */ +/* A Bison parser, made by GNU Bison 2.6.4.4-8c79c-dirty. */ /* Bison interface for Yacc-like parsers in C @@ -33,19 +33,27 @@ #ifndef YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED # define YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED /* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG +#ifndef GRAM_DEBUG +# if defined YYDEBUG +# if YYDEBUG +# define GRAM_DEBUG 1 +# else +# define GRAM_DEBUG 0 +# endif +# else /* ! defined YYDEBUG */ +# define GRAM_DEBUG 1 +# endif /* ! defined YYDEBUG */ +#endif /* ! defined GRAM_DEBUG */ +#if GRAM_DEBUG extern int gram_debug; #endif /* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE +#ifndef GRAM_TOKENTYPE +# define GRAM_TOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ - enum yytokentype { + enum gram_tokentype { GRAM_EOF = 0, STRING = 258, INT = 259, @@ -164,8 +172,8 @@ extern int gram_debug; -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE +#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED +typedef union GRAM_STYPE { /* Line 2077 of yacc.c */ #line 115 "parse-gram.y" @@ -182,24 +190,24 @@ typedef union YYSTYPE /* Line 2077 of yacc.c */ -#line 186 "parse-gram.h" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 +#line 194 "parse-gram.h" +} GRAM_STYPE; +# define GRAM_STYPE_IS_TRIVIAL 1 +# define gram_stype GRAM_STYPE /* obsolescent; will be withdrawn */ +# define GRAM_STYPE_IS_DECLARED 1 #endif -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE +#if ! defined GRAM_LTYPE && ! defined GRAM_LTYPE_IS_DECLARED +typedef struct GRAM_LTYPE { int first_line; int first_column; int last_line; int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 +} GRAM_LTYPE; +# define gram_ltype GRAM_LTYPE /* obsolescent; will be withdrawn */ +# define GRAM_LTYPE_IS_DECLARED 1 +# define GRAM_LTYPE_IS_TRIVIAL 1 #endif From 94843f0aa3d347ed66d09bc8552c3f6c856088c0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 12:28:35 +0200 Subject: [PATCH 39/46] tests: restore the tests on -Werror When run as /bin/sh, Bash sets the shell variable POSIXLY_CORRECT to y. The test suite checks for the envvar POSIXLY_CORRECT to turn of some tests not supported in POSIX mode. Restore these tests. Reported by the Hydra build farm, from Rob Vermaas. * tests/local.at (AT_BISON_CHECK_WARNINGS_): Check the envvar POSIXLY_CORRECT, not the shell variable. --- tests/local.at | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/local.at b/tests/local.at index 036b0a1d..97107a55 100644 --- a/tests/local.at +++ b/tests/local.at @@ -462,10 +462,14 @@ m4_define([AT_BISON_CHECK_WARNINGS], [m4_null_if([$2], [AT_BISON_CHECK_WARNINGS_($@)])])]) m4_define([AT_BISON_CHECK_WARNINGS_], -[[# Defining POSIXLY_CORRECT causes bison to complain if options -# are added after the grammar file name, so skip these checks -# in that case. -if test -z "${POSIXLY_CORRECT+set}"; then +[[# Defining POSIXLY_CORRECT causes bison to complain if options are +# added after the grammar file name, so skip these checks in that +# case. +# +# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched +# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not +# the environment variable. +if env | grep '^POSIXLY_CORRECT=' >/dev/null; then :; else ]AT_SAVE_SPECIAL_FILES[ # To avoid expanding it repeatedly, store specified stdout. From 324a5576515921a9c41913833cacde6dadee303a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 14:26:09 +0200 Subject: [PATCH 40/46] tests: don't use options that Clang does not support * configure.ac (WARN_CFLAGS, WARN_CXXFLAGS): Do not include options that Clang does not support. --- configure.ac | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4cc9ef91..651fa139 100644 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,18 @@ if test "$enable_gcc_warnings" = yes; then -Wshadow -Wstrict-prototypes' warn_cxx='-Wnoexcept' AC_LANG_PUSH([C]) + # Clang supports many of GCC's -W options, but only issues warnings + # on the ones it does not recognize. In that case, gl_WARN_ADD + # thinks the option is supported, and unknown options are then added + # to CFLAGS. But then, when -Werror is added in the test suite for + # instance, the warning about the unknown option turns into an + # error. + # + # This should be addressed by gnulib's gl_WARN_ADD, but in the + # meanwhile, turn warnings about unknown options into errors in + # CFLAGS, and restore CFLAGS after the tests. + save_CFLAGS=$CFLAGS + gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS]) for i in $warn_common $warn_c; do gl_WARN_ADD([$i], [WARN_CFLAGS]) @@ -80,19 +92,23 @@ if test "$enable_gcc_warnings" = yes; then # Warnings for the test suite only. gl_WARN_ADD([-Wundef], [WARN_CFLAGS_TEST]) gl_WARN_ADD([-pedantic], [WARN_CFLAGS_TEST]) + CFLAGS=$save_CFLAGS AC_LANG_POP([C]) AC_LANG_PUSH([C++]) + save_CXXFLAGS=$CXXFLAGS + gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS]) for i in $warn_common $warn_cxx; do gl_WARN_ADD([$i], [WARN_CXXFLAGS]) done - gl_WARN_ADD([ -Wzero-as-null-pointer-constant], [WARN_CXXFLAGS], + gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS], [AC_LANG_PROGRAM([], [nullptr])]) gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS]) # Warnings for the test suite only. gl_WARN_ADD([-Wundef], [WARN_CXXFLAGS_TEST]) gl_WARN_ADD([-pedantic], [WARN_CXXFLAGS_TEST]) + CXXFLAGS=$save_CXXFLAGS AC_LANG_POP([C++]) fi From 54dccdb2ca8bafc7c7556c6b1426caa8feaa5ebe Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 25 Oct 2012 14:42:24 +0200 Subject: [PATCH 41/46] tests: address a warning from GCC 4.4 236. torture.at:465: testing Exploding the Stack Size with Alloca ... ../../../tests/torture.at:474: bison -o input.c input.y ../../../tests/torture.at:474: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS stderr: cc1: warnings being treated as errors input.y: In function 'main': input.y:60: error: 'status' may be used uninitialized in this function * tests/torture.at (AT_DATA_STACK_TORTURE): Initial status to avoid the previous error. --- tests/torture.at | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/torture.at b/tests/torture.at index a5e244b6..5aa18900 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -431,7 +431,7 @@ int main (int argc, const char **argv) { YYSTYPE yylval_init = get_args (argc, argv); - int status; + int status = 0; int count; ]m4_bmatch([$2], [api.push-pull both], [[ yypstate *ps = yypstate_new (); From e0992e5458708f4e57f0ddc387ed5e22f3b9953e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 26 Oct 2012 14:16:29 +0200 Subject: [PATCH 42/46] maint: be compilable with GCC 4.0 The "shadows a global declaration" warning in GCC 4.0 was a bit annoying. It does not like that a type name be used in a prototype of a function (not the implementation, just the declaration): In file included from src/LR0.c:38: src/reader.h:56: warning: declaration of 'named_ref' shadows a global declaration src/named-ref.h:35: warning: shadowed declaration is here It does not like either when a global variable name is used in a prototype. Flex 2.5.37 generates this prototype: void gram_set_debug (int debug_flag ); * src/getargs.h, src/getargs.c (debug_flag): Rename as... (debug): this. Adjust dependencies. * src/reader.h: Don't use "named_ref" as a formal argument name. --- src/getargs.c | 4 ++-- src/getargs.h | 2 +- src/output.c | 2 +- src/parse-gram.y | 2 +- src/reader.h | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/getargs.c b/src/getargs.c index 70a25e03..64905694 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -49,7 +49,7 @@ #include "quote.h" #include "uniqstr.h" -bool debug_flag; +bool debug; bool defines_flag; bool graph_flag; bool xml_flag; @@ -664,7 +664,7 @@ getargs (int argc, char *argv[]) break; case 't': - debug_flag = true; + debug = true; break; case 'v': diff --git a/src/getargs.h b/src/getargs.h index 22538cf3..ef97822a 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -34,7 +34,7 @@ extern int skeleton_prio; /* for -I */ extern char const *include; -extern bool debug_flag; /* for -t */ +extern bool debug; /* for -t */ extern bool defines_flag; /* for -d */ extern bool graph_flag; /* for -g */ extern bool xml_flag; /* for -x */ diff --git a/src/output.c b/src/output.c index e77a2d1a..4a4d62d1 100644 --- a/src/output.c +++ b/src/output.c @@ -628,7 +628,7 @@ prepare (void) use_push_for_pull_flag = true; /* Flags. */ - MUSCLE_INSERT_BOOL ("debug_flag", debug_flag); + MUSCLE_INSERT_BOOL ("debug_flag", debug); MUSCLE_INSERT_BOOL ("defines_flag", defines_flag); MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose); MUSCLE_INSERT_BOOL ("glr_flag", glr_parser); diff --git a/src/parse-gram.y b/src/parse-gram.y index 6a49923c..5f77a5bd 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -252,7 +252,7 @@ prologue_declaration: plain_code.code, @1); code_scanner_last_string_free (); } -| "%debug" { debug_flag = true; } +| "%debug" { debug = true; } | "%define" variable content.opt { muscle_percent_define_insert ($2, @2, $3, diff --git a/src/reader.h b/src/reader.h index 3722a7f5..e154deb0 100644 --- a/src/reader.h +++ b/src/reader.h @@ -51,9 +51,9 @@ void grammar_current_rule_prec_set (symbol *precsym, location loc); void grammar_current_rule_dprec_set (int dprec, location loc); void grammar_current_rule_merge_set (uniqstr name, location loc); void grammar_current_rule_symbol_append (symbol *sym, location loc, - named_ref *named_ref); + named_ref *nref); void grammar_current_rule_action_append (const char *action, location loc, - named_ref *named_ref); + named_ref *nref); void reader (void); void free_merger_functions (void); From 5fb07775a1458defbd958fd4d1b59a49a49a57bf Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 26 Oct 2012 10:31:55 +0200 Subject: [PATCH 43/46] yacc.c: do not define location support when not using locations * data/yacc.c (YYLLOC_DEFAULT, YYRHSLOC): Don't define when not using locations. --- data/yacc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/data/yacc.c b/data/yacc.c index faf1d786..1b3dc752 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -769,10 +769,9 @@ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 +]b4_locations_if([[ ]b4_yylloc_default_define[ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) -]b4_locations_if([[ - /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know @@ -787,18 +786,14 @@ while (YYID (0)) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif -#endif]], [[ - - -/* This macro is provided for backward compatibility. */ - +#endif]], +[[/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif]])[ /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM) #else From bb8674a53789875e36d2eee5aacc42b1bc0c2889 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 26 Oct 2012 14:27:32 +0200 Subject: [PATCH 44/46] regen --- src/parse-gram.c | 306 +++++++++++++++++++++++------------------------ src/parse-gram.h | 6 +- 2 files changed, 155 insertions(+), 157 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 56139fd6..2c08b106 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.4.4-8c79c-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.4.11-d01f-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.4.4-8c79c-dirty" +#define YYBISON_VERSION "2.6.4.11-d01f-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -970,6 +970,7 @@ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 + /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ @@ -996,8 +997,6 @@ while (YYID (0)) #define YYRHSLOC(Rhs, K) ((Rhs)[K]) - - /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ @@ -1015,7 +1014,6 @@ while (YYID (0)) /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) #else @@ -1080,130 +1078,130 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) switch (yytype) { case 3: /* "string" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 205 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); }; -/* Line 833 of yacc.c */ -#line 1088 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1086 "parse-gram.c" break; case 4: /* "integer" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 217 "parse-gram.y" { fprintf (stderr, "%d", ((*yyvaluep).integer)); }; -/* Line 833 of yacc.c */ -#line 1095 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1093 "parse-gram.c" break; case 43: /* "{...}" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); }; -/* Line 833 of yacc.c */ -#line 1102 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1100 "parse-gram.c" break; case 44: /* "[identifier]" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 212 "parse-gram.y" { fprintf (stderr, "[%s]", ((*yyvaluep).uniqstr)); }; -/* Line 833 of yacc.c */ -#line 1109 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1107 "parse-gram.c" break; case 45: /* "char" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 199 "parse-gram.y" { fputs (char_name (((*yyvaluep).character)), stderr); }; -/* Line 833 of yacc.c */ -#line 1116 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1114 "parse-gram.c" break; case 46: /* "epilogue" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 833 of yacc.c */ -#line 1123 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1121 "parse-gram.c" break; case 48: /* "identifier" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; -/* Line 833 of yacc.c */ -#line 1130 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1128 "parse-gram.c" break; case 49: /* "identifier:" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 213 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); }; -/* Line 833 of yacc.c */ -#line 1137 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1135 "parse-gram.c" break; case 52: /* "%{...%}" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 833 of yacc.c */ -#line 1144 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1142 "parse-gram.c" break; case 54: /* "type" */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 214 "parse-gram.y" { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); }; -/* Line 833 of yacc.c */ -#line 1151 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1149 "parse-gram.c" break; case 71: /* symbol.prec */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 833 of yacc.c */ -#line 1158 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1156 "parse-gram.c" break; case 84: /* variable */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 211 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); }; -/* Line 833 of yacc.c */ -#line 1165 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1163 "parse-gram.c" break; case 85: /* content.opt */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 833 of yacc.c */ -#line 1172 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1170 "parse-gram.c" break; case 86: /* braceless */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 207 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; -/* Line 833 of yacc.c */ -#line 1179 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1177 "parse-gram.c" break; case 87: /* id */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 833 of yacc.c */ -#line 1186 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1184 "parse-gram.c" break; case 88: /* id_colon */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 221 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); }; -/* Line 833 of yacc.c */ -#line 1193 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1191 "parse-gram.c" break; case 89: /* symbol */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 833 of yacc.c */ -#line 1200 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1198 "parse-gram.c" break; case 90: /* string_as_id */ -/* Line 833 of yacc.c */ +/* Line 828 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; -/* Line 833 of yacc.c */ -#line 1207 "parse-gram.c" +/* Line 828 of yacc.c */ +#line 1205 "parse-gram.c" break; default: break; @@ -2001,7 +1999,7 @@ YYLTYPE yylloc; #endif /* User initialization code. */ -/* Line 1596 of yacc.c */ +/* Line 1591 of yacc.c */ #line 107 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -2009,8 +2007,8 @@ YYLTYPE yylloc; boundary_set (&yylloc.start, current_file, 1, 1); boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1596 of yacc.c */ -#line 2014 "parse-gram.c" +/* Line 1591 of yacc.c */ +#line 2012 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2204,7 +2202,7 @@ yyreduce: switch (yyn) { case 6: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 246 "parse-gram.y" { code_props plain_code; @@ -2218,13 +2216,13 @@ yyreduce: break; case 7: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 255 "parse-gram.y" - { debug_flag = true; } + { debug = true; } break; case 8: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 257 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), @@ -2233,13 +2231,13 @@ yyreduce: break; case 9: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 261 "parse-gram.y" { defines_flag = true; } break; case 10: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 263 "parse-gram.y" { defines_flag = true; @@ -2248,37 +2246,37 @@ yyreduce: break; case 11: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 267 "parse-gram.y" { error_verbose = true; } break; case 12: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 268 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 269 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 270 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 271 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 273 "parse-gram.y" { nondeterministic_parser = true; @@ -2287,7 +2285,7 @@ yyreduce: break; case 17: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 278 "parse-gram.y" { code_props action; @@ -2300,67 +2298,67 @@ yyreduce: break; case 18: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 286 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 287 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 288 "parse-gram.y" { locations_flag = true; } break; case 21: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 289 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 290 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 291 "parse-gram.y" { no_lines_flag = true; } break; case 24: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 292 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 293 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 294 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 295 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 297 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use @@ -2379,13 +2377,13 @@ yyreduce: break; case 29: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 311 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 313 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); @@ -2413,25 +2411,25 @@ yyreduce: break; case 31: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 336 "parse-gram.y" { token_table_flag = true; } break; case 32: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 337 "parse-gram.y" { report_flag |= report_states; } break; case 33: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 338 "parse-gram.y" { yacc_flag = true; } break; case 37: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 346 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); @@ -2439,7 +2437,7 @@ yyreduce: break; case 38: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 350 "parse-gram.y" { code_props code; @@ -2455,7 +2453,7 @@ yyreduce: break; case 39: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 362 "parse-gram.y" { code_props code; @@ -2471,7 +2469,7 @@ yyreduce: break; case 40: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 374 "parse-gram.y" { default_prec = true; @@ -2479,7 +2477,7 @@ yyreduce: break; case 41: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 378 "parse-gram.y" { default_prec = false; @@ -2487,7 +2485,7 @@ yyreduce: break; case 42: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 382 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes @@ -2498,7 +2496,7 @@ yyreduce: break; case 43: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 389 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2507,19 +2505,19 @@ yyreduce: break; case 44: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 403 "parse-gram.y" {} break; case 45: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 404 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 409 "parse-gram.y" { union_seen = true; @@ -2529,13 +2527,13 @@ yyreduce: break; case 47: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 420 "parse-gram.y" { current_class = nterm_sym; } break; case 48: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 421 "parse-gram.y" { current_class = unknown_sym; @@ -2544,13 +2542,13 @@ yyreduce: break; case 49: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 425 "parse-gram.y" { current_class = token_sym; } break; case 50: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 426 "parse-gram.y" { current_class = unknown_sym; @@ -2559,7 +2557,7 @@ yyreduce: break; case 51: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 431 "parse-gram.y" { symbol_list *list; @@ -2571,7 +2569,7 @@ yyreduce: break; case 52: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 442 "parse-gram.y" { symbol_list *list; @@ -2587,109 +2585,109 @@ yyreduce: break; case 53: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 456 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 457 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 458 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 462 "parse-gram.y" { current_type = NULL; } break; case 57: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 463 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 469 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 471 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 60: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 475 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 476 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } break; case 62: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 482 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 484 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 64: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 488 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 489 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 66: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 493 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 67: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 494 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 68: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 495 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 496 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 502 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); @@ -2698,7 +2696,7 @@ yyreduce: break; case 71: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 507 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); @@ -2707,7 +2705,7 @@ yyreduce: break; case 72: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 512 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2717,7 +2715,7 @@ yyreduce: break; case 73: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 518 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2727,7 +2725,7 @@ yyreduce: break; case 74: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 524 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); @@ -2738,7 +2736,7 @@ yyreduce: break; case 81: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 554 "parse-gram.y" { yyerrok; @@ -2746,13 +2744,13 @@ yyreduce: break; case 82: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 560 "parse-gram.y" { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); } break; case 83: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 561 "parse-gram.y" { /* Free the current lhs. */ @@ -2761,86 +2759,86 @@ yyreduce: break; case 84: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 568 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 569 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 575 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } break; case 88: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 578 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 89: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 580 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 90: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 582 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 584 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 586 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 590 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 592 "parse-gram.y" { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 96: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 604 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 609 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 610 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 621 "parse-gram.y" { code_props plain_code; @@ -2853,13 +2851,13 @@ yyreduce: break; case 101: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 641 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 643 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); @@ -2869,13 +2867,13 @@ yyreduce: break; case 103: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 651 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 663 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); @@ -2884,7 +2882,7 @@ yyreduce: break; case 108: -/* Line 1813 of yacc.c */ +/* Line 1808 of yacc.c */ #line 672 "parse-gram.y" { code_props plain_code; @@ -2897,8 +2895,8 @@ yyreduce: break; -/* Line 1813 of yacc.c */ -#line 2902 "parse-gram.c" +/* Line 1808 of yacc.c */ +#line 2900 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3148,7 +3146,7 @@ yyreturn: } -/* Line 2076 of yacc.c */ +/* Line 2071 of yacc.c */ #line 682 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index a2c9934b..39e29986 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.4.4-8c79c-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.4.11-d01f-dirty. */ /* Bison interface for Yacc-like parsers in C @@ -175,7 +175,7 @@ extern int gram_debug; #if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED typedef union GRAM_STYPE { -/* Line 2077 of yacc.c */ +/* Line 2072 of yacc.c */ #line 115 "parse-gram.y" symbol *symbol; @@ -189,7 +189,7 @@ typedef union GRAM_STYPE named_ref *named_ref; -/* Line 2077 of yacc.c */ +/* Line 2072 of yacc.c */ #line 194 "parse-gram.h" } GRAM_STYPE; # define GRAM_STYPE_IS_TRIVIAL 1 From e20daefe9875f82ba581fdf1f8cce411dd87ff0e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 24 Oct 2012 16:59:30 +0200 Subject: [PATCH 45/46] maint: use gendocs's new -I option * gnulib: Update gendocs. * cfg.mk (gendocs_options_): New. --- cfg.mk | 1 + gnulib | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 3a70379c..9f11f377 100644 --- a/cfg.mk +++ b/cfg.mk @@ -24,6 +24,7 @@ regen: _version # Used in maint.mk's web-manual rule manual_title = The Yacc-compatible Parser Generator +gendocs_options_ = -I $(abs_top_srcdir)/doc -I $(abs_top_builddir)/doc # It's useful to run maintainer-*check* targets during development, but we # don't want to wait on a recompile because of an update to $(VERSION). Thus, diff --git a/gnulib b/gnulib index d245e6dd..0e6a848c 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f +Subproject commit 0e6a848c8cd1e9442e3794c7dcd2f535ea9797c6 From ead713a1767e741f7e5f79d7dc949c0ea837c173 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 24 Oct 2012 16:59:41 +0200 Subject: [PATCH 46/46] doc: minor style change * doc/figs/example-reduce.txt: here. --- doc/figs/example-reduce.txt | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/doc/figs/example-reduce.txt b/doc/figs/example-reduce.txt index 19df1564..d4e8219f 100644 --- a/doc/figs/example-reduce.txt +++ b/doc/figs/example-reduce.txt @@ -1,15 +1,13 @@ - .------------------. - | State 1 | - | 3 a: "0" . [";"] | - | 4 b: "0" . ["."] | - `------------------' - / \ - / \ ["."] - / \ - v v - . . - / \ / \ - / R \ / R \ -(green) \ 3 / \ 4 / (green) - \ / \ / - . . + .------------------. + | State 1 | + | 3 a: "0" . [";"] | + | 4 b: "0" . ["."] | + `------------------' + / \ + / \ ["."] + / \ + v v + / \ / \ + / R \ / R \ +(green) \ 3 / \ 4 / (green) + \ / \ /