style: use consistently *_loc for locations

Some members are called foo_location, others are foo_loc.  Stick to
the latter.

* src/gram.h, src/location.h, src/location.c, src/output.c,
* src/parse-gram.y, src/reader.h, src/reader.c, src/reduce.c,
* src/scan-gram.l, src/symlist.h, src/symlist.c, src/symtab.h,
* src/symtab.c:
Use _loc consistently, not _location.
This commit is contained in:
Akim Demaille
2019-05-03 08:52:26 +02:00
parent 365b4d95a4
commit 013720f0e7
15 changed files with 65 additions and 65 deletions

View File

@@ -203,7 +203,7 @@ typedef struct
int expected_rr_conflicts; int expected_rr_conflicts;
const char *action; const char *action;
location action_location; location action_loc;
} rule; } rule;
/* The used rules (size NRULES). */ /* The used rules (size NRULES). */

View File

@@ -30,7 +30,7 @@
#include "getargs.h" #include "getargs.h"
#include "location.h" #include "location.h"
location const empty_location = EMPTY_LOCATION_INIT; location const empty_loc = EMPTY_LOCATION_INIT;
/* If BUF is null, add BUFSIZE (which in this case must be less than /* If BUF is null, add BUFSIZE (which in this case must be less than
INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to

View File

@@ -102,7 +102,7 @@ typedef struct
# define GRAM_LTYPE location # define GRAM_LTYPE location
# define EMPTY_LOCATION_INIT {{NULL, 0, 0, 0}, {NULL, 0, 0, 0}} # define EMPTY_LOCATION_INIT {{NULL, 0, 0, 0}, {NULL, 0, 0, 0}}
extern location const empty_location; extern location const empty_loc;
/* Set *LOC and adjust scanner cursor to account for token TOKEN of /* Set *LOC and adjust scanner cursor to account for token TOKEN of
size SIZE. */ size SIZE. */

View File

@@ -372,8 +372,8 @@ user_actions_output (FILE *out)
{ {
fprintf (out, "%s(%d, [b4_syncline(%d, ", fprintf (out, "%s(%d, [b4_syncline(%d, ",
rules[r].is_predicate ? "b4_predicate_case" : "b4_case", rules[r].is_predicate ? "b4_predicate_case" : "b4_case",
r + 1, rules[r].action_location.start.line); r + 1, rules[r].action_loc.start.line);
string_output (out, rules[r].action_location.start.file); string_output (out, rules[r].action_loc.start.file);
fprintf (out, ")dnl\n[ %s]])\n\n", rules[r].action); fprintf (out, ")dnl\n[ %s]])\n\n", rules[r].action);
} }
fputs ("])\n\n", out); fputs ("])\n\n", out);

View File

@@ -122,7 +122,7 @@
#include "xmemdup0.h" #include "xmemdup0.h"
static int current_prec = 0; static int current_prec = 0;
static location current_lhs_location; static location current_lhs_loc;
static named_ref *current_lhs_named_ref; static named_ref *current_lhs_named_ref;
static symbol *current_lhs_symbol; static symbol *current_lhs_symbol;
static symbol_class current_class = unknown_sym; static symbol_class current_class = unknown_sym;
@@ -2406,7 +2406,7 @@ yyreduce:
break; break;
case 95: case 95:
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, { grammar_current_rule_begin (current_lhs_symbol, current_lhs_loc,
current_lhs_named_ref); } current_lhs_named_ref); }
break; break;
@@ -3037,7 +3037,7 @@ void
current_lhs (symbol *sym, location loc, named_ref *ref) current_lhs (symbol *sym, location loc, named_ref *ref)
{ {
current_lhs_symbol = sym; current_lhs_symbol = sym;
current_lhs_location = loc; current_lhs_loc = loc;
if (sym) if (sym)
symbol_location_as_lhs_set (sym, loc); symbol_location_as_lhs_set (sym, loc);
/* In order to simplify memory management, named references for lhs /* In order to simplify memory management, named references for lhs

View File

@@ -49,7 +49,7 @@
#include "xmemdup0.h" #include "xmemdup0.h"
static int current_prec = 0; static int current_prec = 0;
static location current_lhs_location; static location current_lhs_loc;
static named_ref *current_lhs_named_ref; static named_ref *current_lhs_named_ref;
static symbol *current_lhs_symbol; static symbol *current_lhs_symbol;
static symbol_class current_class = unknown_sym; static symbol_class current_class = unknown_sym;
@@ -651,7 +651,7 @@ rhses.1:
%token PERCENT_EMPTY "%empty"; %token PERCENT_EMPTY "%empty";
rhs: rhs:
%empty %empty
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, { grammar_current_rule_begin (current_lhs_symbol, current_lhs_loc,
current_lhs_named_ref); } current_lhs_named_ref); }
| rhs symbol named_ref.opt | rhs symbol named_ref.opt
{ grammar_current_rule_symbol_append ($2, @2, $3); } { grammar_current_rule_symbol_append ($2, @2, $3); }
@@ -1050,7 +1050,7 @@ void
current_lhs (symbol *sym, location loc, named_ref *ref) current_lhs (symbol *sym, location loc, named_ref *ref)
{ {
current_lhs_symbol = sym; current_lhs_symbol = sym;
current_lhs_location = loc; current_lhs_loc = loc;
if (sym) if (sym)
symbol_location_as_lhs_set (sym, loc); symbol_location_as_lhs_set (sym, loc);
/* In order to simplify memory management, named references for lhs /* In order to simplify memory management, named references for lhs

View File

@@ -62,7 +62,7 @@ grammar_start_symbol_set (symbol *sym, location loc)
{ {
start_flag = true; start_flag = true;
startsymbol = sym; startsymbol = sym;
startsymbol_location = loc; startsymbol_loc = loc;
} }
} }
@@ -131,12 +131,12 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
quote (merge_function->name), type, quote (merge_function->name), type,
merge_function->type); merge_function->type);
indent += SUB_INDENT; indent += SUB_INDENT;
complain_indent (&merge_function->type_declaration_location, complaint, complain_indent (&merge_function->type_declaration_loc, complaint,
&indent, &indent,
_("previous declaration")); _("previous declaration"));
} }
merge_function->type = uniqstr_new (type); merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc; merge_function->type_declaration_loc = declaration_loc;
} }
/*--------------------------------------. /*--------------------------------------.
@@ -408,11 +408,11 @@ grammar_midrule_action (void)
/* Make a DUMMY nonterminal, whose location is that of the midrule /* Make a DUMMY nonterminal, whose location is that of the midrule
action. Create the MIDRULE. */ action. Create the MIDRULE. */
location dummy_location = current_rule->action_props.location; location dummy_loc = current_rule->action_props.location;
symbol *dummy = dummy_symbol_get (dummy_location); symbol *dummy = dummy_symbol_get (dummy_loc);
symbol_type_set(dummy, symbol_type_set(dummy,
current_rule->action_props.type, current_rule->action_props.location); current_rule->action_props.type, current_rule->action_props.location);
symbol_list *midrule = symbol_list_sym_new (dummy, dummy_location); symbol_list *midrule = symbol_list_sym_new (dummy, dummy_loc);
/* Remember named_ref of previous action. */ /* Remember named_ref of previous action. */
named_ref *action_name = current_rule->action_props.named_ref; named_ref *action_name = current_rule->action_props.named_ref;
@@ -422,7 +422,7 @@ grammar_midrule_action (void)
++nrules; ++nrules;
++nritems; ++nritems;
/* Attach its location and actions to that of the DUMMY. */ /* Attach its location and actions to that of the DUMMY. */
midrule->rhs_loc = dummy_location; midrule->rhs_loc = dummy_loc;
code_props_rule_action_init (&midrule->action_props, code_props_rule_action_init (&midrule->action_props,
current_rule->action_props.code, current_rule->action_props.code,
current_rule->action_props.location, current_rule->action_props.location,
@@ -443,14 +443,14 @@ grammar_midrule_action (void)
grammar = midrule; grammar = midrule;
/* End the dummy's rule. */ /* End the dummy's rule. */
midrule->next = symbol_list_sym_new (NULL, dummy_location); midrule->next = symbol_list_sym_new (NULL, dummy_loc);
midrule->next->next = current_rule; midrule->next->next = current_rule;
previous_rule_end = midrule->next; previous_rule_end = midrule->next;
/* Insert the dummy nonterminal replacing the midrule action into /* Insert the dummy nonterminal replacing the midrule action into
the current rule. Bind it to its dedicated rule. */ the current rule. Bind it to its dedicated rule. */
grammar_current_rule_symbol_append (dummy, dummy_location, grammar_current_rule_symbol_append (dummy, dummy_loc,
action_name); action_name);
grammar_end->midrule = midrule; grammar_end->midrule = midrule;
midrule->midrule_parent_rule = current_rule; midrule->midrule_parent_rule = current_rule;
@@ -509,11 +509,11 @@ grammar_current_rule_dprec_set (int dprec, location loc)
"%dprec"); "%dprec");
else if (current_rule->dprec != 0) else if (current_rule->dprec != 0)
duplicate_rule_directive ("%dprec", duplicate_rule_directive ("%dprec",
current_rule->dprec_location, loc); current_rule->dprec_loc, loc);
else else
{ {
current_rule->dprec = dprec; current_rule->dprec = dprec;
current_rule->dprec_location = loc; current_rule->dprec_loc = loc;
} }
} }
@@ -528,11 +528,11 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
"%merge"); "%merge");
if (current_rule->merger != 0) if (current_rule->merger != 0)
duplicate_rule_directive ("%merge", duplicate_rule_directive ("%merge",
current_rule->merger_declaration_location, loc); current_rule->merger_declaration_loc, loc);
else else
{ {
current_rule->merger = get_merge_function (name); current_rule->merger = get_merge_function (name);
current_rule->merger_declaration_location = loc; current_rule->merger_declaration_loc = loc;
} }
} }
@@ -622,7 +622,7 @@ packgram (void)
{ {
symbol_list *lhs = p; symbol_list *lhs = p;
record_merge_function_type (lhs->merger, lhs->content.sym->content->type_name, record_merge_function_type (lhs->merger, lhs->content.sym->content->type_name,
lhs->merger_declaration_location); lhs->merger_declaration_loc);
/* If the midrule's $$ is set or its $n is used, remove the '$' from the /* If the midrule's $$ is set or its $n is used, remove the '$' from the
symbol name so that it's a user-defined symbol so that the default symbol name so that it's a user-defined symbol so that the default
%destructor and %printer apply. */ %destructor and %printer apply. */
@@ -650,7 +650,7 @@ packgram (void)
rules[ruleno].location = lhs->rhs_loc; rules[ruleno].location = lhs->rhs_loc;
rules[ruleno].useful = true; rules[ruleno].useful = true;
rules[ruleno].action = lhs->action_props.code; rules[ruleno].action = lhs->action_props.code;
rules[ruleno].action_location = lhs->action_props.location; rules[ruleno].action_loc = lhs->action_props.location;
rules[ruleno].is_predicate = lhs->action_props.is_predicate; rules[ruleno].is_predicate = lhs->action_props.is_predicate;
rules[ruleno].expected_sr_conflicts = lhs->expected_sr_conflicts; rules[ruleno].expected_sr_conflicts = lhs->expected_sr_conflicts;
rules[ruleno].expected_rr_conflicts = lhs->expected_rr_conflicts; rules[ruleno].expected_rr_conflicts = lhs->expected_rr_conflicts;
@@ -713,18 +713,18 @@ reader (void)
symbols_new (); symbols_new ();
/* Construct the accept symbol. */ /* Construct the accept symbol. */
accept = symbol_get ("$accept", empty_location); accept = symbol_get ("$accept", empty_loc);
accept->content->class = nterm_sym; accept->content->class = nterm_sym;
accept->content->number = nvars++; accept->content->number = nvars++;
/* Construct the error token */ /* Construct the error token */
errtoken = symbol_get ("error", empty_location); errtoken = symbol_get ("error", empty_loc);
errtoken->content->class = token_sym; errtoken->content->class = token_sym;
errtoken->content->number = ntokens++; errtoken->content->number = ntokens++;
/* Construct a token that represents all undefined literal tokens. /* Construct a token that represents all undefined literal tokens.
It is always token number 2. */ It is always token number 2. */
undeftoken = symbol_get ("$undefined", empty_location); undeftoken = symbol_get ("$undefined", empty_loc);
undeftoken->content->class = token_sym; undeftoken->content->class = token_sym;
undeftoken->content->number = ntokens++; undeftoken->content->number = ntokens++;
@@ -801,7 +801,7 @@ check_and_convert_grammar (void)
/* If the user did not define her ENDTOKEN, do it now. */ /* If the user did not define her ENDTOKEN, do it now. */
if (!endtoken) if (!endtoken)
{ {
endtoken = symbol_get ("$end", empty_location); endtoken = symbol_get ("$end", empty_loc);
endtoken->content->class = token_sym; endtoken->content->class = token_sym;
endtoken->content->number = 0; endtoken->content->number = 0;
/* Value specified by POSIX. */ /* Value specified by POSIX. */
@@ -823,11 +823,11 @@ check_and_convert_grammar (void)
$accept: %start $end. */ $accept: %start $end. */
{ {
symbol_list *p = symbol_list_sym_new (accept, empty_location); symbol_list *p = symbol_list_sym_new (accept, empty_loc);
p->rhs_loc = grammar->rhs_loc; p->rhs_loc = grammar->rhs_loc;
p->next = symbol_list_sym_new (startsymbol, empty_location); p->next = symbol_list_sym_new (startsymbol, empty_loc);
p->next->next = symbol_list_sym_new (endtoken, empty_location); p->next->next = symbol_list_sym_new (endtoken, empty_loc);
p->next->next->next = symbol_list_sym_new (NULL, empty_location); p->next->next->next = symbol_list_sym_new (NULL, empty_loc);
p->next->next->next->next = grammar; p->next->next->next->next = grammar;
nrules += 1; nrules += 1;
nritems += 3; nritems += 3;

View File

@@ -32,7 +32,7 @@ typedef struct merger_list
struct merger_list* next; struct merger_list* next;
uniqstr name; uniqstr name;
uniqstr type; uniqstr type;
location type_declaration_location; location type_declaration_loc;
} merger_list; } merger_list;
/* From the parser. */ /* From the parser. */

View File

@@ -382,7 +382,7 @@ reduce_grammar (void)
reduce_print (); reduce_print ();
if (!bitset_test (N, accept->content->number - ntokens)) if (!bitset_test (N, accept->content->number - ntokens))
complain (&startsymbol_location, fatal, complain (&startsymbol_loc, fatal,
_("start symbol %s does not derive any sentence"), _("start symbol %s does not derive any sentence"),
startsymbol->tag); startsymbol->tag);

View File

@@ -57,8 +57,8 @@ static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
/* A string to be pushed to obstack after dollar/at has been handled. */ /* A string to be pushed to obstack after dollar/at has been handled. */
static char *ref_tail_fields; static char *ref_tail_fields;
static location the_location; static location current_loc;
static location *loc = &the_location; static location *loc = &current_loc;
/* A string representing the most recent translation. */ /* A string representing the most recent translation. */
static char *last_string; static char *last_string;
@@ -187,7 +187,7 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
} }
"@$" { "@$" {
obstack_sgrow (&obstack_for_string, "]b4_at_dollar["); obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
muscle_percent_define_ensure("locations", the_location, true); muscle_percent_define_ensure("locations", *loc, true);
} }
} }

View File

@@ -161,7 +161,7 @@ eqopt ({sp}=)?
int context_state PACIFY_CC (= 0); int context_state PACIFY_CC (= 0);
/* Location of most recent identifier, when applicable. */ /* Location of most recent identifier, when applicable. */
location id_loc PACIFY_CC (= empty_location); location id_loc PACIFY_CC (= empty_loc);
/* Where containing code started, when applicable. Its initial /* Where containing code started, when applicable. Its initial
value is relevant only when yylex is invoked in the SC_EPILOGUE value is relevant only when yylex is invoked in the SC_EPILOGUE

View File

@@ -42,14 +42,14 @@ symbol_list_sym_new (symbol *sym, location loc)
res->midrule_parent_rhs_index = 0; res->midrule_parent_rhs_index = 0;
/* Members used for LHS only. */ /* Members used for LHS only. */
res->rhs_loc = empty_location; res->rhs_loc = empty_loc;
res->ruleprec = NULL; res->ruleprec = NULL;
res->percent_empty_loc = empty_location; res->percent_empty_loc = empty_loc;
code_props_none_init (&res->action_props); code_props_none_init (&res->action_props);
res->dprec = 0; res->dprec = 0;
res->dprec_location = empty_location; res->dprec_loc = empty_loc;
res->merger = 0; res->merger = 0;
res->merger_declaration_location = empty_location; res->merger_declaration_loc = empty_loc;
res->expected_sr_conflicts = -1; res->expected_sr_conflicts = -1;
res->expected_rr_conflicts = -1; res->expected_rr_conflicts = -1;

