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

@@ -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)