mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 22:33:03 +00:00
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:
@@ -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 <string>
|
||||
#include <iostream>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user