From: Paul Eggert Date: Tue, 3 Jan 2006 20:25:54 +0000 (+0000) Subject: * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: X-Git-Tag: v2.3b~522 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/1221b78adb3f243e9afb8096f95218e2b03a4854 * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Allow multiple %union directives, whose contents concatenate. * src/parse-gram.y (grammar_declaration): Likewise. Use muscle_code_grow, so that we don't need stype_line any more. All uses changed. --- diff --git a/ChangeLog b/ChangeLog index f1efb1cd..337397c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2006-01-03 Paul Eggert + * data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: + Allow multiple %union directives, whose contents concatenate. + * src/parse-gram.y (grammar_declaration): Likewise. + Use muscle_code_grow, so that we don't need stype_line any more. + All uses changed. + + * src/muscle_tab.c (muscle_grow): Fix comment. + * ChangeLog, data/c.m4, data/glr.c, data/glr.cc, data/location.cc: * data/yacc.c, src/getargs.c, src/output.c, tests/cxx-type.at: Update copyright year to 2006. diff --git a/data/glr.c b/data/glr.c index d220903a..20f5043f 100644 --- a/data/glr.c +++ b/data/glr.c @@ -173,10 +173,11 @@ m4_define([b4_shared_declarations], #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ]) +b4_stype /* Line __line__ of glr.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;])[ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 diff --git a/data/glr.cc b/data/glr.cc index a3d8121d..20ff2e7e 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -296,10 +296,11 @@ namespace yy /// Symbol semantic values. #if ! defined (YYSTYPE) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) - union semantic_type b4_stype; +[ union semantic_type +b4_stype /* Line __line__ of lalr1.cc. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + ;], [ typedef int semantic_type;])[ #else typedef YYSTYPE semantic_type; diff --git a/data/lalr1.cc b/data/lalr1.cc index 94fc9183..e27cce48 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -2,7 +2,7 @@ m4_divert(-1) # C++ skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006 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 @@ -30,7 +30,7 @@ m4_divert(0)dnl m4_if(b4_defines_flag, 0, [], [@output @output_header_name@ b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], - [2002, 2003, 2004, 2005]) + [2002, 2003, 2004, 2005, 2006]) dnl FIXME: This is wrong, we want computed header guards. [ /* C++ LALR(1) parser skeleton written by Akim Demaille. */ @@ -104,10 +104,11 @@ namespace yy /// Symbol semantic values. #if ! defined (YYSTYPE) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) - union semantic_type b4_stype; +[ union semantic_type +b4_stype /* Line __line__ of lalr1.cc. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + ;], [ typedef int semantic_type;])[ #else typedef YYSTYPE semantic_type; @@ -295,7 +296,7 @@ b4_error_verbose_if([, int tok])[); ])dnl @output @output_parser_name@ b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], - [2002, 2003, 2004, 2005]) + [2002, 2003, 2004, 2005, 2006]) m4_if(b4_prefix[], [yy], [], [ // Take the name prefix into account. @@ -1048,7 +1049,8 @@ b4_error_verbose_if([, int tok])[) ]b4_epilogue dnl @output b4_dir_prefix[]stack.hh -b4_copyright([stack handling for Bison C++ parsers], [2002, 2003, 2004, 2005])[ +b4_copyright([stack handling for Bison C++ parsers], + [2002, 2003, 2004, 2005, 2006])[ #ifndef BISON_STACK_HH # define BISON_STACK_HH diff --git a/data/yacc.c b/data/yacc.c index 893c86a8..af87be3a 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -189,10 +189,11 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ]) +b4_stype /* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;])[ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -1508,10 +1509,11 @@ b4_token_enums_defines(b4_tokens) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_file_name]) -typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; +[typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ]) +b4_stype /* Line __line__ of yacc.c. */ -b4_syncline([@oline@], [@ofile@])], +b4_syncline([@oline@], [@ofile@]) + YYSTYPE;], [typedef int YYSTYPE;]) # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/src/parse-gram.y b/src/parse-gram.y index db63e508..1081f536 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -247,9 +247,19 @@ grammar_declaration: } | "%union {...}" { + char const *body = $1; + + if (typed) + { + /* Concatenate the union bodies, turning the first one's + trailing '}' into '\n', and omitting the second one's '{'. */ + char *code = muscle_find ("stype"); + code[strlen (code) - 1] = '\n'; + body++; + } + typed = true; - MUSCLE_INSERT_INT ("stype_line", @1.start.line); - muscle_insert ("stype", $1); + muscle_code_grow ("stype", body, @1); } | "%destructor {...}" symbols.1 {