diff options
author | Akim Demaille <akim@lrde.epita.fr> | 2015-01-14 13:41:32 +0100 |
---|---|---|
committer | Akim Demaille <akim@lrde.epita.fr> | 2015-01-14 17:05:35 +0100 |
commit | 875ef1b90c4cbdc637b6944d4d6eb5b2b7bb7eef (patch) | |
tree | 0db0ee9890d3ebc879bc0469d8954d3be73b8e87 /tests/reduce.at | |
parent | 650af77812fc55ffc7c45e271b45a9b13a62dfd3 (diff) | |
download | bison-875ef1b90c4cbdc637b6944d4d6eb5b2b7bb7eef.tar.gz |
symbol: use the first occurrence as an LHS as defining location
Currently on the following grammar:
%type <foo> foo
%%
start: foo | bar | "baz"
foo: foo
bar: bar
bison reports:
warning: 2 nonterminals useless in grammar [-Wother]
warning: 4 rules useless in grammar [-Wother]
1.13-15: warning: nonterminal useless in grammar: foo [-Wother]
%type <foo> foo
^^^
3.14-16: warning: nonterminal useless in grammar: bar [-Wother]
start: foo | bar | "baz"
^^^
[...]
i.e., the location of the first occurrence of a symbol is taken as its
definition point. In the case of nonterminals, the first occurrence
as a left-hand side of a rule makes more sense:
warning: 2 nonterminals useless in grammar [-Wother]
warning: 4 rules useless in grammar [-Wother]
4.1-3: warning: nonterminal useless in grammar: foo [-Wother]
foo: foo
^^^
5.1-3: warning: nonterminal useless in grammar: bar [-Wother]
bar: bar
^^^
[...]
* src/symtab.h, src/symtab.c (symbol::location_of_lhs): New.
(symbol_location_as_lhs_set): New.
* src/parse-gram.y (current_lhs): Use it.
* tests/reduce.at: Update locations.
Diffstat (limited to 'tests/reduce.at')
-rw-r--r-- | tests/reduce.at | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/reduce.at b/tests/reduce.at index c7edb10b..d197dc63 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -254,9 +254,9 @@ not-reduced.y: warning: 3 rules useless in grammar [-Wother] not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother] not_reachable: useful { /* A not reachable action. */ } ^^^^^^^^^^^^^ -not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother] - | non_productive { /* A non productive action. */ } - ^^^^^^^^^^^^^^ +not-reduced.y:17.1-14: warning: nonterminal useless in grammar: non_productive [-Wother] + non_productive: non_productive useless_token + ^^^^^^^^^^^^^^ not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother] | non_productive { /* A non productive action. */ } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -330,12 +330,12 @@ indirection: underivable; AT_BISON_CHECK([[-fcaret input.y]], 0, [], [[input.y: warning: 2 nonterminals useless in grammar [-Wother] input.y: warning: 3 rules useless in grammar [-Wother] -input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother] - exp: useful | underivable; - ^^^^^^^^^^^ -input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother] +input.y:6.1-11: warning: nonterminal useless in grammar: underivable [-Wother] underivable: indirection; - ^^^^^^^^^^^ + ^^^^^^^^^^^ +input.y:7.1-11: warning: nonterminal useless in grammar: indirection [-Wother] + indirection: underivable; + ^^^^^^^^^^^ input.y:5.15-25: warning: rule useless in grammar [-Wother] exp: useful | underivable; ^^^^^^^^^^^ |