clearly deprecate %name-prefix

* src/scan-gram.l (%name-prefix): Issue a deprecation warning.

* tests/calc.at, tests/headers.at, tests/input.at, tests/java.at,
* tests/javapush.at, tests/local.at: Adjust expectations.
Or disable -Wdeprecated.

* doc/bison.texi: Document that %name-prefix is replaced by %define
api.prefix.
This commit is contained in:
Akim Demaille
2019-01-02 19:09:56 +01:00
parent 9ec93d4e34
commit b90675e67a
9 changed files with 63 additions and 49 deletions

View File

@@ -445,18 +445,22 @@ sed '/^Starting/d
/ \$[[0-9$]]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
# 2. Create the reference error message.
AT_DATA([[expout]],
[$5
])
# 3. If locations are not used, remove them.
AT_YYERROR_SEES_LOC_IF([],
[[sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout]])
# 4. If error-verbose is not used, strip the', unexpected....' part.
m4_bmatch([$1], [%define parse.error verbose], [],
[[sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout]])
# 5. Check
AT_CHECK([cat stderr], 0, [expout])
])
@@ -494,7 +498,7 @@ AT_SETUP([Calculator $1 $2])
AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]), [], [$2])
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
AT_CHECK_SPACES([calc.AT_LANG_EXT AT_DEFINES_IF([calc.AT_LANG_HDR])])
# Test the priorities.

View File

@@ -84,7 +84,9 @@ AT_DATA_GRAMMAR([input.y],
exp: %empty;
]])
AT_BISON_CHECK([--defines -o input.c input.y])
AT_BISON_CHECK([--defines -o input.c input.y], [], [],
[[input.y:11.1-12: warning: deprecated directive: '%name-prefix', use '%define api.prefix' [-Wdeprecated]
]])
# YYLTYPE should be defined, and MY_LLOC declared.
AT_DATA([caller.c],

View File

@@ -2310,7 +2310,7 @@ m4_pushdef([AT_TEST],
%%
exp: %empty;
]])
AT_BISON_CHECK([[$2 input.y]], [[1]], [[]],
AT_BISON_CHECK([[$2 -Wno-deprecated input.y]], [[1]], [[]],
[[$3: error: '%name-prefix' and '%define api.prefix' cannot be used together
]])
])
@@ -2501,7 +2501,9 @@ AT_DATA_GRAMMAR([[input.y]],
%token_table
%error-verbose
%glr-parser
%% exp : '0'
%name-prefix "bar"
%%
exp : '0'
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
@@ -2512,7 +2514,7 @@ input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-pre
input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated]
input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated]
input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated]
input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated]
input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%define api.prefix' [-Wdeprecated]
input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated]
input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated]
input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated]
@@ -2522,6 +2524,7 @@ input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-tabl
input.y:27.1-14: warning: deprecated directive: '%error-verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:27-6: error: %define variable 'parse.error' redefined
input.y:11-6: previous definition
input.y:29.1-12: warning: deprecated directive: '%name-prefix', use '%define api.prefix' [-Wdeprecated]
]])
AT_CLEANUP
@@ -2581,7 +2584,6 @@ AT_DATA_GRAMMAR([[input.y]],
%file-prefix
"bar"
%fixed-output-files
%name-prefix "foo"
%no-default-prec
%no-lines
%output "foo"

View File

@@ -263,7 +263,7 @@ AT_DATA_JAVA_CALC_Y([$1
$2
}])
AT_BISON_CHECK([-o Calc.java Calc.y])
AT_BISON_CHECK([-Wno-deprecated -o Calc.java Calc.y])
AT_JAVA_COMPILE([Calc.java])
# Test the priorities.
@@ -401,7 +401,7 @@ start: END {$2};
%%
class m4_default([$3], [Position]) {}
])
AT_BISON_CHECK([[YYParser.y]])
AT_BISON_CHECK([[-Wno-deprecated YYParser.y]])
AT_CHECK([[grep '[mb]4_' YYParser.y]], [1], [ignore])
AT_JAVA_COMPILE([[YYParser.java]])
])

View File

@@ -345,7 +345,7 @@ AT_DATA([input],[[1 + 2 * 3 = 7
# Compose pieces to build the actual .y file.
AT_DATA([Calc.y],[[/* Infix notation calculator--calc */
%language "Java"
%name-prefix "Calc"
%define api.parser.class {Calc}
%code {
@@ -619,7 +619,7 @@ AT_BISON_OPTION_PUSHDEFS
AT_DATA([Calc.y],[[/* Infix notation calculator--calc. */
%language "Java"
%name-prefix "Calc"
%define api.parser.class {Calc}
%lex-param { Reader rdr }
%locations

View File

@@ -874,15 +874,16 @@ m4_define([AT_LANG_HDR(c)], [h])
m4_define([AT_LANG_HDR(c++)], [hh])
# AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2], [EXTRA-COMPILER-FLAGS)
# ------------------------------------------------------------------
# AT_FULL_COMPILE(OUTPUT, [OTHER1], [OTHER2],
# [$4: EXTRA-COMPILER-FLAGS, [$5: EXTRA-BISON-FLAGS])
# -------------------------------------------------------------------
# Compile OUTPUT.y to OUTPUT.c, OUTPUT.cc, or OUTPUT.java, and then
# compile it to OUTPUT or OUTPUT.class. If OTHER is specified, compile
# OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or
# OUTPUT.java along with it. Relies on AT_CXX_IF and
# AT_JAVA_IF.
m4_define([AT_FULL_COMPILE],
[AT_BISON_CHECK([-o $1.AT_LANG_EXT $1.y])
[AT_BISON_CHECK([$5 -o $1.AT_LANG_EXT $1.y])
AT_LANG_COMPILE([$1],
m4_join([ ],
[$1.AT_LANG_EXT],