View File

@@ -84,13 +84,13 @@ typedef struct symbol_list
code_props action_props; code_props action_props;
/* The location of the first %empty for this rule, or \a /* The location of the first %empty for this rule, or \a
empty_location. */ empty_loc. */
location percent_empty_loc; location percent_empty_loc;
int dprec; int dprec;
location dprec_location; location dprec_loc;
int merger; int merger;
location merger_declaration_location; location merger_declaration_loc;
/* Counts of the number of expected conflicts for this rule, or -1 if none /* Counts of the number of expected conflicts for this rule, or -1 if none
given. */ given. */

View File

@@ -46,7 +46,7 @@ symbol *undeftoken = NULL;
symbol *endtoken = NULL; symbol *endtoken = NULL;
symbol *accept = NULL; symbol *accept = NULL;
symbol *startsymbol = NULL; symbol *startsymbol = NULL;
location startsymbol_location; location startsymbol_loc;
/* Precedence relation graph. */ /* Precedence relation graph. */
static symgraph **prec_nodes; static symgraph **prec_nodes;
@@ -198,7 +198,7 @@ semantic_type_new (uniqstr tag, const location *loc)
uniqstr_assert (tag); uniqstr_assert (tag);
res->tag = tag; res->tag = tag;
res->location = loc ? *loc : empty_location; res->location = loc ? *loc : empty_loc;
res->status = undeclared; res->status = undeclared;
for (int i = 0; i < CODE_PROPS_SIZE; ++i) for (int i = 0; i < CODE_PROPS_SIZE; ++i)
code_props_none_init (&res->props[i]); code_props_none_init (&res->props[i]);
@@ -339,12 +339,12 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
tag_seen = true; tag_seen = true;
if (sym->content->type_name) if (sym->content->type_name)
complain_symbol_redeclared (sym, "%type", complain_symbol_redeclared (sym, "%type",
sym->content->type_location, loc); sym->content->type_loc, loc);
else else
{ {
uniqstr_assert (type_name); uniqstr_assert (type_name);
sym->content->type_name = type_name; sym->content->type_name = type_name;
sym->content->type_location = loc; sym->content->type_loc = loc;
} }
} }
} }
@@ -426,12 +426,12 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
sym_content *s = sym->content; sym_content *s = sym->content;
if (s->prec) if (s->prec)
complain_symbol_redeclared (sym, assoc_to_string (a), complain_symbol_redeclared (sym, assoc_to_string (a),
s->prec_location, loc); s->prec_loc, loc);
else else
{ {
s->prec = prec; s->prec = prec;
s->assoc = a; s->assoc = a;
s->prec_location = loc; s->prec_loc = loc;
} }
} }
@@ -587,10 +587,10 @@ symbol_merge_properties (symbol *sym, symbol *str)
{ {
if (str->content->type_name) if (str->content->type_name)
symbol_type_set (sym, symbol_type_set (sym,
str->content->type_name, str->content->type_location); str->content->type_name, str->content->type_loc);
else else
symbol_type_set (str, symbol_type_set (str,
sym->content->type_name, sym->content->type_location); sym->content->type_name, sym->content->type_loc);
} }
@@ -604,10 +604,10 @@ symbol_merge_properties (symbol *sym, symbol *str)
{ {
if (str->content->prec) if (str->content->prec)
symbol_precedence_set (sym, str->content->prec, str->content->assoc, symbol_precedence_set (sym, str->content->prec, str->content->assoc,
str->content->prec_location); str->content->prec_loc);
else else
symbol_precedence_set (str, sym->content->prec, sym->content->assoc, symbol_precedence_set (str, sym->content->prec, sym->content->assoc,
sym->content->prec_location); sym->content->prec_loc);
} }
} }
@@ -1034,11 +1034,11 @@ symbols_pack (void)
symbols_token_translations_init (); symbols_token_translations_init ();
if (startsymbol->content->class == unknown_sym) if (startsymbol->content->class == unknown_sym)
complain (&startsymbol_location, fatal, complain (&startsymbol_loc, fatal,
_("the start symbol %s is undefined"), _("the start symbol %s is undefined"),
startsymbol->tag); startsymbol->tag);
else if (startsymbol->content->class == token_sym) else if (startsymbol->content->class == token_sym)
complain (&startsymbol_location, fatal, complain (&startsymbol_loc, fatal,
_("the start symbol %s is a token"), _("the start symbol %s is a token"),
startsymbol->tag); startsymbol->tag);
} }
@@ -1209,14 +1209,14 @@ print_precedence_warnings (void)
&& !prec_nodes[i]->succ) && !prec_nodes[i]->succ)
{ {
if (is_assoc_useless (s)) if (is_assoc_useless (s))
complain (&s->content->prec_location, Wprecedence, complain (&s->content->prec_loc, Wprecedence,
_("useless precedence and associativity for %s"), s->tag); _("useless precedence and associativity for %s"), s->tag);
else if (s->content->assoc == precedence_assoc) else if (s->content->assoc == precedence_assoc)
complain (&s->content->prec_location, Wprecedence, complain (&s->content->prec_loc, Wprecedence,
_("useless precedence for %s"), s->tag); _("useless precedence for %s"), s->tag);
} }
else if (is_assoc_useless (s)) else if (is_assoc_useless (s))
complain (&s->content->prec_location, Wprecedence, complain (&s->content->prec_loc, Wprecedence,
_("useless associativity for %s, use %%precedence"), s->tag); _("useless associativity for %s, use %%precedence"), s->tag);
} }
free (used_assoc); free (used_assoc);

View File

@@ -122,7 +122,7 @@ struct sym_content
uniqstr type_name; uniqstr type_name;
/** Its \c \%type's location. */ /** Its \c \%type's location. */
location type_location; location type_loc;
/** Any \c \%destructor (resp. \%printer) declared specificially for this /** Any \c \%destructor (resp. \%printer) declared specificially for this
symbol. symbol.
@@ -134,7 +134,7 @@ struct sym_content
code_props props[CODE_PROPS_SIZE]; code_props props[CODE_PROPS_SIZE];
symbol_number number; symbol_number number;
location prec_location; location prec_loc;
int prec; int prec;
assoc assoc; assoc assoc;
@@ -246,7 +246,7 @@ extern symbol *accept;
/** The user start symbol. */ /** The user start symbol. */
extern symbol *startsymbol; extern symbol *startsymbol;
/** The location of the \c \%start declaration. */ /** The location of the \c \%start declaration. */
extern location startsymbol_location; extern location startsymbol_loc;
/** Whether a symbol declared with a type tag. */ /** Whether a symbol declared with a type tag. */
extern bool tag_seen; extern bool tag_seen;