From aaf6103699d055b5404eff3b1eb70c2427de6530 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 20 Jul 2012 10:00:51 +0200 Subject: [PATCH 01/29] news: fix typo. * NEWS: here. Reported by Ben Pfaff. --- NEWS | 2 +- THANKS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index be9ed7ca..53ae9647 100644 --- a/NEWS +++ b/NEWS @@ -10,7 +10,7 @@ GNU Bison NEWS The next major release of Bison will drop support for the following deprecated features. Please report disagreements to bug-bison@gnu.org. -*** K&C parsers +*** K&R C parsers Support for generating parsers in K&R C will be removed. Parsers generated for C support ISO C90, and are tested with ISO C99 and ISO C11 diff --git a/THANKS b/THANKS index 284c5a91..75037b1f 100644 --- a/THANKS +++ b/THANKS @@ -13,6 +13,7 @@ Anthony Heading ajrh@ajrh.net Arnold Robbins arnold@skeeve.com Art Haas ahaas@neosoft.com Baron Schwartz baron@sequent.org +Ben Pfaff blp@cs.stanford.edu Benoit Perrot benoit.perrot@epita.fr Bernd Kiefer kiefer@dfki.de Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be From 733d4546cee292f148b8a3ff1d33bc38066338d8 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sat, 21 Jul 2012 17:24:23 +0200 Subject: [PATCH 02/29] configure: fix botched quoting * configure.ac: In the AC_SUBST call on 'VALGRIND_PREBISON'. Without this change, when running ./configure, I see: ... checking for valgrind... valgrind ./configure: line 35221: -q: command not found checking for Java compiler... gcj -C -fsource=1.3 -ftarget=1.4 ... Copyright-paperwork-exempt: yes Signed-off-by: Stefano Lattarini --- .gitignore | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a81896f1..bfb7caf4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /INSTALL /Makefile /Makefile.in +/README-release /_* /a.exe /a.out @@ -31,4 +32,3 @@ /patches /releases /stamp-h* -/README-release diff --git a/configure.ac b/configure.ac index 2773167a..b9d2ea69 100644 --- a/configure.ac +++ b/configure.ac @@ -170,7 +170,7 @@ case $VALGRIND:$host_os in # VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind' VALGRIND=;; *:*) - AC_SUBST([VALGRIND_PREBISON], [$VALGRIND -q]);; + AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]);; esac AM_MISSING_PROG([AUTOM4TE], [autom4te]) From f9b8635172493ffa1593315b71116a8c84bed47e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 24 Jul 2012 13:24:20 +0200 Subject: [PATCH 03/29] doc: avoid problems with case insensitive file systems makeinfo --html generates index.html, and the node "Index" will result in Index.html. On case insensitive file systems, such as on Mac OS X by default, this results in a single, invalid, file (Texinfo 4.13). See http://lists.gnu.org/archive/html/bug-texinfo/2012-07/msg00032.html * doc/bison.texi (Index): Rename as... (Index of Terms): this. --- doc/bison.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index 6346bf03..6156b41f 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -110,7 +110,7 @@ Reference sections: * Glossary:: Basic concepts are explained. * Copying This Manual:: License for copying this manual. * Bibliography:: Publications cited in this manual. -* Index:: Cross-references to the text. +* Index of Terms:: Cross-references to the text. @detailmenu --- The Detailed Node Listing --- @@ -11704,8 +11704,8 @@ London, Department of Computer Science, TR-00-12 (December 2000). @uref{http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps} @end table -@node Index -@unnumbered Index +@node Index of Terms +@unnumbered Index of Terms @printindex cp From 9b8585410ae6c83b558aab76579bdf8506853662 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 25 Jul 2012 17:57:57 +0200 Subject: [PATCH 04/29] maint: style changes * src/scan-code.l: Remove useless braces. Formatting changes. Prefer NULL to 0. * src/muscle-tab.c, src/system.h: Formatting changes. --- src/muscle-tab.c | 34 ++++++++-------- src/muscle-tab.h | 102 +++++++++++++++++++++++------------------------ src/scan-code.l | 18 ++++----- src/system.h | 68 +++++++++++++++---------------- 4 files changed, 110 insertions(+), 112 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index c9168285..199049b5 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -284,23 +284,23 @@ muscle_location_grow (char const *key, location loc) muscle_grow (key, "]]", ""); } -#define MUSCLE_COMMON_DECODE(Value) \ - case '$': \ - aver (*++(Value) == ']'); \ - aver (*++(Value) == '['); \ - obstack_sgrow (&muscle_obstack, "$"); \ - break; \ - case '@': \ - switch (*++(Value)) \ - { \ - case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \ - case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \ - case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \ - default: aver (false); break; \ - } \ - break; \ - default: \ - obstack_1grow (&muscle_obstack, *(Value)); \ +#define MUSCLE_COMMON_DECODE(Value) \ + case '$': \ + aver (*++(Value) == ']'); \ + aver (*++(Value) == '['); \ + obstack_sgrow (&muscle_obstack, "$"); \ + break; \ + case '@': \ + switch (*++(Value)) \ + { \ + case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \ + case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \ + case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \ + default: aver (false); break; \ + } \ + break; \ + default: \ + obstack_1grow (&muscle_obstack, *(Value)); \ break; /* Reverse of MUSCLE_OBSTACK_SGROW. */ diff --git a/src/muscle-tab.h b/src/muscle-tab.h index 74563ba5..6c658be6 100644 --- a/src/muscle-tab.h +++ b/src/muscle-tab.h @@ -35,62 +35,62 @@ void muscle_free (void); /* An obstack dedicated to receive muscle keys and values. */ extern struct obstack muscle_obstack; -#define MUSCLE_INSERT_BOOL(Key, Value) \ -do { \ - int v = Value; \ - MUSCLE_INSERT_INT (Key, v); \ -} while(0) +#define MUSCLE_INSERT_BOOL(Key, Value) \ + do { \ + int v = Value; \ + MUSCLE_INSERT_INT (Key, v); \ + } while (0) -#define MUSCLE_INSERT_INT(Key, Value) \ -do { \ - obstack_fgrow1 (&muscle_obstack, "%d", Value); \ - obstack_1grow (&muscle_obstack, 0); \ - muscle_insert (Key, obstack_finish (&muscle_obstack)); \ -} while(0) +#define MUSCLE_INSERT_INT(Key, Value) \ + do { \ + obstack_fgrow1 (&muscle_obstack, "%d", Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ + } while (0) -#define MUSCLE_INSERT_LONG_INT(Key, Value) \ -do { \ - obstack_fgrow1 (&muscle_obstack, "%ld", Value); \ - obstack_1grow (&muscle_obstack, 0); \ - muscle_insert (Key, obstack_finish (&muscle_obstack)); \ -} while(0) +#define MUSCLE_INSERT_LONG_INT(Key, Value) \ + do { \ + obstack_fgrow1 (&muscle_obstack, "%ld", Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ + } while (0) -#define MUSCLE_INSERT_STRING_RAW(Key, Value) \ -do { \ - obstack_sgrow (&muscle_obstack, Value); \ - obstack_1grow (&muscle_obstack, 0); \ - muscle_insert (Key, obstack_finish (&muscle_obstack)); \ -} while(0) +#define MUSCLE_INSERT_STRING_RAW(Key, Value) \ + do { \ + obstack_sgrow (&muscle_obstack, Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ + } while (0) -#define MUSCLE_INSERT_STRING(Key, Value) \ -do { \ - MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \ - obstack_1grow (&muscle_obstack, 0); \ - muscle_insert (Key, obstack_finish (&muscle_obstack)); \ -} while(0) +#define MUSCLE_INSERT_STRING(Key, Value) \ + do { \ + MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ + } while (0) -#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \ -do { \ - char const *p; \ - for (p = Value; *p; p++) \ - switch (*p) \ - { \ - case '$': obstack_sgrow (Obstack, "$]["); break; \ - case '@': obstack_sgrow (Obstack, "@@" ); break; \ - case '[': obstack_sgrow (Obstack, "@{" ); break; \ - case ']': obstack_sgrow (Obstack, "@}" ); break; \ - default: obstack_1grow (Obstack, *p); break; \ - } \ -} while(0) +#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \ + do { \ + char const *p; \ + for (p = Value; *p; p++) \ + switch (*p) \ + { \ + case '$': obstack_sgrow (Obstack, "$]["); break; \ + case '@': obstack_sgrow (Obstack, "@@" ); break; \ + case '[': obstack_sgrow (Obstack, "@{" ); break; \ + case ']': obstack_sgrow (Obstack, "@}" ); break; \ + default: obstack_1grow (Obstack, *p); break; \ + } \ + } while (0) -#define MUSCLE_INSERT_C_STRING(Key, Value) \ -do { \ - MUSCLE_OBSTACK_SGROW (&muscle_obstack, \ - quotearg_style (c_quoting_style, \ - Value)); \ - obstack_1grow (&muscle_obstack, 0); \ - muscle_insert (Key, obstack_finish (&muscle_obstack)); \ -} while(0) +#define MUSCLE_INSERT_C_STRING(Key, Value) \ + do { \ + MUSCLE_OBSTACK_SGROW (&muscle_obstack, \ + quotearg_style (c_quoting_style, \ + Value)); \ + obstack_1grow (&muscle_obstack, 0); \ + muscle_insert (Key, obstack_finish (&muscle_obstack)); \ + } while (0) /* Append VALUE to the current value of KEY. If KEY did not already exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously @@ -110,7 +110,7 @@ void muscle_code_grow (const char *key, const char *value, location loc); muscle values are output *double* quoted, one needs to strip the first level of quotes to reach the list itself. */ void muscle_pair_list_grow (const char *muscle, - const char *a1, const char *a2); + const char *a1, const char *a2); /* In the format `[[file_name:line.column]], [[file_name:line.column]]', append LOC to MUSCLE. Use digraphs for special characters in each file name. */ diff --git a/src/scan-code.l b/src/scan-code.l index 5bcb5686..785f386d 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -181,19 +181,17 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" { "$"("<"{tag}">")?{ref} { - ref_tail_fields = 0; + ref_tail_fields = NULL; handle_action_dollar (self->rule, yytext, *loc); - if (ref_tail_fields) { + if (ref_tail_fields) obstack_sgrow (&obstack_for_string, ref_tail_fields); - } need_semicolon = true; } "@"{ref} { - ref_tail_fields = 0; + ref_tail_fields = NULL; handle_action_at (self->rule, yytext, *loc); - if (ref_tail_fields) { + if (ref_tail_fields) obstack_sgrow (&obstack_for_string, ref_tail_fields); - } need_semicolon = true; } "$" { @@ -345,7 +343,7 @@ typedef struct not visible from current midrule. */ #define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2) -static variant *variant_table = 0; +static variant *variant_table = NULL; static unsigned variant_table_size = 0; static unsigned variant_count = 0; @@ -367,7 +365,7 @@ static void variant_table_free (void) { free (variant_table); - variant_table = 0; + variant_table = NULL; variant_table_size = variant_count = 0; } @@ -410,7 +408,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index, } static const char * -get_at_spec(unsigned symbol_index) +get_at_spec (unsigned symbol_index) { static char at_buf[20]; if (symbol_index == 0) @@ -826,7 +824,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc) locations_flag = true; n = parse_ref (cp, effective_rule, effective_rule_length, - rule->midrule_parent_rhs_index, text, at_loc, '@'); + rule->midrule_parent_rhs_index, text, at_loc, '@'); switch (n) { case INVALID_REF: diff --git a/src/system.h b/src/system.h index d3c544b4..da3c97ed 100644 --- a/src/system.h +++ b/src/system.h @@ -160,36 +160,36 @@ typedef size_t uintptr_t; # define obstack_chunk_free free # include -# define obstack_sgrow(Obs, Str) \ +# define obstack_sgrow(Obs, Str) \ obstack_grow (Obs, Str, strlen (Str)) -# define obstack_fgrow1(Obs, Format, Arg1) \ -do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1); \ - obstack_grow (Obs, buf, strlen (buf)); \ -} while (0) +# define obstack_fgrow1(Obs, Format, Arg1) \ + do { \ + char buf[4096]; \ + sprintf (buf, Format, Arg1); \ + obstack_grow (Obs, buf, strlen (buf)); \ + } while (0) -# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \ -do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2); \ - obstack_grow (Obs, buf, strlen (buf)); \ -} while (0) +# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \ + do { \ + char buf[4096]; \ + sprintf (buf, Format, Arg1, Arg2); \ + obstack_grow (Obs, buf, strlen (buf)); \ + } while (0) -# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \ -do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2, Arg3); \ - obstack_grow (Obs, buf, strlen (buf)); \ -} while (0) +# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \ + do { \ + char buf[4096]; \ + sprintf (buf, Format, Arg1, Arg2, Arg3); \ + obstack_grow (Obs, buf, strlen (buf)); \ + } while (0) -# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \ -do { \ - char buf[4096]; \ - sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \ - obstack_grow (Obs, buf, strlen (buf)); \ -} while (0) +# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \ + do { \ + char buf[4096]; \ + sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \ + obstack_grow (Obs, buf, strlen (buf)); \ + } while (0) @@ -215,15 +215,15 @@ do { \ | Free a linked list. | `---------------------*/ -# define LIST_FREE(Type, List) \ -do { \ - Type *_node, *_next; \ - for (_node = List; _node; _node = _next) \ - { \ - _next = _node->next; \ - free (_node); \ - } \ -} while (0) +# define LIST_FREE(Type, List) \ + do { \ + Type *_node, *_next; \ + for (_node = List; _node; _node = _next) \ + { \ + _next = _node->next; \ + free (_node); \ + } \ + } while (0) /*---------------------------------------------. From dba9149595b908562a3eead383c064ff5e9b2c02 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 12:16:54 +0200 Subject: [PATCH 05/29] remove dead macro * src/system.h (DEFAULT_TMPDIR): Remove, unused. --- src/system.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/system.h b/src/system.h index da3c97ed..944907ec 100644 --- a/src/system.h +++ b/src/system.h @@ -205,10 +205,6 @@ typedef size_t uintptr_t; # define TAB_EXT ".tab" # endif -# ifndef DEFAULT_TMPDIR -# define DEFAULT_TMPDIR "/tmp" -# endif - /*---------------------. From 13b712d7d492da45303f20502adcf6a8c5a7afa2 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 11:19:18 +0200 Subject: [PATCH 06/29] obstack_escape: escape M4 characters * src/muscle-tab.h (MUSCLE_OBSTACK_SGROW): This is not related to muscles, so move to, and rename as... * src/system.h (obstack_escape): this. Adjust dependencies. --- src/muscle-tab.c | 10 +++++----- src/muscle-tab.h | 21 +++------------------ src/output.c | 2 +- src/system.h | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 199049b5..ce6ac252 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -178,8 +178,8 @@ muscle_syncline_grow (char const *key, location loc) { char *extension = NULL; obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line); - MUSCLE_OBSTACK_SGROW (&muscle_obstack, - quotearg_style (c_quoting_style, loc.start.file)); + obstack_escape (&muscle_obstack, + quotearg_style (c_quoting_style, loc.start.file)); obstack_sgrow (&muscle_obstack, "]])["); obstack_1grow (&muscle_obstack, 0); extension = obstack_finish (&muscle_obstack); @@ -206,9 +206,9 @@ void muscle_pair_list_grow (const char *muscle, { char *pair; obstack_sgrow (&muscle_obstack, "[[["); - MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1); + obstack_escape (&muscle_obstack, a1); obstack_sgrow (&muscle_obstack, "]], [["); - MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2); + obstack_escape (&muscle_obstack, a2); obstack_sgrow (&muscle_obstack, "]]]"); obstack_1grow (&muscle_obstack, 0); pair = obstack_finish (&muscle_obstack); @@ -263,7 +263,7 @@ void muscle_boundary_grow (char const *key, boundary bound) { char *extension; - MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file); + obstack_escape (&muscle_obstack, bound.file); obstack_1grow (&muscle_obstack, ':'); obstack_fgrow1 (&muscle_obstack, "%d", bound.line); obstack_1grow (&muscle_obstack, '.'); diff --git a/src/muscle-tab.h b/src/muscle-tab.h index 6c658be6..b8438218 100644 --- a/src/muscle-tab.h +++ b/src/muscle-tab.h @@ -64,30 +64,15 @@ extern struct obstack muscle_obstack; #define MUSCLE_INSERT_STRING(Key, Value) \ do { \ - MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \ + obstack_escape (&muscle_obstack, Value); \ obstack_1grow (&muscle_obstack, 0); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } while (0) -#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \ - do { \ - char const *p; \ - for (p = Value; *p; p++) \ - switch (*p) \ - { \ - case '$': obstack_sgrow (Obstack, "$]["); break; \ - case '@': obstack_sgrow (Obstack, "@@" ); break; \ - case '[': obstack_sgrow (Obstack, "@{" ); break; \ - case ']': obstack_sgrow (Obstack, "@}" ); break; \ - default: obstack_1grow (Obstack, *p); break; \ - } \ - } while (0) - #define MUSCLE_INSERT_C_STRING(Key, Value) \ do { \ - MUSCLE_OBSTACK_SGROW (&muscle_obstack, \ - quotearg_style (c_quoting_style, \ - Value)); \ + obstack_escape (&muscle_obstack, \ + quotearg_style (c_quoting_style, Value)); \ obstack_1grow (&muscle_obstack, 0); \ muscle_insert (Key, obstack_finish (&muscle_obstack)); \ } while (0) diff --git a/src/output.c b/src/output.c index 29e9ba84..e157460d 100644 --- a/src/output.c +++ b/src/output.c @@ -175,7 +175,7 @@ prepare_symbols (void) if (i) obstack_1grow (&format_obstack, ' '); - MUSCLE_OBSTACK_SGROW (&format_obstack, cp); + obstack_escape (&format_obstack, cp); free (cp); obstack_1grow (&format_obstack, ','); j += width; diff --git a/src/system.h b/src/system.h index 944907ec..06224596 100644 --- a/src/system.h +++ b/src/system.h @@ -192,6 +192,27 @@ typedef size_t uintptr_t; } while (0) +/* Output Str escaped for our postprocessing (i.e., escape M4 special + characters). + + For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */ + +# define obstack_escape(Obs, Str) \ + do { \ + char const *p; \ + for (p = Str; *p; p++) \ + switch (*p) \ + { \ + case '$': obstack_sgrow (Obs, "$]["); break; \ + case '@': obstack_sgrow (Obs, "@@" ); break; \ + case '[': obstack_sgrow (Obs, "@{" ); break; \ + case ']': obstack_sgrow (Obs, "@}" ); break; \ + default: obstack_1grow (Obs, *p ); break; \ + } \ + } while (0) + + + /*-----------------------------------------. | Extensions to use for the output files. | From c1cc91bdcda2844e99403e87790afa55f443e02c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 11:23:55 +0200 Subject: [PATCH 07/29] muscles: rename private functions/macros * src/muscle-tab.c (MUSCLE_COMMON_DECODE, muscle_string_decode) (muscle_location_decode): Not related to muscles, rename as... (COMMON_DECODE, string_decode, location_decode): these. --- src/muscle-tab.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index ce6ac252..c6f48669 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -284,7 +284,7 @@ muscle_location_grow (char const *key, location loc) muscle_grow (key, "]]", ""); } -#define MUSCLE_COMMON_DECODE(Value) \ +#define COMMON_DECODE(Value) \ case '$': \ aver (*++(Value) == ']'); \ aver (*++(Value) == '['); \ @@ -303,9 +303,9 @@ muscle_location_grow (char const *key, location loc) obstack_1grow (&muscle_obstack, *(Value)); \ break; -/* Reverse of MUSCLE_OBSTACK_SGROW. */ +/* Reverse of obstack_escape. */ static char * -muscle_string_decode (char const *key) +string_decode (char const *key) { char const *value; char *value_decoded; @@ -317,7 +317,7 @@ muscle_string_decode (char const *key) do { switch (*value) { - MUSCLE_COMMON_DECODE (value) + COMMON_DECODE (value) case '[': case ']': aver (false); @@ -332,7 +332,7 @@ muscle_string_decode (char const *key) /* Reverse of muscle_location_grow. */ static location -muscle_location_decode (char const *key) +location_decode (char const *key) { location loc; char const *value = muscle_find_const (key); @@ -342,7 +342,7 @@ muscle_location_decode (char const *key) while (*++value) switch (*value) { - MUSCLE_COMMON_DECODE (value) + COMMON_DECODE (value) case '[': aver (false); break; @@ -455,7 +455,7 @@ muscle_percent_define_get (char const *variable) variable, ")"); muscle_insert (usage_name, ""); - value = muscle_string_decode (name); + value = string_decode (name); if (!value) value = xstrdup (""); return value; @@ -469,7 +469,7 @@ muscle_percent_define_get_loc (char const *variable) if (!muscle_find_const (loc_name)) fatal(_("%s: undefined %%define variable %s"), "muscle_percent_define_get_loc", quote (variable)); - return muscle_location_decode (loc_name); + return location_decode (loc_name); } char const * @@ -573,7 +573,7 @@ muscle_percent_define_check_values (char const * const *values) name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")"); - value = muscle_string_decode (name); + value = string_decode (name); if (value) { for (++values; *values; ++values) From e58782294dfdb5ca6f8c69dd65a1ccfb9597efb3 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 11:40:52 +0200 Subject: [PATCH 08/29] muscles: make private functions static * src/muscle-tab.h, src/muscle-tab.c (muscle_boundary_grow) (muscle_location_grow): Now static. --- src/muscle-tab.c | 12 ++++++++++-- src/muscle-tab.h | 8 -------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index c6f48669..b2dca77d 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -259,7 +259,10 @@ muscle_find (char const *key) } -void +/* In the format `file_name:line.column', append BOUND to MUSCLE. Use + digraphs for special characters in the file name. */ + +static void muscle_boundary_grow (char const *key, boundary bound) { char *extension; @@ -274,7 +277,12 @@ muscle_boundary_grow (char const *key, boundary bound) obstack_free (&muscle_obstack, extension); } -void + +/* In the format `[[file_name:line.column]], [[file_name:line.column]]', + append LOC to MUSCLE. Use digraphs for special characters in each + file name. */ + +static void muscle_location_grow (char const *key, location loc) { muscle_grow (key, "[[", ""); diff --git a/src/muscle-tab.h b/src/muscle-tab.h index b8438218..ddbad408 100644 --- a/src/muscle-tab.h +++ b/src/muscle-tab.h @@ -97,14 +97,6 @@ void muscle_code_grow (const char *key, const char *value, location loc); void muscle_pair_list_grow (const char *muscle, const char *a1, const char *a2); -/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append - LOC to MUSCLE. Use digraphs for special characters in each file name. */ -void muscle_location_grow (char const *key, location loc); - -/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs - for special characters in the file name. */ -void muscle_boundary_grow (char const *key, boundary bound); - /* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped with digraphs, so it must not contain `[' or `]'. */ From eea7239a23c96a1b6a8c2811044c7379da2d6a5f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 11:49:42 +0200 Subject: [PATCH 09/29] muscles: shuffle responsabilities * src/muscle-tab.c (muscle_boundary_grow): Be in charge of quotation, instead of leaving this to the caller. --- src/muscle-tab.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index b2dca77d..a498b15b 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -266,12 +266,14 @@ static void muscle_boundary_grow (char const *key, boundary bound) { char *extension; + obstack_sgrow (&muscle_obstack, "[["); obstack_escape (&muscle_obstack, bound.file); - obstack_1grow (&muscle_obstack, ':'); + obstack_1grow (&muscle_obstack, ':'); obstack_fgrow1 (&muscle_obstack, "%d", bound.line); - obstack_1grow (&muscle_obstack, '.'); + obstack_1grow (&muscle_obstack, '.'); obstack_fgrow1 (&muscle_obstack, "%d", bound.column); - obstack_1grow (&muscle_obstack, '\0'); + obstack_sgrow (&muscle_obstack, "]]"); + obstack_1grow (&muscle_obstack, '\0'); extension = obstack_finish (&muscle_obstack); muscle_grow (key, extension, ""); obstack_free (&muscle_obstack, extension); @@ -285,11 +287,9 @@ muscle_boundary_grow (char const *key, boundary bound) static void muscle_location_grow (char const *key, location loc) { - muscle_grow (key, "[[", ""); muscle_boundary_grow (key, loc.start); - muscle_grow (key, "]], [[", ""); + muscle_grow (key, "", ", "); muscle_boundary_grow (key, loc.end); - muscle_grow (key, "]]", ""); } #define COMMON_DECODE(Value) \ From 0601c3bf0f4dda2617ff90a3d419a4e0e387c0b1 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 12:12:38 +0200 Subject: [PATCH 10/29] obstack_quote: escape and quote for M4 * src/system.h (obstack_quote): New. * src/muscle-tab.c: Use it instead of obstack_escape where applicable. * src/scan-code.l: Since obstack_quote supports NULL, leave type_name as NULL instead of defaulting to "". --- src/muscle-tab.c | 18 +++++++++--------- src/scan-code.l | 2 -- src/system.h | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index a498b15b..5c624982 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -177,10 +177,10 @@ static void muscle_syncline_grow (char const *key, location loc) { char *extension = NULL; - obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line); - obstack_escape (&muscle_obstack, - quotearg_style (c_quoting_style, loc.start.file)); - obstack_sgrow (&muscle_obstack, "]])["); + obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line); + obstack_quote (&muscle_obstack, + quotearg_style (c_quoting_style, loc.start.file)); + obstack_sgrow (&muscle_obstack, ")["); obstack_1grow (&muscle_obstack, 0); extension = obstack_finish (&muscle_obstack); muscle_grow (key, extension, ""); @@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle, const char *a1, const char *a2) { char *pair; - obstack_sgrow (&muscle_obstack, "[[["); - obstack_escape (&muscle_obstack, a1); - obstack_sgrow (&muscle_obstack, "]], [["); - obstack_escape (&muscle_obstack, a2); - obstack_sgrow (&muscle_obstack, "]]]"); + obstack_sgrow (&muscle_obstack, "["); + obstack_quote (&muscle_obstack, a1); + obstack_sgrow (&muscle_obstack, ", "); + obstack_quote (&muscle_obstack, a2); + obstack_sgrow (&muscle_obstack, "]"); obstack_1grow (&muscle_obstack, 0); pair = obstack_finish (&muscle_obstack); muscle_grow (muscle, pair, ",\n"); diff --git a/src/scan-code.l b/src/scan-code.l index 785f386d..bc2cd580 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -762,7 +762,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) } else untyped_var_seen = true; - type_name = ""; } obstack_fgrow1 (&obstack_for_string, @@ -783,7 +782,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) cp, quote (effective_rule->content.sym->tag)); else untyped_var_seen = true; - type_name = ""; } obstack_fgrow3 (&obstack_for_string, diff --git a/src/system.h b/src/system.h index 06224596..06fd0f0a 100644 --- a/src/system.h +++ b/src/system.h @@ -212,6 +212,28 @@ typedef size_t uintptr_t; } while (0) +/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped + for our postprocessing (i.e., escape M4 special characters). If + Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4 + programming easier (m4_ifval can be used). + + For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */ + +# define obstack_quote(Obs, Str) \ + do { \ + char const* obstack_quote_p = Str; \ + if (obstack_quote_p && obstack_quote_p[0]) \ + { \ + obstack_sgrow (Obs, "[["); \ + obstack_escape (Obs, obstack_quote_p); \ + obstack_sgrow (Obs, "]]"); \ + } \ + else \ + obstack_sgrow (Obs, "[]"); \ + } while (0) + + + /*-----------------------------------------. From 8617d87e24367e817e00d209b0de40944ce2964b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 12:14:50 +0200 Subject: [PATCH 11/29] be sure to properly escape type names * src/scan-code.l: Use obstack_quote when passing type_name to m4. * tests/input.at (Code injection): New. * NEWS: Document it. Thanks to Paul Eggert for the wording. --- NEWS | 5 +++++ src/scan-code.l | 12 +++++++----- tests/input.at | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 53ae9647..f4decfa8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU Bison NEWS * Noteworthy changes in release ?.? (????-??-??) [?] + Bison no longer executes user-specified M4 code when processing a grammar. + +** Bug fixes + + Type names are now properly escaped. * Noteworthy changes in release 2.6 (2012-07-19) [stable] diff --git a/src/scan-code.l b/src/scan-code.l index bc2cd580..f872285c 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -764,8 +764,9 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) untyped_var_seen = true; } - obstack_fgrow1 (&obstack_for_string, - "]b4_lhs_value([%s])[", type_name); + obstack_sgrow (&obstack_for_string, "]b4_lhs_value("); + obstack_quote (&obstack_for_string, type_name); + obstack_sgrow (&obstack_for_string, ")["); rule->action_props.is_value_used = true; break; @@ -784,9 +785,10 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) untyped_var_seen = true; } - obstack_fgrow3 (&obstack_for_string, - "]b4_rhs_value(%d, %d, [%s])[", - effective_rule_length, n, type_name); + obstack_fgrow2 (&obstack_for_string, + "]b4_rhs_value(%d, %d, ", effective_rule_length, n); + obstack_quote (&obstack_for_string, type_name); + obstack_sgrow (&obstack_for_string, ")["); if (n > 0) symbol_list_n_get (effective_rule, n)->action_props.is_value_used = true; diff --git a/tests/input.at b/tests/input.at index 836ff6d6..eb98cca4 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1369,3 +1369,54 @@ AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18]) m4_popdef([AT_TEST]) AT_CLEANUP + + +## ---------------- ## +## Code injection. ## +## ---------------- ## + + +AT_SETUP([[Code injection]]) + +m4_pattern_allow([^m4_errprintn$]) + +# AT_TEST([MACRO]) +# ---------------- +# Try to have MACRO be run by bison. +m4_pushdef([AT_TEST], +[AT_DATA([[input.y]], +[[%type <$1(DEAD %type)> exp +%token <$1(DEAD %token)> a +%initial-action +{ + $$; + $<$1(DEAD %initial-action)>$ +}; +%% +exp: + a a[last] + { + $$; + $][1; + $<$1(DEAD action 1)>$ + $<$1(DEAD action 2)>1 + $<$1(DEAD action 3)>last + $<$1(DEAD action 4)>0 + ; + }; +]]) + +# FIXME: Provide a means to iterate over all the skeletons. +AT_BISON_CHECK([[-d input.y]]) +AT_BISON_CHECK([[-d -S glr.c input.y]]) +AT_BISON_CHECK([[-d -S lalr1.cc input.y]]) +AT_BISON_CHECK([[-d -S glr.cc input.y]]) +AT_BISON_CHECK([[ -S lalr1.java input.y]]) +]) + +AT_TEST([m4_errprintn]) +AT_TEST([@:>@m4_errprintn]) + +m4_popdef([AT_TEST]) + +AT_CLEANUP From 0bb672d87c92070276fdf92344e30a37e6852ea8 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 15:20:50 +0200 Subject: [PATCH 12/29] tests: adjust to GCC 4.8, which displays caret errors With GCC 4.8, the tests on synclines are skipped. Transform input.y:1:2: error: #error "1" #error "1" ^ into input.y:1: #error "1" * tests/synclines.at (AT_SYNCLINES_COMPILE): Do it, using Perl instead of sed. --- tests/synclines.at | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/synclines.at b/tests/synclines.at index 8d742d53..7e7122f9 100644 --- a/tests/synclines.at +++ b/tests/synclines.at @@ -27,6 +27,11 @@ AT_BANNER([[User Actions.]]) # errors. m4_define([AT_SYNCLINES_COMPILE], [AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr]) + +# Transform stderr into something like this: +# +# input.y:4: #error "4" +# # In case GCC displays column information, strip it down. # # input.y:4:2: #error "4" or @@ -42,6 +47,11 @@ m4_define([AT_SYNCLINES_COMPILE], # => # input.y:4: #error "8" # +# The message may include a caret-error: +# +# input.y:1:2: error: #error "1" +# #error "1" +# ^ # # And possibly distcc adds its bits. # @@ -54,12 +64,15 @@ 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([[sed -e '/^distcc\[[0-9]*\] /d' \ - -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \ - -e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \ - -e "/^[^:]*: In function '[^\']*':$/d" \ - stderr]], - 0, [stdout]) +AT_CHECK([[perl -p -0777 -f - stderr <<\EOF + s/^distcc\[\d+\] .*\n//gm; + s/^([^:]*:\d+)[.:][^:]*:(.*)$/$][1:$][2/gm; + s/^([^:]*:\d+:)[^#]*( #error)/$][1$][2/gm; + s/^[^:]*: In function '[^']*':\n//gm; + s/^\ +#error.*\n\ *\^\n//gm; +EOF +]], + 0, [stdout]) ]) # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG) From 55e075f2299757daf62fd72796d4027502ac40ea Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 16:07:26 +0200 Subject: [PATCH 13/29] tests: fix an assertion * tests/local.at (AT_YYLEX_DEFINE): Be sure to check the array against its length, not its size in bytes. --- tests/local.at | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/local.at b/tests/local.at index 2dbbfc71..5c9b865e 100644 --- a/tests/local.at +++ b/tests/local.at @@ -333,7 +333,7 @@ static static size_t toknum = 0; int res; ]AT_USE_LEX_ARGS[; - assert (toknum < sizeof input); + assert (toknum < sizeof input / sizeof input[0]); res = input[toknum++]; ]$2[;]AT_LOCATION_IF([[ ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1; From 9c46ba16e344c9ffe4185dc08f970724cbd5afb7 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 14:41:20 +0200 Subject: [PATCH 14/29] formatting changes * src/symtab.h: here. --- src/symtab.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/symtab.h b/src/symtab.h index db902e75..abcafa6c 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -62,21 +62,23 @@ struct symbol /** Its \c \%type. */ uniqstr type_name; + /** Its \c \%type's location. */ location type_location; /** Any \c \%destructor declared specifically for this symbol. - Access this field only through symbol's interface functions. For - example, if symbol::destructor = NULL, a default \c \%destructor - or a per-type \c \%destructor might be appropriate, and - \c symbol_destructor_get will compute the correct one. */ + Access this field only through symbol's interface + functions. For example, if symbol::destructor = NULL, a + default \c \%destructor or a per-type \c \%destructor might be + appropriate, and \c symbol_destructor_get will compute the + correct one. */ code_props destructor; /** Any \c \%printer declared specifically for this symbol. - Access this field only through symbol's interface functions. - \sa symbol::destructor */ + Access this field only through symbol's interface functions. + \sa symbol::destructor */ code_props printer; symbol_number number; From d511fbd576e8249633776ba21a9209465fa1e59f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 13:28:58 +0200 Subject: [PATCH 15/29] gnulib: update --- bootstrap | 4 +++- gnulib | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bootstrap b/bootstrap index e00c8bbb..e3e270b0 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-07-10.09; # UTC +scriptversion=2012-07-19.14; # UTC # Bootstrap this package from checked-out sources. @@ -214,6 +214,8 @@ use_git=true # otherwise find the first of the NAMES that can be run (i.e., # supports --version). If found, set ENVVAR to the program name, # die otherwise. +# +# FIXME: code duplication, see also gnu-web-doc-update. find_tool () { find_tool_envvar=$1 diff --git a/gnulib b/gnulib index 2f67aa79..dbd91449 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 2f67aa79c6f13961eda685144130692dc9f7b95f +Subproject commit dbd914496c99c52220e5f5ba4121d6cb55fb3beb From 0e164d43d115b13f300892a4c0ab643ed03020c9 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 16:44:45 +0200 Subject: [PATCH 16/29] glr.cc: fix the handling of yydebug * data/glr.cc (yydebug_): Remove, unused. (set_debug_level, debug_level): Work on yydebug instead. * doc/bison.texi, NEWS: Document this. --- NEWS | 4 +++- data/glr.cc | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f4decfa8..b97956cc 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,9 @@ GNU Bison NEWS ** Bug fixes - Type names are now properly escaped. +*** Type names are now properly escaped. + +*** glr.cc: set_debug_level and debug_level work as expected. * Noteworthy changes in release 2.6 (2012-07-19) [stable] diff --git a/data/glr.cc b/data/glr.cc index ba6ceac0..78a7ae51 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -131,7 +131,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ :])[ #if ]b4_api_PREFIX[DEBUG - ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), + ]m4_ifset([b4_parse_param], [ ], [ :])[ yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ #endif]b4_parse_param_cons[ { @@ -199,13 +199,14 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl ]b4_parser_class_name[::debug_level_type ]b4_parser_class_name[::debug_level () const { - return yydebug_; + return yydebug; } void ]b4_parser_class_name[::set_debug_level (debug_level_type l) { - yydebug_ = l; + // Actually, it is yydebug which is really used. + yydebug = l; } #endif @@ -320,7 +321,6 @@ b4_user_stype const location_type* yylocationp); private: /* Debugging. */ - int yydebug_; std::ostream* yycdebug_; # endif From 9a86ee6058b0fa85f2625b4a0a784eab5098ed58 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 14:41:55 +0200 Subject: [PATCH 17/29] muscles: fix another occurrence of unescaped type name * src/output.c (quoted_output): Split into... (quoted_output, string_output): these. Use the former when outputting a type_name. * tests/input.at: Check this case. * src/symtab.h: Comment changes. --- src/output.c | 37 +++++++++++++++++++++++++------------ src/symtab.h | 7 ++++++- tests/input.at | 13 +++++++++++++ 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/output.c b/src/output.c index e157460d..d52a7113 100644 --- a/src/output.c +++ b/src/output.c @@ -110,29 +110,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number) GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number) -/*--------------------------------------------------------------------. -| Print to OUT a representation of STRING escaped both for C and M4. | -`--------------------------------------------------------------------*/ +/*----------------------------------------------------------------. +| Print to OUT a representation of CP quoted and escaped for M4. | +`----------------------------------------------------------------*/ static void -escaped_output (FILE *out, char const *string) +quoted_output (FILE *out, char const *cp) { - char const *p; fprintf (out, "[["); - for (p = quotearg_style (c_quoting_style, string); *p; p++) - switch (*p) + for (; *cp; cp++) + switch (*cp) { case '$': fputs ("$][", out); break; case '@': fputs ("@@", out); break; case '[': fputs ("@{", out); break; case ']': fputs ("@}", out); break; - default: fputc (*p, out); break; + default: fputc (*cp, out); break; } fprintf (out, "]]"); } +/*----------------------------------------------------------------. +| Print to OUT a representation of STRING quoted and escaped both | +| for C and M4. | +`----------------------------------------------------------------*/ + +static void +string_output (FILE *out, char const *string) +{ + quoted_output (out, quotearg_style (c_quoting_style, string)); +} + /*------------------------------------------------------------------. | Prepare the muscles related to the symbols: translate, tname, and | @@ -299,7 +309,7 @@ user_actions_output (FILE *out) { fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1, rules[r].action_location.start.line); - escaped_output (out, rules[r].action_location.start.file); + string_output (out, rules[r].action_location.start.file); fprintf (out, ")\n[ %s]])\n\n", rules[r].action); } fputs ("])\n\n", out); @@ -405,12 +415,15 @@ symbol_code_props_output (FILE *out, char const *what, code, optional typename. */ fprintf (out, "%s[", sep); sep = ",\n"; - escaped_output (out, loc.start.file); + string_output (out, loc.start.file); fprintf (out, ", %d, ", loc.start.line); - escaped_output (out, sym->tag); + quoted_output (out, sym->tag); fprintf (out, ", %d, [[%s]]", sym->number, code); if (sym->type_name) - fprintf (out, ", [[%s]]", sym->type_name); + { + fputs (", ", out); + quoted_output (out, sym->type_name); + } fputc (']', out); } } diff --git a/src/symtab.h b/src/symtab.h index abcafa6c..7d8cf982 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -60,7 +60,12 @@ struct symbol /** The location of its first occurrence. */ location location; - /** Its \c \%type. */ + /** Its \c \%type. + + Beware that this is the type_name as was entered by the user, + including silly things such as "]" if she entered "%token <]> t". + Therefore, when outputting type_name to M4, be sure to escape it + into "@}". See quoted_output for instance. */ uniqstr type_name; /** Its \c \%type's location. */ diff --git a/tests/input.at b/tests/input.at index eb98cca4..82d97f53 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1392,6 +1392,19 @@ m4_pushdef([AT_TEST], $$; $<$1(DEAD %initial-action)>$ }; +%printer +{ + $$ + $<$1(DEAD %printer)>$ +} <> <*>; +%lex-param +{ + $1(DEAD %lex-param) +}; +%parse-param +{ + $1(DEAD %parse-param) +}; %% exp: a a[last] From 65a99eca252e9c8c042fb529d86046cbc8adad95 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 12:06:28 +0200 Subject: [PATCH 18/29] scan-code: factor the handling of the type in $$ * src/scan-code.l (fetch_type_name): New. (handle_action_dollar): Use it. (gt_ptr): Remove, useless. --- src/scan-code.l | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/scan-code.l b/src/scan-code.l index f872285c..2fab6d9d 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -46,6 +46,9 @@ YY_DECL; #define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng); +static char *fetch_type_name (char *cp, char const **type_name, + location dollar_loc); + static void handle_action_dollar (symbol_list *rule, char *cp, location dollar_loc); static void handle_action_at (symbol_list *rule, char *cp, location at_loc); @@ -686,6 +689,31 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, int max_left_semantic_context = 0; +/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its + beginning (i.e., after the opening "<", and return the pointer + immediately after it. */ + +static +char * +fetch_type_name (char *cp, char const **type_name, + location dollar_loc) +{ + if (*cp == '<') + { + *type_name = ++cp; + while (*cp != '>') + ++cp; + + /* The '>' symbol will be later replaced by '\0'. Original + 'text' is needed for error messages. */ + ++cp; + if (untyped_var_seen) + complain_at (dollar_loc, _("explicit type given in untyped grammar")); + tag_seen = true; + } + return cp; +} + /*------------------------------------------------------------------. | TEXT is pointing to a wannabee semantic value (i.e., a '$'). | | | @@ -699,7 +727,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) { char const *type_name = NULL; char *cp = text + 1; - char *gt_ptr = 0; symbol_list *effective_rule; int effective_rule_length; int n; @@ -716,26 +743,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) } /* Get the type name if explicit. */ - if (*cp == '<') - { - type_name = ++cp; - while (*cp != '>') - ++cp; - - /* The '>' symbol will be later replaced by '\0'. Original - 'text' is needed for error messages. */ - gt_ptr = cp; - ++cp; - if (untyped_var_seen) - complain_at (dollar_loc, _("explicit type given in untyped grammar")); - tag_seen = true; - } + cp = fetch_type_name (cp, &type_name, dollar_loc); n = parse_ref (cp, effective_rule, effective_rule_length, rule->midrule_parent_rhs_index, text, dollar_loc, '$'); - if (gt_ptr) - *gt_ptr = '\0'; + /* End type_name. */ + if (type_name) + cp[-1] = '\0'; switch (n) { From 4982f078bfd98d50b9c97d2bcddb7a89d20ff3df Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 16:52:35 +0200 Subject: [PATCH 19/29] support $$ in printers and destructors * src/scan-code.l (SC_SYMBOL_ACTION): Accept $$, not just $$. * data/c.m4 (b4_dollar_dollar_): New. (b4_symbol_actions): Let b4_dollar_dollar use b4_dollar_dollar_. * NEWS, doc/bison.texi: Document it. * tests/actions.at: Check this for C and C++. --- NEWS | 10 ++++ data/c.m4 | 17 +++++- doc/bison.texi | 19 +++---- src/scan-code.l | 8 ++- tests/actions.at | 137 +++++++++++++++++++++++++++++++++++++++++++++++ tests/calc.at | 6 +-- 6 files changed, 182 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index b97956cc..56961cc2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,16 @@ GNU Bison NEWS *** glr.cc: set_debug_level and debug_level work as expected. +** Type names in printers and destructors + + For consistency with rule actions, it is now possible to qualify $$ by a + type-name in printers and destructors. For instance: + + %printer { fprintf (yyo, "(%d, %f)", $$, $$); } <*> <>; + + will display two values for each typed and untyped symbol (provided + that YYSTYPE supports it). + * Noteworthy changes in release 2.6 (2012-07-19) [stable] ** Future Changes diff --git a/data/c.m4 b/data/c.m4 index 08296c65..3954613b 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -417,13 +417,28 @@ m4_define([b4_case], $2 break;]) +# b4_dollar_dollar_(NAME, FIELD, DEFAULT-FIELD) +# --------------------------------------------- +# If FIELD (or DEFAULT-FIELD) is non-null, read it in pointer NAME, +# otherwise just dereference. +m4_define([b4_dollar_dollar_], +[m4_if([$2], [[]], + [m4_ifval([$3], [($1->$3)], + [(*$1)])], + [($1->$2)])]) + + # b4_symbol_actions(FILENAME, LINENO, # SYMBOL-TAG, SYMBOL-NUM, # SYMBOL-ACTION, SYMBOL-TYPENAME) # ------------------------------------------------- +# Issue the code for a symbol action (e.g., %printer). +# +# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are +# invoked where $$ and @$ were specified by the user. m4_define([b4_symbol_actions], [m4_pushdef([b4_dollar_dollar], - [m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl + [b4_dollar_dollar_([yyvaluep], m4_dquote($][1), [$6])])dnl m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl case $4: /* $3 */ b4_syncline([$2], [$1]) diff --git a/doc/bison.texi b/doc/bison.texi index 6156b41f..e50bd171 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -4592,11 +4592,11 @@ symbol is automatically discarded. @deffn {Directive} %destructor @{ @var{code} @} @var{symbols} @findex %destructor Invoke the braced @var{code} whenever the parser discards one of the -@var{symbols}. -Within @var{code}, @code{$$} designates the semantic value associated -with the discarded symbol, and @code{@@$} designates its location. -The additional parser parameters are also available (@pxref{Parser Function, , -The Parser Function @code{yyparse}}). +@var{symbols}. Within @var{code}, @code{$$} (or @code{$<@var{tag}>$}) +designates the semantic value associated with the discarded symbol, and +@code{@@$} designates its location. The additional parser parameters are +also available (@pxref{Parser Function, , The Parser Function +@code{yyparse}}). When a symbol is listed among @var{symbols}, its @code{%destructor} is called a per-symbol @code{%destructor}. @@ -4734,10 +4734,11 @@ Decl, , Freeing Discarded Symbols}). @c This is the same text as for %destructor. Invoke the braced @var{code} whenever the parser displays one of the @var{symbols}. Within @var{code}, @code{yyoutput} denotes the output stream -(a @code{FILE*} in C, and an @code{std::ostream&} in C++), -@code{$$} designates the semantic value associated with the symbol, and -@code{@@$} its location. The additional parser parameters are also -available (@pxref{Parser Function, , The Parser Function @code{yyparse}}). +(a @code{FILE*} in C, and an @code{std::ostream&} in C++), @code{$$} (or +@code{$<@var{tag}>$}) designates the semantic value associated with the +symbol, and @code{@@$} its location. The additional parser parameters are +also available (@pxref{Parser Function, , The Parser Function +@code{yyparse}}). The @var{symbols} are defined as for @code{%destructor} (@pxref{Destructor Decl, , Freeing Discarded Symbols}.): they can be per-type (e.g., diff --git a/src/scan-code.l b/src/scan-code.l index 2fab6d9d..e30bf9db 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -264,8 +264,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" { - "$$" { - obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar["); + "$"("<"{tag}">")?"$" { + const char *type_name = NULL; + fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0; + obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar("); + obstack_quote (&obstack_for_string, type_name); + obstack_sgrow (&obstack_for_string, ")["); self->is_value_used = true; } "@$" { diff --git a/tests/actions.at b/tests/actions.at index e8e8cd97..dd909b00 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1230,6 +1230,143 @@ AT_CHECK_ACTION_LOCATIONS([[%destructor]]) AT_CHECK_ACTION_LOCATIONS([[%printer]]) +## ------------------------- ## +## Qualified $$ in actions. ## +## ------------------------- ## + +# Check that we can used qualified $$ (v.g., $$) not only in +# rule actions, but also where $$ is valid: %printer and %destructor. +# +# FIXME: Not actually checking %desctructor, but it's the same code as +# %printer... +# +# To do that, use a semantic value that has two fields (sem_type), +# declare symbols to have only one of these types (INT, float), and +# use $$ to get the other one. Including for symbols that are +# not typed (UNTYPED). + +m4_pushdef([AT_TEST], +[AT_SETUP([[Qualified $$ in actions: $1]]) + +AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1"]) + +AT_DATA_GRAMMAR([[input.y]], +[[%skeleton "$1" +%defines // FIXME: Mandated by lalr1.cc in Bison 2.6. +%locations // FIXME: Mandated by lalr1.cc in Bison 2.6. +%debug +%code requires +{ +# include + + typedef struct sem_type + { + int ival; + float fval; + } sem_type; + +# define YYSTYPE sem_type + +#ifdef __cplusplus +# include + static void + report (std::ostream& yyo, int ival, float fval) + { + yyo << "ival: " << ival << ", fval: " << fval; + } +#else + static void + report (FILE* yyo, int ival, float fval) + { + fprintf (yyo, "ival: %d, fval: %1.1f", ival, fval); + } +#endif +} + +%code +{ + ]AT_YYERROR_DECLARE[ + ]AT_YYLEX_DECLARE[ +} + +%token UNTYPED +%token INT +%type float +%printer { report (yyo, $$, $$); } ; +%printer { report (yyo, $$, $$ ); } ; +%printer { report (yyo, $$, $$); } <>; + +]AT_SKEL_CC_IF([[ +/* The lalr1.cc skeleton, for backward compatibility, defines + a constructor for position that initializes the filename. The + glr.cc skeleton does not (and in fact cannot: location/position + are stored in a union, from which objects with constructors are + excluded in C++). */ +%initial-action { + @$.initialize (); +} +]])[ + +// %initial-action +// { +// $$ = 42; +// $$ = 4.2; +// } + +%% +float: UNTYPED INT +{ + $$ = $1 + $2; + $$ = $1 + $][2; +}; +%% +]AT_YYERROR_DEFINE[ +]AT_YYLEX_DEFINE(AT_SKEL_CC_IF([[{yy::parser::token::UNTYPED, + yy::parser::token::INT, + EOF}]], + [[{UNTYPED, INT, EOF}]]), + [AT_VAL.ival = toknum * 10; AT_VAL.fval = toknum / 10.0;])[ +int +main (void) +{]AT_SKEL_CC_IF([[ + yy::parser p; + p.set_debug_level(1); + return p.parse ();]], [[ + yydebug = 1; + return yyparse ();]])[ +} +]]) + +AT_FULL_COMPILE([[input]]) +AT_PARSER_CHECK([./input], 0, [], [stderr]) +# Don't be too picky on the traces, GLR is not exactly the same. Keep +# only the lines from the printer. +# +# Don't care about locations. FIXME: remove their removal when Bison +# supports C++ without locations. +AT_CHECK([[sed -ne 's/([-0-9.]*: /(/;/ival:/p' stderr]], 0, +[[Reading a token: Next token is token UNTYPED (ival: 10, fval: 0.1) +Shifting token UNTYPED (ival: 10, fval: 0.1) +Reading a token: Next token is token INT (ival: 20, fval: 0.2) +Shifting token INT (ival: 20, fval: 0.2) + $][1 = token UNTYPED (ival: 10, fval: 0.1) + $][2 = token INT (ival: 20, fval: 0.2) +-> $$ = nterm float (ival: 30, fval: 0.3) +Cleanup: popping nterm float (ival: 30, fval: 0.3) +]]) + +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]) + ## ----------------------------------------------- ## ## Fix user actions without a trailing semicolon. ## ## ----------------------------------------------- ## diff --git a/tests/calc.at b/tests/calc.at index e4cb07f1..31ee44e2 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -288,16 +288,16 @@ static int power (int base, int exponent); ]AT_YYLEX_DECLARE_EXTERN[ } -]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [ +]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [[ /* The lalr1.cc skeleton, for backward compatibility, defines a constructor for position that initializes the filename. The glr.cc skeleton does not (and in fact cannot: location/position are stored in a union, from which objects with constructors are - excluded in C++. */ + excluded in C++). */ %initial-action { @$.initialize (); } -])])[ +]])])[ /* Bison Declarations */ %token CALC_EOF 0 "end of input" From a74a3158d47827616b2d5fc282b7ad4bf69c4261 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 26 Jul 2012 17:19:04 +0200 Subject: [PATCH 20/29] regen --- src/parse-gram.c | 581 +++++++++++++++++++++++++++++++---------------- src/parse-gram.h | 8 +- 2 files changed, 387 insertions(+), 202 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 31d20854..12ca07dc 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.1.19-ced26-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.22-9f3f1. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5.1.19-ced26-dirty" +#define YYBISON_VERSION "2.6.22-9f3f1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,8 +58,6 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ #define yyparse gram_parse @@ -73,7 +71,7 @@ /* Copy the first part of user declarations. */ -/* Line 323 of yacc.c */ +/* Line 336 of yacc.c */ #line 1 "parse-gram.y" /* Bison Grammar Parser -*- C -*- @@ -169,8 +167,8 @@ current_lhs(symbol *sym, location loc, named_ref *ref) #define YYTYPE_UINT8 uint_fast8_t -/* Line 323 of yacc.c */ -#line 174 "parse-gram.c" +/* Line 336 of yacc.c */ +#line 172 "parse-gram.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -188,18 +186,204 @@ current_lhs(symbol *sym, location loc, named_ref *ref) # define YYERROR_VERBOSE 1 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* 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 +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif +#if YYDEBUG +extern int gram_debug; #endif -#include "parse-gram.h" +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + GRAM_EOF = 0, + STRING = 258, + INT = 259, + PERCENT_TOKEN = 260, + PERCENT_NTERM = 261, + PERCENT_TYPE = 262, + PERCENT_DESTRUCTOR = 263, + PERCENT_PRINTER = 264, + PERCENT_LEFT = 265, + PERCENT_RIGHT = 266, + PERCENT_NONASSOC = 267, + PERCENT_PREC = 268, + PERCENT_DPREC = 269, + PERCENT_MERGE = 270, + PERCENT_CODE = 271, + PERCENT_DEBUG = 272, + PERCENT_DEFAULT_PREC = 273, + PERCENT_DEFINE = 274, + PERCENT_DEFINES = 275, + PERCENT_ERROR_VERBOSE = 276, + PERCENT_EXPECT = 277, + PERCENT_EXPECT_RR = 278, + PERCENT_FILE_PREFIX = 279, + PERCENT_GLR_PARSER = 280, + PERCENT_INITIAL_ACTION = 281, + PERCENT_LANGUAGE = 282, + PERCENT_LEX_PARAM = 283, + PERCENT_LOCATIONS = 284, + PERCENT_NAME_PREFIX = 285, + PERCENT_NO_DEFAULT_PREC = 286, + PERCENT_NO_LINES = 287, + PERCENT_NONDETERMINISTIC_PARSER = 288, + PERCENT_OUTPUT = 289, + PERCENT_PARSE_PARAM = 290, + PERCENT_PURE_PARSER = 291, + PERCENT_REQUIRE = 292, + PERCENT_SKELETON = 293, + PERCENT_START = 294, + PERCENT_TOKEN_TABLE = 295, + PERCENT_VERBOSE = 296, + PERCENT_YACC = 297, + BRACED_CODE = 298, + BRACKETED_ID = 299, + CHAR = 300, + EPILOGUE = 301, + EQUAL = 302, + ID = 303, + ID_COLON = 304, + PERCENT_PERCENT = 305, + PIPE = 306, + PROLOGUE = 307, + SEMICOLON = 308, + TYPE = 309, + TYPE_TAG_ANY = 310, + TYPE_TAG_NONE = 311, + PERCENT_UNION = 312 + }; +#endif +/* Tokens. */ +#define GRAM_EOF 0 +#define STRING 258 +#define INT 259 +#define PERCENT_TOKEN 260 +#define PERCENT_NTERM 261 +#define PERCENT_TYPE 262 +#define PERCENT_DESTRUCTOR 263 +#define PERCENT_PRINTER 264 +#define PERCENT_LEFT 265 +#define PERCENT_RIGHT 266 +#define PERCENT_NONASSOC 267 +#define PERCENT_PREC 268 +#define PERCENT_DPREC 269 +#define PERCENT_MERGE 270 +#define PERCENT_CODE 271 +#define PERCENT_DEBUG 272 +#define PERCENT_DEFAULT_PREC 273 +#define PERCENT_DEFINE 274 +#define PERCENT_DEFINES 275 +#define PERCENT_ERROR_VERBOSE 276 +#define PERCENT_EXPECT 277 +#define PERCENT_EXPECT_RR 278 +#define PERCENT_FILE_PREFIX 279 +#define PERCENT_GLR_PARSER 280 +#define PERCENT_INITIAL_ACTION 281 +#define PERCENT_LANGUAGE 282 +#define PERCENT_LEX_PARAM 283 +#define PERCENT_LOCATIONS 284 +#define PERCENT_NAME_PREFIX 285 +#define PERCENT_NO_DEFAULT_PREC 286 +#define PERCENT_NO_LINES 287 +#define PERCENT_NONDETERMINISTIC_PARSER 288 +#define PERCENT_OUTPUT 289 +#define PERCENT_PARSE_PARAM 290 +#define PERCENT_PURE_PARSER 291 +#define PERCENT_REQUIRE 292 +#define PERCENT_SKELETON 293 +#define PERCENT_START 294 +#define PERCENT_TOKEN_TABLE 295 +#define PERCENT_VERBOSE 296 +#define PERCENT_YACC 297 +#define BRACED_CODE 298 +#define BRACKETED_ID 299 +#define CHAR 300 +#define EPILOGUE 301 +#define EQUAL 302 +#define ID 303 +#define ID_COLON 304 +#define PERCENT_PERCENT 305 +#define PIPE 306 +#define PROLOGUE 307 +#define SEMICOLON 308 +#define TYPE 309 +#define TYPE_TAG_ANY 310 +#define TYPE_TAG_NONE 311 +#define PERCENT_UNION 312 + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 350 of yacc.c */ +#line 114 "parse-gram.y" + + symbol *symbol; + symbol_list *list; + int integer; + char const *chars; + char *code; + assoc assoc; + uniqstr uniqstr; + unsigned char character; + named_ref *named_ref; + + + +/* Line 350 of yacc.c */ +#line 346 "parse-gram.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + 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 +#endif + + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int gram_parse (void *YYPARSE_PARAM); +#else +int gram_parse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int gram_parse (void); +#else +int gram_parse (); +#endif +#endif /* ! YYPARSE_PARAM */ + +#endif /* !GRAM_Y_TAB_H */ /* Copy the second part of user declarations. */ -/* Line 344 of yacc.c */ -#line 203 "parse-gram.c" +/* Line 353 of yacc.c */ +#line 387 "parse-gram.c" #ifdef short # undef short @@ -520,7 +704,7 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || 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[] = @@ -780,32 +964,33 @@ 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). */ -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ while (YYID (0)) #endif +#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 @@ -888,167 +1073,167 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) # endif switch (yytype) { - case 3: /* "\"string\"" */ + case 3: /* "string" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 204 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; -/* Line 822 of yacc.c */ -#line 899 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1084 "parse-gram.c" break; - case 4: /* "\"integer\"" */ + case 4: /* "integer" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 216 "parse-gram.y" { fprintf (stderr, "%d", (yyvaluep->integer)); }; -/* Line 822 of yacc.c */ -#line 908 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1093 "parse-gram.c" break; - case 43: /* "\"{...}\"" */ + case 43: /* "{...}" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; -/* Line 822 of yacc.c */ -#line 917 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1102 "parse-gram.c" break; - case 44: /* "\"[identifier]\"" */ + case 44: /* "[identifier]" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 211 "parse-gram.y" { fprintf (stderr, "[%s]", (yyvaluep->uniqstr)); }; -/* Line 822 of yacc.c */ -#line 926 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1111 "parse-gram.c" break; - case 45: /* "\"char\"" */ + case 45: /* "char" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 198 "parse-gram.y" { fputs (char_name ((yyvaluep->character)), stderr); }; -/* Line 822 of yacc.c */ -#line 935 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1120 "parse-gram.c" break; - case 46: /* "\"epilogue\"" */ + case 46: /* "epilogue" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 822 of yacc.c */ -#line 944 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1129 "parse-gram.c" break; - case 48: /* "\"identifier\"" */ + case 48: /* "identifier" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 210 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 822 of yacc.c */ -#line 953 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1138 "parse-gram.c" break; - case 49: /* "\"identifier:\"" */ + case 49: /* "identifier:" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 212 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; -/* Line 822 of yacc.c */ -#line 962 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1147 "parse-gram.c" break; - case 52: /* "\"%{...%}\"" */ + case 52: /* "%{...%}" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 822 of yacc.c */ -#line 971 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1156 "parse-gram.c" break; - case 54: /* "\"type\"" */ + case 54: /* "type" */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 213 "parse-gram.y" { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; -/* Line 822 of yacc.c */ -#line 980 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1165 "parse-gram.c" break; - case 71: /* "symbol.prec" */ + case 71: /* symbol.prec */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 822 of yacc.c */ -#line 989 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1174 "parse-gram.c" break; - case 84: /* "variable" */ + case 84: /* variable */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 210 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 822 of yacc.c */ -#line 998 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1183 "parse-gram.c" break; - case 85: /* "content.opt" */ + case 85: /* content.opt */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 822 of yacc.c */ -#line 1007 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1192 "parse-gram.c" break; - case 86: /* "braceless" */ + case 86: /* braceless */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 206 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 822 of yacc.c */ -#line 1016 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1201 "parse-gram.c" break; - case 87: /* "id" */ + case 87: /* id */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 822 of yacc.c */ -#line 1025 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1210 "parse-gram.c" break; - case 88: /* "id_colon" */ + case 88: /* id_colon */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 220 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; -/* Line 822 of yacc.c */ -#line 1034 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1219 "parse-gram.c" break; - case 89: /* "symbol" */ + case 89: /* symbol */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 822 of yacc.c */ -#line 1043 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1228 "parse-gram.c" break; - case 90: /* "string_as_id" */ + case 90: /* string_as_id */ -/* Line 822 of yacc.c */ +/* Line 809 of yacc.c */ #line 219 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 822 of yacc.c */ -#line 1052 "parse-gram.c" +/* Line 809 of yacc.c */ +#line 1237 "parse-gram.c" break; default: break; @@ -1825,7 +2010,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1585 of yacc.c */ +/* Line 1572 of yacc.c */ #line 106 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -1834,8 +2019,8 @@ YYLTYPE yylloc; boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1585 of yacc.c */ -#line 1839 "parse-gram.c" +/* Line 1572 of yacc.c */ +#line 2024 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -2029,7 +2214,7 @@ yyreduce: { case 6: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 245 "parse-gram.y" { code_props plain_code; @@ -2044,14 +2229,14 @@ yyreduce: case 7: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 254 "parse-gram.y" { debug_flag = true; } break; case 8: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 256 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), @@ -2061,14 +2246,14 @@ yyreduce: case 9: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 260 "parse-gram.y" { defines_flag = true; } break; case 10: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 262 "parse-gram.y" { defines_flag = true; @@ -2078,42 +2263,42 @@ yyreduce: case 11: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 266 "parse-gram.y" { error_verbose = true; } break; case 12: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 267 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 268 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 269 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 270 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 272 "parse-gram.y" { nondeterministic_parser = true; @@ -2123,7 +2308,7 @@ yyreduce: case 17: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 277 "parse-gram.y" { code_props action; @@ -2137,77 +2322,77 @@ yyreduce: case 18: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 285 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 286 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 287 "parse-gram.y" { locations_flag = true; } break; case 21: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 288 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 289 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 290 "parse-gram.y" { no_lines_flag = true; } break; case 24: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 291 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 292 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 293 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 294 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 296 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use @@ -2227,14 +2412,14 @@ yyreduce: case 29: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 310 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 312 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); @@ -2263,28 +2448,28 @@ yyreduce: case 31: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 335 "parse-gram.y" { token_table_flag = true; } break; case 32: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 336 "parse-gram.y" { report_flag |= report_states; } break; case 33: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 337 "parse-gram.y" { yacc_flag = true; } break; case 37: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 345 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); @@ -2293,7 +2478,7 @@ yyreduce: case 38: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 349 "parse-gram.y" { symbol_list *list; @@ -2305,7 +2490,7 @@ yyreduce: case 39: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 356 "parse-gram.y" { symbol_list *list; @@ -2317,7 +2502,7 @@ yyreduce: case 40: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 363 "parse-gram.y" { default_prec = true; @@ -2326,7 +2511,7 @@ yyreduce: case 41: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 367 "parse-gram.y" { default_prec = false; @@ -2335,7 +2520,7 @@ yyreduce: case 42: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 371 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes @@ -2347,7 +2532,7 @@ yyreduce: case 43: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 378 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2357,21 +2542,21 @@ yyreduce: case 44: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 392 "parse-gram.y" {} break; case 45: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 393 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 398 "parse-gram.y" { union_seen = true; @@ -2382,14 +2567,14 @@ yyreduce: case 47: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 409 "parse-gram.y" { current_class = nterm_sym; } break; case 48: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 410 "parse-gram.y" { current_class = unknown_sym; @@ -2399,14 +2584,14 @@ yyreduce: case 49: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 414 "parse-gram.y" { current_class = token_sym; } break; case 50: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 415 "parse-gram.y" { current_class = unknown_sym; @@ -2416,7 +2601,7 @@ yyreduce: case 51: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 420 "parse-gram.y" { symbol_list *list; @@ -2429,7 +2614,7 @@ yyreduce: case 52: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 431 "parse-gram.y" { symbol_list *list; @@ -2446,126 +2631,126 @@ yyreduce: case 53: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 445 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 446 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 447 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 451 "parse-gram.y" { current_type = NULL; } break; case 57: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 452 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 458 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 460 "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 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 464 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 465 "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 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 471 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 473 "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 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 477 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 478 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 66: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 482 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 67: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 483 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 68: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 484 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 485 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 491 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); @@ -2575,7 +2760,7 @@ yyreduce: case 71: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 496 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); @@ -2585,7 +2770,7 @@ yyreduce: case 72: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 501 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2596,7 +2781,7 @@ yyreduce: case 73: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 507 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2607,7 +2792,7 @@ yyreduce: case 74: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 513 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); @@ -2619,7 +2804,7 @@ yyreduce: case 81: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 543 "parse-gram.y" { yyerrok; @@ -2628,14 +2813,14 @@ yyreduce: case 82: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 549 "parse-gram.y" { current_lhs ((yyvsp[(1) - (2)].symbol), (yylsp[(1) - (2)]), (yyvsp[(2) - (2)].named_ref)); } break; case 83: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 550 "parse-gram.y" { /* Free the current lhs. */ @@ -2645,21 +2830,21 @@ yyreduce: case 84: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 557 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 558 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 564 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } @@ -2667,77 +2852,77 @@ yyreduce: case 88: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 567 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (3)].symbol), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 89: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 569 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (3)].code), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].named_ref)); } break; case 90: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 571 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 573 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 575 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 579 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 581 "parse-gram.y" { (yyval.named_ref) = named_ref_new((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 96: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 593 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 598 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 599 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 610 "parse-gram.y" { code_props plain_code; @@ -2751,14 +2936,14 @@ yyreduce: case 101: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 630 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 632 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); @@ -2769,14 +2954,14 @@ yyreduce: case 103: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 640 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 652 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); @@ -2786,7 +2971,7 @@ yyreduce: case 108: -/* Line 1801 of yacc.c */ +/* Line 1788 of yacc.c */ #line 661 "parse-gram.y" { code_props plain_code; @@ -2800,8 +2985,8 @@ yyreduce: -/* Line 1801 of yacc.c */ -#line 2805 "parse-gram.c" +/* Line 1788 of yacc.c */ +#line 2990 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3050,7 +3235,7 @@ yyreturn: -/* Line 2062 of yacc.c */ +/* Line 2049 of yacc.c */ #line 671 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index 97dbfcf3..32c51798 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.5.1.19-ced26-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.22-9f3f1. */ /* Bison interface for Yacc-like parsers in C @@ -168,7 +168,7 @@ extern int gram_debug; typedef union YYSTYPE { -/* Line 2063 of yacc.c */ +/* Line 2050 of yacc.c */ #line 114 "parse-gram.y" symbol *symbol; @@ -183,7 +183,7 @@ typedef union YYSTYPE -/* Line 2063 of yacc.c */ +/* Line 2050 of yacc.c */ #line 188 "parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -204,6 +204,7 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif + #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int gram_parse (void *YYPARSE_PARAM); @@ -218,5 +219,4 @@ int gram_parse (); #endif #endif /* ! YYPARSE_PARAM */ - #endif /* !GRAM__________SRC_PARSE_GRAM_H */ From 4d24ffb75ebfc7c4fae027e23132c6d3630998b5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 11:11:19 +0200 Subject: [PATCH 21/29] style changes in the scanners * src/scan-code.l, src/scan-skel.l: Use a more traditional indentation style for start-conditions. Prefer "continue" to a comment, for empty actions. Strip useless {}. Remove useless start-condition clauses. --- src/scan-code.l | 14 ++++++++------ src/scan-skel.l | 40 +++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/scan-code.l b/src/scan-code.l index e30bf9db..31b44298 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -98,11 +98,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" int braces_level = 0; /* Whether a semicolon is probably needed. - The heuristic is that a semicolon is not needed after '{', '}', ';', - or a C preprocessor directive, and that whitespaces and comments - do not affect this flag. - Note that '{' does not need a semicolon because of '{}'. - A semicolon may be needed before a cpp direcive, but don't bother. */ + + The heuristic is that a semicolon is not needed after '{', '}', + ';', or a C preprocessor directive, and that whitespaces and + comments do not affect this flag. Note that '{' does not need a + semicolon because of '{}'. A semicolon may be needed before a + cpp directive, but don't bother. */ bool need_semicolon = false; /* Whether in a C preprocessor directive. Don't use a start condition @@ -160,7 +161,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" } -{ + +{ "'" { STRING_GROW; BEGIN SC_CHARACTER; diff --git a/src/scan-skel.l b/src/scan-skel.l index 24339057..862b34fd 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at); "@@" fputc ('@', yyout); "@{" fputc ('[', yyout); "@}" fputc (']', yyout); -"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */ -@\n /* Likewise. */ +"@`" continue; /* Used by b4_cat in ../data/bison.m4. */ +@\n continue; "@oline@" fprintf (yyout, "%d", out_lineno + 1); "@ofile@" QPUTS (outname); @@ -87,11 +87,11 @@ static void fail_for_invalid_at (char const *at); } /* This pattern must not match more than the previous @ patterns. */ -@[^@{}`(\n]* fail_for_invalid_at (yytext); -\n out_lineno++; ECHO; -[^@\n]+ ECHO; +@[^@{}`(\n]* fail_for_invalid_at (yytext); +\n out_lineno++; ECHO; +[^@\n]+ ECHO; -<> { +<> { if (outname) { free (outname); @@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at); return EOF; } -{ - [^@]+ { STRING_GROW; } + +{ + [^@]+ STRING_GROW; - "@@" { obstack_1grow (&obstack_for_string, '@'); } - "@{" { obstack_1grow (&obstack_for_string, '['); } - "@}" { obstack_1grow (&obstack_for_string, ']'); } - "@`" /* Empty. Useful for starting an argument - that begins with whitespace. */ - @\n /* Empty. */ + "@@" obstack_1grow (&obstack_for_string, '@'); + "@{" obstack_1grow (&obstack_for_string, '['); + "@}" obstack_1grow (&obstack_for_string, ']'); + "@`" continue; /* For starting an argument that begins with whitespace. */ + @\n continue; @[,)] { if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX) @@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at); } } - @.? { fail_for_invalid_at (yytext); } + @.? fail_for_invalid_at (yytext); } -{ - [ \t\r\n] - . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } + +{ + [ \t\r\n] continue; + . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } } -{ + +{ <> { fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]); } From e20e6a50d57ce0fb1a51a4b27cf6c8cfdd64bf99 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 12:19:01 +0200 Subject: [PATCH 22/29] news: schedule the removal of the ";" hack scan-code.l is significantly more complex because of this. * NEWS: Doc it. --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 56961cc2..5a9d314a 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,18 @@ GNU Bison NEWS Bison no longer executes user-specified M4 code when processing a grammar. +** Future Changes + + In addition to the removal of the features announced in Bison 2.6, the + next major release will remove the "Temporary hack for adding a semicolon + to the user action", as announced in the release 2.5. Instead of: + + exp: exp "+" exp { $$ = $1 + $3 }; + + write: + + exp: exp "+" exp { $$ = $1 + $3; }; + ** Bug fixes *** Type names are now properly escaped. From 263137264fa5e5a9fb03bc75f941c14bedfe47c4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 11:22:22 +0200 Subject: [PATCH 23/29] factor the handling of m4 escaping The conversion from @ to @@ and so forth is coded is too many different places. Factor, a bit. * src/scan-code.l: Instead of duplicating the logic of obstack_escape, use it. It sure is less efficient, but the cost is negligible. This allows to factor rules that are alike. And to factor some start-condition clauses. * tests/input.at (Stray $ or @): New. * NEWS: Document it. --- NEWS | 6 +++++ src/scan-code.l | 60 +++++++++++++++++-------------------------------- tests/input.at | 30 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/NEWS b/NEWS index 5a9d314a..b62aac6d 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,12 @@ GNU Bison NEWS *** glr.cc: set_debug_level and debug_level work as expected. +*** Stray @ or $ in actions + + While Bison used to warn about stray $ or @ in action rules, it did not + for other actions such as printers, destructors, or initial actions. It + now does. + ** Type names in printers and destructors For consistency with rule actions, it is now possible to qualify $$ by a diff --git a/src/scan-code.l b/src/scan-code.l index 31b44298..31befe91 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -103,7 +103,10 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" ';', or a C preprocessor directive, and that whitespaces and comments do not affect this flag. Note that '{' does not need a semicolon because of '{}'. A semicolon may be needed before a - cpp directive, but don't bother. */ + cpp directive, but don't bother. + + While it is maintained in several start-conditions (factoring + opportunities), it is meaningful only for SC_RULE_ACTION. */ bool need_semicolon = false; /* Whether in a C preprocessor directive. Don't use a start condition @@ -181,6 +184,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" STRING_GROW; BEGIN SC_LINE_COMMENT; } + [$@] { + warn_at (*loc, _("stray '%s'"), yytext); + obstack_escape (&obstack_for_string, yytext); + need_semicolon = true; + } + [\[\]] { + obstack_escape (&obstack_for_string, yytext); + need_semicolon = true; + } } @@ -199,24 +211,6 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" obstack_sgrow (&obstack_for_string, ref_tail_fields); need_semicolon = true; } - "$" { - warn_at (*loc, _("stray '$'")); - obstack_sgrow (&obstack_for_string, "$]["); - need_semicolon = true; - } - "@" { - warn_at (*loc, _("stray '@'")); - obstack_sgrow (&obstack_for_string, "@@"); - need_semicolon = true; - } - "[" { - obstack_sgrow (&obstack_for_string, "@{"); - need_semicolon = true; - } - "]" { - obstack_sgrow (&obstack_for_string, "@}"); - need_semicolon = true; - } ";" STRING_GROW; need_semicolon = false; "{" STRING_GROW; ++braces_level; need_semicolon = false; @@ -281,30 +275,18 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" } - /*-----------------------------------------. - | Escape M4 quoting characters in C code. | - `-----------------------------------------*/ - <*> { - \$ obstack_sgrow (&obstack_for_string, "$]["); - \@ obstack_sgrow (&obstack_for_string, "@@"); - \[ obstack_sgrow (&obstack_for_string, "@{"); - \] obstack_sgrow (&obstack_for_string, "@}"); + /* Escape M4 quoting characters in C code. */ + [$@\[\]] obstack_escape (&obstack_for_string, yytext); + + /* By default, grow the string obstack with the input. */ + .|\n STRING_GROW; + + /* End of processing. */ + <> STRING_FINISH; return last_string; } - /*-----------------------------------------------------. - | By default, grow the string obstack with the input. | - `-----------------------------------------------------*/ - -<*>.|\n STRING_GROW; - - /* End of processing. */ -<*><> { - STRING_FINISH; - return last_string; - } - %% static inline bool diff --git a/tests/input.at b/tests/input.at index 82d97f53..6b90b21e 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1371,6 +1371,36 @@ m4_popdef([AT_TEST]) AT_CLEANUP +## -------------- ## +## Stray $ or @. ## +## -------------- ## + +AT_SETUP([[Stray $ or @]]) + +AT_DATA_GRAMMAR([[input.y]], +[[%token TOK +%destructor { $%; @%; } <*>; +%initial-action { $%; @%; }; +%printer { $%; @%; } <*>; +%% +exp: TOK { $%; @%; }; +]]) + +AT_BISON_CHECK([[input.y]], 0, [], +[[input.y:10.19: warning: stray '$' +input.y:10.23: warning: stray '@' +input.y:11.19: warning: stray '$' +input.y:11.23: warning: stray '@' +input.y:12.19: warning: stray '$' +input.y:12.23: warning: stray '@' +input.y:14.19: warning: stray '$' +input.y:14.23: warning: stray '@' +]]) + +AT_CLEANUP + + + ## ---------------- ## ## Code injection. ## ## ---------------- ## From 1c292035e12d4c2c782f1dba6f78e690ad5635b3 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 12:47:02 +0200 Subject: [PATCH 24/29] printer/destructor: translate only once Currently "%printer {...} a b c d e f" translates the {...} six times. Not only is this bad for time and space, it also issues six times the same warnings. * src/symlist.h, src/symlist.c (symbol_list_destructor_set) (symbol_list_printer_set): Take the action as code_props instead of const char *. * src/parse-gram.y: Translate these actions here. * src/scan-code.h: Comment change. * tests/input.at: Check that warnings are issued only once. --- src/parse-gram.y | 26 ++++++++++++++++++-------- src/scan-code.h | 5 ++++- src/symlist.c | 26 ++++++++++---------------- src/symlist.h | 8 ++++---- tests/input.at | 9 ++++++--- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/parse-gram.y b/src/parse-gram.y index eb034b08..e6a27c50 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -347,17 +347,27 @@ grammar_declaration: } | "%destructor" "{...}" generic_symlist { - symbol_list *list; - for (list = $3; list; list = list->next) - symbol_list_destructor_set (list, $2, @2); - symbol_list_free ($3); + code_props code; + code_props_symbol_action_init (&code, $2, @2); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = $3; list; list = list->next) + symbol_list_destructor_set (list, &code); + symbol_list_free ($3); + } } | "%printer" "{...}" generic_symlist { - symbol_list *list; - for (list = $3; list; list = list->next) - symbol_list_printer_set (list, $2, @2); - symbol_list_free ($3); + code_props code; + code_props_symbol_action_init (&code, $2, @2); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = $3; list; list = list->next) + symbol_list_printer_set (list, &code); + symbol_list_free ($3); + } } | "%default-prec" { diff --git a/src/scan-code.h b/src/scan-code.h index 0a5bb996..c8d554d5 100644 --- a/src/scan-code.h +++ b/src/scan-code.h @@ -45,7 +45,10 @@ typedef struct code_props { CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION } kind; - /** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */ + /** + * \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. + * Memory is allocated in an obstack freed elsewhere. + */ char const *code; /** Undefined iff \c code_props::code is \c NULL. */ location location; diff --git a/src/symlist.c b/src/symlist.c index bf47da1e..69ac8a1b 100644 --- a/src/symlist.c +++ b/src/symlist.c @@ -223,49 +223,43 @@ symbol_list_null (symbol_list *node) } void -symbol_list_destructor_set (symbol_list *node, char const *code, location loc) +symbol_list_destructor_set (symbol_list *node, code_props const *destructor) { - code_props destructor; - code_props_symbol_action_init (&destructor, code, loc); - code_props_translate_code (&destructor); switch (node->content_type) { case SYMLIST_SYMBOL: - symbol_destructor_set (node->content.sym, &destructor); + symbol_destructor_set (node->content.sym, destructor); break; case SYMLIST_TYPE: semantic_type_destructor_set ( - semantic_type_get (node->content.type_name), &destructor); + semantic_type_get (node->content.type_name), destructor); break; case SYMLIST_DEFAULT_TAGGED: - default_tagged_destructor_set (&destructor); + default_tagged_destructor_set (destructor); break; case SYMLIST_DEFAULT_TAGLESS: - default_tagless_destructor_set (&destructor); + default_tagless_destructor_set (destructor); break; } } void -symbol_list_printer_set (symbol_list *node, char const *code, location loc) +symbol_list_printer_set (symbol_list *node, code_props const *printer) { - code_props printer; - code_props_symbol_action_init (&printer, code, loc); - code_props_translate_code (&printer); switch (node->content_type) { case SYMLIST_SYMBOL: - symbol_printer_set (node->content.sym, &printer); + symbol_printer_set (node->content.sym, printer); break; case SYMLIST_TYPE: semantic_type_printer_set ( - semantic_type_get (node->content.type_name), &printer); + semantic_type_get (node->content.type_name), printer); break; case SYMLIST_DEFAULT_TAGGED: - default_tagged_printer_set (&printer); + default_tagged_printer_set (printer); break; case SYMLIST_DEFAULT_TAGLESS: - default_tagless_printer_set (&printer); + default_tagless_printer_set (printer); break; } } diff --git a/src/symlist.h b/src/symlist.h index 43936b29..63577f79 100644 --- a/src/symlist.h +++ b/src/symlist.h @@ -119,11 +119,11 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n); bool symbol_list_null (symbol_list *node); /** Set the \c \%destructor for \c node as \c code at \c loc. */ -void symbol_list_destructor_set (symbol_list *node, char const *code, - location loc); +void symbol_list_destructor_set (symbol_list *node, + code_props const *destructor); /** Set the \c \%printer for \c node as \c code at \c loc. */ -void symbol_list_printer_set (symbol_list *node, char const *code, - location loc); +void symbol_list_printer_set (symbol_list *node, + code_props const *printer); #endif /* !SYMLIST_H_ */ diff --git a/tests/input.at b/tests/input.at index 6b90b21e..ff1d3924 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1377,13 +1377,16 @@ AT_CLEANUP AT_SETUP([[Stray $ or @]]) +# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to +# check that the warnings are reported once, not three times. + AT_DATA_GRAMMAR([[input.y]], [[%token TOK -%destructor { $%; @%; } <*>; +%destructor { $%; @%; } <*> exp TOK; %initial-action { $%; @%; }; -%printer { $%; @%; } <*>; +%printer { $%; @%; } <*> exp TOK; %% -exp: TOK { $%; @%; }; +exp: TOK { $%; @%; $$ = $1; }; ]]) AT_BISON_CHECK([[input.y]], 0, [], From 93e3dbab95d1ae7b7b4511e30b912769e432c514 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 12:53:46 +0200 Subject: [PATCH 25/29] regen --- src/parse-gram.c | 166 +++++++++++++++++++++++++---------------------- src/parse-gram.h | 2 +- 2 files changed, 89 insertions(+), 79 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index 12ca07dc..b2ca9ec9 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.22-9f3f1. */ +/* A Bison parser, made by GNU Bison 2.6.26-54c4-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.22-9f3f1" +#define YYBISON_VERSION "2.6.26-54c4-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -693,14 +693,14 @@ static const yytype_uint16 yyrline[] = 0, 229, 229, 237, 239, 243, 244, 254, 255, 260, 261, 266, 267, 268, 269, 270, 271, 276, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 310, - 311, 335, 336, 337, 338, 342, 343, 344, 348, 355, - 362, 366, 370, 377, 392, 393, 397, 409, 409, 414, - 414, 419, 430, 445, 446, 447, 451, 452, 457, 459, - 464, 465, 470, 472, 477, 478, 482, 483, 484, 485, - 490, 495, 500, 506, 512, 523, 524, 533, 534, 540, - 541, 542, 549, 549, 557, 558, 559, 564, 566, 568, - 570, 572, 574, 579, 581, 592, 593, 598, 599, 600, - 609, 629, 631, 640, 645, 646, 651, 658, 660 + 311, 335, 336, 337, 338, 342, 343, 344, 348, 360, + 372, 376, 380, 387, 402, 403, 407, 419, 419, 424, + 424, 429, 440, 455, 456, 457, 461, 462, 467, 469, + 474, 475, 480, 482, 487, 488, 492, 493, 494, 495, + 500, 505, 510, 516, 522, 533, 534, 543, 544, 550, + 551, 552, 559, 559, 567, 568, 569, 574, 576, 578, + 580, 582, 584, 589, 591, 602, 603, 608, 609, 610, + 619, 639, 641, 650, 655, 656, 661, 668, 670 }; #endif @@ -2481,29 +2481,39 @@ yyreduce: /* Line 1788 of yacc.c */ #line 349 "parse-gram.y" { - symbol_list *list; - for (list = (yyvsp[(3) - (3)].list); list; list = list->next) - symbol_list_destructor_set (list, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)])); - symbol_list_free ((yyvsp[(3) - (3)].list)); + code_props code; + code_props_symbol_action_init (&code, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)])); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = (yyvsp[(3) - (3)].list); list; list = list->next) + symbol_list_destructor_set (list, &code); + symbol_list_free ((yyvsp[(3) - (3)].list)); + } } break; case 39: /* Line 1788 of yacc.c */ -#line 356 "parse-gram.y" +#line 361 "parse-gram.y" { - symbol_list *list; - for (list = (yyvsp[(3) - (3)].list); list; list = list->next) - symbol_list_printer_set (list, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)])); - symbol_list_free ((yyvsp[(3) - (3)].list)); + code_props code; + code_props_symbol_action_init (&code, (yyvsp[(2) - (3)].code), (yylsp[(2) - (3)])); + code_props_translate_code (&code); + { + symbol_list *list; + for (list = (yyvsp[(3) - (3)].list); list; list = list->next) + symbol_list_printer_set (list, &code); + symbol_list_free ((yyvsp[(3) - (3)].list)); + } } break; case 40: /* Line 1788 of yacc.c */ -#line 363 "parse-gram.y" +#line 373 "parse-gram.y" { default_prec = true; } @@ -2512,7 +2522,7 @@ yyreduce: case 41: /* Line 1788 of yacc.c */ -#line 367 "parse-gram.y" +#line 377 "parse-gram.y" { default_prec = false; } @@ -2521,7 +2531,7 @@ yyreduce: case 42: /* Line 1788 of yacc.c */ -#line 371 "parse-gram.y" +#line 381 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ @@ -2533,7 +2543,7 @@ yyreduce: case 43: /* Line 1788 of yacc.c */ -#line 378 "parse-gram.y" +#line 388 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); code_scanner_last_string_free (); @@ -2543,21 +2553,21 @@ yyreduce: case 44: /* Line 1788 of yacc.c */ -#line 392 "parse-gram.y" +#line 402 "parse-gram.y" {} break; case 45: /* Line 1788 of yacc.c */ -#line 393 "parse-gram.y" +#line 403 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: /* Line 1788 of yacc.c */ -#line 398 "parse-gram.y" +#line 408 "parse-gram.y" { union_seen = true; muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2568,14 +2578,14 @@ yyreduce: case 47: /* Line 1788 of yacc.c */ -#line 409 "parse-gram.y" +#line 419 "parse-gram.y" { current_class = nterm_sym; } break; case 48: /* Line 1788 of yacc.c */ -#line 410 "parse-gram.y" +#line 420 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2585,14 +2595,14 @@ yyreduce: case 49: /* Line 1788 of yacc.c */ -#line 414 "parse-gram.y" +#line 424 "parse-gram.y" { current_class = token_sym; } break; case 50: /* Line 1788 of yacc.c */ -#line 415 "parse-gram.y" +#line 425 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2602,7 +2612,7 @@ yyreduce: case 51: /* Line 1788 of yacc.c */ -#line 420 "parse-gram.y" +#line 430 "parse-gram.y" { symbol_list *list; tag_seen = true; @@ -2615,7 +2625,7 @@ yyreduce: case 52: /* Line 1788 of yacc.c */ -#line 431 "parse-gram.y" +#line 441 "parse-gram.y" { symbol_list *list; ++current_prec; @@ -2632,126 +2642,126 @@ yyreduce: case 53: /* Line 1788 of yacc.c */ -#line 445 "parse-gram.y" +#line 455 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: /* Line 1788 of yacc.c */ -#line 446 "parse-gram.y" +#line 456 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: /* Line 1788 of yacc.c */ -#line 447 "parse-gram.y" +#line 457 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: /* Line 1788 of yacc.c */ -#line 451 "parse-gram.y" +#line 461 "parse-gram.y" { current_type = NULL; } break; case 57: /* Line 1788 of yacc.c */ -#line 452 "parse-gram.y" +#line 462 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: /* Line 1788 of yacc.c */ -#line 458 "parse-gram.y" +#line 468 "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 460 "parse-gram.y" +#line 470 "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 464 "parse-gram.y" +#line 474 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: /* Line 1788 of yacc.c */ -#line 465 "parse-gram.y" +#line 475 "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 471 "parse-gram.y" +#line 481 "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 473 "parse-gram.y" +#line 483 "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 477 "parse-gram.y" +#line 487 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: /* Line 1788 of yacc.c */ -#line 478 "parse-gram.y" +#line 488 "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 482 "parse-gram.y" +#line 492 "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 483 "parse-gram.y" +#line 493 "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 484 "parse-gram.y" +#line 494 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: /* Line 1788 of yacc.c */ -#line 485 "parse-gram.y" +#line 495 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: /* Line 1788 of yacc.c */ -#line 491 "parse-gram.y" +#line 501 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; @@ -2761,7 +2771,7 @@ yyreduce: case 71: /* Line 1788 of yacc.c */ -#line 496 "parse-gram.y" +#line 506 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)])); @@ -2771,7 +2781,7 @@ yyreduce: case 72: /* Line 1788 of yacc.c */ -#line 501 "parse-gram.y" +#line 511 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2782,7 +2792,7 @@ yyreduce: case 73: /* Line 1788 of yacc.c */ -#line 507 "parse-gram.y" +#line 517 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2793,7 +2803,7 @@ yyreduce: case 74: /* Line 1788 of yacc.c */ -#line 513 "parse-gram.y" +#line 523 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)])); @@ -2805,7 +2815,7 @@ yyreduce: case 81: /* Line 1788 of yacc.c */ -#line 543 "parse-gram.y" +#line 553 "parse-gram.y" { yyerrok; } @@ -2814,14 +2824,14 @@ yyreduce: case 82: /* Line 1788 of yacc.c */ -#line 549 "parse-gram.y" +#line 559 "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 550 "parse-gram.y" +#line 560 "parse-gram.y" { /* Free the current lhs. */ current_lhs (0, (yylsp[(1) - (4)]), 0); @@ -2831,21 +2841,21 @@ yyreduce: case 84: /* Line 1788 of yacc.c */ -#line 557 "parse-gram.y" +#line 567 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: /* Line 1788 of yacc.c */ -#line 558 "parse-gram.y" +#line 568 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: /* Line 1788 of yacc.c */ -#line 564 "parse-gram.y" +#line 574 "parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } break; @@ -2853,77 +2863,77 @@ yyreduce: case 88: /* Line 1788 of yacc.c */ -#line 567 "parse-gram.y" +#line 577 "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 569 "parse-gram.y" +#line 579 "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 571 "parse-gram.y" +#line 581 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: /* Line 1788 of yacc.c */ -#line 573 "parse-gram.y" +#line 583 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: /* Line 1788 of yacc.c */ -#line 575 "parse-gram.y" +#line 585 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: /* Line 1788 of yacc.c */ -#line 579 "parse-gram.y" +#line 589 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: /* Line 1788 of yacc.c */ -#line 581 "parse-gram.y" +#line 591 "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 593 "parse-gram.y" +#line 603 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: /* Line 1788 of yacc.c */ -#line 598 "parse-gram.y" +#line 608 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: /* Line 1788 of yacc.c */ -#line 599 "parse-gram.y" +#line 609 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: /* Line 1788 of yacc.c */ -#line 610 "parse-gram.y" +#line 620 "parse-gram.y" { code_props plain_code; (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n'; @@ -2937,14 +2947,14 @@ yyreduce: case 101: /* Line 1788 of yacc.c */ -#line 630 "parse-gram.y" +#line 640 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: /* Line 1788 of yacc.c */ -#line 632 "parse-gram.y" +#line 642 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2955,14 +2965,14 @@ yyreduce: case 103: /* Line 1788 of yacc.c */ -#line 640 "parse-gram.y" +#line 650 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: /* Line 1788 of yacc.c */ -#line 652 "parse-gram.y" +#line 662 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2972,7 +2982,7 @@ yyreduce: case 108: /* Line 1788 of yacc.c */ -#line 661 "parse-gram.y" +#line 671 "parse-gram.y" { code_props plain_code; code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); @@ -2986,7 +2996,7 @@ yyreduce: /* Line 1788 of yacc.c */ -#line 2990 "parse-gram.c" +#line 3000 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3236,7 +3246,7 @@ yyreturn: /* Line 2049 of yacc.c */ -#line 671 "parse-gram.y" +#line 681 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index 32c51798..0780d85a 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.22-9f3f1. */ +/* A Bison parser, made by GNU Bison 2.6.26-54c4-dirty. */ /* Bison interface for Yacc-like parsers in C From d6a44ffd0021ab0ca23e5e6243ecacb4e4b17ef1 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 13:47:24 +0200 Subject: [PATCH 26/29] skeletons: b4_dollar_pushdef and popdef to simpify complex definitions M4 is really making it uselessly hard to define macros that define macros. * data/c.m4 (b4_dollar_pushdef, b4_dollar_popdef): New. Use it. --- data/c.m4 | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/data/c.m4 b/data/c.m4 index 3954613b..12794e06 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -427,6 +427,21 @@ m4_define([b4_dollar_dollar_], [(*$1)])], [($1->$2)])]) +# b4_dollar_pushdef(VALUE, DEFAULT-FIELD, LOCATION) +# b4_dollar_popdef +# ------------------------------------------------- +# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD, +# and b4_at_dollar for LOCATION. +m4_define([b4_dollar_pushdef], +[m4_pushdef([b4_dollar_dollar], + [b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl +m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl +]) +m4_define([b4_dollar_popdef], +[m4_popdef([b4_at_dollar])dnl +m4_popdef([b4_dollar_dollar])dnl +]) + # b4_symbol_actions(FILENAME, LINENO, # SYMBOL-TAG, SYMBOL-NUM, @@ -437,16 +452,13 @@ m4_define([b4_dollar_dollar_], # Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are # invoked where $$ and @$ were specified by the user. m4_define([b4_symbol_actions], -[m4_pushdef([b4_dollar_dollar], - [b4_dollar_dollar_([yyvaluep], m4_dquote($][1), [$6])])dnl -m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl +[b4_dollar_pushdef([yyvaluep], [$6], [(*yylocationp)])dnl case $4: /* $3 */ b4_syncline([$2], [$1]) $5; b4_syncline([@oline@], [@ofile@]) break; -m4_popdef([b4_at_dollar])dnl -m4_popdef([b4_dollar_dollar])dnl +b4_dollar_popdef[]dnl ]) From cd735a8c6caab8f705fe551cc0316d0292eef11d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 14:20:00 +0200 Subject: [PATCH 27/29] also support $$ in the %initial-action scan-code.l is already passing argument to b4_dollar_dollar for the initial acton, but its definition (of b4_dollar_dollar) does not use this argument. Generalize this definition, and use it for the %initial-action too. * data/c.m4 (b4_dollar_dollar_, b4_dollar_pushdef, b4_dollar_popdef): Instead of expecting a pointer, require a value, and use ".". Since they are now generic enough, move to... * data/c-like.m4: this new file. * data/c.m4, data/java.m4: Load it. * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Use b4_dollar_pushdef for the %initial-action. * tests/actions.at: Check that. * data/Makefile.am: Adjust. * NEWS, doc/bison.texi: Document. --- NEWS | 6 +++--- data/Makefile.am | 1 + data/c-like.m4 | 44 ++++++++++++++++++++++++++++++++++++++++++++ data/c.m4 | 29 ++--------------------------- data/glr.c | 10 ++++------ data/java.m4 | 1 + data/lalr1.cc | 10 ++++------ data/lalr1.java | 10 ++++------ data/yacc.c | 11 +++++------ doc/bison.texi | 6 +++--- tests/actions.at | 10 +++++----- 11 files changed, 76 insertions(+), 62 deletions(-) create mode 100644 data/c-like.m4 diff --git a/NEWS b/NEWS index b62aac6d..b99290c9 100644 --- a/NEWS +++ b/NEWS @@ -28,15 +28,15 @@ GNU Bison NEWS for other actions such as printers, destructors, or initial actions. It now does. -** Type names in printers and destructors +** Type names in actions For consistency with rule actions, it is now possible to qualify $$ by a - type-name in printers and destructors. For instance: + type-name in destructors, printers, and initial actions. For instance: %printer { fprintf (yyo, "(%d, %f)", $$, $$); } <*> <>; will display two values for each typed and untyped symbol (provided - that YYSTYPE supports it). + that YYSTYPE has both "ival" and "fval" fields). * Noteworthy changes in release 2.6 (2012-07-19) [stable] diff --git a/data/Makefile.am b/data/Makefile.am index c2231886..1fd10b4a 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -14,6 +14,7 @@ # along with this program. If not, see . dist_pkgdata_DATA = README bison.m4 \ + c-like.m4 \ c-skel.m4 c.m4 yacc.c glr.c \ c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \ java-skel.m4 java.m4 lalr1.java diff --git a/data/c-like.m4 b/data/c-like.m4 new file mode 100644 index 00000000..c2abce7e --- /dev/null +++ b/data/c-like.m4 @@ -0,0 +1,44 @@ + -*- Autoconf -*- + +# Common code for C-like languages (C, C++, Java, etc.) + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD) +# ---------------------------------------------- +# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD", +# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a +# pointer. +m4_define([b4_dollar_dollar_], +[m4_if([$2], [[]], + [m4_ifval([$3], [($1.$3)], + [$1])], + [($1.$2)])]) + +# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION) +# b4_dollar_popdef +# --------------------------------------------------------- +# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD, +# and b4_at_dollar for LOCATION. +m4_define([b4_dollar_pushdef], +[m4_pushdef([b4_dollar_dollar], + [b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl +m4_pushdef([b4_at_dollar], [$3])dnl +]) +m4_define([b4_dollar_popdef], +[m4_popdef([b4_at_dollar])dnl +m4_popdef([b4_dollar_dollar])dnl +]) diff --git a/data/c.m4 b/data/c.m4 index 12794e06..45468e3c 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +m4_include(b4_pkgdatadir/[c-like.m4]) # b4_tocpp(STRING) # ---------------- @@ -417,32 +418,6 @@ m4_define([b4_case], $2 break;]) -# b4_dollar_dollar_(NAME, FIELD, DEFAULT-FIELD) -# --------------------------------------------- -# If FIELD (or DEFAULT-FIELD) is non-null, read it in pointer NAME, -# otherwise just dereference. -m4_define([b4_dollar_dollar_], -[m4_if([$2], [[]], - [m4_ifval([$3], [($1->$3)], - [(*$1)])], - [($1->$2)])]) - -# b4_dollar_pushdef(VALUE, DEFAULT-FIELD, LOCATION) -# b4_dollar_popdef -# ------------------------------------------------- -# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD, -# and b4_at_dollar for LOCATION. -m4_define([b4_dollar_pushdef], -[m4_pushdef([b4_dollar_dollar], - [b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl -m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl -]) -m4_define([b4_dollar_popdef], -[m4_popdef([b4_at_dollar])dnl -m4_popdef([b4_dollar_dollar])dnl -]) - - # b4_symbol_actions(FILENAME, LINENO, # SYMBOL-TAG, SYMBOL-NUM, # SYMBOL-ACTION, SYMBOL-TYPENAME) @@ -452,7 +427,7 @@ m4_popdef([b4_dollar_dollar])dnl # Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are # invoked where $$ and @$ were specified by the user. m4_define([b4_symbol_actions], -[b4_dollar_pushdef([yyvaluep], [$6], [(*yylocationp)])dnl +[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl case $4: /* $3 */ b4_syncline([$2], [$1]) $5; diff --git a/data/glr.c b/data/glr.c index ebef9694..08f6cd8d 100644 --- a/data/glr.c +++ b/data/glr.c @@ -2302,12 +2302,10 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) #endif ]) m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [yylloc])dnl -m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ - b4_user_initial_action -m4_popdef([b4_dollar_dollar])dnl -m4_popdef([b4_at_dollar])])dnl +b4_dollar_pushdef([yylval], [], [yylloc])dnl +/* User initialization code. */ +b4_user_initial_action +b4_dollar_popdef])[]dnl [ if (! yyinitGLRStack (yystackp, YYINITDEPTH)) goto yyexhaustedlab; diff --git a/data/java.m4 b/data/java.m4 index d137fd59..18ea30b5 100644 --- a/data/java.m4 +++ b/data/java.m4 @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +m4_include(b4_pkgdatadir/[c-like.m4]) # b4_comment(TEXT) # ---------------- diff --git a/data/lalr1.cc b/data/lalr1.cc index 17a8f22c..c1639033 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -536,12 +536,10 @@ do { \ YYCDEBUG << "Starting parse" << std::endl; ]m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [yylloc])dnl -m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ - b4_user_initial_action -m4_popdef([b4_dollar_dollar])dnl -m4_popdef([b4_at_dollar])])dnl +b4_dollar_pushdef([yylval], [], [yylloc])dnl +/* User initialization code. */ +b4_user_initial_action +b4_dollar_popdef])[]dnl [ /* Initialize the stacks. The initial state will be pushed in yynewstate, since the latter expects the semantical and the diff --git a/data/lalr1.java b/data/lalr1.java index 103c03dd..d1410a10 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -458,12 +458,10 @@ b4_lexer_if([[ yyerrstatus_ = 0; ]m4_ifdef([b4_initial_action], [ -m4_pushdef([b4_at_dollar], [yylloc])dnl -m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ - b4_user_initial_action -m4_popdef([b4_dollar_dollar])dnl -m4_popdef([b4_at_dollar])])dnl +b4_dollar_pushdef([yylval], [], [yylloc])dnl +/* User initialization code. */ +b4_user_initial_action +b4_dollar_popdef])[]dnl [ /* Initialize the stack. */ yystack.push (yystate, yylval]b4_locations_if([, yylloc])[); diff --git a/data/yacc.c b/data/yacc.c index 5e77f844..1cd9ffbb 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -1570,17 +1570,16 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; #endif]]) m4_ifdef([b4_initial_action],[ -m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl -m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl +b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], + [m4_define([b4_at_dollar_used])yylloc])dnl /* User initialization code. */ b4_user_initial_action -m4_popdef([b4_dollar_dollar])dnl -m4_popdef([b4_at_dollar])])dnl +b4_dollar_popdef[]dnl m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval; ]])dnl m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; -]])[ - goto yysetstate; +]])])dnl +[ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | diff --git a/doc/bison.texi b/doc/bison.texi index e50bd171..ad605054 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -4552,9 +4552,9 @@ code. @deffn {Directive} %initial-action @{ @var{code} @} @findex %initial-action Declare that the braced @var{code} must be invoked before parsing each time -@code{yyparse} is called. The @var{code} may use @code{$$} and -@code{@@$} --- initial value and location of the lookahead --- and the -@code{%parse-param}. +@code{yyparse} is called. The @var{code} may use @code{$$} (or +@code{$<@var{tag}>$}) and @code{@@$} --- initial value and location of the +lookahead --- and the @code{%parse-param}. @end deffn For instance, if your locations use a file name, you may use diff --git a/tests/actions.at b/tests/actions.at index dd909b00..8232a007 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1307,11 +1307,11 @@ AT_DATA_GRAMMAR([[input.y]], } ]])[ -// %initial-action -// { -// $$ = 42; -// $$ = 4.2; -// } +%initial-action +{ + $$ = 42; + $$ = 4.2; +} %% float: UNTYPED INT From e6cab382c5a2c18e165cafae3666201ff5f89c02 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 14:52:23 +0200 Subject: [PATCH 28/29] synclines: remove spurious empty line * data/bison.m4 (b4_syncline): Do not start with an empty line. --- data/bison.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/bison.m4 b/data/bison.m4 index 178134a4..fac86f2a 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -259,8 +259,8 @@ m4_define([b4_basename], # b4_syncline(LINE, FILE) # ----------------------- m4_define([b4_syncline], -[b4_flag_if([synclines], [ -b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) +[b4_flag_if([synclines], +[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) b4_sync_start([$1], [$2])])]) m4_define([b4_sync_end], [b4_comment([Line $1 of $2])]) From 7b18c112316339685df9ba15f44741c608a29145 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 14:52:55 +0200 Subject: [PATCH 29/29] regen --- src/parse-gram.c | 436 ++++++++++++++++------------------------------- src/parse-gram.h | 10 +- 2 files changed, 155 insertions(+), 291 deletions(-) diff --git a/src/parse-gram.c b/src/parse-gram.c index b2ca9ec9..3d0e0b8a 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.26-54c4-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.29-cd73-dirty. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.6.26-54c4-dirty" +#define YYBISON_VERSION "2.6.29-cd73-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -70,7 +70,6 @@ #define yylloc gram_lloc /* Copy the first part of user declarations. */ - /* Line 336 of yacc.c */ #line 1 "parse-gram.y" /* Bison Grammar Parser -*- C -*- @@ -166,9 +165,8 @@ 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 172 "parse-gram.c" +#line 170 "parse-gram.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -325,7 +323,6 @@ extern int gram_debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { - /* Line 350 of yacc.c */ #line 114 "parse-gram.y" @@ -340,9 +337,8 @@ typedef union YYSTYPE named_ref *named_ref; - /* Line 350 of yacc.c */ -#line 346 "parse-gram.c" +#line 342 "parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -381,9 +377,8 @@ int gram_parse (); /* Copy the second part of user declarations. */ - /* Line 353 of yacc.c */ -#line 387 "parse-gram.c" +#line 382 "parse-gram.c" #ifdef short # undef short @@ -1074,166 +1069,130 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) switch (yytype) { case 3: /* "string" */ - /* Line 809 of yacc.c */ #line 204 "parse-gram.y" - { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; - + { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); }; +/* Line 809 of yacc.c */ +#line 1077 "parse-gram.c" + break; + case 4: /* "integer" */ +/* Line 809 of yacc.c */ +#line 216 "parse-gram.y" + { fprintf (stderr, "%d", ((*yyvaluep).integer)); }; /* Line 809 of yacc.c */ #line 1084 "parse-gram.c" break; - case 4: /* "integer" */ - -/* Line 809 of yacc.c */ -#line 216 "parse-gram.y" - { fprintf (stderr, "%d", (yyvaluep->integer)); }; - -/* Line 809 of yacc.c */ -#line 1093 "parse-gram.c" - break; case 43: /* "{...}" */ - /* Line 809 of yacc.c */ #line 206 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; - + { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); }; /* Line 809 of yacc.c */ -#line 1102 "parse-gram.c" +#line 1091 "parse-gram.c" break; case 44: /* "[identifier]" */ - /* Line 809 of yacc.c */ #line 211 "parse-gram.y" - { fprintf (stderr, "[%s]", (yyvaluep->uniqstr)); }; - + { fprintf (stderr, "[%s]", ((*yyvaluep).uniqstr)); }; /* Line 809 of yacc.c */ -#line 1111 "parse-gram.c" +#line 1098 "parse-gram.c" break; case 45: /* "char" */ - /* Line 809 of yacc.c */ #line 198 "parse-gram.y" - { fputs (char_name ((yyvaluep->character)), stderr); }; - + { fputs (char_name (((*yyvaluep).character)), stderr); }; /* Line 809 of yacc.c */ -#line 1120 "parse-gram.c" +#line 1105 "parse-gram.c" break; case 46: /* "epilogue" */ - /* Line 809 of yacc.c */ #line 206 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; - + { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 809 of yacc.c */ -#line 1129 "parse-gram.c" +#line 1112 "parse-gram.c" break; case 48: /* "identifier" */ - /* Line 809 of yacc.c */ #line 210 "parse-gram.y" - { fputs ((yyvaluep->uniqstr), stderr); }; - + { fputs (((*yyvaluep).uniqstr), stderr); }; /* Line 809 of yacc.c */ -#line 1138 "parse-gram.c" +#line 1119 "parse-gram.c" break; case 49: /* "identifier:" */ - /* Line 809 of yacc.c */ #line 212 "parse-gram.y" - { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; - + { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); }; +/* Line 809 of yacc.c */ +#line 1126 "parse-gram.c" + break; + case 52: /* "%{...%}" */ +/* Line 809 of yacc.c */ +#line 206 "parse-gram.y" + { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; +/* Line 809 of yacc.c */ +#line 1133 "parse-gram.c" + break; + case 54: /* "type" */ +/* Line 809 of yacc.c */ +#line 213 "parse-gram.y" + { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); }; +/* Line 809 of yacc.c */ +#line 1140 "parse-gram.c" + break; + case 71: /* symbol.prec */ +/* Line 809 of yacc.c */ +#line 219 "parse-gram.y" + { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 809 of yacc.c */ #line 1147 "parse-gram.c" break; - case 52: /* "%{...%}" */ - -/* Line 809 of yacc.c */ -#line 206 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; - -/* Line 809 of yacc.c */ -#line 1156 "parse-gram.c" - break; - case 54: /* "type" */ - -/* Line 809 of yacc.c */ -#line 213 "parse-gram.y" - { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; - -/* Line 809 of yacc.c */ -#line 1165 "parse-gram.c" - break; - case 71: /* symbol.prec */ - -/* Line 809 of yacc.c */ -#line 219 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; - -/* Line 809 of yacc.c */ -#line 1174 "parse-gram.c" - break; case 84: /* variable */ - /* Line 809 of yacc.c */ #line 210 "parse-gram.y" - { fputs ((yyvaluep->uniqstr), stderr); }; - + { fputs (((*yyvaluep).uniqstr), stderr); }; /* Line 809 of yacc.c */ -#line 1183 "parse-gram.c" +#line 1154 "parse-gram.c" break; case 85: /* content.opt */ - /* Line 809 of yacc.c */ #line 206 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; - + { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 809 of yacc.c */ -#line 1192 "parse-gram.c" +#line 1161 "parse-gram.c" break; case 86: /* braceless */ - /* Line 809 of yacc.c */ #line 206 "parse-gram.y" - { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; - + { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); }; /* Line 809 of yacc.c */ -#line 1201 "parse-gram.c" +#line 1168 "parse-gram.c" break; case 87: /* id */ - /* Line 809 of yacc.c */ #line 219 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; - + { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 809 of yacc.c */ -#line 1210 "parse-gram.c" +#line 1175 "parse-gram.c" break; case 88: /* id_colon */ - /* Line 809 of yacc.c */ #line 220 "parse-gram.y" - { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; - + { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); }; /* Line 809 of yacc.c */ -#line 1219 "parse-gram.c" +#line 1182 "parse-gram.c" break; case 89: /* symbol */ - /* Line 809 of yacc.c */ #line 219 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; - + { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 809 of yacc.c */ -#line 1228 "parse-gram.c" +#line 1189 "parse-gram.c" break; case 90: /* string_as_id */ - /* Line 809 of yacc.c */ #line 219 "parse-gram.y" - { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; - + { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); }; /* Line 809 of yacc.c */ -#line 1237 "parse-gram.c" +#line 1196 "parse-gram.c" break; default: break; @@ -2009,7 +1968,6 @@ YYLTYPE yylloc; #endif /* User initialization code. */ - /* Line 1572 of yacc.c */ #line 106 "parse-gram.y" { @@ -2018,11 +1976,9 @@ YYLTYPE yylloc; boundary_set (&yylloc.start, current_file, 1, 1); boundary_set (&yylloc.end, current_file, 1, 1); } - /* Line 1572 of yacc.c */ -#line 2024 "parse-gram.c" +#line 1981 "parse-gram.c" yylsp[0] = yylloc; - goto yysetstate; /*------------------------------------------------------------. @@ -2213,8 +2169,7 @@ yyreduce: switch (yyn) { case 6: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 245 "parse-gram.y" { code_props plain_code; @@ -2228,15 +2183,13 @@ yyreduce: break; case 7: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 254 "parse-gram.y" { debug_flag = true; } break; case 8: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 256 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), @@ -2245,15 +2198,13 @@ yyreduce: break; case 9: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 260 "parse-gram.y" { defines_flag = true; } break; case 10: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 262 "parse-gram.y" { defines_flag = true; @@ -2262,43 +2213,37 @@ yyreduce: break; case 11: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 266 "parse-gram.y" { error_verbose = true; } break; case 12: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 267 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 268 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 269 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 270 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 272 "parse-gram.y" { nondeterministic_parser = true; @@ -2307,8 +2252,7 @@ yyreduce: break; case 17: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 277 "parse-gram.y" { code_props action; @@ -2321,78 +2265,67 @@ yyreduce: break; case 18: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 285 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } break; case 19: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 286 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 287 "parse-gram.y" { locations_flag = true; } break; case 21: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 288 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 289 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 290 "parse-gram.y" { no_lines_flag = true; } break; case 24: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 291 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 292 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 293 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 294 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 296 "parse-gram.y" { /* %pure-parser is deprecated in favor of `%define api.pure', so use @@ -2411,15 +2344,13 @@ yyreduce: break; case 29: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 310 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 312 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); @@ -2447,29 +2378,25 @@ yyreduce: break; case 31: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 335 "parse-gram.y" { token_table_flag = true; } break; case 32: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 336 "parse-gram.y" { report_flag |= report_states; } break; case 33: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 337 "parse-gram.y" { yacc_flag = true; } break; case 37: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 345 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); @@ -2477,8 +2404,7 @@ yyreduce: break; case 38: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 349 "parse-gram.y" { code_props code; @@ -2494,8 +2420,7 @@ yyreduce: break; case 39: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 361 "parse-gram.y" { code_props code; @@ -2511,8 +2436,7 @@ yyreduce: break; case 40: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 373 "parse-gram.y" { default_prec = true; @@ -2520,8 +2444,7 @@ yyreduce: break; case 41: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 377 "parse-gram.y" { default_prec = false; @@ -2529,8 +2452,7 @@ yyreduce: break; case 42: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 381 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes @@ -2541,8 +2463,7 @@ yyreduce: break; case 43: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 388 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2551,22 +2472,19 @@ yyreduce: break; case 44: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 402 "parse-gram.y" {} break; case 45: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 403 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 408 "parse-gram.y" { union_seen = true; @@ -2576,15 +2494,13 @@ yyreduce: break; case 47: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 419 "parse-gram.y" { current_class = nterm_sym; } break; case 48: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 420 "parse-gram.y" { current_class = unknown_sym; @@ -2593,15 +2509,13 @@ yyreduce: break; case 49: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 424 "parse-gram.y" { current_class = token_sym; } break; case 50: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 425 "parse-gram.y" { current_class = unknown_sym; @@ -2610,8 +2524,7 @@ yyreduce: break; case 51: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 430 "parse-gram.y" { symbol_list *list; @@ -2623,8 +2536,7 @@ yyreduce: break; case 52: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 441 "parse-gram.y" { symbol_list *list; @@ -2640,127 +2552,109 @@ yyreduce: break; case 53: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 455 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 456 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 457 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 461 "parse-gram.y" { current_type = NULL; } break; case 57: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 462 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 468 "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 1787 of yacc.c */ #line 470 "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 1787 of yacc.c */ #line 474 "parse-gram.y" { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } break; case 61: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 475 "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 1787 of yacc.c */ #line 481 "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 1787 of yacc.c */ #line 483 "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 1787 of yacc.c */ #line 487 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 65: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 488 "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 1787 of yacc.c */ #line 492 "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 1787 of yacc.c */ #line 493 "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 1787 of yacc.c */ #line 494 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 69: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 495 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 70: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 501 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); @@ -2769,8 +2663,7 @@ yyreduce: break; case 71: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 506 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); @@ -2779,8 +2672,7 @@ yyreduce: break; case 72: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 511 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2790,8 +2682,7 @@ yyreduce: break; case 73: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 517 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); @@ -2801,8 +2692,7 @@ yyreduce: break; case 74: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 523 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); @@ -2813,8 +2703,7 @@ yyreduce: break; case 81: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 553 "parse-gram.y" { yyerrok; @@ -2822,15 +2711,13 @@ yyreduce: break; case 82: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 559 "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 1787 of yacc.c */ #line 560 "parse-gram.y" { /* Free the current lhs. */ @@ -2839,100 +2726,86 @@ yyreduce: break; case 84: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 567 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 85: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 568 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 87: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 574 "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 1787 of yacc.c */ #line 577 "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 1787 of yacc.c */ #line 579 "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 1787 of yacc.c */ #line 581 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 91: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 583 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 92: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 585 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 93: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 589 "parse-gram.y" { (yyval.named_ref) = 0; } break; case 94: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 591 "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 1787 of yacc.c */ #line 603 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 97: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 608 "parse-gram.y" { (yyval.chars) = ""; } break; case 98: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 609 "parse-gram.y" { (yyval.chars) = (yyvsp[(1) - (1)].uniqstr); } break; case 100: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 620 "parse-gram.y" { code_props plain_code; @@ -2945,15 +2818,13 @@ yyreduce: break; case 101: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 640 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 102: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 642 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); @@ -2963,15 +2834,13 @@ yyreduce: break; case 103: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 650 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 106: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 662 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); @@ -2980,8 +2849,7 @@ yyreduce: break; case 108: - -/* Line 1788 of yacc.c */ +/* Line 1787 of yacc.c */ #line 671 "parse-gram.y" { code_props plain_code; @@ -2994,9 +2862,8 @@ yyreduce: break; - -/* Line 1788 of yacc.c */ -#line 3000 "parse-gram.c" +/* Line 1787 of yacc.c */ +#line 2867 "parse-gram.c" default: break; } if (yychar_backup != yychar) @@ -3244,8 +3111,7 @@ yyreturn: } - -/* Line 2049 of yacc.c */ +/* Line 2048 of yacc.c */ #line 681 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index 0780d85a..10de0a64 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.6.26-54c4-dirty. */ +/* A Bison parser, made by GNU Bison 2.6.29-cd73-dirty. */ /* Bison interface for Yacc-like parsers in C @@ -167,8 +167,7 @@ extern int gram_debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { - -/* Line 2050 of yacc.c */ +/* Line 2049 of yacc.c */ #line 114 "parse-gram.y" symbol *symbol; @@ -182,9 +181,8 @@ typedef union YYSTYPE named_ref *named_ref; - -/* Line 2050 of yacc.c */ -#line 188 "parse-gram.h" +/* Line 2049 of yacc.c */ +#line 186 "parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */