deprecate %defines in favor of %header

This is consistent with --defines being deprecated in favor of
--header.  The directive %defines is also too similar to %define.
And %header matches nicely with api.header.name.

* src/scan-gram.l (%defines): Deprecate to %header.
(%header): Scan it.
* src/parse-gram.y (PERCENT_DEFINES): Replace with...
(PERCENT_HEADER): this.
* data/skeletons/lalr1.java
* doc/bison.texi
* tests/actions.at, tests/c++.at, tests/calc.at, tests/conflicts.at,
* tests/input.at, tests/java.at, tests/local.at, tests/output.at,
* tests/synclines.at, tests/types.at:
Convert most tests to check %header instead of %defines.
This commit is contained in:
Akim Demaille
2020-09-06 14:20:43 +02:00
parent 75c3746ce2
commit b327f38832
17 changed files with 185 additions and 136 deletions

7
NEWS
View File

@@ -6,10 +6,11 @@ GNU Bison NEWS
** New features ** New features
*** Option -H, --header *** Option -H, --header and directive %header
The option -H/--header replaces the option --defines (maintained for The option -H/--header supersedes the option --defines, and the directive
backward compatibility). %header supersedes %defines. Both --defines and %defines are, of course,
maintained for backward compatibility.
*** A C++ native GLR parser *** A C++ native GLR parser

View File

