[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
style: use _foo for private macros, not foo_
From: |
Akim Demaille |
Subject: |
style: use _foo for private macros, not foo_ |
Date: |
Wed, 19 Sep 2018 20:58:15 +0200 |
commit b7613423ce12d417d04fdbd20ae2cb87dcd0582e
Author: Akim Demaille <address@hidden>
Date: Wed Sep 19 18:05:05 2018 +0200
style: use _foo for private macros, not foo_
We use both styles, let's stick to a single one. Autoconf uses the
prefix one, let's do the same.
* data/bison.m4, data/c++.m4, data/c-like.m4, data/lalr1.cc,
* data/variant.hh, data/yacc.c: Rename all the b4_*_ macros
as _b4_*.
diff --git a/data/bison.m4 b/data/bison.m4
index 80e025c9..cd810501 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -389,11 +389,11 @@ b4_define_flag_if([yacc]) # Whether POSIX
Yacc is emulated.
#
# The following macros provide access to these values.
-# b4_symbol_(NUM, FIELD)
+# _b4_symbol(NUM, FIELD)
# ----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
-m4_define([b4_symbol_],
+m4_define([_b4_symbol],
[m4_indir([b4_symbol($1, $2)])])
@@ -404,8 +404,8 @@ m4_define([b4_symbol_],
m4_define([b4_symbol],
[m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
- [b4_symbol_([$1], [id])])],
- [b4_symbol_($@)])])
+ [_b4_symbol([$1], [id])])],
+ [_b4_symbol($@)])])
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
@@ -443,7 +443,7 @@ m4_define([b4_symbol_action],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[(*yylocationp)])dnl
- b4_symbol_case_([$1])[]dnl
+ _b4_symbol_case([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline(address@hidden@], address@hidden@])
@@ -478,10 +478,10 @@ m4_ifval(m4_defn([b4_actions_]),
m4_popdef([b4_actions_])dnl
])
-# b4_symbol_case_(SYMBOL-NUM)
+# _b4_symbol_case(SYMBOL-NUM)
# ---------------------------
# Issue a "case NUM" for SYMBOL-NUM.
-m4_define([b4_symbol_case_],
+m4_define([_b4_symbol_case],
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
])
@@ -536,16 +536,16 @@ m4_define([b4_token_format],
## Types. ##
## ------- ##
-# b4_type_action_(NUMS)
+# _b4_type_action(NUMS)
# ---------------------
# Run actions for the symbol NUMS that all have the same type-name.
# Skip NUMS that have no type-name.
#
# To specify the action to run, define b4_dollar_dollar(NUMBER,
# TAG, TYPE).
-m4_define([b4_type_action_],
+m4_define([_b4_type_action],
[b4_symbol_if([$1], [has_type],
-[m4_map([ b4_symbol_case_], address@hidden)[]dnl
+[m4_map([ _b4_symbol_case], address@hidden)[]dnl
b4_dollar_dollar([b4_symbol([$1], [number])],
[b4_symbol([$1], [tag])],
[b4_symbol([$1], [type])]);
@@ -701,7 +701,7 @@ m4_define([b4_percent_define_use],
# b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl
-b4_percent_define_ifdef_([$1],
+_b4_percent_define_ifdef([$1],
[m4_indir([b4_percent_define(]$1[)])],
[$2])])
@@ -755,15 +755,15 @@ m4_define([b4_percent_define_get_syncline],
[m4_indir([b4_percent_define_syncline(]$1[)])],
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
-# b4_percent_define_ifdef_(VARIABLE, IF-TRUE, [IF-FALSE])
+# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
# IF-FALSE. Don't record usage of VARIABLE.
#
# For example:
#
-# b4_percent_define_ifdef_([[foo]], [[it's defined]], [[it's undefined]])
-m4_define([b4_percent_define_ifdef_],
+# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
+m4_define([_b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)],
[$2],
[$3])])
@@ -779,7 +779,7 @@ m4_define([b4_percent_define_ifdef_],
#
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef],
-[b4_percent_define_ifdef_([$1],
+[_b4_percent_define_ifdef([$1],
[b4_percent_define_use([$1])$2],
[$3])])
@@ -824,7 +824,7 @@ m4_define([b4_percent_define_flag_if],
#
# b4_percent_define_default([[foo]], [[default value]])
m4_define([b4_percent_define_default],
-[b4_percent_define_ifdef_([$1], [],
+[_b4_percent_define_ifdef([$1], [],
[m4_define([b4_percent_define(]$1[)], [$2])dnl
m4_define([b4_percent_define_kind(]$1[)],
[m4_default([$3], [keyword])])dnl
@@ -839,19 +839,19 @@ m4_define([b4_percent_define_default],
# Define b4_NAME_if that executes its $1 or $2 depending whether
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
# to '_'.
-m4_define([b4_percent_define_if_define_],
+m4_define([_b4_percent_define_if_define],
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
[b4_percent_define_flag_if(m4_default([$2], [$1]),
[$3], [$4])])])
m4_define([b4_percent_define_if_define],
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
-b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
+_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
# ---------------------------------------------------------------------
m4_define([b4_percent_define_check_kind],
-[b4_percent_define_ifdef_([$1],
+[_b4_percent_define_ifdef([$1],
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
[b4_error([m4_default([$3], [complain])],
b4_percent_define_get_loc([$1]),
@@ -884,7 +884,7 @@ m4_define([b4_percent_define_check_values],
[_b4_percent_define_check_values(b4_sublist)])])
m4_define([_b4_percent_define_check_values],
-[b4_percent_define_ifdef_([$1],
+[_b4_percent_define_ifdef([$1],
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
m4_pushdef([b4_good_value], [0])dnl
m4_if($#, 1, [],
diff --git a/data/c++.m4 b/data/c++.m4
index 4cf51d40..5beb5f0e 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -36,7 +36,7 @@ b4_percent_define_check_kind([parser_class_name], [code],
[deprecated])
# --------------------------
# Put TEXT in comment. Prefix all the output lines with PREFIX.
m4_define([b4_comment],
-[b4_comment_([$1], [$2// ], [$2// ])])
+[_b4_comment([$1], [$2// ], [$2// ])])
# b4_inline(hh|cc)
diff --git a/data/c-like.m4 b/data/c-like.m4
index 26bab42e..4e476ac8 100644
--- a/data/c-like.m4
+++ b/data/c-like.m4
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# b4_comment_(TEXT, OPEN, CONTINUE, END)
+# _b4_comment(TEXT, OPEN, CONTINUE, END)
# --------------------------------------
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
# Avoid adding indentation to the first line, as the indentation comes
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
#
# Prefix all the output lines with PREFIX.
-m4_define([b4_comment_],
+m4_define([_b4_comment],
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
\(.\)], [
$3\1])$4])
@@ -34,17 +34,17 @@ $3\1])$4])
# --------------------------
# Put TEXT in comment. Prefix all the output lines with PREFIX.
m4_define([b4_comment],
-[b4_comment_([$1], [$2/* ], [$2 ], [ */])])
+[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
-# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
+# _b4_dollar_dollar(VALUE, FIELD, DEFAULT-FIELD)
# ----------------------------------------------
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
# pointer.
-m4_define([b4_dollar_dollar_],
+m4_define([_b4_dollar_dollar],
[b4_symbol_value([$1],
m4_if([$2], [[]],
[[$3]], [[$2]]))])
@@ -56,7 +56,7 @@ m4_define([b4_dollar_dollar_],
# and b4_at_dollar for LOCATION.
m4_define([b4_dollar_pushdef],
[m4_pushdef([b4_dollar_dollar],
- [b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
+ [_b4_dollar_dollar([$1], m4_dquote($][1), [$2])])dnl
m4_pushdef([b4_at_dollar], [$3])dnl
])
m4_define([b4_dollar_popdef],
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 15fd6fb9..1a5138bf 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -106,7 +106,7 @@ b4_dollar_pushdef([yysym.value],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[yysym.location])dnl
- b4_symbol_case_([$1])
+ _b4_symbol_case([$1])
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline(address@hidden@], address@hidden@])
diff --git a/data/variant.hh b/data/variant.hh
index 4ba3f006..d573666b 100644
--- a/data/variant.hh
+++ b/data/variant.hh
@@ -29,7 +29,7 @@ m4_define([b4_symbol_variant],
[$2.$3< $][3 > (m4_shift3($@))])dnl
switch ($1)
{
-b4_type_foreach([b4_type_action_])[]dnl
+b4_type_foreach([_b4_type_action])[]dnl
default:
break;
}
@@ -299,15 +299,15 @@ m4_define([b4_symbol_value_template],
## ------------- ##
-# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
+# _b4_symbol_constructor_declare(SYMBOL-NUMBER)
# ---------------------------------------------
# Declare the overloaded version of make_symbol for the (common) type of
# these SYMBOL-NUMBERS. Use at class-level.
-m4_define([b4_symbol_constructor_declare_],
+m4_define([_b4_symbol_constructor_declare],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ static
symbol_type
- make_[]b4_symbol_([$1], [id]) (dnl
+ make_[]_b4_symbol([$1], [id]) (dnl
b4_join(b4_symbol_if([$1], [has_type],
[YY_COPY (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_COPY (location_type) l])));
@@ -321,18 +321,18 @@ b4_join(b4_symbol_if([$1], [has_type],
# Use at class-level.
m4_define([b4_symbol_constructor_declare],
[ // Symbol constructors declarations.
-b4_symbol_foreach([b4_symbol_constructor_declare_])])
+b4_symbol_foreach([_b4_symbol_constructor_declare])])
-# b4_symbol_constructor_define_(SYMBOL-NUMBER)
+# _b4_symbol_constructor_define(SYMBOL-NUMBER)
# --------------------------------------------
# Define symbol constructor for this SYMBOL-NUMBER.
-m4_define([b4_symbol_constructor_define_],
+m4_define([_b4_symbol_constructor_define],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ inline
b4_parser_class_name::symbol_type
- b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
+ b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
b4_join(b4_symbol_if([$1], [has_type],
[YY_COPY (b4_symbol([$1], [type])) v]),
b4_locations_if([YY_COPY (location_type) l])))
@@ -376,4 +376,4 @@ m4_define([b4_basic_symbol_constructor_define],
# Define the overloaded versions of make_symbol for all the value types.
m4_define([b4_symbol_constructor_define],
[ // Implementation of make_symbol for each symbol type.
-b4_symbol_foreach([b4_symbol_constructor_define_])])
+b4_symbol_foreach([_b4_symbol_constructor_define])])
diff --git a/data/yacc.c b/data/yacc.c
index e72b098b..15b0c160 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -237,11 +237,11 @@ m4_define([b4_declare_parser_state_variables],
[b4_pure_if([[
YYSIZE_T yyes_capacity;]])])
-# b4_declare_yyparse_push_
+# _b4_declare_yyparse_push
# ------------------------
# Declaration of yyparse (and dependencies) when using the push parser
# (including in pull mode).
-m4_define([b4_declare_yyparse_push_],
+m4_define([_b4_declare_yyparse_push],
[[#ifndef YYPUSH_MORE_DEFINED
# define YYPUSH_MORE_DEFINED
enum { YYPUSH_MORE = 4 };
@@ -265,18 +265,18 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *ps]], [[ps]]])dnl
])
-# b4_declare_yyparse_
+# _b4_declare_yyparse
# -------------------
# When not the push parser.
-m4_define([b4_declare_yyparse_],
+m4_define([_b4_declare_yyparse],
[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
# b4_declare_yyparse
# ------------------
m4_define([b4_declare_yyparse],
-[b4_push_if([b4_declare_yyparse_push_],
- [b4_declare_yyparse_])[]dnl
+[b4_push_if([_b4_declare_yyparse_push],
+ [_b4_declare_yyparse])[]dnl
])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- style: use _foo for private macros, not foo_,
Akim Demaille <=