From: Akim Demaille Date: Tue, 26 Jun 2012 14:43:22 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~419 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/297e263a0050959e0fd139ad66e71383fc9ac4db Merge remote-tracking branch 'origin/maint' * origin/maint: tests: do not output m4 set up. tests: use the generic yyerror function. tests: use assert instead of plain abort. tests: improve the generic yylex implementation. tests: generalize the compilation macros. tests: fix confusion between api.prefix and name-prefix. maint: gitignores. yacc: work around the ylwrap limitation. Conflicts: NEWS tests/local.at --- 297e263a0050959e0fd139ad66e71383fc9ac4db diff --cc NEWS index 28654769,10829f54..41e68519 --- a/NEWS +++ b/NEWS @@@ -2,130 -2,33 +2,144 @@@ GNU Bison NEW * Noteworthy changes in release ?.? (????-??-??) [?] +** Warnings about useless semantic types + + Bison now warns about useless (uninhabited) semantic types. Since + semantic types are not declared to Bison (they are defined in the opaque + %union structure), it is %printer/%destructor directives about useless + types that trigger the warning: + + %token term + %type nterm + %printer {} + %destructor {} + %% + nterm: term { $$ = $1; }; + + 3.28-34: warning: type is used, but is not associated to any symbol + 4.28-34: warning: type is used, but is not associated to any symbol + +** Warnings about undeclared symbols + + Bison used to raise an error for %printer and %destructor directives for + undefined symbols. + + %printer {} symbol1 + %destructor {} symbol2 + %% + exp: "a"; + + This is now only a warning. + +** Warnings about useless destructors or printers + + Bison now warns about useless destructors or printers. In the following + example, the printer for , and the destructor for are + useless: all symbols of (token1) already have a printer, and all + symbols of type (token2) already have a destructor. + + %token token1 + token2 + token3 + token4 + %printer {} token1 + %destructor {} token2 + +** Additional yylex/yyparse arguments + + The new directive %param declares additional arguments to both yylex and + yyparse. The %lex-param, %parse-param, and %param directives support one + or more arguments. Instead of + + %lex-param {arg1_type *arg1} + %lex-param {arg2_type *arg2} + %parse-param {arg1_type *arg1} + %parse-param {arg2_type *arg2} + + one may now declare + + %param {arg1_type *arg1} {arg2_type *arg2} + +** Java skeleton improvements + + The constants for token names were moved to the Lexer interface. + Also, it is possible to add code to the parser's constructors using + "%code init" and "%define init_throws". + +** C++ skeleton improvements + + The C++ parser features a syntax_error exception, which can be + thrown from the scanner or from user rules to raise syntax errors. + This facilitates reporting errors caught in sub-functions (e.g., + rejecting too large integral literals from a conversion function + used by the scanner, or rejecting invalid combinations from a + factory invoked by the user actions). + +** Variable api.tokens.prefix + + The variable api.tokens.prefix changes the way tokens are identified in + the generated files. This is especially useful to avoid collisions + with identifiers in the target language. For instance + + %token FILE for ERROR + %define api.tokens.prefix "TOK_" + %% + start: FILE for ERROR; + + will generate the definition of the symbols TOK_FILE, TOK_for, and + TOK_ERROR in the generated sources. In particular, the scanner must + use these prefixed token names, although the grammar itself still + uses the short names (as in the sample rule given above). + +** Variable api.namespace + + The "namespace" variable is renamed "api.namespace". Backward + compatibility is ensured, but upgrading is recommended. + +** Variable parse.error + + The variable error controls the verbosity of error messages. The + use of the %error-verbose directive is deprecated in favor of + %define parse.error "verbose". + +** Semantic predicates + + The new, experimental, semantic-predicate feature allows actions of + the form %?{ BOOLEAN-EXPRESSION }, which cause syntax errors (as for + YYERROR) if the expression evaluates to 0, and are evaluated immediately + in GLR parsers, rather than being deferred. The result is that they + allow the programmer to prune possible parses based on the values of + runtime expressions. + +* Noteworthy changes in release ?.? (????-??-??) [?] + - ** Future changes: + ** Future changes + + The next major release of Bison will drop support for the following + deprecated features. Please report disagreements to bug-bison@gnu.org. + + *** K&C parsers + + Support for generating parsers in K&R C will be removed. Parsers + generated for C supprt ISO C90, and are tested with ISO C99 and ISO C11 + compilers. + + *** Deprecated features - The next major release will drop support for generating parsers in K&R C, - and remove the definitions of yystype and yyltype (removal announced since - Bison 1.875). YYPARSE_PARAM and YYLEX_PARAM, which were deprecated in - favor of %parse-param and %lex-param (introduced in Bison 1.875 too), will - no longer be supported. + The definitions of yystype and yyltype will be removed, as announced since + Bison 1.875. Use YYSTYPE and YYLTYPE only. - ** The generated header is included (yacc.c) + YYPARSE_PARAM and YYLEX_PARAM, which were deprecated in favor of + %parse-param and %lex-param (introduced in Bison 1.875), will no longer be + supported. + + *** The generated header will be included (yacc.c) Instead of duplicating the content of the generated header (definition of - YYSTYPE, yyltype etc.), the generated parser now includes it, as was - already the case for GLR or C++ parsers. + YYSTYPE, yyparse declaration etc.), the generated parser will include it, + as is already the case for GLR or C++ parsers. This change is deferred + because existing versions of ylwrap (e.g., Automake 1.12.1) do not support + it. ** Headers (yacc.c, glr.c, glr.cc) diff --cc data/yacc.c index 0c442ae0,57f3dace..b57794f0 --- a/data/yacc.c +++ b/data/yacc.c @@@ -1992,14 -2063,13 +1997,12 @@@ yypushreturn:]]) return YYID (yyresult); } - -]b4_epilogue +]b4_epilogue[]dnl b4_defines_if( [@output(b4_spec_defines_file@)@ -b4_copyright([Bison interface for Yacc-like parsers in C], - [1984, 1989-1990, 2000-2012])[ +b4_copyright([Bison interface for Yacc-like parsers in C])[ - ]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_shared_declarations[ - ]b4_cpp_guard_close([b4_spec_defines_file])[ ]])dnl b4_defines_if m4_divert_pop(0) +m4_popdef([b4_copyright_years]) diff --cc src/symtab.c index c65bd201,002f6e37..124da372 --- a/src/symtab.c +++ b/src/symtab.c @@@ -997,16 -958,14 +997,15 @@@ default_tagged_code_props_set (code_pro } void -default_tagless_printer_set (code_props const *printer) +default_tagless_code_props_set (code_props_type kind, code_props const *code) { - if (default_tagless_printer.code) + if (default_tagless_code_props[kind].code) { - complain_at (printer->location, - _("redeclaration for default tagless %%printer")); - complain_at (default_tagless_printer.location, - _("previous declaration")); + complain_at (code->location, + _("redeclaration for default tagless %s"), + code_props_type_string (kind)); + complain_at (default_tagless_code_props[kind].location, + _("previous declaration")); } - default_tagless_printer = *printer; + default_tagless_code_props[kind] = *code; } - diff --cc tests/actions.at index 4af56153,3f47928a..1f05eb8e --- a/tests/actions.at +++ b/tests/actions.at @@@ -257,14 -261,15 +261,15 @@@ input /* Nothing. */ { $$ = 0; - printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$)); + V(input, $$, @$, ": /* Nothing */\n"); } | line input /* Right recursive to load the stack so that popping at - END can be exercised. */ + END can be exercised. */ { $$ = 2; - printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n", - $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2)); + V(input, $$, @$, ": "); + V(line, $1, @1, " "); + V(input, $2, @2, "\n"); } ; diff --cc tests/local.at index 649e9943,5a5bbdd0..d5c73657 --- a/tests/local.at +++ b/tests/local.at @@@ -140,13 -141,10 +141,13 @@@ m4_pushdef([AT_NAME_PREFIX] [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"], [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], [yy])]) +m4_pushdef([AT_TOKEN_PREFIX], +[m4_bmatch([$3], [%define api.tokens.prefix ".*"], + [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])]) + m4_pushdef([AT_API_prefix], + [m4_bmatch([$3], [%define api\.prefix ".*"], + [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])], + [yy])]) # yyerror receives the location if %location & %pure & (%glr or %parse-param). m4_pushdef([AT_YYERROR_ARG_LOC_IF], [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], @@@ -163,21 -161,29 +164,29 @@@ m4_pushdef([AT_YYERROR_SEES_LOC_IF] # are using the C++ parsers. m4_pushdef([AT_PURE_LEX_IF], [AT_PURE_IF([$1], - [AT_SKEL_CC_IF([$1], [$2])])]) + [AT_SKEL_CC_IF([$1], [$2])])]) + m4_pushdef([AT_YYSTYPE], + [AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]], + [[YYSTYPE]])]) + m4_pushdef([AT_YYLTYPE], + [AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::location_type]], + [[YYLTYPE]])]) + + AT_PURE_LEX_IF( [m4_pushdef([AT_LOC], [(*llocp)]) m4_pushdef([AT_VAL], [(*lvalp)]) m4_pushdef([AT_YYLEX_FORMALS], - [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])]) - [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])]) ++ [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])]) m4_pushdef([AT_YYLEX_ARGS], - [lvalp[]AT_LOCATION_IF([, llocp])]) + [lvalp[]AT_LOCATION_IF([, llocp])]) m4_pushdef([AT_USE_LEX_ARGS], - [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) + [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) m4_pushdef([AT_YYLEX_PRE_FORMALS], -- [AT_YYLEX_FORMALS, ]) ++ [AT_YYLEX_FORMALS, ]) m4_pushdef([AT_YYLEX_PRE_ARGS], -- [AT_YYLEX_ARGS, ]) ++ [AT_YYLEX_ARGS, ]) ], [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]]) m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]]) @@@ -540,22 -549,38 +552,38 @@@ m4_define([AT_QUELL_VALGRIND] # AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]) # ---------------------------------------- - # Compile SOURCES into OUTPUT. If OUTPUT does not contain '.', - # assume that we are linking too; this is a hack. + # Compile SOURCES into OUTPUT. + # + # If OUTPUT does not contain '.', assume that we are linking too, + # otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT + # with trailing .o removed, and ".c" appended. m4_define([AT_COMPILE], - [AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])], + [AT_CHECK(m4_join([ ], + [$CC $CFLAGS $CPPFLAGS], + [m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])], + [-o $1], + [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])], + [m4_bmatch([$1], [[.]], [], [$LIBS])]), - 0, [ignore], [ignore])]) + 0, [ignore], [ignore])]) # AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc]) - # -------------------------------------------- - # Compile SOURCES into OUTPUT. If OUTPUT does not contain '.', - # assume that we are linking too; this is a hack. - # If the C++ compiler does not work, ignore the test. + # --------------------------------------------- + # Compile SOURCES into OUTPUT. If the C++ compiler does not work, + # ignore the test. + # + # If OUTPUT does not contain '.', assume that we are linking too, + # otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT + # with trailing .o removed, and ".cc" appended. m4_define([AT_COMPILE_CXX], [AT_KEYWORDS(c++) AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore) - AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])], + AT_CHECK(m4_join([ ], + [$CXX $CXXFLAGS $CPPFLAGS], + [m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])], + [-o $1], + [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])], + [m4_bmatch([$1], [[.]], [], [$LIBS])]), - 0, [ignore], [ignore])]) + 0, [ignore], [ignore])]) # AT_JAVA_COMPILE(SOURCES) # ------------------------