diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-05-03 08:52:26 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-05-03 16:28:28 +0200 |
commit | 013720f0e7bd9558eacf7e3a9852ab922030c947 (patch) | |
tree | 2a8e564f12acd23eea1791ac03367e700464a726 /src | |
parent | 365b4d95a49dabdc08d271a31ca3eb9c6591ba91 (diff) | |
download | bison-013720f0e7bd9558eacf7e3a9852ab922030c947.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/gram.h | 2 | ||||
-rw-r--r-- | src/location.c | 2 | ||||
-rw-r--r-- | src/location.h | 2 | ||||
-rw-r--r-- | src/output.c | 4 | ||||
-rw-r--r-- | src/parse-gram.c | 6 | ||||
-rw-r--r-- | src/parse-gram.y | 6 | ||||
-rw-r--r-- | src/reader.c | 46 | ||||
-rw-r--r-- | src/reader.h | 2 | ||||
-rw-r--r-- | src/reduce.c | 2 | ||||
-rw-r--r-- | src/scan-code.l | 6 | ||||
-rw-r--r-- | src/scan-gram.l | 2 | ||||
-rw-r--r-- | src/symlist.c | 8 | ||||
-rw-r--r-- | src/symlist.h | 6 | ||||
-rw-r--r-- | src/symtab.c | 30 | ||||
-rw-r--r-- | src/symtab.h | 6 |
15 files changed, 65 insertions, 65 deletions
@@ -203,7 +203,7 @@ typedef struct int expected_rr_conflicts; const char *action; - location action_location; + location action_loc; } rule; /* The used rules (size NRULES). */ diff --git a/src/location.c b/src/location.c index 2e8b62b8..80e71fb8 100644 --- a/src/location.c +++ b/src/location.c @@ -30,7 +30,7 @@ #include "getargs.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 INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to diff --git a/src/location.h b/src/location.h index 2539f27f..995e13a4 100644 --- a/src/location.h +++ b/src/location.h @@ -102,7 +102,7 @@ typedef struct # define GRAM_LTYPE location # 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 size SIZE. */ diff --git a/src/output.c b/src/output.c index 05e712f1..1f519d0c 100644 --- a/src/output.c +++ b/src/output.c @@ -372,8 +372,8 @@ user_actions_output (FILE *out) { fprintf (out, "%s(%d, [b4_syncline(%d, ", rules[r].is_predicate ? "b4_predicate_case" : "b4_case", - r + 1, rules[r].action_location.start.line); - string_output (out, rules[r].action_location.start.file); + r + 1, rules[r].action_loc.start.line); + string_output (out, rules[r].action_loc.start.file); fprintf (out, ")dnl\n[ %s]])\n\n", rules[r].action); } fputs ("])\n\n", out); diff --git a/src/parse-gram.c b/src/parse-gram.c index df993638..86e33518 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -122,7 +122,7 @@ #include "xmemdup0.h" static int current_prec = 0; - static location current_lhs_location; + static location current_lhs_loc; static named_ref *current_lhs_named_ref; static symbol *current_lhs_symbol; static symbol_class current_class = unknown_sym; @@ -2406,7 +2406,7 @@ yyreduce: break; 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); } break; @@ -3037,7 +3037,7 @@ void current_lhs (symbol *sym, location loc, named_ref *ref) { current_lhs_symbol = sym; - current_lhs_location = loc; + current_lhs_loc = loc; if (sym) symbol_location_as_lhs_set (sym, loc); /* In order to simplify memory management, named references for lhs diff --git a/src/parse-gram.y b/src/parse-gram.y index 263db619..175cfd62 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -49,7 +49,7 @@ #include "xmemdup0.h" static int current_prec = 0; - static location current_lhs_location; + static location current_lhs_loc; static named_ref *current_lhs_named_ref; static symbol *current_lhs_symbol; static symbol_class current_class = unknown_sym; @@ -651,7 +651,7 @@ rhses.1: %token PERCENT_EMPTY "%empty"; rhs: %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); } | rhs symbol named_ref.opt { 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; - current_lhs_location = loc; + current_lhs_loc = loc; if (sym) symbol_location_as_lhs_set (sym, loc); /* In order to simplify memory management, named references for lhs diff --git a/src/reader.c b/src/reader.c index fecb999e..b5eda9ef 100644 --- a/src/reader.c +++ b/src/reader.c @@ -62,7 +62,7 @@ grammar_start_symbol_set (symbol *sym, location loc) { start_flag = true; 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, merge_function->type); indent += SUB_INDENT; - complain_indent (&merge_function->type_declaration_location, complaint, + complain_indent (&merge_function->type_declaration_loc, complaint, &indent, _("previous declaration")); } 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 action. Create the MIDRULE. */ - location dummy_location = current_rule->action_props.location; - symbol *dummy = dummy_symbol_get (dummy_location); + location dummy_loc = current_rule->action_props.location; + symbol *dummy = dummy_symbol_get (dummy_loc); symbol_type_set(dummy, 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. */ named_ref *action_name = current_rule->action_props.named_ref; @@ -422,7 +422,7 @@ grammar_midrule_action (void) ++nrules; ++nritems; /* 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, current_rule->action_props.code, current_rule->action_props.location, @@ -443,14 +443,14 @@ grammar_midrule_action (void) grammar = midrule; /* 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; previous_rule_end = midrule->next; /* Insert the dummy nonterminal replacing the midrule action into 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); grammar_end->midrule = midrule; midrule->midrule_parent_rule = current_rule; @@ -509,11 +509,11 @@ grammar_current_rule_dprec_set (int dprec, location loc) "%dprec"); else if (current_rule->dprec != 0) duplicate_rule_directive ("%dprec", - current_rule->dprec_location, loc); + current_rule->dprec_loc, loc); else { 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"); if (current_rule->merger != 0) duplicate_rule_directive ("%merge", - current_rule->merger_declaration_location, loc); + current_rule->merger_declaration_loc, loc); else { 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; 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 symbol name so that it's a user-defined symbol so that the default %destructor and %printer apply. */ @@ -650,7 +650,7 @@ packgram (void) rules[ruleno].location = lhs->rhs_loc; rules[ruleno].useful = true; 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].expected_sr_conflicts = lhs->expected_sr_conflicts; rules[ruleno].expected_rr_conflicts = lhs->expected_rr_conflicts; @@ -713,18 +713,18 @@ reader (void) symbols_new (); /* Construct the accept symbol. */ - accept = symbol_get ("$accept", empty_location); + accept = symbol_get ("$accept", empty_loc); accept->content->class = nterm_sym; accept->content->number = nvars++; /* Construct the error token */ - errtoken = symbol_get ("error", empty_location); + errtoken = symbol_get ("error", empty_loc); errtoken->content->class = token_sym; errtoken->content->number = ntokens++; /* Construct a token that represents all undefined literal tokens. 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->number = ntokens++; @@ -801,7 +801,7 @@ check_and_convert_grammar (void) /* If the user did not define her ENDTOKEN, do it now. */ if (!endtoken) { - endtoken = symbol_get ("$end", empty_location); + endtoken = symbol_get ("$end", empty_loc); endtoken->content->class = token_sym; endtoken->content->number = 0; /* Value specified by POSIX. */ @@ -823,11 +823,11 @@ check_and_convert_grammar (void) $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->next = symbol_list_sym_new (startsymbol, empty_location); - p->next->next = symbol_list_sym_new (endtoken, empty_location); - p->next->next->next = symbol_list_sym_new (NULL, empty_location); + p->next = symbol_list_sym_new (startsymbol, empty_loc); + p->next->next = symbol_list_sym_new (endtoken, empty_loc); + p->next->next->next = symbol_list_sym_new (NULL, empty_loc); p->next->next->next->next = grammar; nrules += 1; nritems += 3; diff --git a/src/reader.h b/src/reader.h index 9f59dc00..0171af29 100644 --- a/src/reader.h +++ b/src/reader.h @@ -32,7 +32,7 @@ typedef struct merger_list struct merger_list* next; uniqstr name; uniqstr type; - location type_declaration_location; + location type_declaration_loc; } merger_list; /* From the parser. */ diff --git a/src/reduce.c b/src/reduce.c index 5ec63fde..55f6a767 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -382,7 +382,7 @@ reduce_grammar (void) reduce_print (); if (!bitset_test (N, accept->content->number - ntokens)) - complain (&startsymbol_location, fatal, + complain (&startsymbol_loc, fatal, _("start symbol %s does not derive any sentence"), startsymbol->tag); diff --git a/src/scan-code.l b/src/scan-code.l index 0974905a..73a3b2d7 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -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. */ static char *ref_tail_fields; -static location the_location; -static location *loc = &the_location; +static location current_loc; +static location *loc = ¤t_loc; /* A string representing the most recent translation. */ static char *last_string; @@ -187,7 +187,7 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" } "@$" { obstack_sgrow (&obstack_for_string, "]b4_at_dollar["); - muscle_percent_define_ensure("locations", the_location, true); + muscle_percent_define_ensure("locations", *loc, true); } } diff --git a/src/scan-gram.l b/src/scan-gram.l index f03acfd6..ca4173b8 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -161,7 +161,7 @@ eqopt ({sp}=)? int context_state PACIFY_CC (= 0); /* 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 value is relevant only when yylex is invoked in the SC_EPILOGUE diff --git a/src/symlist.c b/src/symlist.c index d594ddbe..12751c8f 100644 --- a/src/symlist.c +++ b/src/symlist.c @@ -42,14 +42,14 @@ symbol_list_sym_new (symbol *sym, location loc) res->midrule_parent_rhs_index = 0; /* Members used for LHS only. */ - res->rhs_loc = empty_location; + res->rhs_loc = empty_loc; res->ruleprec = NULL; - res->percent_empty_loc = empty_location; + res->percent_empty_loc = empty_loc; code_props_none_init (&res->action_props); res->dprec = 0; - res->dprec_location = empty_location; + res->dprec_loc = empty_loc; res->merger = 0; - res->merger_declaration_location = empty_location; + res->merger_declaration_loc = empty_loc; res->expected_sr_conflicts = -1; res->expected_rr_conflicts = -1; diff --git a/src/symlist.h b/src/symlist.h index 880e8544..a7225e18 100644 --- a/src/symlist.h +++ b/src/symlist.h @@ -84,13 +84,13 @@ typedef struct symbol_list code_props action_props; /* The location of the first %empty for this rule, or \a - empty_location. */ + empty_loc. */ location percent_empty_loc; int dprec; - location dprec_location; + location dprec_loc; int merger; - location merger_declaration_location; + location merger_declaration_loc; /* Counts of the number of expected conflicts for this rule, or -1 if none given. */ diff --git a/src/symtab.c b/src/symtab.c index dd2a3d53..83e8256b 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -46,7 +46,7 @@ symbol *undeftoken = NULL; symbol *endtoken = NULL; symbol *accept = NULL; symbol *startsymbol = NULL; -location startsymbol_location; +location startsymbol_loc; /* Precedence relation graph. */ static symgraph **prec_nodes; @@ -198,7 +198,7 @@ semantic_type_new (uniqstr tag, const location *loc) uniqstr_assert (tag); res->tag = tag; - res->location = loc ? *loc : empty_location; + res->location = loc ? *loc : empty_loc; res->status = undeclared; for (int i = 0; i < CODE_PROPS_SIZE; ++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; if (sym->content->type_name) complain_symbol_redeclared (sym, "%type", - sym->content->type_location, loc); + sym->content->type_loc, loc); else { uniqstr_assert (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; if (s->prec) complain_symbol_redeclared (sym, assoc_to_string (a), - s->prec_location, loc); + s->prec_loc, loc); else { s->prec = prec; 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) symbol_type_set (sym, - str->content->type_name, str->content->type_location); + str->content->type_name, str->content->type_loc); else 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) symbol_precedence_set (sym, str->content->prec, str->content->assoc, - str->content->prec_location); + str->content->prec_loc); else 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 (); if (startsymbol->content->class == unknown_sym) - complain (&startsymbol_location, fatal, + complain (&startsymbol_loc, fatal, _("the start symbol %s is undefined"), startsymbol->tag); else if (startsymbol->content->class == token_sym) - complain (&startsymbol_location, fatal, + complain (&startsymbol_loc, fatal, _("the start symbol %s is a token"), startsymbol->tag); } @@ -1209,14 +1209,14 @@ print_precedence_warnings (void) && !prec_nodes[i]->succ) { 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); 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); } 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); } free (used_assoc); diff --git a/src/symtab.h b/src/symtab.h index 8f4f5a1a..0cfb13b8 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -122,7 +122,7 @@ struct sym_content uniqstr type_name; /** Its \c \%type's location. */ - location type_location; + location type_loc; /** Any \c \%destructor (resp. \%printer) declared specificially for this symbol. @@ -134,7 +134,7 @@ struct sym_content code_props props[CODE_PROPS_SIZE]; symbol_number number; - location prec_location; + location prec_loc; int prec; assoc assoc; @@ -246,7 +246,7 @@ extern symbol *accept; /** The user start symbol. */ extern symbol *startsymbol; /** The location of the \c \%start declaration. */ -extern location startsymbol_location; +extern location startsymbol_loc; /** Whether a symbol declared with a type tag. */ extern bool tag_seen; |