mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
%nterm: do not accept numbers nor string alias
Reported by Rici Lake. http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html * src/parse-gram.y (symbol_def): Refuse string aliases and numbers for non-terminals. (prologue_declaration): Recover from errors ended with ';'. * tests/input.at (Invalid %nterm uses): New.
This commit is contained in:
@@ -130,6 +130,48 @@ AT_BISON_CHECK([input.y], [1], [],
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Invalid %nterm uses. ##
|
||||
## --------------------- ##
|
||||
|
||||
AT_SETUP([Invalid %nterm uses])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%nterm expr "expression";
|
||||
%nterm term 123;
|
||||
%nterm fact 124 "factor";
|
||||
%%
|
||||
expr: expr '+' term | term;
|
||||
term: term '*' fact | fact;
|
||||
fact: '0';
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [1], [],
|
||||
[[input.y:1.1-6: warning: deprecated directive, use '%type' [-Wdeprecated]
|
||||
%nterm expr "expression";
|
||||
^^^^^^
|
||||
input.y:1.13-24: error: non-terminals cannot be given a string alias
|
||||
%nterm expr "expression";
|
||||
^^^^^^^^^^^^
|
||||
input.y:2.1-6: warning: deprecated directive, use '%type' [-Wdeprecated]
|
||||
%nterm term 123;
|
||||
^^^^^^
|
||||
input.y:2.13-15: error: non-terminals cannot be given an explicit number
|
||||
%nterm term 123;
|
||||
^^^
|
||||
input.y:3.1-6: warning: deprecated directive, use '%type' [-Wdeprecated]
|
||||
%nterm fact 124 "factor";
|
||||
^^^^^^
|
||||
input.y:3.13-15: error: non-terminals cannot be given an explicit number
|
||||
%nterm fact 124 "factor";
|
||||
^^^
|
||||
input.y:3.17-24: error: non-terminals cannot be given a string alias
|
||||
%nterm fact 124 "factor";
|
||||
^^^^^^^^
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Invalid $n. ##
|
||||
|
||||
Reference in New Issue
Block a user