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.
This commit is contained in:
Joel E. Denny
2007-01-16 06:16:04 +00:00
parent e37c665c41
commit a4e25e1dec
11 changed files with 269 additions and 214 deletions

View File

@@ -1,3 +1,42 @@
2007-01-15 Paolo Bonzini <bonzini@gnu.org>
and Joel E. Denny <jdenny@ces.clemson.edu>
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 <juan.guerrero@gmx.de> 2007-01-14 Juan Manuel Guerrero <juan.guerrero@gmx.de>
DJGPP specific issues. DJGPP specific issues.
@@ -134,10 +173,7 @@
b4_check_percent_code_qualifiers. Use b4_get_percent_code. b4_check_percent_code_qualifiers. Use b4_get_percent_code.
* data/glr.cc, data/lalr1.cc: Likewise, and use b4_get_percent_define. * data/glr.cc, data/lalr1.cc: Likewise, and use b4_get_percent_define.
(b4_parser_class_name, b4_namespace): Define these using (b4_parser_class_name, b4_namespace): Define these using
b4_get_percent_define for parser_class_name and namespace. Normally b4_get_percent_define for parser_class_name and namespace.
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.
* data/location.cc: Use b4_get_percent_define. * data/location.cc: Use b4_get_percent_define.
* data/push.c: Don't use b4_check_percent_define_variables and * data/push.c: Don't use b4_check_percent_define_variables and
b4_check_percent_code_qualifiers. Use b4_get_percent_code. b4_check_percent_code_qualifiers. Use b4_get_percent_code.

View File