@@ -17,7 +17,7 @@
m4_include(b4_skeletonsdir/[java.m4]) m4_include(b4_skeletonsdir/[java.m4])
b4_header_if([b4_complain([%defines does not make sense in Java])]) b4_header_if([b4_complain([%header/%defines does not make sense in Java])])
m4_define([b4_symbol_no_destructor_assert], m4_define([b4_symbol_no_destructor_assert],
[b4_symbol_if([$1], [has_destructor], [b4_symbol_if([$1], [has_destructor],

View File

@@ -5794,6 +5794,22 @@ Define a variable to adjust Bison's behavior. @xref{%define Summary}.
@end deffn @end deffn
@deffn {Directive} %defines @deffn {Directive} %defines
@deffnx {Directive} %defines @var{defines-file}
Historical name for @code{%header}. @xref{%header,,@code{%header}}.
@end deffn
@deffn {Directive} %destructor
Specify how the parser should reclaim the memory associated to
discarded symbols. @xref{Destructor Decl}.
@end deffn
@deffn {Directive} %file-prefix "@var{prefix}"
Specify a prefix to use for all Bison output file names. The names
are chosen as if the grammar file were named @file{@var{prefix}.y}.
@end deffn
@anchor{%header}
@deffn {Directive} %header
Write a parser header file containing definitions for the token kind names Write a parser header file containing definitions for the token kind names
defined in the grammar as well as a few other declarations. If the parser defined in the grammar as well as a few other declarations. If the parser
implementation file is named @file{@var{name}.c} then the parser header file implementation file is named @file{@var{name}.c} then the parser header file
@@ -5835,7 +5851,7 @@ preprocessor guard: @samp{YY_@var{PREFIX}_@var{FILE}_INCLUDED}, where
generated file name turned uppercase, with each series of non alphanumerical generated file name turned uppercase, with each series of non alphanumerical
characters converted to a single underscore. characters converted to a single underscore.
For instance with @samp{%define api.prefix @{calc@}} and @samp{%defines For instance with @samp{%define api.prefix @{calc@}} and @samp{%header
"lib/parse.h"}, the header will be guarded as follows. "lib/parse.h"}, the header will be guarded as follows.
@example @example
#ifndef YY_CALC_LIB_PARSE_H_INCLUDED #ifndef YY_CALC_LIB_PARSE_H_INCLUDED
@@ -5843,20 +5859,12 @@ For instance with @samp{%define api.prefix @{calc@}} and @samp{%defines
... ...
#endif /* ! YY_CALC_LIB_PARSE_H_INCLUDED */ #endif /* ! YY_CALC_LIB_PARSE_H_INCLUDED */
@end example @end example
Introduced in Bison 3.8.
@end deffn @end deffn
@deffn {Directive} %defines @var{defines-file} @deffn {Directive} %header @var{header-file}
Same as above, but save in the file @file{@var{defines-file}}. Same as above, but save in the file @file{@var{header-file}}.
@end deffn
@deffn {Directive} %destructor
Specify how the parser should reclaim the memory associated to
discarded symbols. @xref{Destructor Decl}.
@end deffn
@deffn {Directive} %file-prefix "@var{prefix}"
Specify a prefix to use for all Bison output file names. The names
are chosen as if the grammar file were named @file{@var{prefix}.y}.
@end deffn @end deffn
@deffn {Directive} %language "@var{language}" @deffn {Directive} %language "@var{language}"
@@ -6153,7 +6161,7 @@ types are generated. @xref{Exposing the Location Classes}.
@table @asis @table @asis
@item @code{none} @item @code{none}
If locations are enabled, generate the definition of the @code{position} and If locations are enabled, generate the definition of the @code{position} and
@code{location} classes in the header file if @code{%defines}, otherwise in @code{location} classes in the header file if @code{%header}, otherwise in
the parser implementation. the parser implementation.
@item "@var{file}" @item "@var{file}"
@@ -7256,8 +7264,8 @@ You call the function @code{yypstate_new} to create a new parser instance.
This function is available if either the @samp{%define api.push-pull push} This function is available if either the @samp{%define api.push-pull push}
or @samp{%define api.push-pull both} declaration is used. @xref{Push Decl}. or @samp{%define api.push-pull both} declaration is used. @xref{Push Decl}.
@deftypefun {yypstate*} yypstate_new (@code{void})
@anchor{yypstate_new} @anchor{yypstate_new}
@deftypefun {yypstate*} yypstate_new (@code{void})
Return a valid parser instance if there is memory available, 0 otherwise. Return a valid parser instance if there is memory available, 0 otherwise.
In impure mode, it will also return 0 if a parser instance is currently In impure mode, it will also return 0 if a parser instance is currently
allocated. allocated.
@@ -7269,8 +7277,8 @@ function is available if either the @samp{%define api.push-pull push} or
@samp{%define api.push-pull both} declaration is used. @samp{%define api.push-pull both} declaration is used.
@xref{Push Decl}. @xref{Push Decl}.
@deftypefun void yypstate_delete (@code{yypstate *}@var{yyps})
@anchor{yypstate_delete} @anchor{yypstate_delete}
@deftypefun void yypstate_delete (@code{yypstate *}@var{yyps})
Reclaim the memory associated with a parser instance. After this call, you Reclaim the memory associated with a parser instance. After this call, you
should no longer attempt to use the parser instance. should no longer attempt to use the parser instance.
@end deftypefun @end deftypefun
@@ -7280,8 +7288,8 @@ You call the function @code{yypush_parse} to parse a single token. This
function is available if either the @samp{%define api.push-pull push} or function is available if either the @samp{%define api.push-pull push} or
@samp{%define api.push-pull both} declaration is used. @xref{Push Decl}. @samp{%define api.push-pull both} declaration is used. @xref{Push Decl}.
@deftypefun int yypush_parse (@code{yypstate *}@var{yyps})
@anchor{yypush_parse} @anchor{yypush_parse}
@deftypefun int yypush_parse (@code{yypstate *}@var{yyps})
The value returned by @code{yypush_parse} is the same as for @code{yyparse} The value returned by @code{yypush_parse} is the same as for @code{yyparse}
with the following exception: it returns @code{YYPUSH_MORE} if more input is with the following exception: it returns @code{YYPUSH_MORE} if more input is
required to finish parsing the grammar. required to finish parsing the grammar.
@@ -7303,8 +7311,8 @@ You call the function @code{yypull_parse} to parse the rest of the input
stream. This function is available if the @samp{%define api.push-pull both} stream. This function is available if the @samp{%define api.push-pull both}
declaration is used. @xref{Push Decl}. declaration is used. @xref{Push Decl}.
@deftypefun int yypull_parse (@code{yypstate *}@var{yyps})
@anchor{yypull_parse} @anchor{yypull_parse}
@deftypefun int yypull_parse (@code{yypstate *}@var{yyps})
The value returned by @code{yypull_parse} is the same as for @code{yyparse}. The value returned by @code{yypull_parse} is the same as for @code{yyparse}.
The parser instance @code{yyps} may be reused for new parses. The parser instance @code{yyps} may be reused for new parses.
@@ -11800,12 +11808,12 @@ Options controlling the output.
@table @option @table @option
@item -H [@var{file}] @item -H [@var{file}]
@itemx --header=[@var{file}] @itemx --header=[@var{file}]
Pretend that @code{%defines} was specified, i.e., write an extra output file Pretend that @code{%header} was specified, i.e., write an extra output file
containing definitions for the token kind names defined in the grammar, as containing definitions for the token kind names defined in the grammar, as
well as a few other declarations. @xref{Decl Summary}. well as a few other declarations. @xref{Decl Summary}.
@item --defines[=@var{file}] @item --defines[=@var{file}]
Historical name for option @option{--header}. Historical name for option @option{--header} before Bison 3.8.
@item -d @item -d
This is the same as @option{--header} except @option{-d} does not accept a This is the same as @option{--header} except @option{-d} does not accept a
@@ -12211,7 +12219,7 @@ these two files (@file{@var{file}.hh} and @file{@var{file}.cc}) follow the
same rules as with regular C parsers (@pxref{Invocation}). same rules as with regular C parsers (@pxref{Invocation}).
@item location.hh @item location.hh
Generated when both @code{%defines} and @code{%locations} are enabled, this Generated when both @code{%header} and @code{%locations} are enabled, this
file contains the definition of the classes @code{position} and file contains the definition of the classes @code{position} and
@code{location}, used for location tracking. It is not generated if @code{location}, used for location tracking. It is not generated if
@samp{%define api.location.file none} is specified, or if user defined @samp{%define api.location.file none} is specified, or if user defined
@@ -12608,7 +12616,7 @@ Report @var{p} on @var{o}, taking care of special cases such as: no
@node Exposing the Location Classes @node Exposing the Location Classes
@subsubsection Exposing the Location Classes @subsubsection Exposing the Location Classes
When both @code{%defines} and @code{%locations} are enabled, Bison generates When both @code{%header} and @code{%locations} are enabled, Bison generates
an additional file: @file{location.hh}. If you don't use locations outside an additional file: @file{location.hh}. If you don't use locations outside
of the parser, you may avoid its creation with @samp{%define of the parser, you may avoid its creation with @samp{%define
api.location.file none}. api.location.file none}.
@@ -12697,7 +12705,7 @@ definitions for @code{position} and @code{location}. For instance, one
parser @file{master/parser.yy} might use: parser @file{master/parser.yy} might use:
@example @example
%defines %header
%locations %locations
%define api.namespace @{master::@} %define api.namespace @{master::@}
@end example @end example
@@ -13273,7 +13281,7 @@ designed the grammar for.
@example @example
%skeleton "lalr1.cc" // -*- C++ -*- %skeleton "lalr1.cc" // -*- C++ -*-
%require "@value{VERSION}" %require "@value{VERSION}"
%defines %header
@end example @end example
@noindent @noindent
@@ -13798,7 +13806,7 @@ GLR parsers are currently unsupported in Java. Do not use the
@code{glr-parser} directive. @code{glr-parser} directive.
No header file can be generated for Java parsers. Do not use the No header file can be generated for Java parsers. Do not use the
@code{%defines} directive or the @option{-d}/@option{-H}/@option{--header} @code{%header} directive or the @option{-d}/@option{-H}/@option{--header}
options. options.
@c FIXME: Possible code change. @c FIXME: Possible code change.
@@ -15221,12 +15229,8 @@ Define a variable to adjust Bison's behavior. @xref{%define Summary}.
@end deffn @end deffn
@deffn {Directive} %defines @deffn {Directive} %defines
Bison declaration to create a parser header file, which is usually @deffnx {Directive} %defines @var{defines-file}
meant for the scanner. @xref{Decl Summary}. Historical name for @code{%header}.
@end deffn
@deffn {Directive} %defines @var{defines-file}
Same as above, but save in the file @var{defines-file}.
@xref{Decl Summary}. @xref{Decl Summary}.
@end deffn @end deffn
@@ -15275,6 +15279,16 @@ Bison declaration to produce a GLR parser. @xref{GLR
Parsers}. Parsers}.
@end deffn @end deffn
@deffn {Directive} %header
Bison declaration to create a parser header file, which is usually
meant for the scanner. @xref{Decl Summary}.
@end deffn
@deffn {Directive} %header @var{header-file}
Same as above, but save in the file @var{header-file}.
@xref{Decl Summary}.
@end deffn
@deffn {Directive} %initial-action @deffn {Directive} %initial-action
Run user code before parsing. @xref{Initial Action Decl}. Run user code before parsing. @xref{Initial Action Decl}.
@end deffn @end deffn

View File

@@ -581,7 +581,7 @@ sub generate_grammar_list ($$@)
or die; or die;
print $out <<EOF; print $out <<EOF;
%language "C++" %language "C++"
%defines %header
%locations %locations
$directives $directives

View File

@@ -96,8 +96,8 @@
string from the scanner (should be CODE). */ string from the scanner (should be CODE). */
static char const *translate_code_braceless (char *code, location loc); static char const *translate_code_braceless (char *code, location loc);
/* Handle a %defines directive. */ /* Handle a %header directive. */
static void handle_defines (char const *value); static void handle_header (char const *value);
/* Handle a %error-verbose directive. */ /* Handle a %error-verbose directive. */
static void handle_error_verbose (location const *loc, char const *directive); static void handle_error_verbose (location const *loc, char const *directive);
@@ -153,7 +153,7 @@
%define parse.error custom %define parse.error custom
%define parse.lac full %define parse.lac full
%define parse.trace %define parse.trace
%defines %header
%expect 0 %expect 0
%verbose %verbose
@@ -188,20 +188,19 @@
PERCENT_CODE "%code" PERCENT_CODE "%code"
PERCENT_DEFAULT_PREC "%default-prec" PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define" PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines"
PERCENT_ERROR_VERBOSE "%error-verbose" PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect" PERCENT_EXPECT "%expect"
PERCENT_EXPECT_RR "%expect-rr" PERCENT_EXPECT_RR "%expect-rr"
PERCENT_FLAG "%<flag>"
PERCENT_FILE_PREFIX "%file-prefix" PERCENT_FILE_PREFIX "%file-prefix"
PERCENT_FLAG "%<flag>"
PERCENT_GLR_PARSER "%glr-parser" PERCENT_GLR_PARSER "%glr-parser"
PERCENT_HEADER "%header"
PERCENT_INITIAL_ACTION "%initial-action" PERCENT_INITIAL_ACTION "%initial-action"
PERCENT_LANGUAGE "%language" PERCENT_LANGUAGE "%language"
PERCENT_NAME_PREFIX "%name-prefix" PERCENT_NAME_PREFIX "%name-prefix"
PERCENT_NO_DEFAULT_PREC "%no-default-prec" PERCENT_NO_DEFAULT_PREC "%no-default-prec"
PERCENT_NO_LINES "%no-lines" PERCENT_NO_LINES "%no-lines"
PERCENT_NONDETERMINISTIC_PARSER PERCENT_NONDETERMINISTIC_PARSER "%nondeterministic-parser"
"%nondeterministic-parser"
PERCENT_OUTPUT "%output" PERCENT_OUTPUT "%output"
PERCENT_PURE_PARSER "%pure-parser" PERCENT_PURE_PARSER "%pure-parser"
PERCENT_REQUIRE "%require" PERCENT_REQUIRE "%require"
@@ -339,8 +338,7 @@ prologue_declaration:
muscle_percent_define_insert ($2, @$, $3.kind, $3.chars, muscle_percent_define_insert ($2, @$, $3.kind, $3.chars,
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
} }
| "%defines" { header_flag = true; } | "%header" string.opt { handle_header ($2); }
| "%defines" STRING { handle_defines ($2); }
| "%error-verbose" { handle_error_verbose (&@$, $1); } | "%error-verbose" { handle_error_verbose (&@$, $1); }
| "%expect" INT_LITERAL { expected_sr_conflicts = $2; } | "%expect" INT_LITERAL { expected_sr_conflicts = $2; }
| "%expect-rr" INT_LITERAL { expected_rr_conflicts = $2; } | "%expect-rr" INT_LITERAL { expected_rr_conflicts = $2; }
@@ -485,6 +483,12 @@ precedence_declarator:
| "%precedence" { $$ = precedence_assoc; } | "%precedence" { $$ = precedence_assoc; }
; ;
%type <char*> string.opt;
string.opt:
%empty { $$ = NULL; }
| STRING { $$ = $1; }
;
tag.opt: tag.opt:
%empty { $$ = NULL; } %empty { $$ = NULL; }
| TAG { $$ = $1; } | TAG { $$ = $1; }
@@ -947,13 +951,16 @@ add_param (param_type type, char *decl, location loc)
static void static void
handle_defines (char const *value) handle_header (char const *value)
{ {
header_flag = true; header_flag = true;
char *file = unquote (value); if (value)
spec_header_file = xstrdup (file); {
gram_scanner_last_string_free (); char *file = unquote (value);
unquote_free (file); spec_header_file = xstrdup (file);
gram_scanner_last_string_free ();
unquote_free (file);
}
} }

View File

@@ -245,15 +245,16 @@ eqopt ({sp}=)?
"%debug" RETURN_PERCENT_FLAG ("parse.trace"); "%debug" RETURN_PERCENT_FLAG ("parse.trace");
"%default-prec" return BISON_DIRECTIVE (DEFAULT_PREC); "%default-prec" return BISON_DIRECTIVE (DEFAULT_PREC);
"%define" return BISON_DIRECTIVE (DEFINE); "%define" return BISON_DIRECTIVE (DEFINE);
"%defines" return BISON_DIRECTIVE (DEFINES); "%defines" return BISON_DIRECTIVE (HEADER); // Deprecated in 3.8.
"%destructor" return BISON_DIRECTIVE (DESTRUCTOR); "%destructor" return BISON_DIRECTIVE (DESTRUCTOR);
"%dprec" return BISON_DIRECTIVE (DPREC); "%dprec" return BISON_DIRECTIVE (DPREC);
"%empty" return BISON_DIRECTIVE (EMPTY); "%empty" return BISON_DIRECTIVE (EMPTY);
"%expect" return BISON_DIRECTIVE (EXPECT); "%expect" return BISON_DIRECTIVE (EXPECT);
"%expect-rr" return BISON_DIRECTIVE (EXPECT_RR); "%expect-rr" return BISON_DIRECTIVE (EXPECT_RR);
"%file-prefix" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext)); "%file-prefix" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext));
"%initial-action" return BISON_DIRECTIVE (INITIAL_ACTION);
"%glr-parser" return BISON_DIRECTIVE (GLR_PARSER); "%glr-parser" return BISON_DIRECTIVE (GLR_PARSER);
"%header" return BISON_DIRECTIVE (HEADER);
"%initial-action" return BISON_DIRECTIVE (INITIAL_ACTION);
"%language" return BISON_DIRECTIVE (LANGUAGE); "%language" return BISON_DIRECTIVE (LANGUAGE);
"%left" return PERCENT_LEFT; "%left" return PERCENT_LEFT;
"%lex-param" RETURN_PERCENT_PARAM (lex); "%lex-param" RETURN_PERCENT_PARAM (lex);

View File

@@ -1050,14 +1050,14 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([], [ with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [ with union]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [ with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "lalr1.cc"])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [ with union]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "lalr1.cc"], [ with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "glr.cc"]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "glr.cc"])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "glr.cc"], [ with union]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "glr.cc"], [ with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "glr2.cc"]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "glr2.cc"])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "glr2.cc"], [ with union]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%header %skeleton "glr2.cc"], [ with union])

