diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-02-02 16:21:45 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-02-02 16:37:25 +0100 |
commit | 31788ed4c7714b133bddf7ce719c28b0384c6679 (patch) | |
tree | 346634494172c76a63b98613df9c80cbd855b4e1 | |
parent | 69061fed8274a1394d62289eb3e3e2e19df115d0 (diff) | |
download | bison-31788ed4c7714b133bddf7ce719c28b0384c6679.tar.gz |
style: rename local variable
* src/reduce.c (nonterminals_reduce): Rename nontermmap as nterm_map.
We will expose it.
-rw-r--r-- | src/reduce.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/reduce.c b/src/reduce.c index 46eeebb5..e3a5e039 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -265,16 +265,16 @@ nonterminals_reduce (void) /* Map the nonterminals to their new index: useful first, useless afterwards. Kept for later report. */ - symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap); + symbol_number *nterm_map = xnmalloc (nvars, sizeof *nterm_map); { symbol_number n = ntokens; for (symbol_number i = ntokens; i < nsyms; ++i) if (bitset_test (V, i)) - nontermmap[i - ntokens] = n++; + nterm_map[i - ntokens] = n++; for (symbol_number i = ntokens; i < nsyms; ++i) if (!bitset_test (V, i)) { - nontermmap[i - ntokens] = n++; + nterm_map[i - ntokens] = n++; if (symbols[i]->content->status != used) complain (&symbols[i]->location, Wother, _("nonterminal useless in grammar: %s"), @@ -282,32 +282,32 @@ nonterminals_reduce (void) } } - /* Shuffle elements of tables indexed by symbol number. */ { symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted); for (symbol_number i = ntokens; i < nsyms; ++i) - symbols[i]->content->number = nontermmap[i - ntokens]; + symbols[i]->content->number = nterm_map[i - ntokens]; for (symbol_number i = ntokens; i < nsyms; ++i) - symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i]; + symbols_sorted[nterm_map[i - ntokens] - ntokens] = symbols[i]; for (symbol_number i = ntokens; i < nsyms; ++i) symbols[i] = symbols_sorted[i - ntokens]; free (symbols_sorted); } + /* Renumber non terminal numbers in the RHS of the rules. LHS are + pointers to the symbol structure, they don't need renumbering. */ { for (rule_number r = 0; r < nrules; ++r) for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) if (ISVAR (*rhsp)) - *rhsp = symbol_number_as_item_number (nontermmap[*rhsp - - ntokens]); - accept->content->number = nontermmap[accept->content->number - ntokens]; + *rhsp = symbol_number_as_item_number (nterm_map[*rhsp - ntokens]); + accept->content->number = nterm_map[accept->content->number - ntokens]; } nsyms -= nuseless_nonterminals; nvars -= nuseless_nonterminals; - free (nontermmap); + free (nterm_map); } |