mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: comment and formatting changes
* data/bison.m4, data/c++.m4, data/glr.c, data/java.m4, data/lalr1.cc, * data/yacc.c, src/scan-code.l: Fix comments. Prefer POS to denote the position of a symbol in a rule, since NUM is also used to denote symbol numbers.
This commit is contained in:
@@ -391,7 +391,7 @@ b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
# If has_id, the id. Guaranteed to be usable as a C identifier.
|
||||
# Prefixed by api.token.prefix if defined.
|
||||
# - tag: string.
|
||||
# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||
# A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
|
||||
# - user_number: integer
|
||||
# The assigned (external) number as used by yylex.
|
||||
# - is_token: 0 or 1
|
||||
@@ -497,7 +497,7 @@ m4_define([b4_symbol_actions],
|
||||
m4_ifval(m4_defn([b4_actions_]),
|
||||
[switch (m4_default([$2], [yytype]))
|
||||
{
|
||||
m4_defn([b4_actions_])
|
||||
m4_defn([b4_actions_])[]dnl
|
||||
default:
|
||||
break;
|
||||
}dnl
|
||||
@@ -569,7 +569,7 @@ m4_define([b4_token_format],
|
||||
# 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,
|
||||
# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM,
|
||||
# TAG, TYPE).
|
||||
m4_define([_b4_type_action],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
|
||||
@@ -528,10 +528,11 @@ m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([yyval], [$1])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
|
||||
# --------------------------------------
|
||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||
# Expansion of $<TYPE>POS, where the current rule has RULE-LENGTH
|
||||
# symbols on RHS.
|
||||
# FIXME: Dead code.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
||||
|
||||
@@ -543,9 +544,9 @@ m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylocation_stack_@{($1) - ($2)@})])
|
||||
|
||||
@@ -119,10 +119,10 @@ m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([(*yyvalp)], [$1])])
|
||||
|
||||
|
||||
# b4_rhs_data(RULE-LENGTH, NUM)
|
||||
# b4_rhs_data(RULE-LENGTH, POS)
|
||||
# -----------------------------
|
||||
# Expand to the semantic stack place that contains value and location
|
||||
# of symbol number NUM in a rule of length RULE-LENGTH.
|
||||
# of symbol number POS in a rule of length RULE-LENGTH.
|
||||
m4_define([b4_rhs_data],
|
||||
[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
|
||||
|
||||
|
||||
@@ -242,9 +242,9 @@ m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[yystack.locationAt ($1-($2))])
|
||||
|
||||
@@ -61,23 +61,23 @@ m4_define([b4_lhs_value],
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[yylhs.location])
|
||||
[yylhs.location])
|
||||
|
||||
|
||||
# b4_rhs_data(RULE-LENGTH, NUM)
|
||||
# b4_rhs_data(RULE-LENGTH, POS)
|
||||
# -----------------------------
|
||||
# Return the data corresponding to the symbol #NUM, where the current
|
||||
# Return the data corresponding to the symbol #POS, where the current
|
||||
# rule has RULE-LENGTH symbols on RHS.
|
||||
m4_define([b4_rhs_data],
|
||||
[yystack_@{b4_subtract($@)@}])
|
||||
[yystack_@{b4_subtract($@)@}])
|
||||
|
||||
|
||||
# b4_rhs_state(RULE-LENGTH, NUM)
|
||||
# b4_rhs_state(RULE-LENGTH, POS)
|
||||
# ------------------------------
|
||||
# The state corresponding to the symbol #NUM, where the current
|
||||
# The state corresponding to the symbol #POS, where the current
|
||||
# rule has RULE-LENGTH symbols on RHS.
|
||||
m4_define([b4_rhs_state],
|
||||
[b4_rhs_data([$1], [$2]).state])
|
||||
[b4_rhs_data([$1], [$2]).state])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||
@@ -93,12 +93,12 @@ m4_define([b4_rhs_value],
|
||||
[_b4_rhs_value($@)])])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[b4_rhs_data([$1], [$2]).location])
|
||||
[b4_rhs_data([$1], [$2]).location])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||
|
||||
@@ -154,12 +154,12 @@ m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylsp@{b4_subtract([$2], [$1])@})])
|
||||
[(yylsp@{b4_subtract([$2], [$1])@})])
|
||||
|
||||
|
||||
## -------------- ##
|
||||
|
||||
113
src/scan-code.l
113
src/scan-code.l
@@ -611,14 +611,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
effective_rule_length = symbol_list_length (rule->next);
|
||||
}
|
||||
|
||||
/* Get the type name if explicit. */
|
||||
/* The type name if explicit, otherwise left null. */
|
||||
char const *type_name = NULL;
|
||||
char *cp = fetch_type_name (text + 1, &type_name, dollar_loc);
|
||||
|
||||
int n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
||||
|
||||
/* End type_name. */
|
||||
/* End type_name. Don't do it ealier: parse_ref depends on TEXT. */
|
||||
if (type_name)
|
||||
cp[-1] = '\0';
|
||||
|
||||
@@ -628,63 +626,68 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
break;
|
||||
|
||||
case LHS_REF:
|
||||
if (!type_name)
|
||||
type_name = symbol_list_n_type_name_get (rule, 0);
|
||||
{
|
||||
if (!type_name)
|
||||
type_name = symbol_list_n_type_name_get (rule, 0);
|
||||
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
{
|
||||
if (rule->midrule_parent_rule)
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$$ for the midrule at $%d of %s"
|
||||
" has no declared type"),
|
||||
rule->midrule_parent_rhs_index,
|
||||
quote (effective_rule->content.sym->tag));
|
||||
else
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$$ of %s has no declared type"),
|
||||
quote (rule->content.sym->tag));
|
||||
}
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
}
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
{
|
||||
if (rule->midrule_parent_rule)
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$$ for the midrule at $%d of %s"
|
||||
" has no declared type"),
|
||||
rule->midrule_parent_rhs_index,
|
||||
quote (effective_rule->content.sym->tag));
|
||||
else
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$$ of %s has no declared type"),
|
||||
quote (rule->content.sym->tag));
|
||||
}
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
}
|
||||
|
||||
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
rule->action_props.is_value_used = true;
|
||||
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
rule->action_props.is_value_used = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Reference to a RHS symbol. */
|
||||
default:
|
||||
if (max_left_semantic_context < 1 - n)
|
||||
max_left_semantic_context = 1 - n;
|
||||
if (!type_name && 0 < n)
|
||||
type_name = symbol_list_n_type_name_get (effective_rule, n);
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$%s of %s has no declared type"), cp,
|
||||
quote (effective_rule->content.sym->tag));
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
}
|
||||
{
|
||||
if (max_left_semantic_context < 1 - n)
|
||||
max_left_semantic_context = 1 - n;
|
||||
if (!type_name && 0 < n)
|
||||
type_name = symbol_list_n_type_name_get (effective_rule, n);
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
complain (&dollar_loc, complaint,
|
||||
_("$%s of %s has no declared type"), cp,
|
||||
quote (effective_rule->content.sym->tag));
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
}
|
||||
|
||||
obstack_printf (&obstack_for_string,
|
||||
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
if (0 < n)
|
||||
{
|
||||
symbol_list *sym = symbol_list_n_get (effective_rule, n);
|
||||
if (muscle_percent_define_ifdef ("api.value.automove")
|
||||
&& sym->action_props.is_value_used)
|
||||
complain (&dollar_loc, Wother,
|
||||
_("multiple occurrences of $%d with api.value.automove"),
|
||||
n);
|
||||
sym->action_props.is_value_used = true;
|
||||
}
|
||||
obstack_printf (&obstack_for_string,
|
||||
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
if (0 < n)
|
||||
{
|
||||
symbol_list *sym = symbol_list_n_get (effective_rule, n);
|
||||
if (muscle_percent_define_ifdef ("api.value.automove")
|
||||
&& sym->action_props.is_value_used)
|
||||
complain (&dollar_loc, Wother,
|
||||
_("multiple occurrences of $%d with api.value.automove"),
|
||||
n);
|
||||
sym->action_props.is_value_used = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user