From: Joel E. Denny Date: Tue, 16 Jan 2007 06:16:04 +0000 (+0000) Subject: Clean up %define and %code implementation in M4 some. Most X-Git-Tag: v2.3b~181 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/a4e25e1dec3b4e5ff028817eaefa9827041636c2 Clean up %define and %code implementation in M4 some. Most importantly, rename all related macros to be in the b4_percent_define and b4_percent_code namespaces. Also, complete support for `.' in %define variable names and %code qualifiers. * data/bison.m4 (b4_check_user_names): Check for special "SKELETON-NAMESPACE(name)" macros instead of using two nested m4_foreach loops. (b4_get_percent_define, b4_get_percent_code): Rename to... (b4_percent_define_get, b4_percent_code_get): ... these. Extend documentation with examples. For SKELETON-NAMESPACE (as documented for b4_check_user_names), use b4_percent_define_skeleton_variables and b4_percent_code_skeleton_qualifiers. Expect any value for the %define variable `foo' to be stored in the macro named `b4_percent_define(foo)'; expect any %code blocks for the qualifier `foo' to be stored in a macro named `b4_percent_code(foo)'; expect any unqualified %code blocks to be stored in a macro named `b4_percent_code_unqualified'. Use m4_indir so that %define variable names and %code qualifiers can contain `.', which is allowed by the grammar parser. (b4_percent_define_default): New macro to set a default value for a %define variable. (m4_wrap): Update wrapped code, and fix some underquoting. (b4_check_user_names_wrap): Update and define outside the m4_wrap. Expect grammar uses of %define variables and %code qualifiers to be defined in b4_percent_define_user_variables and b4_percent_code_user_qualifiers. * data/c++.m4: Use b4_percent_define_default rather than m4_define_default. Fix some underquoting. Skeleton usage of %define variable define_location_comparison now implies skeleton usage of %define variable filename_type. * data/glr.c, data/glr.cc, data/lalr1.cc, data/location.cc, data/push.c, data/yacc.c: Update macro names. * src/parse-gram.y (prologue_declaration, grammar_declaration): Update muscle names. --- diff --git a/ChangeLog b/ChangeLog index 449b09db..9fe8bddb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2007-01-15 Paolo Bonzini + and Joel E. Denny + + Clean up %define and %code implementation in M4 some. Most + importantly, rename all related macros to be in the b4_percent_define + and b4_percent_code namespaces. Also, complete support for `.' in + %define variable names and %code qualifiers. + * data/bison.m4 (b4_check_user_names): Check for special + "SKELETON-NAMESPACE(name)" macros instead of using two nested + m4_foreach loops. + (b4_get_percent_define, b4_get_percent_code): Rename to... + (b4_percent_define_get, b4_percent_code_get): ... these. + Extend documentation with examples. + For SKELETON-NAMESPACE (as documented for b4_check_user_names), use + b4_percent_define_skeleton_variables and + b4_percent_code_skeleton_qualifiers. + Expect any value for the %define variable `foo' to be stored in the + macro named `b4_percent_define(foo)'; expect any %code blocks for the + qualifier `foo' to be stored in a macro named `b4_percent_code(foo)'; + expect any unqualified %code blocks to be stored in a macro named + `b4_percent_code_unqualified'. + Use m4_indir so that %define variable names and %code qualifiers can + contain `.', which is allowed by the grammar parser. + (b4_percent_define_default): New macro to set a default value for a + %define variable. + (m4_wrap): Update wrapped code, and fix some underquoting. + (b4_check_user_names_wrap): Update and define outside the m4_wrap. + Expect grammar uses of %define variables and %code qualifiers to be + defined in b4_percent_define_user_variables and + b4_percent_code_user_qualifiers. + * data/c++.m4: Use b4_percent_define_default rather than + m4_define_default. Fix some underquoting. Skeleton usage of %define + variable define_location_comparison now implies skeleton usage of + %define variable filename_type. + * data/glr.c, data/glr.cc, data/lalr1.cc, data/location.cc, + data/push.c, data/yacc.c: Update macro names. + * src/parse-gram.y (prologue_declaration, grammar_declaration): Update + muscle names. + 2007-01-14 Juan Manuel Guerrero DJGPP specific issues. @@ -134,10 +173,7 @@ b4_check_percent_code_qualifiers. Use b4_get_percent_code. * data/glr.cc, data/lalr1.cc: Likewise, and use b4_get_percent_define. (b4_parser_class_name, b4_namespace): Define these using - b4_get_percent_define for parser_class_name and namespace. Normally - this would be a bad idea since there might be cases when the variables - aren't used, but these variables are too pervasive in these skeletons - for that to be a problem. + b4_get_percent_define for parser_class_name and namespace. * data/location.cc: Use b4_get_percent_define. * data/push.c: Don't use b4_check_percent_define_variables and b4_check_percent_code_qualifiers. Use b4_get_percent_code. diff --git a/data/bison.m4 b/data/bison.m4 index 6ac4d9b0..6d37e980 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -285,84 +285,103 @@ b4_define_user_code([pre_prologue]) b4_define_user_code([stype]) -# b4_check_user_names(WHAT, USER-LIST, SKELETON-LIST) -# --------------------------------------------------- +# b4_check_user_names(WHAT, USER-LIST, SKELETON-NAMESPACE) +# -------------------------------------------------------- # Warn if any name of type WHAT is used by the user (as recorded in USER-LIST) -# but is not used by the skeleton (as recorded in SKELETON-LIST). +# but is not used by the skeleton (as recorded by macros in the namespace +# SKELETON-NAMESPACE). # # USER-LIST must expand to a list specifying all grammar occurrences of all -# names of type WHAT. Each item in the list is a triplet specifying one +# names of type WHAT. Each item in the list must be a triplet specifying one # occurrence: name, start boundary, and end boundary. Empty string names are # fine. An empty list is fine. # -# For example, to define b4_user_foo_names to be used for USER-LIST with three +# For example, to define b4_foo_user_names to be used for USER-LIST with three # name occurrences and with correct quoting: # -# m4_define([b4_user_foo_names], +# m4_define([b4_foo_user_names], # [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]], # [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]], # [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]]) # -# SKELETON-LIST must expand to a list specifying all names of type WHAT that -# are used by the skeleton. Multiple occurrences of the same name are fine. -# Empty string names are fine, but it would be ugly for a Bison skeleton to -# actually use one. An empty list is fine. +# The macro SKELETON-NAMESPACE(bar) must be defined iff the name bar of type +# WHAT is used in the skeleton. Empty string names are fine, but it would be +# ugly for a Bison skeleton to actually use one. # -# For example, to define b4_skeleton_foo_names to be used for SKELETON-LIST -# with two names and with correct quoting: +# For example, to use b4_foo_skeleton_names for SKELETON-NAMESPACE and define +# that the names bar and baz are used in the skeleton: # -# m4_define([b4_skeleton_foo_names], -# [[[[bar]], [[baz]]]]) +# m4_define([b4_foo_skeleton_names(bar)]) +# m4_define([b4_foo_skeleton_names(baz)]) # # To invoke b4_check_user_names with TYPE foo, with USER-LIST -# b4_user_foo_names, with SKELETON-LIST b4_skeleton_foo_names, and with correct -# quoting: +# b4_foo_user_names, with SKELETON-NAMESPACE b4_foo_skeleton_names, and with +# correct quoting: # -# b4_check_user_names([[foo]], [b4_user_foo_names], [b4_skeleton_foo_names]) +# b4_check_user_names([[foo]], [b4_foo_user_names], +# [[b4_foo_skeleton_names]]) m4_define([b4_check_user_names], [m4_foreach([b4_occurrence], $2, [m4_pushdef([b4_occurrence], b4_occurrence)dnl m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl -m4_pushdef([b4_found], [[0]])dnl -m4_foreach([b4_skeleton_name], $3, - [m4_if(m4_quote(b4_user_name), - m4_quote(b4_skeleton_name), - [m4_define([b4_found], [[1]])])])dnl -m4_if(b4_found, [0], [b4_warn_at([b4_start], [b4_end], - [[%s `%s' is not used]], - [$1], [b4_user_name])])[]dnl -m4_popdef([b4_found])dnl +m4_ifndef($3[(]m4_quote(b4_user_name)[)], + [b4_warn_at([b4_start], [b4_end], + [[%s `%s' is not used]], + [$1], [b4_user_name])])[]dnl m4_popdef([b4_occurrence])dnl m4_popdef([b4_user_name])dnl m4_popdef([b4_start])dnl m4_popdef([b4_end])dnl ])]) -# b4_get_percent_define(VARIABLE) -# -------------------------------- -# If the %define variable VARIABLE is defined, emit it. Also, record VARIABLE -# in b4_skeleton_percent_define_variables. -m4_define([b4_get_percent_define], -[m4_append([b4_skeleton_percent_define_variables], [[$1]], [[, ]])dnl -m4_ifdef([b4_percent_define_]$1, [b4_percent_define_]$1)]) +# b4_percent_define_get(VARIABLE) +# ------------------------------- +# If the %define variable VARIABLE is defined, emit its value. Also, record +# the skeleton's usage of VARIABLE by defining +# b4_percent_define_skeleton_variables(VARIABLE). +# +# For example: +# +# b4_percent_define_get([[foo]]) +m4_define([b4_percent_define_get], +[m4_define([b4_percent_define_skeleton_variables(]$1[)])dnl +m4_ifdef([b4_percent_define(]$1[)], [m4_indir([b4_percent_define(]$1[)])])]) + +# b4_percent_define_default(VARIABLE, DEFAULT) +# -------------------------------------------- +# If the %define variable VARIABLE is undefined, set its value to DEFAULT. +# +# For example: +# +# b4_percent_define_default([[foo]], [[default value]]) +m4_define([b4_percent_define_default], +[m4_ifndef([b4_percent_define(]$1[)], + [m4_define([b4_percent_define(]$1[)], [$2])])]) -# b4_get_percent_code([QUALIFIER]) +# b4_percent_code_get([QUALIFIER]) # -------------------------------- # If any %code blocks for QUALIFIER are defined, emit them beginning with a # comment and ending with synclines and a newline. If QUALIFIER is not -# specified (thus, b4_get_percent_code is invoked without parens), do this for -# the unqualified %code blocks. Also, record QUALIFIER (if specified) in -# b4_skeleton_percent_code_qualifiers. -m4_define([b4_get_percent_code], -[m4_pushdef([b4_macro_name], [[b4_percent_code]]m4_if([$#], [1], [[[_]$1]]))dnl -m4_if([$#], [1], - [m4_append([b4_skeleton_percent_code_qualifiers], [[$1]], [[, ]])])dnl +# specified (thus, b4_percent_code_get is invoked without parens), do this for +# the unqualified %code blocks. Also, record the skeleton's usage of QUALIFIER +# (if specified) by defining b4_percent_code_skeleton_qualifiers(QUALIFIER). +# +# For example, to emit any unqualified %code blocks followed by any %code +# blocks for the qualifier foo: +# +# b4_percent_code_get +# b4_percent_code_get([[foo]]) +m4_define([b4_percent_code_get], +[m4_pushdef([b4_macro_name], [[b4_percent_code]]m4_if([$#], [1], [[[(]$1[)]]], + [[[_unqualified]]]))dnl +m4_if([$#], [1], [m4_define([b4_percent_code_skeleton_qualifiers(]$1[)])])dnl m4_ifdef(b4_macro_name, [b4_comment([m4_if([$#], [0], [[Unqualified %code]], [[%code "]$1["]])[ blocks.]]) -b4_user_code(b4_macro_name)])dnl +b4_user_code([m4_indir(b4_macro_name)]) +])dnl m4_popdef([b4_macro_name])]) @@ -371,21 +390,13 @@ m4_popdef([b4_macro_name])]) ## %define variables and %code qualifiers were used. ## ## --------------------------------------------------------- ## -m4_wrap([ -m4_pushdef([b4_check_user_names_wrap], -[m4_ifdef([b4_skeleton_percent_$1], - [m4_define([b4_skeleton_percent_$1], - m4_dquote(m4_dquote(b4_skeleton_percent_$1)))], - [m4_define([b4_skeleton_percent_$1], [[]])]) - -m4_ifdef([b4_user_percent_$1], - [b4_check_user_names([$2], - [b4_user_percent_$1], - [b4_skeleton_percent_$1])]) -]) - -b4_check_user_names_wrap([define_variables], [[%define variable]]) -b4_check_user_names_wrap([code_qualifiers], [[%code qualifier]]) +m4_define([b4_check_user_names_wrap], +[m4_ifdef([b4_percent_]$1[_user_]$2[s], + [b4_check_user_names([[%]$1 $2], + [b4_percent_]$1[_user_]$2[s], + [[b4_percent_]$1[_skeleton_]$2[s]])])]) -m4_popdef([b4_check_user_names_wrap]) +m4_wrap([ +b4_check_user_names_wrap([[define]], [[variable]]) +b4_check_user_names_wrap([[code]], [[qualifier]]) ]) diff --git a/data/c++.m4 b/data/c++.m4 index d712917d..96fba673 100644 --- a/data/c++.m4 +++ b/data/c++.m4 @@ -26,13 +26,13 @@ m4_include(b4_pkgdatadir/[c.m4]) ## ---------------- ## # Default parser class name. -m4_define_default([b4_percent_define_parser_class_name], [parser]) -m4_define_default([b4_percent_define_location_type], [location]) -m4_define_default([b4_percent_define_filename_type], [std::string]) -m4_define_default([b4_percent_define_namespace], m4_defn([b4_prefix])) -m4_define_default([b4_percent_define_define_location_comparison], - m4_if(b4_percent_define_filename_type, [std::string], - [1], [0])) +b4_percent_define_default([[parser_class_name]], [[parser]]) +b4_percent_define_default([[location_type]], [[location]]) +b4_percent_define_default([[filename_type]], [[std::string]]) +b4_percent_define_default([[namespace]], m4_defn([b4_prefix])) +b4_percent_define_default([[define_location_comparison]], + [m4_if(b4_percent_define_get([[filename_type]]), + [std::string], [[1]], [[0]])]) # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) diff --git a/data/glr.c b/data/glr.c index 8910737c..09c7ab53 100644 --- a/data/glr.c +++ b/data/glr.c @@ -153,7 +153,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C], ]b4_identification -b4_get_percent_code([[top]])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse @@ -173,7 +173,7 @@ dnl # ---------------------- dnl # Declaration that might either go into the header (if --defines) dnl # or open coded in the parser body. m4_define([b4_shared_declarations], -[b4_get_percent_code([[requires]])[]dnl +[b4_percent_code_get([[requires]])[]dnl b4_token_enums(b4_tokens) @@ -205,7 +205,7 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif -]b4_get_percent_code([[provides]])[]dnl +]b4_percent_code_get([[provides]])[]dnl ]) b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], @@ -238,7 +238,7 @@ static YYSTYPE yyval_default; /* Copy the second part of user declarations. */ ]b4_user_post_prologue -b4_get_percent_code[]dnl +b4_percent_code_get[]dnl [#include #include diff --git a/data/glr.cc b/data/glr.cc index 6d3151b0..297d6c44 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -58,9 +58,9 @@ m4_include(b4_pkgdatadir/[c++.m4]) m4_include(b4_pkgdatadir/[location.cc]) m4_define([b4_parser_class_name], - [b4_get_percent_define([[parser_class_name]])]) + [b4_percent_define_get([[parser_class_name]])]) m4_define([b4_namespace], - [b4_get_percent_define([[namespace]])]) + [b4_percent_define_get([[namespace]])]) # Save the parse parameters. m4_define([b4_parse_param_orig], m4_defn([b4_parse_param])) @@ -230,7 +230,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], #ifndef PARSER_HEADER_H # define PARSER_HEADER_H -]b4_get_percent_code([[requires]])[ +]b4_percent_code_get([[requires]])[ #include #include @@ -290,7 +290,7 @@ b4_user_stype typedef YYSTYPE semantic_type; #endif /// Symbol locations. - typedef ]b4_get_percent_define([[location_type]])[ location_type; + typedef ]b4_percent_define_get([[location_type]])[ location_type; /// Tokens. struct token { @@ -365,7 +365,7 @@ b4_user_stype }; ]dnl Redirections for glr.c. -m4_ifval(b4_get_percent_define([[global_tokens_and_yystype]]), +m4_ifval(b4_percent_define_get([[global_tokens_and_yystype]]), [b4_token_defines(b4_tokens)]) [ #ifndef YYSTYPE @@ -377,7 +377,7 @@ m4_ifval(b4_get_percent_define([[global_tokens_and_yystype]]), } -]b4_get_percent_code([[provides]])[]dnl +]b4_percent_code_get([[provides]])[]dnl [#endif /* ! defined PARSER_HEADER_H */] m4_divert_pop(0) diff --git a/data/lalr1.cc b/data/lalr1.cc index 6682378d..95ae986a 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -20,9 +20,9 @@ m4_include(b4_pkgdatadir/[c++.m4]) m4_define([b4_parser_class_name], - [b4_get_percent_define([[parser_class_name]])]) + [b4_percent_define_get([[parser_class_name]])]) m4_define([b4_namespace], - [b4_get_percent_define([[namespace]])]) + [b4_percent_define_get([[namespace]])]) # The header is mandatory. b4_defines_if([], @@ -46,7 +46,7 @@ dnl FIXME: This is wrong, we want computed header guards. #ifndef PARSER_HEADER_H # define PARSER_HEADER_H -]b4_get_percent_code([[requires]])[ +]b4_percent_code_get([[requires]])[ #include #include @@ -118,7 +118,7 @@ b4_user_stype typedef YYSTYPE semantic_type; #endif /// Symbol locations. - typedef ]b4_get_percent_define([[location_type]])[ location_type; + typedef ]b4_percent_define_get([[location_type]])[ location_type; /// Tokens. struct token { @@ -289,7 +289,7 @@ b4_error_verbose_if([, int tok])[); }; } -]m4_ifval(b4_get_percent_define([[global_tokens_and_yystype]]), +]m4_ifval(b4_percent_define_get([[global_tokens_and_yystype]]), [b4_token_defines(b4_tokens) #ifndef YYSTYPE @@ -297,14 +297,14 @@ b4_error_verbose_if([, int tok])[); # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type #endif ]) -b4_get_percent_code([[provides]])[]dnl +b4_percent_code_get([[provides]])[]dnl [#endif /* ! defined PARSER_HEADER_H */] ])dnl @output(b4_parser_file_name@) b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], [2002, 2003, 2004, 2005, 2006]) -b4_get_percent_code([[top]])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [ // Take the name prefix into account. @@ -318,7 +318,7 @@ b4_defines_if([[ /* User implementation prologue. */ ]b4_user_post_prologue -b4_get_percent_code[]dnl +b4_percent_code_get[]dnl [#ifndef YY_ # if YYENABLE_NLS diff --git a/data/location.cc b/data/location.cc index c3432678..bbb7a91a 100644 --- a/data/location.cc +++ b/data/location.cc @@ -26,7 +26,7 @@ b4_copyright([Positions for Bison parsers in C++], /** ** \file position.hh - ** Define the ]b4_get_percent_define([[namespace]])[::position class. + ** Define the ]b4_percent_define_get([[namespace]])[::position class. */ #ifndef BISON_POSITION_HH @@ -36,7 +36,7 @@ b4_copyright([Positions for Bison parsers in C++], # include # include -namespace ]b4_get_percent_define([[namespace]])[ +namespace ]b4_percent_define_get([[namespace]])[ { /// Abstract a position. class position @@ -51,7 +51,7 @@ namespace ]b4_get_percent_define([[namespace]])[ ])[ /// Initialization. - inline void initialize (]b4_get_percent_define([[filename_type]])[* fn) + inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) { filename = fn; line = ]b4_location_initial_line[; @@ -77,7 +77,7 @@ namespace ]b4_get_percent_define([[namespace]])[ public: /// File name to which this position refers. - ]b4_get_percent_define([[filename_type]])[* filename; + ]b4_percent_define_get([[filename_type]])[* filename; /// Current line number. unsigned int line; /// Current column number. @@ -113,7 +113,7 @@ namespace ]b4_get_percent_define([[namespace]])[ { return begin + -width; } -]m4_if(b4_get_percent_define([[define_location_comparison]]), [1], [[ +]m4_if(b4_percent_define_get([[define_location_comparison]]), [1], [[ /// Compare two position objects. inline bool operator== (const position& pos1, const position& pos2) @@ -151,7 +151,7 @@ b4_copyright([Locations for Bison parsers in C++], /** ** \file location.hh - ** Define the ]b4_get_percent_define([[namespace]])[::location class. + ** Define the ]b4_percent_define_get([[namespace]])[::location class. */ #ifndef BISON_LOCATION_HH @@ -161,7 +161,7 @@ b4_copyright([Locations for Bison parsers in C++], # include # include "position.hh" -namespace ]b4_get_percent_define([[namespace]])[ +namespace ]b4_percent_define_get([[namespace]])[ { /// Abstract a location. @@ -177,7 +177,7 @@ namespace ]b4_get_percent_define([[namespace]])[ ])[ /// Initialization. - inline void initialize (]b4_get_percent_define([[filename_type]])[* fn) + inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) { begin.initialize (fn); end = begin; @@ -235,7 +235,7 @@ namespace ]b4_get_percent_define([[namespace]])[ res.columns (width); return res; } -]m4_if(b4_get_percent_define([[define_location_comparison]]), [1], [[ +]m4_if(b4_percent_define_get([[define_location_comparison]]), [1], [[ /// Compare two location objects. inline bool operator== (const location& loc1, const location& loc2) diff --git a/data/push.c b/data/push.c index 739ac2a7..5ad90616 100644 --- a/data/push.c +++ b/data/push.c @@ -160,7 +160,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' USER NAME SPACE" below. */ ]b4_identification -b4_get_percent_code([[top]])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */ ]b4_pull_if([[#define yyparse ]b4_prefix[parse @@ -198,7 +198,7 @@ m4_if(b4_prefix, [yy], [], # define YYTOKEN_TABLE ]b4_token_table[ #endif -]b4_get_percent_code([[requires]])[]dnl +]b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens)[ @@ -250,11 +250,11 @@ b4_c_function_decl([[yypstate_delete]], [[void]], [[[yypstate *yyps]], [[yyps]]])[ #endif ]]) -b4_get_percent_code([[provides]])[]dnl +b4_percent_code_get([[provides]])[]dnl [/* Copy the second part of user declarations. */ ]b4_user_post_prologue -b4_get_percent_code[]dnl +b4_percent_code_get[]dnl [#ifdef short # undef short @@ -1656,7 +1656,7 @@ b4_defines_if( b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) -b4_get_percent_code([[requires]])[]dnl +b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens) @@ -1714,6 +1714,6 @@ b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], [[b4_prefix[pstate *yyps]], [[yyps]]])[ #endif ]]) -b4_get_percent_code([[provides]])[]dnl +b4_percent_code_get([[provides]])[]dnl ])dnl b4_defines_if m4_divert_pop(0) diff --git a/data/yacc.c b/data/yacc.c index 0df00a1f..3f5ef720 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -152,7 +152,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' USER NAME SPACE" below. */ ]b4_identification -b4_get_percent_code([[top]])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [/* Substitute the variable and function names. */ #define yyparse b4_prefix[]parse @@ -185,7 +185,7 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[ # define YYTOKEN_TABLE ]b4_token_table[ #endif -]b4_get_percent_code([[requires]])[]dnl +]b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens)[ @@ -216,11 +216,11 @@ typedef struct YYLTYPE # define YYLTYPE_IS_TRIVIAL 1 #endif]) -b4_get_percent_code([[provides]])[]dnl +b4_percent_code_get([[provides]])[]dnl [/* Copy the second part of user declarations. */ ]b4_user_post_prologue -b4_get_percent_code[]dnl +b4_percent_code_get[]dnl [#ifdef short # undef short @@ -1491,7 +1491,7 @@ b4_defines_if( b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) -b4_get_percent_code([[requires]])[]dnl +b4_percent_code_get([[requires]])[]dnl b4_token_enums_defines(b4_tokens) @@ -1530,7 +1530,7 @@ typedef struct YYLTYPE [extern YYLTYPE b4_prefix[]lloc;]) )dnl b4_locations_if -b4_get_percent_code([[provides]]) +b4_percent_code_get([[provides]]) ])dnl b4_defines_if m4_divert_pop(0) diff --git a/src/parse-gram.c b/src/parse-gram.c index 7759618e..1453ee90 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -675,17 +675,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 210, 210, 218, 220, 224, 225, 235, 236, 248, - 249, 254, 255, 256, 257, 258, 259, 264, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 295, 296, 297, - 301, 308, 315, 319, 323, 328, 349, 350, 354, 366, - 366, 371, 371, 376, 387, 402, 403, 404, 408, 409, - 414, 416, 421, 422, 426, 427, 428, 429, 434, 439, - 444, 450, 456, 467, 468, 477, 478, 484, 485, 486, - 493, 493, 497, 498, 499, 504, 505, 507, 509, 511, - 513, 523, 524, 530, 534, 543, 563, 565, 574, 579, - 580, 585, 592, 594 + 0, 210, 210, 218, 220, 224, 225, 235, 236, 250, + 251, 256, 257, 258, 259, 260, 261, 266, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, + 287, 288, 289, 290, 291, 292, 293, 297, 298, 299, + 303, 310, 317, 321, 325, 330, 353, 354, 358, 370, + 370, 375, 375, 380, 391, 406, 407, 408, 412, 413, + 418, 420, 425, 426, 430, 431, 432, 433, 438, 443, + 448, 454, 460, 471, 472, 481, 482, 488, 489, 490, + 497, 497, 501, 502, 503, 508, 509, 511, 513, 515, + 517, 527, 528, 534, 538, 547, 567, 569, 578, 583, + 584, 589, 596, 598 }; #endif @@ -1914,29 +1914,31 @@ yyreduce: /* Line 1537 of yacc.c */ #line 237 "parse-gram.y" { - char const name_prefix[] = "percent_define_"; - char *name = xmalloc (sizeof name_prefix + strlen ((yyvsp[(2) - (3)].uniqstr))); + char const name_prefix[] = "percent_define("; + size_t length = strlen ((yyvsp[(2) - (3)].uniqstr)); + char *name = xmalloc (sizeof name_prefix + length + 1); strcpy (name, name_prefix); strcpy (name + sizeof name_prefix - 1, (yyvsp[(2) - (3)].uniqstr)); + strcpy (name + sizeof name_prefix - 1 + length, ")"); if (muscle_find_const (name)) warn_at ((yylsp[(2) - (3)]), _("%s `%s' redefined"), "%define variable", (yyvsp[(2) - (3)].uniqstr)); MUSCLE_INSERT_STRING (uniqstr_new (name), (yyvsp[(3) - (3)].chars)); free (name); - muscle_grow_user_name_list ("user_percent_define_variables", (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)])); + muscle_grow_user_name_list ("percent_define_user_variables", (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)])); } break; case 9: /* Line 1537 of yacc.c */ -#line 248 "parse-gram.y" +#line 250 "parse-gram.y" { defines_flag = true; } break; case 10: /* Line 1537 of yacc.c */ -#line 250 "parse-gram.y" +#line 252 "parse-gram.y" { defines_flag = true; spec_defines_file = xstrdup ((yyvsp[(2) - (2)].chars)); @@ -1946,42 +1948,42 @@ yyreduce: case 11: /* Line 1537 of yacc.c */ -#line 254 "parse-gram.y" +#line 256 "parse-gram.y" { error_verbose = true; } break; case 12: /* Line 1537 of yacc.c */ -#line 255 "parse-gram.y" +#line 257 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: /* Line 1537 of yacc.c */ -#line 256 "parse-gram.y" +#line 258 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: /* Line 1537 of yacc.c */ -#line 257 "parse-gram.y" +#line 259 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: /* Line 1537 of yacc.c */ -#line 258 "parse-gram.y" +#line 260 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: /* Line 1537 of yacc.c */ -#line 260 "parse-gram.y" +#line 262 "parse-gram.y" { nondeterministic_parser = true; glr_parser = true; @@ -1991,7 +1993,7 @@ yyreduce: case 17: /* Line 1537 of yacc.c */ -#line 265 "parse-gram.y" +#line 267 "parse-gram.y" { code_props action; code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); @@ -2005,133 +2007,133 @@ yyreduce: case 18: /* Line 1537 of yacc.c */ -#line 273 "parse-gram.y" +#line 275 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), 1, &(yylsp[(1) - (2)])); } break; case 19: /* Line 1537 of yacc.c */ -#line 274 "parse-gram.y" +#line 276 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: /* Line 1537 of yacc.c */ -#line 275 "parse-gram.y" +#line 277 "parse-gram.y" { locations_flag = true; } break; case 21: /* Line 1537 of yacc.c */ -#line 276 "parse-gram.y" +#line 278 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: /* Line 1537 of yacc.c */ -#line 277 "parse-gram.y" +#line 279 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: /* Line 1537 of yacc.c */ -#line 278 "parse-gram.y" +#line 280 "parse-gram.y" { no_lines_flag = true; } break; case 24: /* Line 1537 of yacc.c */ -#line 279 "parse-gram.y" +#line 281 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: /* Line 1537 of yacc.c */ -#line 280 "parse-gram.y" +#line 282 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: /* Line 1537 of yacc.c */ -#line 281 "parse-gram.y" +#line 283 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: /* Line 1537 of yacc.c */ -#line 282 "parse-gram.y" +#line 284 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: /* Line 1537 of yacc.c */ -#line 283 "parse-gram.y" +#line 285 "parse-gram.y" { pure_parser = true; } break; case 29: /* Line 1537 of yacc.c */ -#line 284 "parse-gram.y" +#line 286 "parse-gram.y" { push_parser = true; pull_parser = false; } break; case 30: /* Line 1537 of yacc.c */ -#line 285 "parse-gram.y" +#line 287 "parse-gram.y" { push_parser = true; pull_parser = true; } break; case 31: /* Line 1537 of yacc.c */ -#line 286 "parse-gram.y" +#line 288 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 32: /* Line 1537 of yacc.c */ -#line 287 "parse-gram.y" +#line 289 "parse-gram.y" { skeleton_arg ((yyvsp[(2) - (2)].chars), 1, &(yylsp[(1) - (2)])); } break; case 33: /* Line 1537 of yacc.c */ -#line 288 "parse-gram.y" +#line 290 "parse-gram.y" { token_table_flag = true; } break; case 34: /* Line 1537 of yacc.c */ -#line 289 "parse-gram.y" +#line 291 "parse-gram.y" { report_flag = report_states; } break; case 35: /* Line 1537 of yacc.c */ -#line 290 "parse-gram.y" +#line 292 "parse-gram.y" { yacc_flag = true; } break; case 39: /* Line 1537 of yacc.c */ -#line 298 "parse-gram.y" +#line 300 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } @@ -2140,7 +2142,7 @@ yyreduce: case 40: /* Line 1537 of yacc.c */ -#line 302 "parse-gram.y" +#line 304 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2152,7 +2154,7 @@ yyreduce: case 41: /* Line 1537 of yacc.c */ -#line 309 "parse-gram.y" +#line 311 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2164,7 +2166,7 @@ yyreduce: case 42: /* Line 1537 of yacc.c */ -#line 316 "parse-gram.y" +#line 318 "parse-gram.y" { default_prec = true; } @@ -2173,7 +2175,7 @@ yyreduce: case 43: /* Line 1537 of yacc.c */ -#line 320 "parse-gram.y" +#line 322 "parse-gram.y" { default_prec = false; } @@ -2182,9 +2184,9 @@ yyreduce: case 44: /* Line 1537 of yacc.c */ -#line 324 "parse-gram.y" +#line 326 "parse-gram.y" { - muscle_code_grow ("percent_code", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); + muscle_code_grow ("percent_code_unqualified", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); code_scanner_last_string_free (); } break; @@ -2192,37 +2194,39 @@ yyreduce: case 45: /* Line 1537 of yacc.c */ -#line 329 "parse-gram.y" +#line 331 "parse-gram.y" { - char const name_prefix[] = "percent_code_"; - char *name = xmalloc (sizeof name_prefix + strlen ((yyvsp[(2) - (3)].uniqstr))); + char const name_prefix[] = "percent_code("; + size_t length = strlen ((yyvsp[(2) - (3)].uniqstr)); + char *name = xmalloc (sizeof name_prefix + length + 1); strcpy (name, name_prefix); strcpy (name + sizeof name_prefix - 1, (yyvsp[(2) - (3)].uniqstr)); + strcpy (name + sizeof name_prefix - 1 + length, ")"); muscle_code_grow (uniqstr_new (name), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); free (name); code_scanner_last_string_free (); - muscle_grow_user_name_list ("user_percent_code_qualifiers", (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)])); + muscle_grow_user_name_list ("percent_code_user_qualifiers", (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)])); } break; case 46: /* Line 1537 of yacc.c */ -#line 349 "parse-gram.y" +#line 353 "parse-gram.y" {} break; case 47: /* Line 1537 of yacc.c */ -#line 350 "parse-gram.y" +#line 354 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 48: /* Line 1537 of yacc.c */ -#line 355 "parse-gram.y" +#line 359 "parse-gram.y" { union_seen = true; muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2233,14 +2237,14 @@ yyreduce: case 49: /* Line 1537 of yacc.c */ -#line 366 "parse-gram.y" +#line 370 "parse-gram.y" { current_class = nterm_sym; } break; case 50: /* Line 1537 of yacc.c */ -#line 367 "parse-gram.y" +#line 371 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2250,14 +2254,14 @@ yyreduce: case 51: /* Line 1537 of yacc.c */ -#line 371 "parse-gram.y" +#line 375 "parse-gram.y" { current_class = token_sym; } break; case 52: /* Line 1537 of yacc.c */ -#line 372 "parse-gram.y" +#line 376 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2267,7 +2271,7 @@ yyreduce: case 53: /* Line 1537 of yacc.c */ -#line 377 "parse-gram.y" +#line 381 "parse-gram.y" { symbol_list *list; tag_seen = true; @@ -2280,7 +2284,7 @@ yyreduce: case 54: /* Line 1537 of yacc.c */ -#line 388 "parse-gram.y" +#line 392 "parse-gram.y" { symbol_list *list; ++current_prec; @@ -2297,98 +2301,98 @@ yyreduce: case 55: /* Line 1537 of yacc.c */ -#line 402 "parse-gram.y" +#line 406 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 56: /* Line 1537 of yacc.c */ -#line 403 "parse-gram.y" +#line 407 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 57: /* Line 1537 of yacc.c */ -#line 404 "parse-gram.y" +#line 408 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 58: /* Line 1537 of yacc.c */ -#line 408 "parse-gram.y" +#line 412 "parse-gram.y" { current_type = NULL; } break; case 59: /* Line 1537 of yacc.c */ -#line 409 "parse-gram.y" +#line 413 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 60: /* Line 1537 of yacc.c */ -#line 415 "parse-gram.y" +#line 419 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 61: /* Line 1537 of yacc.c */ -#line 417 "parse-gram.y" +#line 421 "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 62: /* Line 1537 of yacc.c */ -#line 421 "parse-gram.y" +#line 425 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 63: /* Line 1537 of yacc.c */ -#line 422 "parse-gram.y" +#line 426 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 64: /* Line 1537 of yacc.c */ -#line 426 "parse-gram.y" +#line 430 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 65: /* Line 1537 of yacc.c */ -#line 427 "parse-gram.y" +#line 431 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 66: /* Line 1537 of yacc.c */ -#line 428 "parse-gram.y" +#line 432 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 67: /* Line 1537 of yacc.c */ -#line 429 "parse-gram.y" +#line 433 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 68: /* Line 1537 of yacc.c */ -#line 435 "parse-gram.y" +#line 439 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; @@ -2398,7 +2402,7 @@ yyreduce: case 69: /* Line 1537 of yacc.c */ -#line 440 "parse-gram.y" +#line 444 "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)])); @@ -2408,7 +2412,7 @@ yyreduce: case 70: /* Line 1537 of yacc.c */ -#line 445 "parse-gram.y" +#line 449 "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)])); @@ -2419,7 +2423,7 @@ yyreduce: case 71: /* Line 1537 of yacc.c */ -#line 451 "parse-gram.y" +#line 455 "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)])); @@ -2430,7 +2434,7 @@ yyreduce: case 72: /* Line 1537 of yacc.c */ -#line 457 "parse-gram.y" +#line 461 "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)])); @@ -2442,7 +2446,7 @@ yyreduce: case 79: /* Line 1537 of yacc.c */ -#line 487 "parse-gram.y" +#line 491 "parse-gram.y" { yyerrok; } @@ -2451,77 +2455,77 @@ yyreduce: case 80: /* Line 1537 of yacc.c */ -#line 493 "parse-gram.y" +#line 497 "parse-gram.y" { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); } break; case 82: /* Line 1537 of yacc.c */ -#line 497 "parse-gram.y" +#line 501 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 83: /* Line 1537 of yacc.c */ -#line 498 "parse-gram.y" +#line 502 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 85: /* Line 1537 of yacc.c */ -#line 504 "parse-gram.y" +#line 508 "parse-gram.y" { grammar_current_rule_begin (current_lhs, current_lhs_location); } break; case 86: /* Line 1537 of yacc.c */ -#line 506 "parse-gram.y" +#line 510 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } break; case 87: /* Line 1537 of yacc.c */ -#line 508 "parse-gram.y" +#line 512 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 88: /* Line 1537 of yacc.c */ -#line 510 "parse-gram.y" +#line 514 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 89: /* Line 1537 of yacc.c */ -#line 512 "parse-gram.y" +#line 516 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 90: /* Line 1537 of yacc.c */ -#line 514 "parse-gram.y" +#line 518 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 92: /* Line 1537 of yacc.c */ -#line 524 "parse-gram.y" +#line 528 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 93: /* Line 1537 of yacc.c */ -#line 530 "parse-gram.y" +#line 534 "parse-gram.y" { static char one[] = "1"; (yyval.chars) = one; @@ -2531,7 +2535,7 @@ yyreduce: case 95: /* Line 1537 of yacc.c */ -#line 544 "parse-gram.y" +#line 548 "parse-gram.y" { code_props plain_code; (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n'; @@ -2545,14 +2549,14 @@ yyreduce: case 96: /* Line 1537 of yacc.c */ -#line 564 "parse-gram.y" +#line 568 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 97: /* Line 1537 of yacc.c */ -#line 566 "parse-gram.y" +#line 570 "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); @@ -2563,14 +2567,14 @@ yyreduce: case 98: /* Line 1537 of yacc.c */ -#line 574 "parse-gram.y" +#line 578 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 101: /* Line 1537 of yacc.c */ -#line 586 "parse-gram.y" +#line 590 "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); @@ -2580,7 +2584,7 @@ yyreduce: case 103: /* Line 1537 of yacc.c */ -#line 595 "parse-gram.y" +#line 599 "parse-gram.y" { code_props plain_code; code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); @@ -2594,7 +2598,7 @@ yyreduce: /* Line 1537 of yacc.c */ -#line 2598 "parse-gram.c" +#line 2602 "parse-gram.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2813,7 +2817,7 @@ yyreturn: /* Line 1537 of yacc.c */ -#line 605 "parse-gram.y" +#line 609 "parse-gram.y" diff --git a/src/parse-gram.y b/src/parse-gram.y index 802347fa..18eb1ac3 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -235,15 +235,17 @@ prologue_declaration: | "%debug" { debug_flag = true; } | "%define" variable content.opt { - char const name_prefix[] = "percent_define_"; - char *name = xmalloc (sizeof name_prefix + strlen ($2)); + char const name_prefix[] = "percent_define("; + size_t length = strlen ($2); + char *name = xmalloc (sizeof name_prefix + length + 1); strcpy (name, name_prefix); strcpy (name + sizeof name_prefix - 1, $2); + strcpy (name + sizeof name_prefix - 1 + length, ")"); if (muscle_find_const (name)) warn_at (@2, _("%s `%s' redefined"), "%define variable", $2); MUSCLE_INSERT_STRING (uniqstr_new (name), $3); free (name); - muscle_grow_user_name_list ("user_percent_define_variables", $2, @2); + muscle_grow_user_name_list ("percent_define_user_variables", $2, @2); } | "%defines" { defines_flag = true; } | "%defines" STRING @@ -322,19 +324,21 @@ grammar_declaration: } | "%code" braceless { - muscle_code_grow ("percent_code", $2, @2); + muscle_code_grow ("percent_code_unqualified", $2, @2); code_scanner_last_string_free (); } | "%code" ID braceless { - char const name_prefix[] = "percent_code_"; - char *name = xmalloc (sizeof name_prefix + strlen ($2)); + char const name_prefix[] = "percent_code("; + size_t length = strlen ($2); + char *name = xmalloc (sizeof name_prefix + length + 1); strcpy (name, name_prefix); strcpy (name + sizeof name_prefix - 1, $2); + strcpy (name + sizeof name_prefix - 1 + length, ")"); muscle_code_grow (uniqstr_new (name), $3, @3); free (name); code_scanner_last_string_free (); - muscle_grow_user_name_list ("user_percent_code_qualifiers", $2, @2); + muscle_grow_user_name_list ("percent_code_user_qualifiers", $2, @2); } ;