mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
%union: fix the support for named %union
Bison supports a union tag, for obscure reasons. But it does a poor job at it, especially since Bison 3.0. Reported by Stephen Cameron and Tobias Frost. It did not ensure that the name was not given several times. An easy way to do this is to make the %union tag be handled as a %define variable, as they cannot be defined several times. Since Bison 3.0, the synclines were wrongly placed, resulting in invalid code. Addressing this issue, because of the way the union tag was stored (as a code muscle), would have been tedious. Unless we rather define the %union tag as a %percent variable, whose synclines are easier to manipulate. So replace the b4_union_name muscle by the api.value.union.name %define variable, document, and check. * data/bison.m4: Make sure that api.value.union.name has a keyword value. * data/c++.m4: Make sure that api.value.union.name is not defined. * data/c.m4 (b4_union_name): No longer use it, use api.value.union.name. * doc/bison.texi (%define Summary): Document it. * src/parse-gram.y (union_name): No longer define b4_uion_name, but api.value.union.name. * tests/input.at (Redefined %union name): New. * tests/synclines.at (%union name syncline): New. * tests/types.at: Check named %unions.
This commit is contained in:
374
src/parse-gram.c
374
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,7 @@ extern int gram_debug;
|
||||
param_parse = 1 << 1,
|
||||
param_both = param_lex | param_parse
|
||||
} param_type;
|
||||
#line 645 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
#line 647 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
#include "muscle-tab.h"
|
||||
|
||||
#line 68 "src/parse-gram.h" /* yacc.c:1909 */
|
||||
@@ -132,7 +132,7 @@ extern int gram_debug;
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
|
||||
typedef union GRAM_STYPE GRAM_STYPE;
|
||||
|
||||
union GRAM_STYPE
|
||||
{
|
||||
#line 182 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
@@ -155,7 +155,7 @@ named_ref *named_ref;
|
||||
param_type param;
|
||||
#line 409 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
code_props_type code_type;
|
||||
#line 647 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
#line 649 "src/parse-gram.y" /* yacc.c:1909 */
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -165,6 +165,8 @@ code_props_type code_type;
|
||||
|
||||
#line 167 "src/parse-gram.h" /* yacc.c:1909 */
|
||||
};
|
||||
|
||||
typedef union GRAM_STYPE GRAM_STYPE;
|
||||
# define GRAM_STYPE_IS_TRIVIAL 1
|
||||
# define GRAM_STYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
@@ -421,7 +421,9 @@ code_props_type:
|
||||
|
||||
union_name:
|
||||
%empty {}
|
||||
| ID { muscle_code_grow ("union_name", $1, @1); }
|
||||
| ID { muscle_percent_define_insert ("api.value.union.name",
|
||||
@1, muscle_keyword, $1,
|
||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); }
|
||||
;
|
||||
|
||||
grammar_declaration:
|
||||
|
||||
Reference in New Issue
Block a user