View File

@@ -593,7 +593,7 @@ AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
AT_DATA_GRAMMAR([[input.y]], AT_DATA_GRAMMAR([[input.y]],
[[%skeleton "lalr1.cc" [[%skeleton "lalr1.cc"
%defines %header
%debug %debug
%define parse.assert %define parse.assert
@@ -727,7 +727,7 @@ AT_DATA([input.yy],
[[%require "3.2" [[%require "3.2"
%skeleton "lalr1.cc" %skeleton "lalr1.cc"
%locations %locations
%defines %header
%debug %debug
%% %%
exp: %empty; exp: %empty;
@@ -964,7 +964,7 @@ AT_BISON_OPTION_PUSHDEFS([$1 %debug])
AT_DATA_GRAMMAR([[input.yy]], AT_DATA_GRAMMAR([[input.yy]],
[[$1 [[$1
%defines %header
%code %code
{ {
@@ -1453,7 +1453,7 @@ AT_BISON_OPTION_POPDEFS
mkdir -p include/ast mkdir -p include/ast
AT_TEST([x1], AT_TEST([x1],
[%defines [%header
%locations %locations
%define api.location.file "include/ast/loc.hh" %define api.location.file "include/ast/loc.hh"
%define api.location.include {<ast/loc.hh>}]) %define api.location.include {<ast/loc.hh>}])
@@ -1468,7 +1468,7 @@ AT_CHECK([sed -ne '/INCLUDED/p;/\\file/{p;n;p;}' include/ast/loc.hh], [],
]]) ]])
AT_TEST([x2], AT_TEST([x2],
[%defines [%header
%locations %locations
%code requires {#include <ast/loc.hh>} %code requires {#include <ast/loc.hh>}
%define api.location.type {x1::location}]) %define api.location.type {x1::location}])

View File

@@ -422,14 +422,14 @@ m4_define([AT_CALC_YYLEX(java)],
# _AT_DATA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES]) # _AT_DATA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES])
# ----------------------------------------------- # -----------------------------------------------
# Produce 'calc.y' and, if %defines was specified, 'calc-lex.c' or # Produce 'calc.y' and, if %header was specified, 'calc-lex.c' or
# 'calc-lex.cc'. # 'calc-lex.cc'.
# #
# Don't call this macro directly, because it contains some occurrences # Don't call this macro directly, because it contains some occurrences
# of '$1' etc. which will be interpreted by m4. So you should call it # of '$1' etc. which will be interpreted by m4. So you should call it
# with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does. # with $1, $2, and $3 as arguments, which is what AT_DATA_CALC_Y does.
# #
# When %defines is not passed, generate a single self-contained file. # When %header is not passed, generate a single self-contained file.
# Otherwise, generate three: calc.y with the parser, calc-lex.c with # Otherwise, generate three: calc.y with the parser, calc-lex.c with
# the scanner, and calc-main.c with "main()". This is in order to # the scanner, and calc-main.c with "main()". This is in order to
# stress the use of the generated parser header. To avoid code # stress the use of the generated parser header. To avoid code
@@ -647,11 +647,11 @@ location_print (FILE *o, Span s)
} }
]])])[ ]])])[
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
]AT_DEFINES_IF([], ]AT_HEADER_IF([],
[AT_CALC_YYLEX [AT_CALC_YYLEX
AT_CALC_MAIN])]) AT_CALC_MAIN])])
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.]AT_LANG_EXT], AT_HEADER_IF([AT_DATA_SOURCE([[calc-lex.]AT_LANG_EXT],
[[#include "calc.]AT_LANG_HDR[" [[#include "calc.]AT_LANG_HDR["
]AT_CALC_YYLEX]) ]AT_CALC_YYLEX])
@@ -752,7 +752,7 @@ exp:
# AT_DATA_CALC_Y([BISON-OPTIONS]) # AT_DATA_CALC_Y([BISON-OPTIONS])
# ------------------------------- # -------------------------------
# Produce 'calc.y' and, if %defines was specified, 'calc-lex.c' or # Produce 'calc.y' and, if %header was specified, 'calc-lex.c' or
# 'calc-lex.cc'. # 'calc-lex.cc'.
m4_define([AT_DATA_CALC_Y], m4_define([AT_DATA_CALC_Y],
[_AT_DATA_CALC_Y($[1], $[2], $[3], [$1]) [_AT_DATA_CALC_Y($[1], $[2], $[3], [$1])
@@ -914,7 +914,7 @@ AT_SETUP([Calculator $1 $2])
AT_BISON_OPTION_PUSHDEFS([$1]) AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1]) AT_DATA_CALC_Y([$1])
AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_DEFINES_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated]) AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_HEADER_IF([[lex], [main]], [[], []]), [$2], [-Wno-deprecated])
AT_YACC_IF( AT_YACC_IF(
[# No direct calls to malloc/free. [# No direct calls to malloc/free.
@@ -926,7 +926,7 @@ AT_PUSH_IF([AT_JAVA_IF(
AT_CHECK_JAVA_GREP([[Calc.java]], AT_CHECK_JAVA_GREP([[Calc.java]],
[[.*public void push_parse_initialize ().*]])])]) [[.*public void push_parse_initialize ().*]])])])
AT_CHECK_SPACES([AT_JAVA_IF([Calc], [calc]).AT_LANG_EXT AT_DEFINES_IF([AT_JAVA_IF([Calc], [calc]).AT_LANG_HDR])]) AT_CHECK_SPACES([AT_JAVA_IF([Calc], [calc]).AT_LANG_EXT AT_HEADER_IF([AT_JAVA_IF([Calc], [calc]).AT_LANG_HDR])])
# Test the precedences. # Test the precedences.
# The Java traces do not show the clean up sequence at the end, # The Java traces do not show the clean up sequence at the end,
@@ -1081,7 +1081,7 @@ m4_define([AT_CHECK_CALC_LALR],
AT_CHECK_CALC_LALR([%define parse.trace]) AT_CHECK_CALC_LALR([%define parse.trace])
AT_CHECK_CALC_LALR([%defines]) AT_CHECK_CALC_LALR([%header])
AT_CHECK_CALC_LALR([%debug %locations]) AT_CHECK_CALC_LALR([%debug %locations])
AT_CHECK_CALC_LALR([%locations %define api.location.type {Span}]) AT_CHECK_CALC_LALR([%locations %define api.location.type {Span}])
@@ -1095,19 +1095,20 @@ AT_CHECK_CALC_LALR([%define api.pure full %locations])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations]) AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %locations])
AT_CHECK_CALC_LALR([%define parse.error detailed %locations]) AT_CHECK_CALC_LALR([%define parse.error detailed %locations])
AT_CHECK_CALC_LALR([%define parse.error detailed %locations %defines %define api.prefix {calc} %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error detailed %locations %header %define api.prefix {calc} %verbose %yacc])
AT_CHECK_CALC_LALR([%define parse.error detailed %locations %defines %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error detailed %locations %header %name-prefix "calc" %define api.token.prefix {TOK_} %verbose %yacc])
AT_CHECK_CALC_LALR([%debug]) AT_CHECK_CALC_LALR([%debug])
AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %header %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %defines %define api.prefix {calc} %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure full %define parse.error detailed %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%define api.pure full %define parse.error detailed %debug %locations %header %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error detailed %debug %locations %defines %define api.prefix {calc} %verbose %yacc]) AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure full %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc])
AT_CHECK_CALC_LALR([%define api.pure %define parse.error detailed %debug %locations %defines %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR([%define api.pure %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error detailed %debug %locations %defines %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error detailed %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR([%no-lines %define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %yacc %parse-param {semantic_value *result}{int *count}{int *nerrs}])
@@ -1128,7 +1129,7 @@ m4_define([AT_CHECK_CALC_GLR],
AT_CHECK_CALC_GLR() AT_CHECK_CALC_GLR()
AT_CHECK_CALC_GLR([%defines]) AT_CHECK_CALC_GLR([%header])
AT_CHECK_CALC_GLR([%locations]) AT_CHECK_CALC_GLR([%locations])
AT_CHECK_CALC_GLR([%locations %define api.location.type {Span}]) AT_CHECK_CALC_GLR([%locations %define api.location.type {Span}])
AT_CHECK_CALC_GLR([%name-prefix "calc"]) AT_CHECK_CALC_GLR([%name-prefix "calc"])
@@ -1139,20 +1140,20 @@ AT_CHECK_CALC_GLR([%define parse.error verbose])
AT_CHECK_CALC_GLR([%define api.pure %locations]) AT_CHECK_CALC_GLR([%define api.pure %locations])
AT_CHECK_CALC_GLR([%define parse.error verbose %locations]) AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
AT_CHECK_CALC_GLR([%define parse.error custom %locations %defines %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR([%define parse.error custom %locations %header %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR([%define parse.error detailed %locations %defines %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR([%define parse.error detailed %locations %header %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR([%define parse.error verbose %locations %header %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR([%debug]) AT_CHECK_CALC_GLR([%debug])
AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose]) AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %header %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose])
AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose %debug %locations %header %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
# ---------------------- # # ---------------------- #
@@ -1162,7 +1163,7 @@ AT_CHECK_CALC_GLR([%no-lines %define api.pure %define parse.error verbose %debug
AT_BANNER([[LALR(1) C++ Calculator.]]) AT_BANNER([[LALR(1) C++ Calculator.]])
# First let's try using %skeleton # First let's try using %skeleton
AT_CHECK_CALC([%skeleton "lalr1.cc" %defines]) AT_CHECK_CALC([%skeleton "lalr1.cc" %header])
m4_define([AT_CHECK_CALC_LALR1_CC], m4_define([AT_CHECK_CALC_LALR1_CC],
[AT_CHECK_CALC([%language "C++" $1], [$2])]) [AT_CHECK_CALC([%language "C++" $1], [$2])])
@@ -1171,7 +1172,7 @@ AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%locations]) AT_CHECK_CALC_LALR1_CC([%locations])
AT_CHECK_CALC_LALR1_CC([%locations], [$NO_EXCEPTIONS_CXXFLAGS]) AT_CHECK_CALC_LALR1_CC([%locations], [$NO_EXCEPTIONS_CXXFLAGS])
AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type {Span}]) AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type {Span}])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %name-prefix "calc" %verbose]) AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %name-prefix "calc" %verbose])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix {calc} %verbose]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix {calc} %verbose])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose])
@@ -1179,15 +1180,15 @@ AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-pref
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %verbose]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %verbose])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %define api.prefix {calc} %define api.token.prefix {TOK_} %verbose])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR1_CC([%define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_LALR1_CC([%header %locations %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file none]) AT_CHECK_CALC_LALR1_CC([%header %locations %define api.location.file none])
AT_CHECK_CALC_LALR1_CC([%defines %locations %define api.location.file "my-location.hh"]) AT_CHECK_CALC_LALR1_CC([%header %locations %define api.location.file "my-location.hh"])
AT_CHECK_CALC_LALR1_CC([%no-lines %defines %locations %define api.location.file "my-location.hh"]) AT_CHECK_CALC_LALR1_CC([%no-lines %header %locations %define api.location.file "my-location.hh"])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error verbose]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error verbose])
AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error detailed]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.lac full %define parse.error detailed])
@@ -1212,7 +1213,7 @@ m4_define([AT_CHECK_CALC_GLR_CC],
AT_CHECK_CALC_GLR_CC([]) AT_CHECK_CALC_GLR_CC([])
AT_CHECK_CALC_GLR_CC([%locations]) AT_CHECK_CALC_GLR_CC([%locations])
AT_CHECK_CALC_GLR_CC([%locations %define api.location.type {Span}]) AT_CHECK_CALC_GLR_CC([%locations %define api.location.type {Span}])
AT_CHECK_CALC_GLR_CC([%defines %define parse.error verbose %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR_CC([%header %define parse.error verbose %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix {calc} %verbose]) AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix {calc} %verbose])
AT_CHECK_CALC_GLR_CC([%debug]) AT_CHECK_CALC_GLR_CC([%debug])
@@ -1220,10 +1221,10 @@ AT_CHECK_CALC_GLR_CC([%debug])
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose]) AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose])
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose]) AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix {TOK_} %verbose])
AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %name-prefix "calc" %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_GLR_CC([%locations %defines %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR_CC([%locations %header %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
AT_CHECK_CALC_GLR_CC([%no-lines %locations %defines %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}]) AT_CHECK_CALC_GLR_CC([%no-lines %locations %header %define parse.error verbose %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
# -------------------- # # -------------------- #

View File

@@ -405,7 +405,7 @@ m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [
AT_SETUP([[parse.error=verbose and consistent errors: ]$1]) AT_SETUP([[parse.error=verbose and consistent errors: ]$1])
AT_BISON_OPTION_PUSHDEFS([$1 AT_CXX_IF([[%defines]], [[%define api.pure]])]) AT_BISON_OPTION_PUSHDEFS([$1 AT_CXX_IF([[%header]], [[%define api.pure]])])
AT_DATA_GRAMMAR([input.y], AT_DATA_GRAMMAR([input.y],
[AT_JAVA_IF([[ [AT_JAVA_IF([[
@@ -421,7 +421,7 @@ AT_DATA_GRAMMAR([input.y],
#define USE(Var) #define USE(Var)
} }
]AT_CXX_IF([[%defines]], [[%define api.pure]])])[ ]AT_CXX_IF([[%header]], [[%define api.pure]])])[
]AT_YACC_IF([[ ]AT_YACC_IF([[
%code { %code {

View File

@@ -2361,7 +2361,7 @@ m4_define([AT_CHECK_NAMESPACE_ERROR],
[ [
AT_DATA([[input.y]], AT_DATA([[input.y]],
[[%language "C++" [[%language "C++"
%defines %header
%define api.namespace {]$1[} %define api.namespace {]$1[}
%% %%
start: %empty; start: %empty;
@@ -2908,6 +2908,7 @@ AT_DATA_GRAMMAR([[input.y]],
%error-verbose %error-verbose
%glr-parser %glr-parser
%name-prefix "bar" %name-prefix "bar"
%defines "header.h"
%% %%
exp : '0' exp : '0'
]]) ]])
@@ -2991,6 +2992,7 @@ AT_CHECK([sed -e '1,8d' input.y], [],
%define api.pure %define api.pure
%token-table %token-table
%glr-parser %glr-parser
%defines "header.h"
%% %%
exp : '0' exp : '0'
]]) ]])

View File

@@ -24,6 +24,21 @@ AT_BANNER([[Java Calculator.]])
AT_SETUP([Java invalid directives]) AT_SETUP([Java invalid directives])
AT_DATA([[YYParser.y]], [
%language "Java"
%header
%destructor { /* Nothing. */ } exp
%%
exp:
])
AT_BISON_CHECK([[-fcaret YYParser.y]], [1], [],
[[YYParser.y: error: %header/%defines does not make sense in Java
YYParser.y:4.13-30: error: %destructor does not make sense in Java
4 | %destructor { /* Nothing. */ } exp
| ^~~~~~~~~~~~~~~~~~
]])
AT_DATA([[YYParser.y]], [ AT_DATA([[YYParser.y]], [
%language "Java" %language "Java"
%defines %defines
@@ -33,7 +48,7 @@ exp:
]) ])
AT_BISON_CHECK([[-fcaret YYParser.y]], [1], [], AT_BISON_CHECK([[-fcaret YYParser.y]], [1], [],
[[YYParser.y: error: %defines does not make sense in Java [[YYParser.y: error: %header/%defines does not make sense in Java
YYParser.y:4.13-30: error: %destructor does not make sense in Java YYParser.y:4.13-30: error: %destructor does not make sense in Java
4 | %destructor { /* Nothing. */ } exp 4 | %destructor { /* Nothing. */ } exp
| ^~~~~~~~~~~~~~~~~~ | ^~~~~~~~~~~~~~~~~~

View File

@@ -210,8 +210,8 @@ m4_if([$1$2], $[1]$[2], [],
[m4_fatal([$0: invalid arguments: $@])])dnl [m4_fatal([$0: invalid arguments: $@])])dnl
m4_pushdef([AT_AUTOMOVE_IF], m4_pushdef([AT_AUTOMOVE_IF],
[m4_bmatch([$3], [%define api\.value\.automove], [$1], [$2])]) [m4_bmatch([$3], [%define api\.value\.automove], [$1], [$2])])
m4_pushdef([AT_DEFINES_IF], m4_pushdef([AT_HEADER_IF],
[m4_bmatch([$3], [%defines], [$1], [$2])]) [m4_bmatch([$3], [%defines\|%header], [$1], [$2])])
m4_pushdef([AT_DEBUG_IF], m4_pushdef([AT_DEBUG_IF],
[m4_bmatch([$3], [%debug\|%define parse.trace], [$1], [$2])]) [m4_bmatch([$3], [%debug\|%define parse.trace], [$1], [$2])])
m4_pushdef([AT_ERROR_CUSTOM_IF], m4_pushdef([AT_ERROR_CUSTOM_IF],
@@ -442,7 +442,7 @@ m4_popdef([AT_ERROR_VERBOSE_IF])
m4_popdef([AT_ERROR_DETAILED_IF]) m4_popdef([AT_ERROR_DETAILED_IF])
m4_popdef([AT_ERROR_CUSTOM_IF]) m4_popdef([AT_ERROR_CUSTOM_IF])
m4_popdef([AT_DEBUG_IF]) m4_popdef([AT_DEBUG_IF])
m4_popdef([AT_DEFINES_IF]) m4_popdef([AT_HEADER_IF])
m4_popdef([AT_AUTOMOVE_IF]) m4_popdef([AT_AUTOMOVE_IF])
AT_LOC_POPDEF])dnl AT_LOC_POPDEF])dnl
])# AT_BISON_OPTION_POPDEFS ])# AT_BISON_OPTION_POPDEFS

View File

@@ -106,30 +106,30 @@ AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
[foo.c foo.dot foo.h foo.output]) [foo.c foo.dot foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [], AT_CHECK_OUTPUT([foo.y], [%header %verbose], [],
[foo.output foo.tab.c foo.tab.h]) [foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[], AT_CHECK_OUTPUT([foo.y], [%header %verbose %yacc],[],
[y.output y.tab.c y.tab.h]) [y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[], AT_CHECK_OUTPUT([foo.yy], [%header %verbose %yacc],[],
[y.output y.tab.c y.tab.h]) [y.output y.tab.c y.tab.h])
# Exercise %output and %file-prefix including deprecated '=' # Exercise %output and %file-prefix including deprecated '='
AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [], AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %header %verbose], [],
[bar.output bar.tab.c bar.tab.h]) [bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[], AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %header %verbose %yacc],[],
[bar.c bar.h bar.output]) [bar.c bar.h bar.output])
AT_CHECK_OUTPUT([foo.y], AT_CHECK_OUTPUT([foo.y],
[%file-prefix "baz" %output "bar.c" %defines %verbose %yacc], [%file-prefix "baz" %output "bar.c" %header %verbose %yacc],
[], [],
[bar.c bar.h bar.output]) [bar.c bar.h bar.output])
# Check priorities of extension control. # Check priorities of extension control.
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [], AT_CHECK_OUTPUT([foo.yy], [%header %verbose], [],
[foo.output foo.tab.cc foo.tab.hh]) [foo.output foo.tab.cc foo.tab.hh])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c], AT_CHECK_OUTPUT([foo.yy], [%header %verbose ], [-o foo.c],
[foo.c foo.h foo.output]) [foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.yy], [], AT_CHECK_OUTPUT([foo.yy], [],
@@ -137,10 +137,10 @@ AT_CHECK_OUTPUT([foo.yy], [],
[foo.c++ foo.hpp]) [foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [], AT_CHECK_OUTPUT([foo.yy], [],
[--defines=foo.hpp -o foo.c++], [--header=foo.hpp -o foo.c++],
[foo.c++ foo.hpp]) [foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"], AT_CHECK_OUTPUT([foo.yy], [%header "foo.hpp"],
[-o foo.c++], [-o foo.c++],
[foo.c++ foo.hpp]) [foo.c++ foo.hpp])
@@ -162,6 +162,14 @@ AT_CHECK_OUTPUT([foo.y], [%define useless],
[foo.dot foo.output foo.xml], [foo.dot foo.output foo.xml],
[1]) [1])
# %header was spelled %defines before.
AT_CHECK_OUTPUT([foo.yy], [%defines],
[-o foo.c++],
[foo.c++ foo.h++])
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
[-o foo.c++],
[foo.c++ foo.hpp])
## ------------ ## ## ------------ ##
## C++ output. ## ## C++ output. ##
@@ -179,48 +187,48 @@ AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc"], [],
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [], AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
[foo.output foo.tab.cc]) [foo.output foo.tab.cc])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %header %verbose], [],
[foo.output foo.tab.cc foo.tab.hh stack.hh]) [foo.output foo.tab.cc foo.tab.hh stack.hh])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [], AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [],
[foo.output foo.tab.cc]) [foo.output foo.tab.cc])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [], AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %header %verbose %locations], [],
[foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh]) [foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %header %verbose], [],
[foo.output foo.tab.cc foo.tab.hh stack.hh], [foo.output foo.tab.cc foo.tab.hh stack.hh],
[], [AT_CHECK_NO_SUBDIR_PART([foo.tab])]) [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %header %verbose %locations],
[-o subdir/foo.cc], [-o subdir/foo.cc],
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh], [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh],
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])]) [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
AT_CHECK_OUTPUT([gram_dir/foo.yy], AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"], [%skeleton "lalr1.cc" %header %verbose %file-prefix "output_dir/foo"],
[], [],
[output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh]) [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh])
AT_CHECK_OUTPUT([gram_dir/foo.yy], AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"], [%skeleton "lalr1.cc" %header %locations %verbose %file-prefix "output_dir/foo"],
[], [],
[output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh]) [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh])
# %require "3.2" => no position.hh not stack.hh. # %require "3.2" => no position.hh not stack.hh.
AT_CHECK_OUTPUT([foo.yy], AT_CHECK_OUTPUT([foo.yy],
[%skeleton "lalr1.cc" %defines %locations %define api.location.file none %require "3.2"], [%skeleton "lalr1.cc" %header %locations %define api.location.file none %require "3.2"],
[], [],
[foo.tab.cc foo.tab.hh]) [foo.tab.cc foo.tab.hh])
AT_CHECK_OUTPUT([foo.yy], AT_CHECK_OUTPUT([foo.yy],
[%skeleton "lalr1.cc" %defines %locations %define api.location.file "foo.loc.hh" %require "3.2"], [%skeleton "lalr1.cc" %header %locations %define api.location.file "foo.loc.hh" %require "3.2"],
[], [],
[foo.loc.hh foo.tab.cc foo.tab.hh]) [foo.loc.hh foo.tab.cc foo.tab.hh])
# Absolute paths. # Absolute paths.
AT_CHECK_OUTPUT([foo.yy], AT_CHECK_OUTPUT([foo.yy],
[%skeleton "lalr1.cc" %defines %locations %define api.location.file "$at_dir/foo.loc.hh" %require "3.2"], [%skeleton "lalr1.cc" %header %locations %define api.location.file "$at_dir/foo.loc.hh" %require "3.2"],
[], [],
[foo.loc.hh foo.tab.cc foo.tab.hh]) [foo.loc.hh foo.tab.cc foo.tab.hh])
@@ -255,12 +263,12 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y],
]]) ]])
AT_CHECK_CONFLICTING_OUTPUT([foo.y], AT_CHECK_CONFLICTING_OUTPUT([foo.y],
[%defines "foo.output"], [-v], [%header "foo.output"], [-v],
[[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother] [[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother]
]]) ]])
AT_CHECK_CONFLICTING_OUTPUT([foo.y], AT_CHECK_CONFLICTING_OUTPUT([foo.y],
[%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"], [%skeleton "lalr1.cc" %header %locations], [--graph="location.hh"],
[[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother] [[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother]
]]) ]])
@@ -757,7 +765,7 @@ AT_BISON_OPTION_POPDEFS
mkdir -p out/include/ast mkdir -p out/include/ast
AT_TEST([x1], AT_TEST([x1],
[%defines [%header
%locations %locations
%define api.location.file "include/ast/loc.hh" %define api.location.file "include/ast/loc.hh"
]) ])
@@ -788,7 +796,7 @@ AT_CHECK([[sed -ne 's/^#line [0-9][0-9]* "/#line "/p;/INCLUDED/p;/\\file/{p;n;p;
]]) ]])
AT_TEST([x2], AT_TEST([x2],
[%defines [%header
%locations %locations
%code requires {#include "include/ast/loc.hh"} %code requires {#include "include/ast/loc.hh"}
%define api.location.type {x1::location}]) %define api.location.type {x1::location}])

View File

@@ -1505,7 +1505,7 @@ m4_pushdef([AT_TEST],
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }]) AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }])
AT_DATA_GRAMMAR([input.y], AT_DATA_GRAMMAR([input.y],
[[%defines [[%header
%locations %locations
%skeleton "$1" %skeleton "$1"
%union { int ival; } %union { int ival; }

View File

@@ -452,9 +452,9 @@ m4_popdef([AT_TEST])
m4_pushdef([AT_TEST], m4_pushdef([AT_TEST],
[AT_SETUP([%no-lines: $1]) [AT_SETUP([%no-lines: $1])
AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %defines]) AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %header])
AT_DATA_GRAMMAR([input.y], AT_DATA_GRAMMAR([input.y],
[[%skeleton "$1" %defines [[%skeleton "$1" %header
%{ %{
]AT_YYERROR_DECLARE_EXTERN[ ]AT_YYERROR_DECLARE_EXTERN[
]AT_YYLEX_DECLARE_EXTERN[ ]AT_YYLEX_DECLARE_EXTERN[

View File

@@ -123,7 +123,7 @@ AT_CLEANUP
# $6: RESULT, # $6: RESULT,
# $7: REQUIREMENT) # $7: REQUIREMENT)
# -------------------------------------- # --------------------------------------
# Check with and without %defines, to avoid regressions. It turns out # Check with and without %header, to avoid regressions. It turns out
# that in that case yacc.c calls the set-up of the %union twice, # that in that case yacc.c calls the set-up of the %union twice,
# because YYSTYPE is defined once in the header, and once in the # because YYSTYPE is defined once in the header, and once in the
# implementation file (eventually it'd be better to include the header # implementation file (eventually it'd be better to include the header
@@ -131,8 +131,8 @@ AT_CLEANUP
# a second time doubled the side-effects and resulted in a double # a second time doubled the side-effects and resulted in a double
# definition of the union members. # definition of the union members.
m4_pushdef([AT_TEST], m4_pushdef([AT_TEST],
[_AT_TEST([$1], [$2], [$3], [$4], [$5], [$6], [$7]) [_AT_TEST([$1], [$2], [$3], [$4], [$5], [$6], [$7])
_AT_TEST([$1 %defines], [$2], [$3], [$4], [$5], [$6], [$7]) _AT_TEST([$1 %header], [$2], [$3], [$4], [$5], [$6], [$7])
]) ])
m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc], [glr2.cc]], m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc], [glr2.cc]],