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:
Akim Demaille
2018-12-02 08:32:01 +01:00
parent d527b2d0f1
commit e40db8976c
7 changed files with 83 additions and 79 deletions

View File

@@ -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;
}
}