api.value.type: diagnose guaranteed failure with --yacc

Instead of generating invalid C code, generate an error when --yacc and
'%define api.value.type union' are used together.

* data/bison.m4: Issue an error in this case.
* tests/types.at (%yacc vs. %define api.value.type union): New, check this
error.
* doc/bison.texi (Type Generation): Document it.
* tests/output.at: Check that '-o y.tab.c' and '-y' behave equally
wrt generated file names.
* NEWS (Use of YACC='bison -y'): New.
Promote the use of 'bison -o y.tab.c'.
This commit is contained in:
Akim Demaille
2013-03-27 09:18:32 +01:00
parent d1a07886ee
commit 1fa19a7697
5 changed files with 70 additions and 4 deletions

View File

@@ -62,8 +62,13 @@ AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
[y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y],
[y.dot y.output y.tab.c y.tab.h y.xml])
# With '-o y.tab.c', we expect 'y.output' etc. (for compatility with Yacc).
AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -o y.tab.c],
[y.dot y.output y.tab.c y.tab.h y.xml])
AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
[bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],

View File

@@ -37,6 +37,26 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]],
AT_CLEANUP
## ---------------------------------------- ##
## %yacc vs. %define api.value.type union. ##
## ---------------------------------------- ##
AT_SETUP([[%yacc vs. %define api.value.type union]])
AT_DATA([[input.y]],
[[%yacc
%define api.value.type "union"
%%
exp: %empty;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:2.9-22: error: '%yacc' and '%define api.value.type "union"' cannot be used together
]])
AT_CLEANUP
## ---------------- ##
## api.value.type. ##
## ---------------- ##