@@ -285,84 +285,103 @@ b4_define_user_code([pre_prologue])
b4_define_user_code([stype]) 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) # 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 # 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 # occurrence: name, start boundary, and end boundary. Empty string names are
# fine. An empty list is fine. # 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: # 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:1.7]], [[parser.y:1.16]]]],
# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]], # [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]],
# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]]) # [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])
# #
# SKELETON-LIST must expand to a list specifying all names of type WHAT that # The macro SKELETON-NAMESPACE(bar) must be defined iff the name bar of type
# are used by the skeleton. Multiple occurrences of the same name are fine. # WHAT is used in the skeleton. Empty string names are fine, but it would be
# Empty string names are fine, but it would be ugly for a Bison skeleton to # ugly for a Bison skeleton to actually use one.
# actually use one. An empty list is fine.
# #
# For example, to define b4_skeleton_foo_names to be used for SKELETON-LIST # For example, to use b4_foo_skeleton_names for SKELETON-NAMESPACE and define
# with two names and with correct quoting: # that the names bar and baz are used in the skeleton:
# #
# m4_define([b4_skeleton_foo_names], # m4_define([b4_foo_skeleton_names(bar)])
# [[[[bar]], [[baz]]]]) # m4_define([b4_foo_skeleton_names(baz)])
# #
# To invoke b4_check_user_names with TYPE foo, with USER-LIST # 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 # b4_foo_user_names, with SKELETON-NAMESPACE b4_foo_skeleton_names, and with
# quoting: # 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_define([b4_check_user_names],
[m4_foreach([b4_occurrence], $2, [m4_foreach([b4_occurrence], $2,
[m4_pushdef([b4_occurrence], b4_occurrence)dnl [m4_pushdef([b4_occurrence], b4_occurrence)dnl
m4_pushdef([b4_user_name], m4_car(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_start], m4_car(m4_shift(b4_occurrence)))dnl
m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl
m4_pushdef([b4_found], [[0]])dnl m4_ifndef($3[(]m4_quote(b4_user_name)[)],
m4_foreach([b4_skeleton_name], $3, [b4_warn_at([b4_start], [b4_end],
[m4_if(m4_quote(b4_user_name), [[%s `%s' is not used]],
m4_quote(b4_skeleton_name), [$1], [b4_user_name])])[]dnl
[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_popdef([b4_occurrence])dnl m4_popdef([b4_occurrence])dnl
m4_popdef([b4_user_name])dnl m4_popdef([b4_user_name])dnl
m4_popdef([b4_start])dnl m4_popdef([b4_start])dnl
m4_popdef([b4_end])dnl m4_popdef([b4_end])dnl
])]) ])])
# b4_get_percent_define(VARIABLE) # b4_percent_define_get(VARIABLE)
# -------------------------------- # -------------------------------
# If the %define variable VARIABLE is defined, emit it. Also, record VARIABLE # If the %define variable VARIABLE is defined, emit its value. Also, record
# in b4_skeleton_percent_define_variables. # the skeleton's usage of VARIABLE by defining
m4_define([b4_get_percent_define], # b4_percent_define_skeleton_variables(VARIABLE).
[m4_append([b4_skeleton_percent_define_variables], [[$1]], [[, ]])dnl #
m4_ifdef([b4_percent_define_]$1, [b4_percent_define_]$1)]) # 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_get_percent_code([QUALIFIER]) # 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_percent_code_get([QUALIFIER])
# -------------------------------- # --------------------------------
# If any %code blocks for QUALIFIER are defined, emit them beginning with a # 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 # 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 # specified (thus, b4_percent_code_get is invoked without parens), do this for
# the unqualified %code blocks. Also, record QUALIFIER (if specified) in # the unqualified %code blocks. Also, record the skeleton's usage of QUALIFIER
# b4_skeleton_percent_code_qualifiers. # (if specified) by defining b4_percent_code_skeleton_qualifiers(QUALIFIER).
m4_define([b4_get_percent_code], #
[m4_pushdef([b4_macro_name], [[b4_percent_code]]m4_if([$#], [1], [[[_]$1]]))dnl # For example, to emit any unqualified %code blocks followed by any %code
m4_if([$#], [1], # blocks for the qualifier foo:
[m4_append([b4_skeleton_percent_code_qualifiers], [[$1]], [[, ]])])dnl #
# 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, m4_ifdef(b4_macro_name,
[b4_comment([m4_if([$#], [0], [[Unqualified %code]], [b4_comment([m4_if([$#], [0], [[Unqualified %code]],
[[%code "]$1["]])[ blocks.]]) [[%code "]$1["]])[ blocks.]])
b4_user_code(b4_macro_name)])dnl b4_user_code([m4_indir(b4_macro_name)])
])dnl
m4_popdef([b4_macro_name])]) m4_popdef([b4_macro_name])])
@@ -371,21 +390,13 @@ m4_popdef([b4_macro_name])])
## %define variables and %code qualifiers were used. ## ## %define variables and %code qualifiers were used. ##
## --------------------------------------------------------- ## ## --------------------------------------------------------- ##
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_wrap([ m4_wrap([
m4_pushdef([b4_check_user_names_wrap], b4_check_user_names_wrap([[define]], [[variable]])
[m4_ifdef([b4_skeleton_percent_$1], b4_check_user_names_wrap([[code]], [[qualifier]])
[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_popdef([b4_check_user_names_wrap])
]) ])

View File

@@ -26,13 +26,13 @@ m4_include(b4_pkgdatadir/[c.m4])
## ---------------- ## ## ---------------- ##
# Default parser class name. # Default parser class name.
m4_define_default([b4_percent_define_parser_class_name], [parser]) b4_percent_define_default([[parser_class_name]], [[parser]])
m4_define_default([b4_percent_define_location_type], [location]) b4_percent_define_default([[location_type]], [[location]])
m4_define_default([b4_percent_define_filename_type], [std::string]) b4_percent_define_default([[filename_type]], [[std::string]])
m4_define_default([b4_percent_define_namespace], m4_defn([b4_prefix])) b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
m4_define_default([b4_percent_define_define_location_comparison], b4_percent_define_default([[define_location_comparison]],
m4_if(b4_percent_define_filename_type, [std::string], [m4_if(b4_percent_define_get([[filename_type]]),
[1], [0])) [std::string], [[1]], [[0]])])
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)

View File

@@ -153,7 +153,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
]b4_identification ]b4_identification
b4_get_percent_code([[top]])[]dnl b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [], m4_if(b4_prefix, [yy], [],
[/* Substitute the variable and function names. */ [/* Substitute the variable and function names. */
#define yyparse b4_prefix[]parse #define yyparse b4_prefix[]parse
@@ -173,7 +173,7 @@ dnl # ----------------------
dnl # Declaration that might either go into the header (if --defines) dnl # Declaration that might either go into the header (if --defines)
dnl # or open coded in the parser body. dnl # or open coded in the parser body.
m4_define([b4_shared_declarations], m4_define([b4_shared_declarations],
[b4_get_percent_code([[requires]])[]dnl [b4_percent_code_get([[requires]])[]dnl
b4_token_enums(b4_tokens) b4_token_enums(b4_tokens)
@@ -205,7 +205,7 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1 # define YYLTYPE_IS_TRIVIAL 1
#endif #endif
]b4_get_percent_code([[provides]])[]dnl ]b4_percent_code_get([[provides]])[]dnl
]) ])
b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
@@ -238,7 +238,7 @@ static YYSTYPE yyval_default;
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
]b4_user_post_prologue ]b4_user_post_prologue
b4_get_percent_code[]dnl b4_percent_code_get[]dnl
[#include <stdio.h> [#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@@ -58,9 +58,9 @@ m4_include(b4_pkgdatadir/[c++.m4])
m4_include(b4_pkgdatadir/[location.cc]) m4_include(b4_pkgdatadir/[location.cc])
m4_define([b4_parser_class_name], m4_define([b4_parser_class_name],
[b4_get_percent_define([[parser_class_name]])]) [b4_percent_define_get([[parser_class_name]])])
m4_define([b4_namespace], m4_define([b4_namespace],
[b4_get_percent_define([[namespace]])]) [b4_percent_define_get([[namespace]])])
# Save the parse parameters. # Save the parse parameters.
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param])) 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 #ifndef PARSER_HEADER_H
# define PARSER_HEADER_H # define PARSER_HEADER_H
]b4_get_percent_code([[requires]])[ ]b4_percent_code_get([[requires]])[
#include <string> #include <string>
#include <iostream> #include <iostream>
@@ -290,7 +290,7 @@ b4_user_stype
typedef YYSTYPE semantic_type; typedef YYSTYPE semantic_type;
#endif #endif
/// Symbol locations. /// Symbol locations.
typedef ]b4_get_percent_define([[location_type]])[ location_type; typedef ]b4_percent_define_get([[location_type]])[ location_type;
/// Tokens. /// Tokens.
struct token struct token
{ {
@@ -365,7 +365,7 @@ b4_user_stype
}; };
]dnl Redirections for glr.c. ]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)]) [b4_token_defines(b4_tokens)])
[ [
#ifndef YYSTYPE #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 */] [#endif /* ! defined PARSER_HEADER_H */]
m4_divert_pop(0) m4_divert_pop(0)

View File

@@ -20,9 +20,9 @@
m4_include(b4_pkgdatadir/[c++.m4]) m4_include(b4_pkgdatadir/[c++.m4])
m4_define([b4_parser_class_name], m4_define([b4_parser_class_name],
[b4_get_percent_define([[parser_class_name]])]) [b4_percent_define_get([[parser_class_name]])])
m4_define([b4_namespace], m4_define([b4_namespace],
[b4_get_percent_define([[namespace]])]) [b4_percent_define_get([[namespace]])])
# The header is mandatory. # The header is mandatory.
b4_defines_if([], b4_defines_if([],
@@ -46,7 +46,7 @@ dnl FIXME: This is wrong, we want computed header guards.
#ifndef PARSER_HEADER_H #ifndef PARSER_HEADER_H
# define PARSER_HEADER_H # define PARSER_HEADER_H
]b4_get_percent_code([[requires]])[ ]b4_percent_code_get([[requires]])[
#include <string> #include <string>
#include <iostream> #include <iostream>
@@ -118,7 +118,7 @@ b4_user_stype
typedef YYSTYPE semantic_type; typedef YYSTYPE semantic_type;
#endif #endif
/// Symbol locations. /// Symbol locations.
typedef ]b4_get_percent_define([[location_type]])[ location_type; typedef ]b4_percent_define_get([[location_type]])[ location_type;
/// Tokens. /// Tokens.
struct token 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) [b4_token_defines(b4_tokens)
#ifndef YYSTYPE #ifndef YYSTYPE
@@ -297,14 +297,14 @@ b4_error_verbose_if([, int tok])[);
# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
#endif #endif
]) ])
b4_get_percent_code([[provides]])[]dnl b4_percent_code_get([[provides]])[]dnl
[#endif /* ! defined PARSER_HEADER_H */] [#endif /* ! defined PARSER_HEADER_H */]
])dnl ])dnl
@output(b4_parser_file_name@) @output(b4_parser_file_name@)
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
[2002, 2003, 2004, 2005, 2006]) [2002, 2003, 2004, 2005, 2006])
b4_get_percent_code([[top]])[]dnl b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [], m4_if(b4_prefix, [yy], [],
[ [
// Take the name prefix into account. // Take the name prefix into account.
@@ -318,7 +318,7 @@ b4_defines_if([[
/* User implementation prologue. */ /* User implementation prologue. */
]b4_user_post_prologue ]b4_user_post_prologue
b4_get_percent_code[]dnl b4_percent_code_get[]dnl
[#ifndef YY_ [#ifndef YY_
# if YYENABLE_NLS # if YYENABLE_NLS

View File

@@ -26,7 +26,7 @@ b4_copyright([Positions for Bison parsers in C++],
/** /**
** \file position.hh ** \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 #ifndef BISON_POSITION_HH
@@ -36,7 +36,7 @@ b4_copyright([Positions for Bison parsers in C++],
# include <string> # include <string>
# include <algorithm> # include <algorithm>
namespace ]b4_get_percent_define([[namespace]])[ namespace ]b4_percent_define_get([[namespace]])[
{ {
/// Abstract a position. /// Abstract a position.
class position class position
@@ -51,7 +51,7 @@ namespace ]b4_get_percent_define([[namespace]])[
])[ ])[
/// Initialization. /// Initialization.
inline void initialize (]b4_get_percent_define([[filename_type]])[* fn) inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
{ {
filename = fn; filename = fn;
line = ]b4_location_initial_line[; line = ]b4_location_initial_line[;
@@ -77,7 +77,7 @@ namespace ]b4_get_percent_define([[namespace]])[
public: public:
/// File name to which this position refers. /// File name to which this position refers.
]b4_get_percent_define([[filename_type]])[* filename; ]b4_percent_define_get([[filename_type]])[* filename;
/// Current line number. /// Current line number.
unsigned int line; unsigned int line;
/// Current column number. /// Current column number.
@@ -113,7 +113,7 @@ namespace ]b4_get_percent_define([[namespace]])[
{ {
return begin + -width; 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. /// Compare two position objects.
inline bool inline bool
operator== (const position& pos1, const position& pos2) operator== (const position& pos1, const position& pos2)
@@ -151,7 +151,7 @@ b4_copyright([Locations for Bison parsers in C++],
/** /**
** \file location.hh ** \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 #ifndef BISON_LOCATION_HH
@@ -161,7 +161,7 @@ b4_copyright([Locations for Bison parsers in C++],
# include <string> # include <string>
# include "position.hh" # include "position.hh"
namespace ]b4_get_percent_define([[namespace]])[ namespace ]b4_percent_define_get([[namespace]])[
{ {
/// Abstract a location. /// Abstract a location.
@@ -177,7 +177,7 @@ namespace ]b4_get_percent_define([[namespace]])[
])[ ])[
/// Initialization. /// Initialization.
inline void initialize (]b4_get_percent_define([[filename_type]])[* fn) inline void initialize (]b4_percent_define_get([[filename_type]])[* fn)
{ {
begin.initialize (fn); begin.initialize (fn);
end = begin; end = begin;
@@ -235,7 +235,7 @@ namespace ]b4_get_percent_define([[namespace]])[
res.columns (width); res.columns (width);
return res; 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. /// Compare two location objects.
inline bool inline bool
operator== (const location& loc1, const location& loc2) operator== (const location& loc1, const location& loc2)

View File

@@ -160,7 +160,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
USER NAME SPACE" below. */ USER NAME SPACE" below. */
]b4_identification ]b4_identification
b4_get_percent_code([[top]])[]dnl b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [], m4_if(b4_prefix, [yy], [],
[[/* Substitute the variable and function names. */ [[/* Substitute the variable and function names. */
]b4_pull_if([[#define yyparse ]b4_prefix[parse ]b4_pull_if([[#define yyparse ]b4_prefix[parse
@@ -198,7 +198,7 @@ m4_if(b4_prefix, [yy], [],
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
]b4_get_percent_code([[requires]])[]dnl ]b4_percent_code_get([[requires]])[]dnl
b4_token_enums_defines(b4_tokens)[ b4_token_enums_defines(b4_tokens)[
@@ -250,11 +250,11 @@ b4_c_function_decl([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[ [[[yypstate *yyps]], [[yyps]]])[
#endif #endif
]]) ]])
b4_get_percent_code([[provides]])[]dnl b4_percent_code_get([[provides]])[]dnl
[/* Copy the second part of user declarations. */ [/* Copy the second part of user declarations. */
]b4_user_post_prologue ]b4_user_post_prologue
b4_get_percent_code[]dnl b4_percent_code_get[]dnl
[#ifdef short [#ifdef short
# undef short # undef short
@@ -1656,7 +1656,7 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) [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) b4_token_enums_defines(b4_tokens)
@@ -1714,6 +1714,6 @@ b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *yyps]], [[yyps]]])[ [[b4_prefix[pstate *yyps]], [[yyps]]])[
#endif #endif
]]) ]])
b4_get_percent_code([[provides]])[]dnl b4_percent_code_get([[provides]])[]dnl
])dnl b4_defines_if ])dnl b4_defines_if
m4_divert_pop(0) m4_divert_pop(0)

View File

@@ -152,7 +152,7 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
USER NAME SPACE" below. */ USER NAME SPACE" below. */
]b4_identification ]b4_identification
b4_get_percent_code([[top]])[]dnl b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [], m4_if(b4_prefix, [yy], [],
[/* Substitute the variable and function names. */ [/* Substitute the variable and function names. */
#define yyparse b4_prefix[]parse #define yyparse b4_prefix[]parse
@@ -185,7 +185,7 @@ b4_locations_if([#define yylloc b4_prefix[]lloc])])[
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
]b4_get_percent_code([[requires]])[]dnl ]b4_percent_code_get([[requires]])[]dnl
b4_token_enums_defines(b4_tokens)[ b4_token_enums_defines(b4_tokens)[
@@ -216,11 +216,11 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1 # define YYLTYPE_IS_TRIVIAL 1
#endif]) #endif])
b4_get_percent_code([[provides]])[]dnl b4_percent_code_get([[provides]])[]dnl
[/* Copy the second part of user declarations. */ [/* Copy the second part of user declarations. */
]b4_user_post_prologue ]b4_user_post_prologue
b4_get_percent_code[]dnl b4_percent_code_get[]dnl
[#ifdef short [#ifdef short
# undef short # undef short
@@ -1491,7 +1491,7 @@ b4_defines_if(
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) [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) b4_token_enums_defines(b4_tokens)
@@ -1530,7 +1530,7 @@ typedef struct YYLTYPE
[extern YYLTYPE b4_prefix[]lloc;]) [extern YYLTYPE b4_prefix[]lloc;])
)dnl b4_locations_if )dnl b4_locations_if
b4_get_percent_code([[provides]]) b4_percent_code_get([[provides]])
])dnl b4_defines_if ])dnl b4_defines_if
m4_divert_pop(0) m4_divert_pop(0)

View File

@@ -675,17 +675,17 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] = static const yytype_uint16 yyrline[] =
{ {
0, 210, 210, 218, 220, 224, 225, 235, 236, 248, 0, 210, 210, 218, 220, 224, 225, 235, 236, 250,
249, 254, 255, 256, 257, 258, 259, 264, 273, 274, 251, 256, 257, 258, 259, 260, 261, 266, 275, 276,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286,
285, 286, 287, 288, 289, 290, 291, 295, 296, 297, 287, 288, 289, 290, 291, 292, 293, 297, 298, 299,
301, 308, 315, 319, 323, 328, 349, 350, 354, 366, 303, 310, 317, 321, 325, 330, 353, 354, 358, 370,
366, 371, 371, 376, 387, 402, 403, 404, 408, 409, 370, 375, 375, 380, 391, 406, 407, 408, 412, 413,
414, 416, 421, 422, 426, 427, 428, 429, 434, 439, 418, 420, 425, 426, 430, 431, 432, 433, 438, 443,
444, 450, 456, 467, 468, 477, 478, 484, 485, 486, 448, 454, 460, 471, 472, 481, 482, 488, 489, 490,
493, 493, 497, 498, 499, 504, 505, 507, 509, 511, 497, 497, 501, 502, 503, 508, 509, 511, 513, 515,
513, 523, 524, 530, 534, 543, 563, 565, 574, 579, 517, 527, 528, 534, 538, 547, 567, 569, 578, 583,
580, 585, 592, 594 584, 589, 596, 598
}; };
#endif #endif
@@ -1914,29 +1914,31 @@ yyreduce:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 237 "parse-gram.y" #line 237 "parse-gram.y"
{ {
char const name_prefix[] = "percent_define_"; char const name_prefix[] = "percent_define(";
char *name = xmalloc (sizeof name_prefix + strlen ((yyvsp[(2) - (3)].uniqstr))); size_t length = strlen ((yyvsp[(2) - (3)].uniqstr));
char *name = xmalloc (sizeof name_prefix + length + 1);
strcpy (name, name_prefix); strcpy (name, name_prefix);
strcpy (name + sizeof name_prefix - 1, (yyvsp[(2) - (3)].uniqstr)); strcpy (name + sizeof name_prefix - 1, (yyvsp[(2) - (3)].uniqstr));
strcpy (name + sizeof name_prefix - 1 + length, ")");
if (muscle_find_const (name)) if (muscle_find_const (name))
warn_at ((yylsp[(2) - (3)]), _("%s `%s' redefined"), "%define variable", (yyvsp[(2) - (3)].uniqstr)); warn_at ((yylsp[(2) - (3)]), _("%s `%s' redefined"), "%define variable", (yyvsp[(2) - (3)].uniqstr));
MUSCLE_INSERT_STRING (uniqstr_new (name), (yyvsp[(3) - (3)].chars)); MUSCLE_INSERT_STRING (uniqstr_new (name), (yyvsp[(3) - (3)].chars));
free (name); 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; break;
case 9: case 9:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 248 "parse-gram.y" #line 250 "parse-gram.y"
{ defines_flag = true; } { defines_flag = true; }
break; break;
case 10: case 10:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 250 "parse-gram.y" #line 252 "parse-gram.y"
{ {
defines_flag = true; defines_flag = true;
spec_defines_file = xstrdup ((yyvsp[(2) - (2)].chars)); spec_defines_file = xstrdup ((yyvsp[(2) - (2)].chars));
@@ -1946,42 +1948,42 @@ yyreduce:
case 11: case 11:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 254 "parse-gram.y" #line 256 "parse-gram.y"
{ error_verbose = true; } { error_verbose = true; }
break; break;
case 12: case 12:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 255 "parse-gram.y" #line 257 "parse-gram.y"
{ expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
break; break;
case 13: case 13:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 256 "parse-gram.y" #line 258 "parse-gram.y"
{ expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
break; break;
case 14: case 14:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 257 "parse-gram.y" #line 259 "parse-gram.y"
{ spec_file_prefix = (yyvsp[(2) - (2)].chars); } { spec_file_prefix = (yyvsp[(2) - (2)].chars); }
break; break;
case 15: case 15:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 258 "parse-gram.y" #line 260 "parse-gram.y"
{ spec_file_prefix = (yyvsp[(3) - (3)].chars); } { spec_file_prefix = (yyvsp[(3) - (3)].chars); }
break; break;
case 16: case 16:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 260 "parse-gram.y" #line 262 "parse-gram.y"
{ {
nondeterministic_parser = true; nondeterministic_parser = true;
glr_parser = true; glr_parser = true;
@@ -1991,7 +1993,7 @@ yyreduce:
case 17: case 17:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 265 "parse-gram.y" #line 267 "parse-gram.y"
{ {
code_props action; code_props action;
code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); code_props_symbol_action_init (&action, (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)]));
@@ -2005,133 +2007,133 @@ yyreduce:
case 18: case 18:
/* Line 1537 of yacc.c */ /* 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)])); } { language_argmatch ((yyvsp[(2) - (2)].chars), 1, &(yylsp[(1) - (2)])); }
break; break;
case 19: case 19:
/* Line 1537 of yacc.c */ /* 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)])); } { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 20: case 20:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 275 "parse-gram.y" #line 277 "parse-gram.y"
{ locations_flag = true; } { locations_flag = true; }
break; break;
case 21: case 21:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 276 "parse-gram.y" #line 278 "parse-gram.y"
{ spec_name_prefix = (yyvsp[(2) - (2)].chars); } { spec_name_prefix = (yyvsp[(2) - (2)].chars); }
break; break;
case 22: case 22:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 277 "parse-gram.y" #line 279 "parse-gram.y"
{ spec_name_prefix = (yyvsp[(3) - (3)].chars); } { spec_name_prefix = (yyvsp[(3) - (3)].chars); }
break; break;
case 23: case 23:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 278 "parse-gram.y" #line 280 "parse-gram.y"
{ no_lines_flag = true; } { no_lines_flag = true; }
break; break;
case 24: case 24:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 279 "parse-gram.y" #line 281 "parse-gram.y"
{ nondeterministic_parser = true; } { nondeterministic_parser = true; }
break; break;
case 25: case 25:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 280 "parse-gram.y" #line 282 "parse-gram.y"
{ spec_outfile = (yyvsp[(2) - (2)].chars); } { spec_outfile = (yyvsp[(2) - (2)].chars); }
break; break;
case 26: case 26:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 281 "parse-gram.y" #line 283 "parse-gram.y"
{ spec_outfile = (yyvsp[(3) - (3)].chars); } { spec_outfile = (yyvsp[(3) - (3)].chars); }
break; break;
case 27: case 27:
/* Line 1537 of yacc.c */ /* 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)])); } { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 28: case 28:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 283 "parse-gram.y" #line 285 "parse-gram.y"
{ pure_parser = true; } { pure_parser = true; }
break; break;
case 29: case 29:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 284 "parse-gram.y" #line 286 "parse-gram.y"
{ push_parser = true; pull_parser = false; } { push_parser = true; pull_parser = false; }
break; break;
case 30: case 30:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 285 "parse-gram.y" #line 287 "parse-gram.y"
{ push_parser = true; pull_parser = true; } { push_parser = true; pull_parser = true; }
break; break;
case 31: case 31:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 286 "parse-gram.y" #line 288 "parse-gram.y"
{ version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
break; break;
case 32: case 32:
/* Line 1537 of yacc.c */ /* 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)])); } { skeleton_arg ((yyvsp[(2) - (2)].chars), 1, &(yylsp[(1) - (2)])); }
break; break;
case 33: case 33:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 288 "parse-gram.y" #line 290 "parse-gram.y"
{ token_table_flag = true; } { token_table_flag = true; }
break; break;
case 34: case 34:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 289 "parse-gram.y" #line 291 "parse-gram.y"
{ report_flag = report_states; } { report_flag = report_states; }
break; break;
case 35: case 35:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 290 "parse-gram.y" #line 292 "parse-gram.y"
{ yacc_flag = true; } { yacc_flag = true; }
break; break;
case 39: case 39:
/* Line 1537 of yacc.c */ /* 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)])); grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
} }
@@ -2140,7 +2142,7 @@ yyreduce:
case 40: case 40:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 302 "parse-gram.y" #line 304 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
for (list = (yyvsp[(3) - (3)].list); list; list = list->next) for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
@@ -2152,7 +2154,7 @@ yyreduce:
case 41: case 41:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 309 "parse-gram.y" #line 311 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
for (list = (yyvsp[(3) - (3)].list); list; list = list->next) for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
@@ -2164,7 +2166,7 @@ yyreduce:
case 42: case 42:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 316 "parse-gram.y" #line 318 "parse-gram.y"
{ {
default_prec = true; default_prec = true;
} }
@@ -2173,7 +2175,7 @@ yyreduce:
case 43: case 43:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 320 "parse-gram.y" #line 322 "parse-gram.y"
{ {
default_prec = false; default_prec = false;
} }
@@ -2182,9 +2184,9 @@ yyreduce:
case 44: case 44:
/* Line 1537 of yacc.c */ /* 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 (); code_scanner_last_string_free ();
} }
break; break;
@@ -2192,37 +2194,39 @@ yyreduce:
case 45: case 45:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 329 "parse-gram.y" #line 331 "parse-gram.y"
{ {
char const name_prefix[] = "percent_code_"; char const name_prefix[] = "percent_code(";
char *name = xmalloc (sizeof name_prefix + strlen ((yyvsp[(2) - (3)].uniqstr))); size_t length = strlen ((yyvsp[(2) - (3)].uniqstr));
char *name = xmalloc (sizeof name_prefix + length + 1);
strcpy (name, name_prefix); strcpy (name, name_prefix);
strcpy (name + sizeof name_prefix - 1, (yyvsp[(2) - (3)].uniqstr)); 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)])); muscle_code_grow (uniqstr_new (name), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)]));
free (name); free (name);
code_scanner_last_string_free (); 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; break;
case 46: case 46:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 349 "parse-gram.y" #line 353 "parse-gram.y"
{} {}
break; break;
case 47: case 47:
/* Line 1537 of yacc.c */ /* 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)])); } { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 48: case 48:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 355 "parse-gram.y" #line 359 "parse-gram.y"
{ {
union_seen = true; union_seen = true;
muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)]));
@@ -2233,14 +2237,14 @@ yyreduce:
case 49: case 49:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 366 "parse-gram.y" #line 370 "parse-gram.y"
{ current_class = nterm_sym; } { current_class = nterm_sym; }
break; break;
case 50: case 50:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 367 "parse-gram.y" #line 371 "parse-gram.y"
{ {
current_class = unknown_sym; current_class = unknown_sym;
current_type = NULL; current_type = NULL;
@@ -2250,14 +2254,14 @@ yyreduce:
case 51: case 51:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 371 "parse-gram.y" #line 375 "parse-gram.y"
{ current_class = token_sym; } { current_class = token_sym; }
break; break;
case 52: case 52:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 372 "parse-gram.y" #line 376 "parse-gram.y"
{ {
current_class = unknown_sym; current_class = unknown_sym;
current_type = NULL; current_type = NULL;
@@ -2267,7 +2271,7 @@ yyreduce:
case 53: case 53:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 377 "parse-gram.y" #line 381 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
tag_seen = true; tag_seen = true;
@@ -2280,7 +2284,7 @@ yyreduce:
case 54: case 54:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 388 "parse-gram.y" #line 392 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
++current_prec; ++current_prec;
@@ -2297,98 +2301,98 @@ yyreduce:
case 55: case 55:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 402 "parse-gram.y" #line 406 "parse-gram.y"
{ (yyval.assoc) = left_assoc; } { (yyval.assoc) = left_assoc; }
break; break;
case 56: case 56:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 403 "parse-gram.y" #line 407 "parse-gram.y"
{ (yyval.assoc) = right_assoc; } { (yyval.assoc) = right_assoc; }
break; break;
case 57: case 57:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 404 "parse-gram.y" #line 408 "parse-gram.y"
{ (yyval.assoc) = non_assoc; } { (yyval.assoc) = non_assoc; }
break; break;
case 58: case 58:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 408 "parse-gram.y" #line 412 "parse-gram.y"
{ current_type = NULL; } { current_type = NULL; }
break; break;
case 59: case 59:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 409 "parse-gram.y" #line 413 "parse-gram.y"
{ current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; }
break; break;
case 60: case 60:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
break; break;
case 61: case 61:
/* Line 1537 of yacc.c */ /* 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)]))); } { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
break; break;
case 62: case 62:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 421 "parse-gram.y" #line 425 "parse-gram.y"
{ (yyval.list) = (yyvsp[(1) - (1)].list); } { (yyval.list) = (yyvsp[(1) - (1)].list); }
break; break;
case 63: case 63:
/* Line 1537 of yacc.c */ /* 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)); } { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); }
break; break;
case 64: case 64:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
break; break;
case 65: case 65:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 66: case 66:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); }
break; break;
case 67: case 67:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); }
break; break;
case 68: case 68:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 435 "parse-gram.y" #line 439 "parse-gram.y"
{ {
current_type = (yyvsp[(1) - (1)].uniqstr); current_type = (yyvsp[(1) - (1)].uniqstr);
tag_seen = true; tag_seen = true;
@@ -2398,7 +2402,7 @@ yyreduce:
case 69: case 69:
/* Line 1537 of yacc.c */ /* 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_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)])); symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)]));
@@ -2408,7 +2412,7 @@ yyreduce:
case 70: case 70:
/* Line 1537 of yacc.c */ /* 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_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
@@ -2419,7 +2423,7 @@ yyreduce:
case 71: case 71:
/* Line 1537 of yacc.c */ /* 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_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
@@ -2430,7 +2434,7 @@ yyreduce:
case 72: case 72:
/* Line 1537 of yacc.c */ /* 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_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)])); symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)]));
@@ -2442,7 +2446,7 @@ yyreduce:
case 79: case 79:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 487 "parse-gram.y" #line 491 "parse-gram.y"
{ {
yyerrok; yyerrok;
} }
@@ -2451,77 +2455,77 @@ yyreduce:
case 80: case 80:
/* Line 1537 of yacc.c */ /* 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)]); } { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); }
break; break;
case 82: case 82:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 497 "parse-gram.y" #line 501 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[(1) - (1)])); } { grammar_current_rule_end ((yylsp[(1) - (1)])); }
break; break;
case 83: case 83:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 498 "parse-gram.y" #line 502 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[(3) - (3)])); } { grammar_current_rule_end ((yylsp[(3) - (3)])); }
break; break;
case 85: case 85:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 504 "parse-gram.y" #line 508 "parse-gram.y"
{ grammar_current_rule_begin (current_lhs, current_lhs_location); } { grammar_current_rule_begin (current_lhs, current_lhs_location); }
break; break;
case 86: case 86:
/* Line 1537 of yacc.c */ /* 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)])); } { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
break; break;
case 87: case 87:
/* Line 1537 of yacc.c */ /* 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)])); } { grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 88: case 88:
/* Line 1537 of yacc.c */ /* 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)])); } { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
break; break;
case 89: case 89:
/* Line 1537 of yacc.c */ /* 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)])); } { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
break; break;
case 90: case 90:
/* Line 1537 of yacc.c */ /* 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)])); } { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
break; break;
case 92: case 92:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 524 "parse-gram.y" #line 528 "parse-gram.y"
{ (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); }
break; break;
case 93: case 93:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 530 "parse-gram.y" #line 534 "parse-gram.y"
{ {
static char one[] = "1"; static char one[] = "1";
(yyval.chars) = one; (yyval.chars) = one;
@@ -2531,7 +2535,7 @@ yyreduce:
case 95: case 95:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 544 "parse-gram.y" #line 548 "parse-gram.y"
{ {
code_props plain_code; code_props plain_code;
(yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n'; (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n';
@@ -2545,14 +2549,14 @@ yyreduce:
case 96: case 96:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 97: case 97:
/* Line 1537 of yacc.c */ /* 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)])); (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)]));
symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
@@ -2563,14 +2567,14 @@ yyreduce:
case 98: case 98:
/* Line 1537 of yacc.c */ /* 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)])); } { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 101: case 101:
/* Line 1537 of yacc.c */ /* 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)])); (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); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
@@ -2580,7 +2584,7 @@ yyreduce:
case 103: case 103:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 595 "parse-gram.y" #line 599 "parse-gram.y"
{ {
code_props plain_code; code_props plain_code;
code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]));
@@ -2594,7 +2598,7 @@ yyreduce:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 2598 "parse-gram.c" #line 2602 "parse-gram.c"
default: break; default: break;
} }
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2813,7 +2817,7 @@ yyreturn:
/* Line 1537 of yacc.c */ /* Line 1537 of yacc.c */
#line 605 "parse-gram.y" #line 609 "parse-gram.y"

View File

@@ -235,15 +235,17 @@ prologue_declaration:
| "%debug" { debug_flag = true; } | "%debug" { debug_flag = true; }
| "%define" variable content.opt | "%define" variable content.opt
{ {
char const name_prefix[] = "percent_define_"; char const name_prefix[] = "percent_define(";
char *name = xmalloc (sizeof name_prefix + strlen ($2)); size_t length = strlen ($2);
char *name = xmalloc (sizeof name_prefix + length + 1);
strcpy (name, name_prefix); strcpy (name, name_prefix);
strcpy (name + sizeof name_prefix - 1, $2); strcpy (name + sizeof name_prefix - 1, $2);
strcpy (name + sizeof name_prefix - 1 + length, ")");
if (muscle_find_const (name)) if (muscle_find_const (name))
warn_at (@2, _("%s `%s' redefined"), "%define variable", $2); warn_at (@2, _("%s `%s' redefined"), "%define variable", $2);
MUSCLE_INSERT_STRING (uniqstr_new (name), $3); MUSCLE_INSERT_STRING (uniqstr_new (name), $3);
free (name); 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" { defines_flag = true; }
| "%defines" STRING | "%defines" STRING
@@ -322,19 +324,21 @@ grammar_declaration:
} }
| "%code" braceless | "%code" braceless
{ {
muscle_code_grow ("percent_code", $2, @2); muscle_code_grow ("percent_code_unqualified", $2, @2);
code_scanner_last_string_free (); code_scanner_last_string_free ();
} }
| "%code" ID braceless | "%code" ID braceless
{ {
char const name_prefix[] = "percent_code_"; char const name_prefix[] = "percent_code(";
char *name = xmalloc (sizeof name_prefix + strlen ($2)); size_t length = strlen ($2);
char *name = xmalloc (sizeof name_prefix + length + 1);
strcpy (name, name_prefix); strcpy (name, name_prefix);
strcpy (name + sizeof name_prefix - 1, $2); strcpy (name + sizeof name_prefix - 1, $2);
strcpy (name + sizeof name_prefix - 1 + length, ")");
muscle_code_grow (uniqstr_new (name), $3, @3); muscle_code_grow (uniqstr_new (name), $3, @3);
free (name); free (name);
code_scanner_last_string_free (); 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);
} }
; ;