mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 10:15:14 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ca964032 | ||
|
|
485b319598 | ||
|
|
1ed94b7c84 | ||
|
|
b119971aef | ||
|
|
2a0f5b17b4 |
@@ -2,11 +2,6 @@
|
||||
** Variable names.
|
||||
What should we name `variant' and `lex_symbol'?
|
||||
|
||||
** Use b4_symbol in all the skeleton
|
||||
Move its definition in the more standard places and deploy it in other
|
||||
skeletons. Then remove the older system, including the tables
|
||||
generated by output.c
|
||||
|
||||
** Update the documentation on gnu.org
|
||||
|
||||
** Get rid of fake #lines [Bison: ...]
|
||||
|
||||
+47
-1
@@ -326,6 +326,13 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
## Symbols. ##
|
||||
## --------- ##
|
||||
|
||||
# In order to unify the handling of the various aspects of symbols
|
||||
# (tag, type_name, whether terminal, etc.), bison.exe defines one
|
||||
# macro per (token, field), where field can has_id, id, etc.: see
|
||||
# src/output.c:prepare_symbols_definitions().
|
||||
#
|
||||
# The following macros provide access to these values.
|
||||
|
||||
# b4_symbol_(NUM, FIELD)
|
||||
# ----------------------
|
||||
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
|
||||
@@ -406,6 +413,45 @@ m4_define([b4_symbol_case_],
|
||||
m4_define([b4_symbol_foreach],
|
||||
[m4_map([$1], m4_defn([b4_symbol_numbers]))])
|
||||
|
||||
# b4_symbol_map(MACRO)
|
||||
# --------------------
|
||||
# Return a list (possibly empty elements) of MACRO invoked for each
|
||||
# SYMBOL-NUM.
|
||||
m4_define([b4_symbol_map],
|
||||
[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)])
|
||||
|
||||
|
||||
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
||||
# -------------------------------------------
|
||||
# Whether NUM denotes a token that has an exported definition (i.e.,
|
||||
# shows in enum yytokentype).
|
||||
m4_define([b4_token_visible_if],
|
||||
[b4_symbol_if([$1], [is_token],
|
||||
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
||||
[$3])])
|
||||
|
||||
# b4_token_has_definition(NUM)
|
||||
# ----------------------------
|
||||
# 1 if NUM is visible, nothing otherwise.
|
||||
m4_define([b4_token_has_definition],
|
||||
[b4_token_visible_if([$1], [1])])
|
||||
|
||||
# b4_any_token_visible_if([IF-TRUE], [IF-FALSE])
|
||||
# ----------------------------------------------
|
||||
# Whether there is a token that needs to be defined.
|
||||
m4_define([b4_any_token_visible_if],
|
||||
[m4_ifval(b4_symbol_foreach([b4_token_has_definition]),
|
||||
[$1], [$2])])
|
||||
|
||||
|
||||
# b4_token_format(FORMAT, NUM)
|
||||
# ----------------------------
|
||||
m4_define([b4_token_format],
|
||||
[b4_token_visible_if([$2],
|
||||
[m4_quote(m4_format([$1],
|
||||
[b4_symbol([$2], [id])],
|
||||
[b4_symbol([$2], [user_number])]))])])
|
||||
|
||||
|
||||
## ------- ##
|
||||
## Types. ##
|
||||
@@ -417,7 +463,7 @@ m4_define([b4_symbol_foreach],
|
||||
# Skip NUMS that have no type-name.
|
||||
m4_define([b4_type_action_],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[m4_map([b4_symbol_case_], [$@])[]dnl
|
||||
[m4_map_args([b4_symbol_case_], $@)[]dnl
|
||||
b4_dollar_dollar([b4_symbol([$1], [number])],
|
||||
[b4_symbol([$1], [tag])],
|
||||
[b4_symbol([$1], [type])]);
|
||||
|
||||
+10
-10
@@ -86,17 +86,17 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[/* Tokens. */
|
||||
enum yytokentype {
|
||||
m4_map_sep([ b4_token_enum], [,
|
||||
],
|
||||
[$@])
|
||||
};
|
||||
])
|
||||
[[/* Tokens. */
|
||||
enum yytokentype {
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
};
|
||||
]])
|
||||
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ m4_define([b4_public_types_declare],
|
||||
/// Tokens.
|
||||
struct token
|
||||
{
|
||||
]b4_token_enums(b4_tokens)[
|
||||
]b4_token_enums[
|
||||
};
|
||||
|
||||
/// Token type.
|
||||
|
||||
@@ -250,57 +250,52 @@ static const b4_int_type_for([$2]) yy$1[[]] =
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
|
||||
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# -----------------------------------------
|
||||
# b4_token_define(TOKEN-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this token as #define.
|
||||
m4_define([b4_token_define],
|
||||
[#define b4_percent_define_get([api.tokens.prefix])$1 $2
|
||||
])
|
||||
[b4_token_format([#define %s %s], [$1])])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as #defines.
|
||||
# b4_token_defines
|
||||
# ----------------
|
||||
# Output the definition of the tokens.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_if([$#$1], [1], [],
|
||||
[/* Tokens. */
|
||||
m4_map([b4_token_define], [$@])])
|
||||
])
|
||||
[b4_any_token_visible_if([/* Tokens. */
|
||||
m4_join([
|
||||
], b4_symbol_map([b4_token_define]))])])
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_percent_define_get([api.tokens.prefix])$1 = $2])
|
||||
[b4_token_format([ %s = %s], [$1])])
|
||||
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[m4_if([$#$1], [1], [],
|
||||
[[/* Tokens. */
|
||||
[b4_any_token_visible_if([[/* Tokens. */
|
||||
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
||||
# define ]b4_api_PREFIX[TOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum ]b4_api_prefix[tokentype {
|
||||
]m4_map_sep([ b4_token_enum], [,
|
||||
],
|
||||
[$@])
|
||||
};[
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum ]b4_api_prefix[tokentype {
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
};
|
||||
#endif
|
||||
]])])
|
||||
|
||||
|
||||
# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are any) as enums and, if POSIX
|
||||
# Yacc is enabled, as #defines.
|
||||
# b4_token_enums_defines
|
||||
# ----------------------
|
||||
# Output the definition of the tokens (if there are any) as enums and,
|
||||
# if POSIX Yacc is enabled, as #defines.
|
||||
m4_define([b4_token_enums_defines],
|
||||
[b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], [])
|
||||
])
|
||||
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ m4_define([b4_rhs_location],
|
||||
m4_define([b4_shared_declarations],
|
||||
[b4_declare_yydebug[
|
||||
]b4_percent_code_get([[requires]])[
|
||||
]b4_token_enums(b4_tokens)[
|
||||
]b4_token_enums[
|
||||
]b4_declare_yylstype[
|
||||
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||
]b4_percent_code_get([[provides]])[]dnl
|
||||
|
||||
+1
-1
@@ -300,7 +300,7 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
|
||||
]dnl Redirections for glr.c.
|
||||
b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
[b4_token_defines(b4_tokens)])
|
||||
[b4_token_defines])
|
||||
[
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
|
||||
|
||||
+12
-15
@@ -142,23 +142,20 @@ m4_define([b4_integral_parser_table_define],
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[ /** Token number, to be returned by the scanner. */
|
||||
static final int b4_percent_define_get([api.tokens.prefix])$1 = $2;
|
||||
])
|
||||
[b4_token_format([ /** Token number, to be returned by the scanner. */
|
||||
static final int %s = %s;
|
||||
], [$1])])
|
||||
|
||||
|
||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -----------------------------------------------------
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[m4_if([$#$1], [1], [],
|
||||
[/* Tokens. */
|
||||
m4_map([b4_token_enum], [$@])])
|
||||
])
|
||||
[b4_any_token_visible_if([/* Tokens. */
|
||||
b4_symbol_foreach([b4_token_enum])])])
|
||||
|
||||
# b4-case(ID, CODE)
|
||||
# -----------------
|
||||
@@ -263,7 +260,7 @@ m4_define([b4_lex_param_decl],
|
||||
[$1])])
|
||||
|
||||
m4_define([b4_param_decls],
|
||||
[m4_map([b4_param_decl], [$@])])
|
||||
[m4_map_args([b4_param_decl], $@)])
|
||||
m4_define([b4_param_decl], [, $1])
|
||||
|
||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||
@@ -290,7 +287,7 @@ m4_define([b4_lex_param_call],
|
||||
b4_param_calls(b4_lex_param))],
|
||||
[$1])])
|
||||
m4_define([b4_param_calls],
|
||||
[m4_map([b4_param_call], [$@])])
|
||||
[m4_map_args([b4_param_call], $@)])
|
||||
m4_define([b4_param_call], [, $2])
|
||||
|
||||
|
||||
@@ -303,7 +300,7 @@ m4_define([b4_parse_param_cons],
|
||||
[b4_constructor_calls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_constructor_calls],
|
||||
[m4_map([b4_constructor_call], [$@])])
|
||||
[m4_map_args([b4_constructor_call], $@)])
|
||||
m4_define([b4_constructor_call],
|
||||
[this.$2 = $2;
|
||||
])
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ b4_public_types_define])[
|
||||
]b4_namespace_close[
|
||||
|
||||
]b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
[b4_token_defines(b4_tokens)
|
||||
[b4_token_defines
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
/* Redirection for backward compatibility. */
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ b4_locations_if([[
|
||||
/** Token returned by the scanner to signal the end of its input. */
|
||||
public static final int EOF = 0;
|
||||
|
||||
]b4_token_enums(b4_tokens)[
|
||||
]b4_token_enums[
|
||||
|
||||
]b4_locations_if([[/**
|
||||
* Method to retrieve the beginning position of the last scanned token.
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ m4_define([b4_char_sizeof_],
|
||||
m4_define([b4_char_sizeof],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[
|
||||
m4_map([b4_char_sizeof_], [$@])dnl
|
||||
m4_map_args([b4_char_sizeof_], $@)dnl
|
||||
char _b4_char_sizeof_dummy@{sizeof([b4_symbol([$1], [type])])@};
|
||||
])])
|
||||
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ m4_define([b4_shared_declarations],
|
||||
[b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_declare_yydebug[
|
||||
]b4_percent_code_get([[requires]])[
|
||||
]b4_token_enums_defines(b4_tokens)[
|
||||
]b4_token_enums_defines[
|
||||
]b4_declare_yylstype[
|
||||
]b4_declare_yyparse[
|
||||
]b4_percent_code_get([[provides]])[
|
||||
|
||||
@@ -469,40 +469,6 @@ prepare_symbol_definitions (void)
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------.
|
||||
| Output the tokens definition to OUT. |
|
||||
`--------------------------------------*/
|
||||
|
||||
static void
|
||||
token_definitions_output (FILE *out)
|
||||
{
|
||||
int i;
|
||||
char const *sep = "";
|
||||
|
||||
fputs ("m4_define([b4_tokens], \n[", out);
|
||||
for (i = 0; i < ntokens; ++i)
|
||||
{
|
||||
symbol *sym = symbols[i];
|
||||
int number = sym->user_token_number;
|
||||
uniqstr id = symbol_id_get (sym);
|
||||
|
||||
/* At this stage, if there are literal string aliases, they are
|
||||
part of SYMBOLS, so we should not find their aliased symbols
|
||||
here. */
|
||||
aver (number != USER_NUMBER_HAS_STRING_ALIAS);
|
||||
|
||||
/* Skip error token and tokens without identifier. */
|
||||
if (sym != errtoken && id)
|
||||
{
|
||||
fprintf (out, "%s[[[%s]], %d]",
|
||||
sep, id, number);
|
||||
sep = ",\n";
|
||||
}
|
||||
}
|
||||
fputs ("])\n\n", out);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
prepare_actions (void)
|
||||
{
|
||||
@@ -561,7 +527,6 @@ muscles_output (FILE *out)
|
||||
fputs ("m4_init()\n", out);
|
||||
merger_output (out);
|
||||
symbol_numbers_output (out);
|
||||
token_definitions_output (out);
|
||||
type_names_output (out);
|
||||
user_actions_output (out);
|
||||
// Must be last.
|
||||
|
||||
+1
-1
Submodule submodules/autoconf updated: 0db9c1a19f...80019ca5bd
Reference in New Issue
Block a user