mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +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:
@@ -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 <string>
|
||||
# include <algorithm>
|
||||
|
||||
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 <string>
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user