diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-08-10 10:33:06 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-08-10 10:42:26 +0300 |
commit | f606bdbedff44a60218a7007de93ee20833c7b17 (patch) | |
tree | 0fd57c06f31dff131521686b3d9eb7def12769ec /contrib | |
parent | 57386fad9537813e2135b5b19949e5597d7b5b50 (diff) | |
download | ydb-f606bdbedff44a60218a7007de93ee20833c7b17.tar.gz |
Update contrib/tools/bison to 3.6.4
9febd1b3a041f2e2083c076fbde9680a7cdc9b9e
Diffstat (limited to 'contrib')
63 files changed, 5354 insertions, 3519 deletions
diff --git a/contrib/tools/bison/NEWS b/contrib/tools/bison/NEWS index 75c8abdcb7..919ff38717 100644 --- a/contrib/tools/bison/NEWS +++ b/contrib/tools/bison/NEWS @@ -1,5 +1,270 @@ GNU Bison NEWS +* Noteworthy changes in release 3.6.4 (2020-06-15) [stable] + +** Bug fixes + + In glr.cc some internal macros leaked in the user's code, and could damage + access to the token kinds. + +* Noteworthy changes in release 3.6.3 (2020-06-03) [stable] + +** Bug fixes + + Incorrect comments in the generated parsers. + + Warnings in push parsers (yacc.c). + + Incorrect display of gotos in LAC traces (lalr1.cc). + +* Noteworthy changes in release 3.6.2 (2020-05-17) [stable] + +** Bug fixes + + Some tests were fixed. + + When token aliases contain comment delimiters: + + %token FOO "/* foo */" + + bison used to emit "nested" comments, which is invalid C. + +* Noteworthy changes in release 3.6.1 (2020-05-10) [stable] + +** Bug fixes + + Restored ANSI-C compliance in yacc.c. + + GNU readline portability issues. + + In C++, yy::parser::symbol_name is now a public member, as was intended. + +** New features + + In C++, yy::parser::symbol_type now has a public name() member function. + +* Noteworthy changes in release 3.6 (2020-05-08) [stable] + +** Backward incompatible changes + + TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose". + + The YYERROR_VERBOSE macro is no longer supported; the parsers that still + depend on it will now produce Yacc-like error messages (just "syntax + error"). It was superseded by the "%error-verbose" directive in Bison + 1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that support + for YYERROR_VERBOSE would be removed. Note that since Bison 3.0 + (2013-07-25), "%error-verbose" is deprecated in favor of "%define + parse.error verbose". + +** Deprecated features + + The YYPRINT macro, which works only with yacc.c and only for tokens, was + obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002). + It is deprecated and its support will be removed eventually. + +** New features + +*** Improved syntax error messages + + Two new values for the %define parse.error variable offer more control to + the user. Available in all the skeletons (C, C++, Java). + +**** %define parse.error detailed + + The behavior of "%define parse.error detailed" is closely resembling that + of "%define parse.error verbose" with a few exceptions. First, it is safe + to use non-ASCII characters in token aliases (with 'verbose', the result + depends on the locale with which bison was run). Second, a yysymbol_name + function is exposed to the user, instead of the yytnamerr function and the + yytname table. Third, token internationalization is supported (see + below). + +**** %define parse.error custom + + With this directive, the user forges and emits the syntax error message + herself by defining the yyreport_syntax_error function. A new type, + yypcontext_t, captures the circumstances of the error, and provides the + user with functions to get details, such as yypcontext_expected_tokens to + get the list of expected token kinds. + + A possible implementation of yyreport_syntax_error is: + + int + yyreport_syntax_error (const yypcontext_t *ctx) + { + int res = 0; + YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx)); + fprintf (stderr, ": syntax error"); + // Report the tokens expected at this point. + { + enum { TOKENMAX = 10 }; + yysymbol_kind_t expected[TOKENMAX]; + int n = yypcontext_expected_tokens (ctx, expected, TOKENMAX); + if (n < 0) + // Forward errors to yyparse. + res = n; + else + for (int i = 0; i < n; ++i) + fprintf (stderr, "%s %s", + i == 0 ? ": expected" : " or", yysymbol_name (expected[i])); + } + // Report the unexpected token. + { + yysymbol_kind_t lookahead = yypcontext_token (ctx); + if (lookahead != YYSYMBOL_YYEMPTY) + fprintf (stderr, " before %s", yysymbol_name (lookahead)); + } + fprintf (stderr, "\n"); + return res; + } + +**** Token aliases internationalization + + When the %define variable parse.error is set to `custom` or `detailed`, + one may specify which token aliases are to be translated using _(). For + instance + + %token + PLUS "+" + MINUS "-" + <double> + NUM _("number") + <symrec*> + FUN _("function") + VAR _("variable") + + In that case the user must define _() and N_(), and yysymbol_name returns + the translated symbol (i.e., it returns '_("variable")' rather that + '"variable"'). In Java, the user must provide an i18n() function. + +*** List of expected tokens (yacc.c) + + Push parsers may invoke yypstate_expected_tokens at any point during + parsing (including even before submitting the first token) to get the list + of possible tokens. This feature can be used to propose autocompletion + (see below the "bistromathic" example). + + It makes little sense to use this feature without enabling LAC (lookahead + correction). + +*** Returning the error token + + When the scanner returns an invalid token or the undefined token + (YYUNDEF), the parser generates an error message and enters error + recovery. Because of that error message, most scanners that find lexical + errors generate an error message, and then ignore the invalid input + without entering the error-recovery. + + The scanners may now return YYerror, the error token, to enter the + error-recovery mode without triggering an additional error message. See + the bistromathic for an example. + +*** Deep overhaul of the symbol and token kinds + + To avoid the confusion with types in programming languages, we now refer + to token and symbol "kinds" instead of token and symbol "types". The + documentation and error messages have been revised. + + All the skeletons have been updated to use dedicated enum types rather + than integral types. Special symbols are now regular citizens, instead of + being declared in ad hoc ways. + +**** Token kinds + + The "token kind" is what is returned by the scanner, e.g., PLUS, NUMBER, + LPAREN, etc. While backward compatibility is of course ensured, users are + nonetheless invited to replace their uses of "enum yytokentype" by + "yytoken_kind_t". + + This type now also includes tokens that were previously hidden: YYEOF (end + of input), YYUNDEF (undefined token), and YYerror (error token). They + now have string aliases, internationalized when internationalization is + enabled. Therefore, by default, error messages now refer to "end of file" + (internationalized) rather than the cryptic "$end", or to "invalid token" + rather than "$undefined". + + Therefore in most cases it is now useless to define the end-of-line token + as follows: + + %token T_EOF 0 "end of file" + + Rather simply use "YYEOF" in your scanner. + +**** Symbol kinds + + The "symbol kinds" is what the parser actually uses. (Unless the + api.token.raw %define variable is used, the symbol kind of a terminal + differs from the corresponding token kind.) + + They are now exposed as a enum, "yysymbol_kind_t". + + This allows users to tailor the error messages the way they want, or to + process some symbols in a specific way in autocompletion (see the + bistromathic example below). + +*** Modernize display of explanatory statements in diagnostics + + Since Bison 2.7, output was indented four spaces for explanatory + statements. For example: + + input.y:2.7-13: error: %type redeclaration for exp + input.y:1.7-11: previous declaration + + Since the introduction of caret-diagnostics, it became less clear. This + indentation has been removed and submessages are displayed similarly as in + GCC: + + input.y:2.7-13: error: %type redeclaration for exp + 2 | %type <float> exp + | ^~~~~~~ + input.y:1.7-11: note: previous declaration + 1 | %type <int> exp + | ^~~~~ + + Contributed by Victor Morales Cayuela. + +*** C++ + + The token and symbol kinds are yy::parser::token_kind_type and + yy::parser::symbol_kind_type. + + The symbol_type::kind() member function allows to get the kind of a + symbol. This can be used to write unit tests for scanners, e.g., + + yy::parser::symbol_type t = make_NUMBER ("123"); + assert (t.kind () == yy::parser::symbol_kind::S_NUMBER); + assert (t.value.as<int> () == 123); + +** Documentation + +*** User Manual + + In order to avoid ambiguities with "type" as in "typing", we now refer to + the "token kind" (e.g., `PLUS`, `NUMBER`, etc.) rather than the "token + type". We now also refer to the "symbol type" (e.g., `PLUS`, `expr`, + etc.). + +*** Examples + + There are now examples/java: a very simple calculator, and a more complete + one (push-parser, location tracking, and debug traces). + + The lexcalc example (a simple example in C based on Flex and Bison) now + also demonstrates location tracking. + + + A new C example, bistromathic, is a fully featured interactive calculator + using many Bison features: pure interface, push parser, autocompletion + based on the current parser state (using yypstate_expected_tokens), + location tracking, internationalized custom error messages, lookahead + correction, rich debug traces, etc. + + It shows how to depend on the symbol kinds to tailor autocompletion. For + instance it recognizes the symbol kind "VARIABLE" to propose + autocompletion on the existing variables, rather than of the word + "variable". + * Noteworthy changes in release 3.5.4 (2020-04-05) [stable] ** WARNING: Future backward-incompatibilities! @@ -2314,7 +2579,7 @@ GNU Bison NEWS Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer halts in the middle of its course. -* Changes in version 2.5 (2011-05-14): +* Noteworthy changes in release 2.5 (2011-05-14) ** Grammar symbol names can now contain non-initial dashes: @@ -2669,7 +2934,7 @@ GNU Bison NEWS This bug has been fixed. -* Changes in version 2.4.3 (2010-08-05): +* Noteworthy changes in release 2.4.3 (2010-08-05) ** Bison now obeys -Werror and --warnings=error for warnings about grammar rules that are useless in the parser due to conflicts. @@ -2689,7 +2954,7 @@ GNU Bison NEWS ** Minor documentation fixes. -* Changes in version 2.4.2 (2010-03-20): +* Noteworthy changes in release 2.4.2 (2010-03-20) ** Some portability problems that resulted in failures and livelocks in the test suite on some versions of at least Solaris, AIX, HP-UX, @@ -2783,7 +3048,7 @@ GNU Bison NEWS message translations were not installed although supported by the host system. -* Changes in version 2.4.1 (2008-12-11): +* Noteworthy changes in release 2.4.1 (2008-12-11) ** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc declarations have been fixed. @@ -2808,7 +3073,7 @@ GNU Bison NEWS ** A few minor improvements to the Bison manual. -* Changes in version 2.4 (2008-11-02): +* Noteworthy changes in release 2.4 (2008-11-02) ** %language is an experimental feature. @@ -2823,7 +3088,7 @@ GNU Bison NEWS ** Several bugs in the C++ skeleton and the experimental Java skeleton have been fixed. -* Changes in version 2.3b (2008-05-27): +* Noteworthy changes in release 2.3b (2008-05-27) ** The quotes around NAME that used to be required in the following directive are now deprecated: @@ -3009,7 +3274,7 @@ GNU Bison NEWS ** The nonfunctional --no-parser, -n, and %no-parser options have been completely removed from Bison. -* Changes in version 2.3a, 2006-09-13: +* Noteworthy changes in release 2.3a (2006-09-13) ** Instead of %union, you can define and use your own union type YYSTYPE if your grammar contains at least one <type> tag. @@ -3123,7 +3388,7 @@ GNU Bison NEWS The old spelling still works, but is not documented and may be removed in a future release. -* Changes in version 2.3, 2006-06-05: +* Noteworthy changes in release 2.3 (2006-06-05) ** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING", for compatibility with LALR(1) grammars. @@ -3131,7 +3396,7 @@ GNU Bison NEWS ** It is now documented that any definition of YYSTYPE or YYLTYPE should be to a type name that does not contain parentheses or brackets. -* Changes in version 2.2, 2006-05-19: +* Noteworthy changes in release 2.2 (2006-05-19) ** The distribution terms for all Bison-generated parsers now permit using the parsers in nonfree programs. Previously, this permission @@ -3213,7 +3478,7 @@ GNU Bison NEWS ** DJGPP support added. -* Changes in version 2.1, 2005-09-16: +* Noteworthy changes in release 2.1 (2005-09-16) ** The C++ lalr1.cc skeleton supports %lex-param. @@ -3239,7 +3504,7 @@ GNU Bison NEWS print 'syntax error, unexpected number' instead of 'syntax error, unexpected "number"'. -* Changes in version 2.0, 2004-12-25: +* Noteworthy changes in release 2.0 (2004-12-25) ** Possibly-incompatible changes @@ -3302,7 +3567,7 @@ GNU Bison NEWS - Semicolons are now allowed before "|" in grammar rules, as POSIX requires. -* Changes in version 1.875, 2003-01-01: +* Noteworthy changes in release 1.875 (2003-01-01) ** The documentation license has been upgraded to version 1.2 of the GNU Free Documentation License. @@ -3422,7 +3687,7 @@ GNU Bison NEWS ago, but nobody noticed until we recently asked someone to try building Bison with a K&R C compiler. -* Changes in version 1.75, 2002-10-14: +* Noteworthy changes in release 1.75 (2002-10-14) ** Bison should now work on 64-bit hosts. @@ -3453,7 +3718,7 @@ GNU Bison NEWS was incorrectly rejected: $1 is defined in the second midrule action, and is equal to the $$ of the first midrule action. -* Changes in version 1.50, 2002-10-04: +* Noteworthy changes in release 1.50 (2002-10-04) ** GLR parsing The declaration @@ -3597,7 +3862,7 @@ GNU Bison NEWS ** GNU M4 is now required when using Bison. -* Changes in version 1.35, 2002-03-25: +* Noteworthy changes in release 1.35 (2002-03-25) ** C Skeleton Some projects use Bison's C parser with C++ compilers, and define @@ -3612,7 +3877,7 @@ GNU Bison NEWS This kludge also addresses some C++ problems when the stack was extended. -* Changes in version 1.34, 2002-03-12: +* Noteworthy changes in release 1.34 (2002-03-12) ** File name clashes are detected $ bison foo.y -d -o foo.x @@ -3632,7 +3897,7 @@ GNU Bison NEWS ** Fix test suite portability problems. -* Changes in version 1.33, 2002-02-07: +* Noteworthy changes in release 1.33 (2002-02-07) ** Fix C++ issues Groff could not be compiled for the definition of size_t was lacking @@ -3641,7 +3906,7 @@ GNU Bison NEWS ** Catch invalid @n As is done with $n. -* Changes in version 1.32, 2002-01-23: +* Noteworthy changes in release 1.32 (2002-01-23) ** Fix Yacc output file names @@ -3649,7 +3914,7 @@ GNU Bison NEWS ** Italian, Dutch translations -* Changes in version 1.31, 2002-01-14: +* Noteworthy changes in release 1.31 (2002-01-14) ** Many Bug Fixes @@ -3736,7 +4001,7 @@ GNU Bison NEWS ** --output New, aliasing "--output-file". -* Changes in version 1.30, 2001-10-26: +* Noteworthy changes in release 1.30 (2001-10-26) ** "--defines" and "--graph" have now an optional argument which is the output file name. "-d" and "-g" do not change; they do not take any @@ -3747,7 +4012,7 @@ GNU Bison NEWS ** Portability fixes. -* Changes in version 1.29, 2001-09-07: +* Noteworthy changes in release 1.29 (2001-09-07) ** The output file does not define const, as this caused problems when used with common autoconfiguration schemes. If you still use ancient compilers @@ -3782,7 +4047,7 @@ GNU Bison NEWS ** @$ Automatic location tracking. -* Changes in version 1.28, 1999-07-06: +* Noteworthy changes in release 1.28 (1999-07-06) ** Should compile better now with K&R compilers. @@ -3792,12 +4057,12 @@ GNU Bison NEWS ** There is now a FAQ. -* Changes in version 1.27: +* Noteworthy changes in release 1.27 ** The make rule which prevented bison.simple from being created on some systems has been fixed. -* Changes in version 1.26: +* Noteworthy changes in release 1.26 ** Bison now uses Automake. @@ -3814,7 +4079,7 @@ GNU Bison NEWS ** Generated parsers should now work even on operating systems which do not provide alloca(). -* Changes in version 1.25, 1995-10-16: +* Noteworthy changes in release 1.25 (1995-10-16) ** Errors in the input grammar are not fatal; Bison keeps reading the grammar file, and reports all the errors found in it. @@ -3839,7 +4104,7 @@ the parser engine; a project can now use its own parser engine. The actions go into a separate file called NAME.act, in the form of a switch statement body. -* Changes in version 1.23: +* Noteworthy changes in release 1.23 The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should @@ -3848,11 +4113,11 @@ by casting it to the proper pointer type. Line numbers in output file corrected. -* Changes in version 1.22: +* Noteworthy changes in release 1.22 --help option added. -* Changes in version 1.20: +* Noteworthy changes in release 1.20 Output file does not redefine const for C++. @@ -3906,7 +4171,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README LocalWords: noexcept constexpr ispell american deprecations backend Teoh LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc - LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata + LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata yytname + LocalWords: yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN + LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF + LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc + LocalWords: yytoken YYUNDEF YYerror Local Variables: ispell-dictionary: "american" diff --git a/contrib/tools/bison/data/README.md b/contrib/tools/bison/data/README.md index c91fe1c545..5d32b75f1a 100644 --- a/contrib/tools/bison/data/README.md +++ b/contrib/tools/bison/data/README.md @@ -83,18 +83,20 @@ field), where field can `has_id`, `id`, etc.: see The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS: -- `has_id`: 0 or 1. - +- `has_id`: 0 or 1 Whether the symbol has an id. - `id`: string If has_id, the id (prefixed by api.token.prefix if defined), otherwise - defined as empty. Guaranteed to be usable as a C identifier. + defined as empty. Guaranteed to be usable as a C identifier. This is + used to define the token kind (i.e., the enum used by the return value of + yylex). -- `tag`: string. - A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc. +- `tag`: string + A human representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc. - `user_number`: integer + The code associated to the `id`. The external number as used by yylex. Can be ASCII code when a character, some number chosen by bison, or some user number in the case of %token FOO <NUM>. Corresponds to yychar in yacc.c. @@ -102,7 +104,12 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS: - `is_token`: 0 or 1 Whether this is a terminal symbol. +- `kind`: string + The symbol kind, i.e., the enumerator of this symbol (token or nonterminal) + which is mapping to its `number`. + - `number`: integer + The code associated to the `kind`. The internal number (computed from the external number by yytranslate). Corresponds to yytoken in yacc.c. This is the same number that serves as key in b4_symbol(NUM, FIELD). diff --git a/contrib/tools/bison/data/skeletons/README-D.txt b/contrib/tools/bison/data/skeletons/README-D.txt index 214e309923..e6068b4edb 100644 --- a/contrib/tools/bison/data/skeletons/README-D.txt +++ b/contrib/tools/bison/data/skeletons/README-D.txt @@ -27,7 +27,7 @@ public interface Lexer * to the next token and prepares to return the semantic value * and beginning/ending positions of the token. * @return the token identifier corresponding to the next token. */ - YYTokenType yylex (); + TokenKind yylex (); /** * Entry point for error reporting. Emits an error @@ -39,7 +39,7 @@ public interface Lexer void yyerror (YYLocation loc, string s); } -- semantic types are handled by D usions (same as for C/C++ parsers) +- semantic types are handled by D unions (same as for C/C++ parsers) - the following (non-standard) %defines are supported: diff --git a/contrib/tools/bison/data/skeletons/bison.m4 b/contrib/tools/bison/data/skeletons/bison.m4 index 8e01bd6a6d..637d2fcbf2 100644 --- a/contrib/tools/bison/data/skeletons/bison.m4 +++ b/contrib/tools/bison/data/skeletons/bison.m4 @@ -19,6 +19,27 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. + +# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...) +# ---------------------------------------------- +# m4 equivalent of +# +# $_ = STRING; +# s/RE1/SUBST1/g; +# s/RE2/SUBST2/g; +# ... +# +# Really similar to m4_bpatsubsts, but behaves properly with quotes. +# See m4.at's "Generating Comments". Super inelegant, but so far, I +# did not find any better solution. +m4_define([b4_gsub], +[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]], + [$2], [$3]), + [$4], [$5]), + [$6], [$7])]) + + + ## ---------------- ## ## Identification. ## ## ---------------- ## @@ -72,8 +93,9 @@ version 2.2 of Bison.]) # ------------- # Issue a warning about private implementation details. m4_define([b4_disclaimer], -[b4_comment([Undocumented macros, especially those whose name start with YY_, -are private implementation details. Do not rely on them.]) +[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, +especially those whose name start with YY_ or yy_. They are +private implementation details that can be changed or removed.]) ]) @@ -369,6 +391,7 @@ m4_define([b4_$3_if], # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. b4_define_flag_if([defines]) # Whether headers are requested. b4_define_flag_if([glr]) # Whether a GLR parser is requested. +b4_define_flag_if([has_translations]) # Whether some tokens are internationalized. b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. b4_define_flag_if([token_table]) # Whether yytoken_table is demanded. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. @@ -384,37 +407,64 @@ m4_define([b4_glr_cc_if], ## Symbols. ## ## --------- ## -# For a description of the Symbol handling, see README. +# For a description of the Symbol handling, see README.md. # # The following macros provide access to symbol related values. # __b4_symbol(NUM, FIELD) # ----------------------- -# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if -# undefined. +# Fetch FIELD of symbol #NUM. Fail if undefined. m4_define([__b4_symbol], [m4_indir([b4_symbol($1, $2)])]) # _b4_symbol(NUM, FIELD) # ---------------------- -# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if -# undefined. +# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md). +# Fail if undefined. m4_define([_b4_symbol], [m4_ifdef([b4_symbol($1, number)], [__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)], [__b4_symbol([$1], [$2])])]) +# b4_symbol_token_kind(NUM) +# ------------------------- +# The token kind of this symbol. +m4_define([b4_symbol_token_kind], +[b4_percent_define_get([api.token.prefix])dnl +_b4_symbol([$1], [id])]) + + +# b4_symbol_kind(NUM) +# ------------------- +# Build the name of the kind of this symbol. It must always exist, +# otherwise some symbols might not be represented in the enum, which +# might be compiled into too small a type to contain all the symbol +# numbers. +m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])]) +m4_define([b4_symbol_kind], +[b4_percent_define_get([api.symbol.prefix])dnl +m4_case([$1], + [-2], [[YYEMPTY]], + [0], [[YYEOF]], + [1], [[YYerror]], + [2], [[YYUNDEF]], + [m4_case(b4_symbol([$1], [tag]), + [$accept], [[YYACCEPT]], + [b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]), + [m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])]) + # b4_symbol(NUM, FIELD) # --------------------- -# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if -# undefined. If FIELD = id, prepend the token prefix. +# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined. +# +# If FIELD = id, prepend the token prefix. m4_define([b4_symbol], [m4_case([$2], - [id], [m4_do([b4_percent_define_get([api.token.prefix])], - [_b4_symbol([$1], [id])])], + [id], [b4_symbol_token_kind([$1])], + [kind], [b4_symbol_kind([$1])], [_b4_symbol($@)])]) @@ -437,9 +487,9 @@ m4_define([b4_symbol_tag_comment], ]) -# b4_symbol_action(SYMBOL-NUM, KIND) -# ---------------------------------- -# Run the action KIND (destructor or printer) for SYMBOL-NUM. +# b4_symbol_action(SYMBOL-NUM, ACTION) +# ------------------------------------ +# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM. m4_define([b4_symbol_action], [b4_symbol_if([$1], [has_$2], [b4_dollar_pushdef([(*yyvaluep)], @@ -463,21 +513,21 @@ m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])]) m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])]) -# b4_symbol_actions(KIND, [TYPE = yytype]) -# ---------------------------------------- -# Emit the symbol actions for KIND ("printer" or "destructor"). -# Dispatch on TYPE. +# b4_symbol_actions(ACTION, [KIND = yykind]) +# ------------------------------------------ +# Emit the symbol actions for ACTION ("destructor" or "printer"). +# Dispatch on KIND. m4_define([b4_symbol_actions], [m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl m4_ifval(m4_defn([b4_actions_]), -[switch (m4_default([$2], [yytype])) +[switch (m4_default([$2], [yykind])) { m4_defn([b4_actions_])[]dnl default: break; }dnl ], -[YYUSE (m4_default([$2], [yytype]));])dnl +[YYUSE (m4_default([$2], [yykind]));])dnl m4_popdef([b4_actions_])dnl ]) @@ -507,13 +557,14 @@ m4_define([b4_symbol_map], # b4_token_visible_if(NUM, IF-TRUE, IF-FALSE) # ------------------------------------------- -# Whether NUM denotes a token that has an exported definition (i.e., -# shows in enum yytokentype). +# Whether NUM denotes a token kind that has an exported definition +# (i.e., shows in enum yytokentype). m4_define([b4_token_visible_if], [b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id], [$2], [$3])], [$3])]) + # b4_token_has_definition(NUM) # ---------------------------- # 1 if NUM is visible, nothing otherwise. @@ -530,12 +581,26 @@ m4_define([b4_any_token_visible_if], # b4_token_format(FORMAT, NUM) # ---------------------------- +# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER. m4_define([b4_token_format], [b4_token_visible_if([$2], [m4_format([[$1]], - m4_quote(b4_symbol([$2], [id])), - m4_quote(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])]) + m4_expand(b4_symbol([$2], [id])), + m4_expand(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])]) + + +# b4_last_enum_token +# ------------------ +# The code of the last token visible token. +m4_define([_b4_last_enum_token], +[b4_token_visible_if([$1], + [m4_define([b4_last_enum_token], [$1])])]) +b4_symbol_foreach([_b4_last_enum_token]) +# b4_last_symbol +# -------------- +# The code of the last symbol. +m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1)) ## ------- ## ## Types. ## @@ -603,7 +668,7 @@ m4_define([b4_sync_end], [ b4_comment([$2:$1])] # This generates dependencies on the Bison skeletons hence lots of # useless 'git diff'. This location is useless for the regular # user (who does not care about the skeletons) and is actually not -# useful for Bison developpers too (I, Akim, never used this to locate +# useful for Bison developers too (I, Akim, never used this to locate # the code in skeletons that generated output). So disable it # completely. If someone thinks this was actually useful, a %define # variable should be provided to control the level of verbosity of @@ -1016,21 +1081,23 @@ m4_define([b4_bison_locations_if], [b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])]) -# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT]) + +# %define parse.error "(custom|detailed|simple|verbose)" # ------------------------------------------------------ -# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and -# b4_error_verbose_flag. b4_percent_define_default([[parse.error]], [[simple]]) b4_percent_define_check_values([[[[parse.error]], - [[simple]], [[verbose]]]]) -m4_define([b4_error_verbose_flag], - [m4_case(b4_percent_define_get([[parse.error]]), - [simple], [[0]], - [verbose], [[1]])]) -b4_define_flag_if([error_verbose]) + [[custom]], [[detailed]], [[simple]], [[verbose]]]]) + +# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE) +# ---------------------------------------------------------- +m4_define([b4_parse_error_case], +[m4_case(b4_percent_define_get([[parse.error]]), $@)]) + +# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE) +# ------------------------------------------------------------------ +m4_define([b4_parse_error_bmatch], +[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)]) -# yytoken_table is needed to support verbose errors. -b4_error_verbose_if([m4_define([b4_token_table_flag], [1])]) # b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) @@ -1116,3 +1183,11 @@ b4_percent_define_ifdef([api.value.type], # api.value.union.name. b4_percent_define_check_kind([api.value.union.name], [keyword]) + +# parse.error (custom|detailed) >< token-table. +b4_token_table_if( +[b4_parse_error_bmatch([custom\|detailed], +[b4_complain_at(b4_percent_define_get_loc([parse.error]), + [['%s' and '%s' cannot be used together]], + [%token-table], + [%define parse.error (custom|detailed)])])]) diff --git a/contrib/tools/bison/data/skeletons/c++.m4 b/contrib/tools/bison/data/skeletons/c++.m4 index c52f034c56..b862bf3ca7 100644 --- a/contrib/tools/bison/data/skeletons/c++.m4 +++ b/contrib/tools/bison/data/skeletons/c++.m4 @@ -22,6 +22,8 @@ b4_percent_define_ifdef([[api.value.union.name]], [b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]), [named %union is invalid in C++])]) +b4_percent_define_default([[api.symbol.prefix]], [[S_]]) + m4_include(b4_skeletonsdir/[c.m4]) b4_percent_define_check_kind([api.namespace], [code], [deprecated]) @@ -160,20 +162,42 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]), [::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])]) +## ------------- ## +## Token kinds. ## +## ------------- ## + + # b4_token_enums # -------------- -# Output the definition of the tokens as enums. +# Output the definition of the token kinds. m4_define([b4_token_enums], -[[enum yytokentype +[[enum token_kind_type { - ]m4_join([, - ], - b4_symbol_map([b4_token_enum]))[ - };]dnl + ]b4_symbol([-2], [id])[ = -2, +]b4_symbol_foreach([b4_token_enum])dnl +[ };]dnl ]) +## -------------- ## +## Symbol kinds. ## +## -------------- ## + +# b4_declare_symbol_enum +# ---------------------- +# The definition of the symbol internal numbers as an enum. +# Defining YYEMPTY here is important: it forces the compiler +# to use a signed type, which matters for yytoken. +m4_define([b4_declare_symbol_enum], +[[enum symbol_kind_type + { + YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens. + ]b4_symbol_kind([-2])[ = -2, +]b4_symbol_foreach([ b4_symbol_enum])dnl +[ };]]) + + ## ----------------- ## ## Semantic Values. ## @@ -231,23 +255,31 @@ m4_define([b4_public_types_declare], location_type location;])[ }; - /// Tokens. + /// Token kinds. struct token { ]b4_token_enums[ + /// Backward compatibility alias (Bison 3.6). + typedef token_kind_type yytokentype; }; - /// (External) token type, as returned by yylex. - typedef token::yytokentype token_type; + /// Token kind, as returned by yylex. + typedef token::yytokentype token_kind_type; + + /// Backward compatibility alias (Bison 3.6). + typedef token_kind_type token_type; - /// Symbol type: an internal symbol number. - typedef int symbol_number_type; + /// Symbol kinds. + struct symbol_kind + { + ]b4_declare_symbol_enum[ + }; - /// The symbol type number to denote an empty symbol. - enum { empty_symbol = -2 }; + /// (Internal) symbol kind. + typedef symbol_kind::symbol_kind_type symbol_kind_type; - /// Internal symbol number for tokens (subsumed by symbol_number_type). - typedef ]b4_int_type_for([b4_translate])[ token_number_type; + /// The number of tokens. + static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS; ]]) @@ -258,8 +290,8 @@ m4_define([b4_public_types_declare], m4_define([b4_symbol_type_define], [[ /// A complete symbol. /// - /// Expects its Base type to provide access to the symbol type - /// via type_get (). + /// Expects its Base type to provide access to the symbol kind + /// via kind (). /// /// Provide access to semantic value]b4_locations_if([ and location])[. template <typename Base> @@ -276,7 +308,14 @@ m4_define([b4_symbol_type_define], #if 201103L <= YY_CPLUSPLUS /// Move constructor. - basic_symbol (basic_symbol&& that); + basic_symbol (basic_symbol&& that) + : Base (std::move (that)) + , value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([ + , location (std::move (that.location))])[ + {]b4_variant_if([ + b4_symbol_variant([this->kind ()], [value], [move], + [std::move (that.value)]) + ])[} #endif /// Copy constructor. @@ -303,21 +342,47 @@ m4_define([b4_symbol_type_define], void clear () {]b4_variant_if([[ // User destructor. - symbol_number_type yytype = this->type_get (); + symbol_kind_type yykind = this->kind (); basic_symbol<Base>& yysym = *this; (void) yysym; - switch (yytype) + switch (yykind) { ]b4_symbol_foreach([b4_symbol_destructor])dnl [ default: break; } - // Type destructor. -]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[ + // Value type destructor. +]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[ Base::clear (); } +]b4_parse_error_bmatch( +[custom\|detailed], +[[ /// The user-facing name of this symbol. + const char *name () const YY_NOEXCEPT + { + return ]b4_parser_class[::symbol_name (this->kind ()); + }]], +[simple], +[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ + /// The user-facing name of this symbol. + const char *name () const YY_NOEXCEPT + { + return ]b4_parser_class[::symbol_name (this->kind ()); + } +#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ +]], +[verbose], +[[ /// The user-facing name of this symbol. + std::string name () const YY_NOEXCEPT + { + return ]b4_parser_class[::symbol_name (this->kind ()); + }]])[ + + /// Backward compatibility (Bison 3.6). + symbol_kind_type type_get () const YY_NOEXCEPT; + /// Whether empty. bool empty () const YY_NOEXCEPT; @@ -338,46 +403,51 @@ m4_define([b4_symbol_type_define], }; /// Type access provider for token (enum) based symbols. - struct by_type + struct by_kind { /// Default constructor. - by_type (); + by_kind (); #if 201103L <= YY_CPLUSPLUS /// Move constructor. - by_type (by_type&& that); + by_kind (by_kind&& that); #endif /// Copy constructor. - by_type (const by_type& that); + by_kind (const by_kind& that); - /// The symbol type as needed by the constructor. - typedef token_type kind_type; + /// The symbol kind as needed by the constructor. + typedef token_kind_type kind_type; /// Constructor from (external) token numbers. - by_type (kind_type t); + by_kind (kind_type t); /// Record that this symbol is empty. void clear (); - /// Steal the symbol type from \a that. - void move (by_type& that); + /// Steal the symbol kind from \a that. + void move (by_kind& that); /// The (internal) type number (corresponding to \a type). /// \a empty when empty. - symbol_number_type type_get () const YY_NOEXCEPT; + symbol_kind_type kind () const YY_NOEXCEPT; - /// The symbol type. - /// \a empty_symbol when empty. - /// An int, not token_number_type, to be able to store empty_symbol. - int type; + /// Backward compatibility (Bison 3.6). + symbol_kind_type type_get () const YY_NOEXCEPT; + + /// The symbol kind. + /// \a ]b4_symbol_prefix[YYEMPTY when empty. + symbol_kind_type kind_; }; + /// Backward compatibility for a private implementation detail (Bison 3.6). + typedef by_kind by_type; + /// "External" symbols: returned by the scanner. - struct symbol_type : basic_symbol<by_type> + struct symbol_type : basic_symbol<by_kind> {]b4_variant_if([[ /// Superclass. - typedef basic_symbol<by_type> super_type; + typedef basic_symbol<by_kind> super_type; /// Empty symbol. symbol_type () {} @@ -393,25 +463,13 @@ m4_define([b4_symbol_type_define], # Provide the implementation needed by the public types. m4_define([b4_public_types_define], [[ // basic_symbol. -#if 201103L <= YY_CPLUSPLUS - template <typename Base> - ]b4_parser_class[::basic_symbol<Base>::basic_symbol (basic_symbol&& that) - : Base (std::move (that)) - , value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([ - , location (std::move (that.location))])[ - {]b4_variant_if([ - b4_symbol_variant([this->type_get ()], [value], [move], - [std::move (that.value)]) - ])[} -#endif - template <typename Base> ]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that) : Base (that) , value (]b4_variant_if([], [that.value]))b4_locations_if([ , location (that.location)])[ {]b4_variant_if([ - b4_symbol_variant([this->type_get ()], [value], [copy], + b4_symbol_variant([this->kind ()], [value], [copy], [YY_MOVE (that.value)]) ])[} @@ -436,13 +494,20 @@ m4_define([b4_public_types_define], , location (YY_MOVE (l))])[ {]b4_variant_if([[ (void) v; - ]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[ + ]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[ + + template <typename Base> + ]b4_parser_class[::symbol_kind_type + ]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT + { + return this->kind (); + } template <typename Base> bool ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT { - return Base::type_get () == empty_symbol; + return this->kind () == symbol_kind::]b4_symbol_prefix[YYEMPTY; } template <typename Base> @@ -450,50 +515,56 @@ m4_define([b4_public_types_define], ]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s) { super_type::move (s); - ]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move], + ]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move], [YY_MOVE (s.value)])], [value = YY_MOVE (s.value);])[]b4_locations_if([ location = YY_MOVE (s.location);])[ } - // by_type. - ]b4_inline([$1])b4_parser_class[::by_type::by_type () - : type (empty_symbol) + // by_kind. + ]b4_inline([$1])b4_parser_class[::by_kind::by_kind () + : kind_ (symbol_kind::]b4_symbol_prefix[YYEMPTY) {} #if 201103L <= YY_CPLUSPLUS - ]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that) - : type (that.type) + ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) + : kind_ (that.kind_) { that.clear (); } #endif - ]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that) - : type (that.type) + ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) + : kind_ (that.kind_) {} - ]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t) - : type (yytranslate_ (t)) + ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) + : kind_ (yytranslate_ (t)) {} ]b4_inline([$1])[void - ]b4_parser_class[::by_type::clear () + ]b4_parser_class[::by_kind::clear () { - type = empty_symbol; + kind_ = symbol_kind::]b4_symbol_prefix[YYEMPTY; } ]b4_inline([$1])[void - ]b4_parser_class[::by_type::move (by_type& that) + ]b4_parser_class[::by_kind::move (by_kind& that) { - type = that.type; + kind_ = that.kind_; that.clear (); } - ]b4_inline([$1])[int - ]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT + ]b4_inline([$1])[]b4_parser_class[::symbol_kind_type + ]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT + { + return kind_; + } + + ]b4_inline([$1])[]b4_parser_class[::symbol_kind_type + ]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT { - return type; + return this->kind (); } ]]) @@ -510,15 +581,15 @@ m4_define([b4_token_constructor_define], []) # Define yytranslate_. Sometimes used in the header file ($1=hh), # sometimes in the cc file. m4_define([b4_yytranslate_define], -[ b4_inline([$1])b4_parser_class[::token_number_type +[ b4_inline([$1])b4_parser_class[::symbol_kind_type ]b4_parser_class[::yytranslate_ (int t) { ]b4_api_token_raw_if( -[[ return static_cast<token_number_type> (t);]], +[[ return static_cast<symbol_kind_type> (t);]], [[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to // TOKEN-NUM as returned by yylex. static - const token_number_type + const ]b4_int_type_for([b4_translate])[ translate_table[] = { ]b4_translate[ @@ -526,11 +597,11 @@ m4_define([b4_yytranslate_define], const int user_token_number_max_ = ]b4_user_token_number_max[; if (t <= 0) - return yyeof_; + return symbol_kind::]b4_symbol_prefix[YYEOF; else if (t <= user_token_number_max_) - return translate_table[t]; + return YY_CAST (symbol_kind_type, translate_table[t]); else - return yy_undef_token_;]])[ + return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[ } ]]) diff --git a/contrib/tools/bison/data/skeletons/c-like.m4 b/contrib/tools/bison/data/skeletons/c-like.m4 index e0460d4834..1e5ab02c8a 100644 --- a/contrib/tools/bison/data/skeletons/c-like.m4 +++ b/contrib/tools/bison/data/skeletons/c-like.m4 @@ -17,15 +17,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. + # _b4_comment(TEXT, OPEN, CONTINUE, END) # -------------------------------------- # Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. # Avoid adding indentation to the first line, as the indentation comes # from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]). +# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close +# the comments before its end. # # Prefix all the output lines with PREFIX. m4_define([_b4_comment], -[$2[]m4_bpatsubst(m4_expand([[$1]]), [ +[$2[]b4_gsub(m4_expand([$1]), + [[*]/], [*\\/], + [/[*]], [/\\*], + [ \(.\)], [ $3\1])$4]) diff --git a/contrib/tools/bison/data/skeletons/c.m4 b/contrib/tools/bison/data/skeletons/c.m4 index 0987ef777a..3c6daef23a 100644 --- a/contrib/tools/bison/data/skeletons/c.m4 +++ b/contrib/tools/bison/data/skeletons/c.m4 @@ -101,6 +101,7 @@ m4_define_default([b4_prefix], [b4_api_prefix]) b4_percent_define_default([[api.value.union.name]], [b4_api_PREFIX[][STYPE]]) +b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]]) ## ------------------------ ## ## Pure/impure interfaces. ## @@ -129,6 +130,13 @@ m4_define([b4_user_args], [m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])]) +# b4_user_formals +# --------------- +# The possible parse-params formal arguments preceded by a comma. +m4_define([b4_user_formals], +[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])]) + + # b4_parse_param # -------------- # If defined, b4_parse_param arrives double quoted, but below we prefer @@ -197,7 +205,11 @@ m4_define([b4_c99_int_type], # Define private types suitable for holding small integers in C99 or later. m4_define([b4_c99_int_type_define], [m4_copy_force([b4_c99_int_type], [b4_int_type])dnl -[/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure +[#ifdef short +# undef short +#endif + +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure <limits.h> and (if available) <stdint.h> are included so that the code can choose integer types of a good width. */ @@ -253,6 +265,50 @@ typedef int yytype_uint16; #endif]]) +# b4_sizes_types_define +# --------------------- +# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM, +# and YYSIZEOF. +m4_define([b4_sizes_types_define], +[[#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned +# endif +#endif + +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) +]]) + + # b4_int_type_for(NAME) # --------------------- # Return a narrow int type able to handle numbers ranging from @@ -418,9 +474,22 @@ static const b4_int_type_for([$2]) yy$1[[]] = ]) -## ------------------------- ## -## Assigning token numbers. ## -## ------------------------- ## +## ------------- ## +## Token kinds. ## +## ------------- ## + +# Because C enums are not scoped, because tokens are exposed in the +# header, and because these tokens are common to all the parsers, we +# need to make sure their names don't collide: use the api.prefix. +# YYEOF is special, since the user may give it a different name. +m4_define([b4_symbol(-2, id)], [b4_api_PREFIX[][EMPTY]]) +m4_define([b4_symbol(-2, tag)], [[No symbol.]]) + +m4_if(b4_symbol(0, id), [YYEOF], + [m4_define([b4_symbol(0, id)], [b4_api_PREFIX[][EOF]])]) +m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][error]]) +m4_define([b4_symbol(2, id)], [b4_api_PREFIX[][UNDEF]]) + # b4_token_define(TOKEN-NUM) # -------------------------- @@ -432,7 +501,7 @@ m4_define([b4_token_define], # ---------------- # Output the definition of the tokens. m4_define([b4_token_defines], -[b4_any_token_visible_if([/* Tokens. */ +[b4_any_token_visible_if([/* Token kinds. */ m4_join([ ], b4_symbol_map([b4_token_define])) ])]) @@ -442,34 +511,81 @@ m4_join([ # ------------------------ # Output the definition of this token as an enum. m4_define([b4_token_enum], -[b4_token_format([%s = %s], [$1])]) +[b4_token_visible_if([$1], + [m4_format([ %-30s %s], + m4_format([[%s = %s%s%s]], + b4_symbol([$1], [id]), + b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])), + m4_if([$1], b4_last_enum_token, [], [[,]])), + [b4_symbol_tag_comment([$1])])])]) # b4_token_enums # -------------- -# Output the definition of the tokens (if there are) as enums. +# The definition of the token kinds. m4_define([b4_token_enums], -[b4_any_token_visible_if([[/* Token type. */ +[b4_any_token_visible_if([[/* Token kinds. */ #ifndef ]b4_api_PREFIX[TOKENTYPE # define ]b4_api_PREFIX[TOKENTYPE enum ]b4_api_prefix[tokentype { - ]m4_join([, - ], - b4_symbol_map([b4_token_enum]))[ - }; + ]b4_symbol([-2], [id])[ = -2, +]b4_symbol_foreach([b4_token_enum])dnl +[ }; + typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t; #endif ]])]) # b4_token_enums_defines # ---------------------- -# Output the definition of the tokens (if there are any) as enums and, +# The definition of the tokens (if there are any) as enums and, # if POSIX Yacc is enabled, as #defines. m4_define([b4_token_enums_defines], [b4_token_enums[]b4_yacc_if([b4_token_defines])]) +# b4_symbol_translate(STRING) +# --------------------------- +# Used by "bison" in the array of symbol names to mark those that +# require translation. +m4_define([b4_symbol_translate], +[[N_($1)]]) + + + +## -------------- ## +## Symbol kinds. ## +## -------------- ## + +# b4_symbol_enum(SYMBOL-NUM) +# -------------------------- +# Output the definition of this symbol as an enum. +m4_define([b4_symbol_enum], +[m4_format([ %-40s %s], + m4_format([[%s = %s%s%s]], + b4_symbol([$1], [kind]), + [$1], + m4_if([$1], b4_last_symbol, [], [[,]])), + [b4_symbol_tag_comment([$1])])]) + + +# b4_declare_symbol_enum +# ---------------------- +# The definition of the symbol internal numbers as an enum. +# Defining YYEMPTY here is important: it forces the compiler +# to use a signed type, which matters for yytoken. +m4_define([b4_declare_symbol_enum], +[[/* Symbol kind. */ +enum yysymbol_kind_t +{ + ]b4_symbol_kind([-2])[ = -2, +]b4_symbol_foreach([b4_symbol_enum])dnl +[}; +typedef enum yysymbol_kind_t yysymbol_kind_t; +]])]) + + ## ----------------- ## ## Semantic Values. ## ## ----------------- ## @@ -493,15 +609,6 @@ m4_define([b4_symbol_value], ## ---------------------- ## -# b4_function_define(NAME, RETURN-VALUE, [DECL1, NAME1], ...) -# ----------------------------------------------------------- -# Declare the function NAME in C. -m4_define([b4_function_define], -[$2 -$1 (b4_formals(m4_shift2($@)))[]dnl -]) - - # b4_formals([DECL1, NAME1], ...) # ------------------------------- # The formal arguments of a C function definition. @@ -515,21 +622,6 @@ m4_define([b4_formal], -## ----------------------- ## -## Declaring C functions. ## -## ----------------------- ## - - -# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...) -# ------------------------------------------------------------ -# Declare the function NAME. -m4_define([b4_function_declare], -[$2 $1 (b4_formals(m4_shift2($@)));[]dnl -]) - - - - ## --------------------- ## ## Calling C functions. ## ## --------------------- ## @@ -593,18 +685,15 @@ m4_define_default([b4_yydestruct_define], | Release the memory associated to this symbol. | `-----------------------------------------------*/ -]b4_function_define([yydestruct], - [static void], - [[const char *yymsg], [yymsg]], - [[int yytype], [yytype]], - [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl -b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl -m4_ifset([b4_parse_param], [, b4_parse_param]))[ +static void +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl +[[, YYLTYPE *yylocationp]])[]b4_user_formals[) { ]b4_parse_param_use([yyvaluep], [yylocationp])dnl [ if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN ]b4_symbol_actions([destructor])[ @@ -622,13 +711,10 @@ m4_define_default([b4_yy_symbol_print_define], | Print this symbol's value on YYO. | `-----------------------------------*/ -]b4_function_define([yy_symbol_value_print], - [static void], - [[FILE *yyo], [yyo]], - [[int yytype], [yytype]], - [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl -b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl -m4_ifset([b4_parse_param], [, b4_parse_param]))[ +static void +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl +[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[) { FILE *yyoutput = yyo; ]b4_parse_param_use([yyoutput], [yylocationp])dnl @@ -637,8 +723,8 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[ dnl glr.c does not feature yytoknum. m4_if(b4_skeleton, ["yacc.c"], [[# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif ]])dnl b4_percent_code_get([[pre-printer]])dnl @@ -653,21 +739,18 @@ b4_percent_code_get([[post-printer]])dnl | Print this symbol on YYO. | `---------------------------*/ -]b4_function_define([yy_symbol_print], - [static void], - [[FILE *yyo], [yyo]], - [[int yytype], [yytype]], - [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl -b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl -m4_ifset([b4_parse_param], [, b4_parse_param]))[ +static void +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl +[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[) { YYFPRINTF (yyo, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); ]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp); YYFPRINTF (yyo, ": "); ])dnl -[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl +[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl b4_locations_if([, yylocationp])[]b4_user_args[); YYFPRINTF (yyo, ")"); }]dnl @@ -693,11 +776,11 @@ m4_define([b4_symbol_type_register], [m4_define([b4_symbol($1, type_tag)], [b4_symbol_if([$1], [has_id], [b4_symbol([$1], [id])], - [yytype_[]b4_symbol([$1], [number])])])dnl + [yykind_[]b4_symbol([$1], [number])])])dnl m4_append([b4_union_members], -m4_expand([ - b4_symbol_tag_comment([$1])dnl - b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);])) +m4_expand([m4_format([ %-40s %s], + m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]), + [b4_symbol_tag_comment([$1])])])) ]) @@ -930,16 +1013,14 @@ m4_define([b4_yy_location_print_define], This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ -#ifndef YY_LOCATION_PRINT -# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL +# ifndef YY_LOCATION_PRINT +# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED -]b4_function_define([yy_location_print_], - [static int], - [[FILE *yyo], [yyo]], - [[YYLTYPE const * const yylocp], [yylocp]])[ +static int +yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { int res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; @@ -963,17 +1044,17 @@ YY_ATTRIBUTE_UNUSED return res; } -# define YY_LOCATION_PRINT(File, Loc) \ +# define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif]], +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +# endif /* !defined YY_LOCATION_PRINT */]], [[/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif]]) +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif]]) ]) # b4_yyloc_default diff --git a/contrib/tools/bison/data/skeletons/glr.cc b/contrib/tools/bison/data/skeletons/glr.cc index 887b6146b4..658b9f20ca 100644 --- a/contrib/tools/bison/data/skeletons/glr.cc +++ b/contrib/tools/bison/data/skeletons/glr.cc @@ -66,30 +66,29 @@ m4_defn([b4_parse_param]))], [[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]]) ]) +# b4_declare_symbol_enum +# ---------------------- +m4_append([b4_declare_symbol_enum], +[[typedef symbol_kind_type yysymbol_kind_t; +]]) + # b4_yy_symbol_print_define # ------------------------- # Bypass the default implementation to generate the "yy_symbol_print" # and "yy_symbol_value_print" functions. m4_define([b4_yy_symbol_print_define], -[[ -/*--------------------. +[[/*--------------------. | Print this symbol. | `--------------------*/ -]b4_function_define([yy_symbol_print], - [static void], - [[FILE *], []], - [[int yytype], [yytype]], - [[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep], - [yyvaluep]][]dnl -b4_locations_if([, - [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], - [yylocationp]]]), - b4_parse_param)[ +static void +yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken, + const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep]b4_locations_if([[, + const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[) { ]b4_parse_param_use[]dnl -[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[); +[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[); } ]])[ @@ -101,45 +100,24 @@ m4_defn([b4_initial_action])]))])[ # Hijack the post prologue to declare yyerror. ]m4_append([b4_post_prologue], [b4_syncline([@oline@], [@ofile@])dnl -b4_function_declare([yyerror], - [static void],b4_locations_if([ - [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], - [yylocationp]],]) - b4_parse_param, - [[const char* msg], [msg]])])[ - - -#undef yynerrs -#undef yychar -#undef yylval]b4_locations_if([ -#undef yylloc]) - -m4_if(b4_prefix, [yy], [], -[[/* Substitute the variable and function names. */ -#define yyparse ]b4_prefix[parse -#define yylex ]b4_prefix[lex -#define yyerror ]b4_prefix[error -#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[ -#define yylval ]b4_prefix[lval -#define yychar ]b4_prefix[char -#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[ -#define yylloc ]b4_prefix[lloc]])])) +[static void +yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp, + ]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param), + ])[const char* msg);]])[ # Hijack the epilogue to define implementations (yyerror, parser member # functions etc.). -m4_append([b4_epilogue], +]m4_append([b4_epilogue], [b4_syncline([@oline@], [@ofile@])dnl [ /*------------------. | Report an error. | `------------------*/ -]b4_function_define([yyerror], - [static void],b4_locations_if([ - [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], - [yylocationp]],]) - b4_parse_param, - [[const char* msg], [msg]])[ +static void +yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp, + ]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param), + ])[const char* msg) { ]b4_parse_param_use[]dnl [ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg); @@ -181,9 +159,9 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl `--------------------*/ void - ]b4_parser_class[::yy_symbol_value_print_ (int yytype, + ]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind, const semantic_type* yyvaluep]b4_locations_if([[, - const location_type* yylocationp]])[) + const location_type* yylocationp]])[) const {]b4_locations_if([[ YYUSE (yylocationp);]])[ YYUSE (yyvaluep); @@ -195,14 +173,14 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl void - ]b4_parser_class[::yy_symbol_print_ (int yytype, + ]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind, const semantic_type* yyvaluep]b4_locations_if([[, - const location_type* yylocationp]])[) + const location_type* yylocationp]])[) const { - *yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm") - << ' ' << yytname[yytype] << " ("]b4_locations_if([[ + *yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm") + << ' ' << yytname[yykind] << " ("]b4_locations_if([[ << *yylocationp << ": "]])[; - yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[, yylocationp]])[); + yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[); *yycdebug_ << ')'; } @@ -238,6 +216,53 @@ b4_namespace_close[]dnl ]) +# b4_glr_cc_setup +# --------------- +# Setup redirections for glr.c: Map the names used in c.m4 to the ones used +# in c++.m4. +m4_define([b4_glr_cc_setup], +[[#undef ]b4_symbol(-2, [id])[ +#define ]b4_symbol(-2, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[ +#undef ]b4_symbol(0, [id])[ +#define ]b4_symbol(0, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[ +#undef ]b4_symbol(1, [id])[ +#define ]b4_symbol(1, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(1, [id])[ + +#ifndef ]b4_api_PREFIX[STYPE +# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type +#endif +#ifndef ]b4_api_PREFIX[LTYPE +# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type +#endif + +typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t; +#define ]b4_symbol_prefix[YYEMPTY ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY +#define ]b4_symbol_prefix[YYerror ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror +#define ]b4_symbol_prefix[YYEOF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF +#define ]b4_symbol_prefix[YYUNDEF ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF +]]) + + +# b4_glr_cc_cleanup +# ----------------- +# Remove redirections for glr.c. +m4_define([b4_glr_cc_cleanup], +[b4_percent_define_flag_if([[global_tokens_and_yystype]], [], +[[#undef ]b4_symbol(-2, [id])[ +#undef ]b4_symbol(0, [id])[ +#undef ]b4_symbol(1, [id])[ +]])[ + +#undef ]b4_api_PREFIX[STYPE +#undef ]b4_api_PREFIX[LTYPE + +#undef ]b4_symbol_prefix[YYEMPTY +#undef ]b4_symbol_prefix[YYerror +#undef ]b4_symbol_prefix[YYEOF +#undef ]b4_symbol_prefix[YYUNDEF +]]) + + # b4_shared_declarations(hh|cc) # ----------------------------- # Declaration that might either go into the header (if --defines, $1 = hh) @@ -328,21 +353,21 @@ b4_percent_code_get([[requires]])[ # if ]b4_api_PREFIX[DEBUG public: /// \brief Report a symbol value on the debug stream. - /// \param yytype The token type. + /// \param yykind The symbol kind. /// \param yyvaluep Its semantic value.]b4_locations_if([[ /// \param yylocationp Its location.]])[ - virtual void yy_symbol_value_print_ (int yytype, + virtual void yy_symbol_value_print_ (symbol_kind_type yykind, const semantic_type* yyvaluep]b4_locations_if([[, - const location_type* yylocationp]])[); + const location_type* yylocationp]])[) const; /// \brief Report a symbol on the debug stream. - /// \param yytype The token type. + /// \param yykind The symbol kind. /// \param yyvaluep Its semantic value.]b4_locations_if([[ /// \param yylocationp Its location.]])[ - virtual void yy_symbol_print_ (int yytype, + virtual void yy_symbol_print_ (symbol_kind_type yykind, const semantic_type* yyvaluep]b4_locations_if([[, - const location_type* yylocationp]])[); + const location_type* yylocationp]])[) const; private: - // Debugging. + /// Debug stream. std::ostream* yycdebug_; #endif @@ -351,21 +376,15 @@ b4_percent_code_get([[requires]])[ ]dnl Redirections for glr.c. b4_percent_define_flag_if([[global_tokens_and_yystype]], -[b4_token_defines]) -[ -#ifndef ]b4_api_PREFIX[STYPE -# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type -#endif -#ifndef ]b4_api_PREFIX[LTYPE -# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type -#endif - +[b4_token_defines +])[ ]b4_namespace_close[ + ]b4_percent_code_get([[provides]])[ ]m4_popdef([b4_parse_param])dnl -]) +])[ -b4_defines_if( +]b4_defines_if( [b4_output_begin([b4_spec_header_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C++], [2002-2015, 2018-2020])[ diff --git a/contrib/tools/bison/data/skeletons/lalr1.cc b/contrib/tools/bison/data/skeletons/lalr1.cc index dc674a2d60..dfffb74b8e 100644 --- a/contrib/tools/bison/data/skeletons/lalr1.cc +++ b/contrib/tools/bison/data/skeletons/lalr1.cc @@ -30,6 +30,15 @@ m4_define([b4_lac_flag], [none], [[0]], [[1]])]) +# b4_tname_if(TNAME-NEEDED, TNAME-NOT-NEEDED) +# ------------------------------------------- +m4_define([b4_tname_if], +[m4_case(b4_percent_define_get([[parse.error]]), + [verbose], [$1], + [b4_token_table_if([$1], + [$2])])]) + + # b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT) # -------------------------------------------------------------- # Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT. @@ -195,6 +204,13 @@ m4_define([b4_shared_declarations], ]b4_parser_class[ (]b4_parse_param_decl[); virtual ~]b4_parser_class[ (); +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + ]b4_parser_class[ (const ]b4_parser_class[&) = delete; + /// Non copyable. + ]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete; +#endif + /// Parse. An alias for parse (). /// \returns 0 iff parsing succeeded. int operator() (); @@ -225,19 +241,57 @@ m4_define([b4_shared_declarations], /// Report a syntax error. void error (const syntax_error& err); -]b4_token_constructor_define[ +]b4_parse_error_bmatch( +[custom\|detailed], +[[ /// The user-facing name of the symbol whose (internal) number is + /// YYSYMBOL. No bounds checking. + static const char *symbol_name (symbol_kind_type yysymbol);]], +[simple], +[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ + /// The user-facing name of the symbol whose (internal) number is + /// YYSYMBOL. No bounds checking. + static const char *symbol_name (symbol_kind_type yysymbol); +#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ +]], +[verbose], +[[ /// The user-facing name of the symbol whose (internal) number is + /// YYSYMBOL. No bounds checking. + static std::string symbol_name (symbol_kind_type yysymbol);]])[ +]b4_token_constructor_define[ +]b4_parse_error_bmatch([custom\|detailed\|verbose], [[ + class context + { + public: + context (const ]b4_parser_class[& yyparser, const symbol_type& yyla); + const symbol_type& lookahead () const { return yyla_; } + symbol_kind_type token () const { return yyla_.kind (); }]b4_locations_if([[ + const location_type& location () const { return yyla_.location; } +]])[ + /// Put in YYARG at most YYARGN of the expected tokens, and return the + /// number of tokens stored in YYARG. If YYARG is null, return the + /// number of expected tokens (guaranteed to be less than YYNTOKENS). + int expected_tokens (symbol_kind_type yyarg[], int yyargn) const; + + private: + const ]b4_parser_class[& yyparser_; + const symbol_type& yyla_; + }; +]])[ private: - /// This class is not copyable. +#if YY_CPLUSPLUS < 201103L + /// Non copyable. ]b4_parser_class[ (const ]b4_parser_class[&); - ]b4_parser_class[& operator= (const ]b4_parser_class[&);]b4_lac_if([[ - + /// Non copyable. + ]b4_parser_class[& operator= (const ]b4_parser_class[&); +#endif +]b4_lac_if([[ /// Check the lookahead yytoken. /// \returns true iff the token will be eventually shifted. - bool yy_lac_check_ (int yytoken) const; + bool yy_lac_check_ (symbol_kind_type yytoken) const; /// Establish the initial context if no initial context currently exists. /// \returns true iff the token will be eventually shifted. - bool yy_lac_establish_ (int yytoken); + bool yy_lac_establish_ (symbol_kind_type yytoken); /// Discard any previous initial lookahead context because of event. /// \param event the event which caused the lookahead to be discarded. /// Only used for debbuging output. @@ -245,13 +299,19 @@ m4_define([b4_shared_declarations], /// Stored state numbers (used for stacks). typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ state_type; +]b4_parse_error_bmatch( + [custom], [[ + /// Report a syntax error + /// \param yyctx the context in which the error occurred. + void report_syntax_error (const context& yyctx) const;]], + [detailed\|verbose], [[ + /// The arguments of the error message. + int yy_syntax_error_arguments_ (const context& yyctx, + symbol_kind_type yyarg[], int yyargn) const; /// Generate an error message. - /// \param yystate the state where the error occurred. - /// \param yyla the lookahead token. - virtual std::string yysyntax_error_ (state_type yystate, - const symbol_type& yyla) const; - + /// \param yyctx the context in which the error occurred. + virtual std::string yysyntax_error_ (const context& yyctx) const;]])[ /// Compute post-reduction state. /// \param yystate the current state /// \param yysym the nonterminal to push on the stack @@ -268,34 +328,43 @@ m4_define([b4_shared_declarations], static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_; static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_; - /// Convert a scanner token number \a t to a symbol number. - /// In theory \a t should be a token_type, but character literals + /// Convert a scanner token kind \a t to a symbol kind. + /// In theory \a t should be a token_kind_type, but character literals /// are valid, yet not members of the token_type enum. - static token_number_type yytranslate_ (int t); + static symbol_kind_type yytranslate_ (int t); - // Tables. -]b4_parser_tables_declare[]b4_error_verbose_if([ - - /// Convert the symbol name \a n to a form suitable for a diagnostic. - static std::string yytnamerr_ (const char *n);])[ +]b4_parse_error_bmatch( +[simple], +[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ +]], +[verbose], +[[ /// Convert the symbol name \a n to a form suitable for a diagnostic. + static std::string yytnamerr_ (const char *yystr); -]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ /// For a symbol, its name in clear. static const char* const yytname_[]; -]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ +]])[ + + // Tables. +]b4_parser_tables_declare[ + +#if ]b4_api_PREFIX[DEBUG ]b4_integral_parser_table_declare([rline], [b4_rline], [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[ /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yy_reduce_print_ (int r); + virtual void yy_reduce_print_ (int r) const; /// Print the state stack on the debug stream. - virtual void yystack_print_ (); + virtual void yy_stack_print_ () const; /// Debugging level. int yydebug_; /// Debug stream. std::ostream* yycdebug_; - /// \brief Display a symbol type, value and location. + /// \brief Display a symbol kind, value and location. /// \param yyo The output stream. /// \param yysym The symbol. template <typename Base> @@ -316,7 +385,7 @@ m4_define([b4_shared_declarations], /// Default constructor. by_state () YY_NOEXCEPT; - /// The symbol type as needed by the constructor. + /// The symbol kind as needed by the constructor. typedef state_type kind_type; /// Constructor. @@ -328,12 +397,12 @@ m4_define([b4_shared_declarations], /// Record that this symbol is empty. void clear () YY_NOEXCEPT; - /// Steal the symbol type from \a that. + /// Steal the symbol kind from \a that. void move (by_state& that); - /// The (internal) type number (corresponding to \a state). - /// \a empty_symbol when empty. - symbol_number_type type_get () const YY_NOEXCEPT; + /// The symbol kind (corresponding to \a state). + /// \a ]b4_symbol(-2, kind)[ when empty. + symbol_kind_type kind () const YY_NOEXCEPT; /// The state number used to denote an empty symbol. /// We use the initial state, as it does not have a value. @@ -401,21 +470,16 @@ m4_define([b4_shared_declarations], /// Pop \a n symbols from the stack. void yypop_ (int n = 1); - /// Some specific tokens. - static const token_number_type yy_error_token_ = 1; - static const token_number_type yy_undef_token_ = ]b4_undef_token_number[; - /// Constants. enum { - yyeof_ = 0, yylast_ = ]b4_last[, ///< Last index in yytable_. yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols. - yyfinal_ = ]b4_final_state_number[, ///< Termination state number. - yyntokens_ = ]b4_tokens_number[ ///< Number of tokens. + yyfinal_ = ]b4_final_state_number[ ///< Termination state number. }; ]b4_parse_param_vars[ +]b4_percent_code_get([[yy_bison_internal_hook]])[ }; ]b4_token_ctor_if([b4_yytranslate_define([$1])[ @@ -484,6 +548,11 @@ m4_if(b4_prefix, [yy], [], # define YY_(msgid) msgid # endif #endif +]b4_has_translations_if([ +#ifndef N_ +# define N_(Msgid) Msgid +#endif +])[ // Whether we are compiled with exception support. #ifndef YY_EXCEPTIONS @@ -523,7 +592,7 @@ m4_if(b4_prefix, [yy], [], # define YY_STACK_PRINT() \ do { \ if (yydebug_) \ - yystack_print_ (); \ + yy_stack_print_ (); \ } while (false) #else // !]b4_api_PREFIX[DEBUG @@ -543,49 +612,7 @@ m4_if(b4_prefix, [yy], [], #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus_) -]b4_namespace_open[]b4_error_verbose_if([[ - - /* Return YYSTR after stripping away unnecessary quotes and - backslashes, so that it's suitable for yyerror. The heuristic is - that double-quoting is unnecessary unless the string contains an - apostrophe, a comma, or backslash (other than backslash-backslash). - YYSTR is taken from yytname. */ - std::string - ]b4_parser_class[::yytnamerr_ (const char *yystr) - { - if (*yystr == '"') - { - std::string yyr; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - else - goto append; - - append: - default: - yyr += *yyp; - break; - - case '"': - return yyr; - } - do_not_strip_quotes: ; - } - - return yystr; - } -]])[ - +]b4_namespace_open[ /// Build a parser object. ]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[) #if ]b4_api_PREFIX[DEBUG @@ -604,7 +631,7 @@ m4_if(b4_prefix, [yy], [], {} /*---------------. - | Symbol types. | + | symbol kinds. | `---------------*/ ]b4_token_ctor_if([], [b4_public_types_define([cc])])[ @@ -635,13 +662,13 @@ m4_if(b4_prefix, [yy], [], : state (s) {} - ]b4_parser_class[::symbol_number_type - ]b4_parser_class[::by_state::type_get () const YY_NOEXCEPT + ]b4_parser_class[::symbol_kind_type + ]b4_parser_class[::by_state::kind () const YY_NOEXCEPT { if (state == empty_state) - return empty_symbol; + return symbol_kind::]b4_symbol(-2, kind)[; else - return yystos_[+state]; + return YY_CAST (symbol_kind_type, yystos_[+state]); } ]b4_parser_class[::stack_symbol_type::stack_symbol_type () @@ -650,7 +677,7 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) : super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[) {]b4_variant_if([ - b4_symbol_variant([that.type_get ()], + b4_symbol_variant([that.kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[ #if 201103L <= YY_CPLUSPLUS // that is emptied. @@ -661,10 +688,10 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) : super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[) {]b4_variant_if([ - b4_symbol_variant([that.type_get ()], + b4_symbol_variant([that.kind ()], [value], [move], [YY_MOVE (that.value)])])[ // that is emptied. - that.type = empty_symbol; + that.kind_ = symbol_kind::]b4_symbol(-2, kind)[; } #if YY_CPLUSPLUS < 201103L @@ -672,7 +699,7 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type& that) { state = that.state; - ]b4_variant_if([b4_symbol_variant([that.type_get ()], + ]b4_variant_if([b4_symbol_variant([that.kind ()], [value], [copy], [that.value])], [[value = that.value;]])[]b4_locations_if([ location = that.location;])[ @@ -683,7 +710,7 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that) { state = that.state; - ]b4_variant_if([b4_symbol_variant([that.type_get ()], + ]b4_variant_if([b4_symbol_variant([that.kind ()], [value], [move], [that.value])], [[value = that.value;]])[]b4_locations_if([ location = that.location;])[ @@ -701,29 +728,27 @@ m4_if(b4_prefix, [yy], [], YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [ // User destructor. - b4_symbol_actions([destructor], [yysym.type_get ()])])[ + b4_symbol_actions([destructor], [yysym.kind ()])])[ } #if ]b4_api_PREFIX[DEBUG template <typename Base> void - ]b4_parser_class[::yy_print_ (std::ostream& yyo, - const basic_symbol<Base>& yysym) const + ]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const { std::ostream& yyoutput = yyo; YYUSE (yyoutput); - symbol_number_type yytype = yysym.type_get (); -#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ * 100 + __GNUC_MINOR__ <= 408 - // Avoid a (spurious) G++ 4.8 warning about "array subscript is - // below array bounds". if (yysym.empty ()) - std::abort (); -#endif - yyo << (yytype < yyntokens_ ? "token" : "nterm") - << ' ' << yytname_[yytype] << " ("]b4_locations_if([ - << yysym.location << ": "])[; - ]b4_symbol_actions([printer])[ - yyo << ')'; + yyo << "empty symbol"; + else + { + symbol_kind_type yykind = yysym.kind (); + yyo << (yykind < YYNTOKENS ? "token" : "nterm") + << ' ' << yysym.name () << " ("]b4_locations_if([ + << yysym.location << ": "])[; + ]b4_symbol_actions([printer])[ + yyo << ')'; + } } #endif @@ -782,11 +807,11 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class[::state_type ]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym) { - int yyr = yypgoto_[yysym - yyntokens_] + yystate; + int yyr = yypgoto_[yysym - YYNTOKENS] + yystate; if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) return yytable_[yyr]; else - return yydefgoto_[yysym - yyntokens_]; + return yydefgoto_[yysym - YYNTOKENS]; } bool @@ -854,6 +879,7 @@ b4_dollar_popdef])[]dnl `-----------------------------------------------*/ yynewstate: YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n'; + YY_STACK_PRINT (); // Accept? if (yystack_[0].state == yyfinal_) @@ -874,14 +900,14 @@ b4_dollar_popdef])[]dnl // Read a lookahead token. if (yyla.empty ()) { - YYCDEBUG << "Reading a token: "; + YYCDEBUG << "Reading a token\n"; #if YY_EXCEPTIONS try #endif // YY_EXCEPTIONS {]b4_token_ctor_if([[ symbol_type yylookahead (]b4_lex[); yyla.move (yylookahead);]], [[ - yyla.type = yytranslate_ (]b4_lex[);]])[ + yyla.kind_ = yytranslate_ (]b4_lex[);]])[ } #if YY_EXCEPTIONS catch (const syntax_error& yyexc) @@ -894,12 +920,22 @@ b4_dollar_popdef])[]dnl } YY_SYMBOL_PRINT ("Next token is", yyla); + if (yyla.kind () == ]symbol_kind::b4_symbol(1, kind)[) + { + // The scanner already issued an error message, process directly + // to error recovery. But do not keep the error token as + // lookahead, it is too special and may lead us to an endless + // loop in error recovery. */ + yyla.kind_ = ]symbol_kind::b4_symbol(2, kind)[; + goto yyerrlab1; + } + /* If the proper action on seeing token YYLA.TYPE is to reduce or to detect an error, take that action. */ - yyn += yyla.type_get (); - if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ()) + yyn += yyla.kind (); + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ()) {]b4_lac_if([[ - if (!yy_lac_establish_ (yyla.type_get ())) + if (!yy_lac_establish_ (yyla.kind ())) goto yyerrlab;]])[ goto yydefault; } @@ -910,7 +946,7 @@ b4_dollar_popdef])[]dnl { if (yy_table_value_is_error_ (yyn)) goto yyerrlab;]b4_lac_if([[ - if (!yy_lac_establish_ (yyla.type_get ())) + if (!yy_lac_establish_ (yyla.kind ())) goto yyerrlab; ]])[ yyn = -yyn; @@ -992,7 +1028,6 @@ b4_dollar_popdef])[]dnl YY_SYMBOL_PRINT ("-> $$ =", yylhs); yypop_ (yylen); yylen = 0; - YY_STACK_PRINT (); // Shift the result of the reduction. yypush_ (YY_NULLPTR, YY_MOVE (yylhs)); @@ -1007,9 +1042,17 @@ b4_dollar_popdef])[]dnl // If not already recovering from an error, report this error. if (!yyerrstatus_) { - ++yynerrs_; - error (]b4_join(b4_locations_if([yyla.location]), - [[yysyntax_error_ (yystack_[0].state, yyla)]])[); + ++yynerrs_;]b4_parse_error_case( + [simple], [[ + std::string msg = YY_("syntax error"); + error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]], + [custom], [[ + context yyctx (*this, yyla); + report_syntax_error (yyctx);]], + [[ + context yyctx (*this, yyla); + std::string msg = yysyntax_error_ (yyctx); + error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]])[ } ]b4_locations_if([[ @@ -1020,7 +1063,7 @@ b4_dollar_popdef])[]dnl error, discard it. */ // Return failure if at end of input. - if (yyla.type_get () == yyeof_) + if (yyla.kind () == symbol_kind::]b4_symbol_prefix[YYEOF) YYABORT; else if (!yyla.empty ()) { @@ -1046,6 +1089,7 @@ b4_dollar_popdef])[]dnl this YYERROR. */ yypop_ (yylen); yylen = 0; + YY_STACK_PRINT (); goto yyerrlab1; @@ -1054,31 +1098,33 @@ b4_dollar_popdef])[]dnl `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus_ = 3; // Each real token shifted decrements this. - { - stack_symbol_type error_token; - for (;;) - { - yyn = yypact_[+yystack_[0].state]; - if (!yy_pact_value_is_default_ (yyn)) - { - yyn += yy_error_token_; - if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } - } + // Pop stack until we find a state that shifts the error token. + for (;;) + { + yyn = yypact_[+yystack_[0].state]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += symbol_kind::]b4_symbol(1, kind)[; + if (0 <= yyn && yyn <= yylast_ + && yycheck_[yyn] == symbol_kind::]b4_symbol(1, kind)[) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } - // Pop the current state because it cannot handle the error token. - if (yystack_.size () == 1) - YYABORT; + // Pop the current state because it cannot handle the error token. + if (yystack_.size () == 1) + YYABORT; ]b4_locations_if([[ - yyerror_range[1].location = yystack_[0].location;]])[ - yy_destroy_ ("Error: popping", yystack_[0]); - yypop_ (); - YY_STACK_PRINT (); - } + yyerror_range[1].location = yystack_[0].location;]])[ + yy_destroy_ ("Error: popping", yystack_[0]); + yypop_ (); + YY_STACK_PRINT (); + } + { + stack_symbol_type error_token; ]b4_locations_if([[ yyerror_range[2].location = yyla.location; YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[ @@ -1117,6 +1163,7 @@ b4_dollar_popdef])[]dnl /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); + YY_STACK_PRINT (); while (1 < yystack_.size ()) { yy_destroy_ ("Cleanup: popping", yystack_[0]); @@ -1149,17 +1196,158 @@ b4_dollar_popdef])[]dnl { error (]b4_join(b4_locations_if([yyexc.location]), [[yyexc.what ()]])[); - }]b4_lac_if([[ + } +]b4_parse_error_bmatch([custom\|detailed], +[[ const char * + ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol) + { + static const char *const yy_sname[] = + { + ]b4_symbol_names[ + };]b4_has_translations_if([[ + /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is + internationalizable. */ + static ]b4_int_type_for([b4_translatable])[ yytranslatable[] = + { + ]b4_translatable[ + }; + return (yysymbol < YYNTOKENS && yytranslatable[yysymbol] + ? _(yy_sname[yysymbol]) + : yy_sname[yysymbol]);]], [[ + return yy_sname[yysymbol];]])[ + } +]], +[simple], +[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ + const char * + ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol) + { + return yytname_[yysymbol]; + } +#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ +]], +[verbose], +[[ /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + ]b4_parser_class[::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + else + goto append; + + append: + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + + std::string + ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol) + { + return yytnamerr_ (yytname_[yysymbol]); + } +]])[ + +]b4_parse_error_bmatch([custom\|detailed\|verbose], [[ + // ]b4_parser_class[::context. + ]b4_parser_class[::context::context (const ]b4_parser_class[& yyparser, const symbol_type& yyla) + : yyparser_ (yyparser) + , yyla_ (yyla) + {} + + int + ]b4_parser_class[::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const + { + // Actual number of expected tokens + int yycount = 0; +]b4_lac_if([[ +#if ]b4_api_PREFIX[DEBUG + // Execute LAC once. We don't care if it is successful, we + // only do it for the sake of debugging output. + if (!yyparser_.yy_lac_established_) + yyparser_.yy_lac_check_ (yyla_.kind ()); +#endif + + for (int yyx = 0; yyx < YYNTOKENS; ++yyx) + { + symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx); + if (yysym != symbol_kind::]b4_symbol(1, kind)[ + && yysym != symbol_kind::]b4_symbol_prefix[YYUNDEF + && yyparser_.yy_lac_check_ (yysym)) + { + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = yysym; + } + }]], [[ + int yyn = yypact_[+yyparser_.yystack_[0].state]; + if (!yy_pact_value_is_default_ (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + // Stay within bounds of both yycheck and yytname. + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::]b4_symbol(1, kind)[ + && !yy_table_value_is_error_ (yytable_[yyx + yyn])) + { + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx); + } + } +]])[ + if (yyarg && yycount == 0 && 0 < yyargn) + yyarg[0] = symbol_kind::]b4_symbol(-2, kind)[; + return yycount; + } + +]])b4_lac_if([[ bool - ]b4_parser_class[::yy_lac_check_ (int yytoken) const + ]b4_parser_class[::yy_lac_check_ (symbol_kind_type yytoken) const { // Logically, the yylac_stack's lifetime is confined to this function. // Clear it, to get rid of potential left-overs from previous call. yylac_stack_.clear (); // Reduce until we encounter a shift and thereby accept the token. #if ]b4_api_PREFIX[DEBUG - YYCDEBUG << "LAC: checking lookahead " << yytname_[yytoken] << ':'; + YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':'; #endif std::ptrdiff_t lac_top = 0; while (true) @@ -1223,14 +1411,14 @@ b4_dollar_popdef])[]dnl : yylac_stack_.back ()); // Push the resulting state of the reduction. state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]); - YYCDEBUG << " G" << state; + YYCDEBUG << " G" << int (state); yylac_stack_.push_back (state); } } // Establish the initial context if no initial context currently exists. bool - ]b4_parser_class[::yy_lac_establish_ (int yytoken) + ]b4_parser_class[::yy_lac_establish_ (symbol_kind_type yytoken) { /* Establish the initial context for the current lookahead if no initial context is currently established. @@ -1259,7 +1447,7 @@ b4_dollar_popdef])[]dnl { #if ]b4_api_PREFIX[DEBUG YYCDEBUG << "LAC: initial context established for " - << yytname_[yytoken] << '\n'; + << symbol_name (yytoken) << '\n'; #endif yy_lac_established_ = true; return yy_lac_check_ (yytoken); @@ -1288,22 +1476,12 @@ b4_dollar_popdef])[]dnl << evt << '\n'; yy_lac_established_ = false; } - }]])[ - - // Generate an error message. - std::string - ]b4_parser_class[::yysyntax_error_ (]dnl -b4_error_verbose_if([state_type yystate, const symbol_type& yyla], - [state_type, const symbol_type&])[) const - {]b4_error_verbose_if([[ - // Number of reported tokens (one for the "unexpected", one per - // "expected"). - std::ptrdiff_t yycount = 0; - // Its maximum. - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - // Arguments of yyformat. - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + }]])b4_parse_error_bmatch([detailed\|verbose], [[ + int + ]b4_parser_class[::yy_syntax_error_arguments_ (const context& yyctx, + symbol_kind_type yyarg[], int yyargn) const + { /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action @@ -1334,46 +1512,26 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], one exception: it will still contain any token that will not be accepted due to an error action in a later state.]])[ */ - if (!yyla.empty ()) - { - symbol_number_type yytoken = yyla.type_get (); - yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[ - -#if ]b4_api_PREFIX[DEBUG - // Execute LAC once. We don't care if it is successful, we - // only do it for the sake of debugging output. - if (!yy_lac_established_) - yy_lac_check_ (yytoken); -#endif]])[ - int yyn = yypact_[+yystate]; - if (!yy_pact_value_is_default_ (yyn)) - {]b4_lac_if([[ - for (int yyx = 0; yyx < yyntokens_; ++yyx) - if (yyx != yy_error_token_ && yyx != yy_undef_token_ - && yy_lac_check_ (yyx)) - {]], [[ - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - // Stay within bounds of both yycheck and yytname. - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != yy_error_token_ - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - {]])[ - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - break; - } - else - yyarg[yycount++] = yytname_[yyx]; - } - } + if (!yyctx.lookahead ().empty ()) + { + if (yyarg) + yyarg[0] = yyctx.token (); + int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1); + return yyn + 1; } + return 0; + } + + // Generate an error message. + std::string + ]b4_parser_class[::yysyntax_error_ (const context& yyctx) const + { + // Its maximum. + enum { YYARGS_MAX = 5 }; + // Arguments of yyformat. + symbol_kind_type yyarg[YYARGS_MAX]; + int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX); char const* yyformat = YY_NULLPTR; switch (yycount) @@ -1398,14 +1556,13 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], for (char const* yyp = yyformat; *yyp; ++yyp) if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) { - yyres += yytnamerr_ (yyarg[yyi++]); + yyres += symbol_name (yyarg[yyi++]); ++yyp; } else yyres += *yyp; - return yyres;]], [[ - return YY_("syntax error");]])[ - } + return yyres; + }]])[ const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[; @@ -1414,21 +1571,23 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], ]b4_parser_tables_define[ -]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ +]b4_parse_error_bmatch([simple\|verbose], +[[#if ]b4_api_PREFIX[DEBUG]b4_tname_if([[ || 1]])[ // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - // First, the terminals, then, starting at \a yyntokens_, nonterminals. + // First, the terminals, then, starting at \a YYNTOKENS, nonterminals. const char* const ]b4_parser_class[::yytname_[] = { ]b4_tname[ }; +#endif +]])[ -]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ +#if ]b4_api_PREFIX[DEBUG][ ]b4_integral_parser_table_define([rline], [b4_rline])[ - // Print the state stack on the debug stream. void - ]b4_parser_class[::yystack_print_ () + ]b4_parser_class[::yy_stack_print_ () const { *yycdebug_ << "Stack now"; for (stack_type::const_iterator @@ -1439,9 +1598,8 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], *yycdebug_ << '\n'; } - // Report on the debug stream that the rule \a yyrule is going to be reduced. void - ]b4_parser_class[::yy_reduce_print_ (int yyrule) + ]b4_parser_class[::yy_reduce_print_ (int yyrule) const { int yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; diff --git a/contrib/tools/bison/data/skeletons/stack.hh b/contrib/tools/bison/data/skeletons/stack.hh index 5eb485696a..0fd3625836 100644 --- a/contrib/tools/bison/data/skeletons/stack.hh +++ b/contrib/tools/bison/data/skeletons/stack.hh @@ -32,8 +32,8 @@ m4_define([b4_stack_define], { public: // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; + typedef typename S::iterator iterator; + typedef typename S::const_iterator const_iterator; typedef typename S::size_type size_type; typedef typename std::ptrdiff_t index_type; @@ -41,6 +41,13 @@ m4_define([b4_stack_define], : seq_ (n) {} +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + stack (const stack&) = delete; + /// Non copyable. + stack& operator= (const stack&) = delete; +#endif + /// Random access. /// /// Index 0 returns the topmost element. @@ -91,24 +98,18 @@ m4_define([b4_stack_define], return index_type (seq_.size ()); } - std::ptrdiff_t - ssize () const YY_NOEXCEPT - { - return std::ptrdiff_t (size ()); - } - /// Iterator on top of the stack (going downwards). const_iterator begin () const YY_NOEXCEPT { - return seq_.rbegin (); + return seq_.begin (); } /// Bottom of the stack. const_iterator end () const YY_NOEXCEPT { - return seq_.rend (); + return seq_.end (); } /// Present a slice of the top of a stack. @@ -132,8 +133,12 @@ m4_define([b4_stack_define], }; private: +#if YY_CPLUSPLUS < 201103L + /// Non copyable. stack (const stack&); + /// Non copyable. stack& operator= (const stack&); +#endif /// The wrapped container. S seq_; }; diff --git a/contrib/tools/bison/data/skeletons/variant.hh b/contrib/tools/bison/data/skeletons/variant.hh index 13a35c6dd5..b594af3808 100644 --- a/contrib/tools/bison/data/skeletons/variant.hh +++ b/contrib/tools/bison/data/skeletons/variant.hh @@ -115,6 +115,13 @@ m4_define([b4_value_type_declare], new (yyas_<T> ()) T (YY_MOVE (t)); } +#if 201103L <= YY_CPLUSPLUS + /// Non copyable. + semantic_type (const self_type&) = delete; + /// Non copyable. + self_type& operator= (const self_type&) = delete; +#endif + /// Destruction, allowed only if empty. ~semantic_type () YY_NOEXCEPT {]b4_parse_assert_if([ @@ -258,9 +265,12 @@ m4_define([b4_value_type_declare], } private: - /// Prohibit blind copies. - self_type& operator= (const self_type&); +#if YY_CPLUSPLUS < 201103L + /// Non copyable. semantic_type (const self_type&); + /// Non copyable. + self_type& operator= (const self_type&); +#endif /// Accessor to raw memory as \a T. template <typename T> diff --git a/contrib/tools/bison/data/skeletons/yacc.c b/contrib/tools/bison/data/skeletons/yacc.c index add9435192..bd5e7d8448 100644 --- a/contrib/tools/bison/data/skeletons/yacc.c +++ b/contrib/tools/bison/data/skeletons/yacc.c @@ -132,6 +132,7 @@ m4_define([b4_rhs_value], # b4_lhs_location() # ----------------- # Expansion of @$. +# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar". m4_define([b4_lhs_location], [(yyloc)]) @@ -140,6 +141,7 @@ m4_define([b4_lhs_location], # --------------------------------- # Expansion of @POS, where the current rule has RULE-LENGTH symbols # on RHS. +# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar". m4_define([b4_rhs_location], [(yylsp@{b4_subtract([$2], [$1])@})]) @@ -178,7 +180,8 @@ int yynerrs;]])]) # --------------------------------- # Declare all the variables that are needed to maintain the parser state # between calls to yypush_parse. -m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ +m4_define([b4_declare_parser_state_variables], +[b4_pure_if([[ /* Number of syntax errors so far. */ int yynerrs; ]])[ @@ -194,6 +197,9 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ + /* Their size. */ + YYPTRDIFF_T yystacksize; + /* The state stack. */ yy_state_t yyssa[YYINITDEPTH]; yy_state_t *yyss; @@ -207,18 +213,65 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; - YYLTYPE *yylsp; - - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3];]])[ - - YYPTRDIFF_T yystacksize;]b4_lac_if([[ + YYLTYPE *yylsp;]])[]b4_lac_if([[ yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@}; yy_state_t *yyes; YYPTRDIFF_T yyes_capacity;]])]) +# b4_initialize_parser_state_variables +# ------------------------------------ +# Initialize these variables. +m4_define([b4_initialize_parser_state_variables], +[[ yynerrs = 0; + yystate = 0; + yyerrstatus = 0; + + yystacksize = YYINITDEPTH; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa;]b4_locations_if([[ + yylsp = yyls = yylsa;]])[]b4_lac_if([[ + + yyes = yyesa; + yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[; + if (YYMAXDEPTH < yyes_capacity) + yyes_capacity = YYMAXDEPTH;]])[ +]]) + + +m4_define([b4_macro_define], +[[#]define $1 $2]) + +m4_define([b4_macro_undef], +[[#]undef $1]) + +m4_define([b4_pstate_macro_define], +[b4_macro_define([$1], [yyps->$1])]) + +# b4_parse_state_variable_macros(b4_macro_define|b4_macro_undef) +# -------------------------------------------------------------- +m4_define([b4_parse_state_variable_macros], +[b4_pure_if([$1([b4_prefix[]nerrs])]) +$1([yystate]) +$1([yyerrstatus]) +$1([yyssa]) +$1([yyss]) +$1([yyssp]) +$1([yyvsa]) +$1([yyvs]) +$1([yyvsp])[]b4_locations_if([ +$1([yylsa]) +$1([yyls]) +$1([yylsp])]) +$1([yystacksize])[]b4_lac_if([ +$1([yyesa]) +$1([yyes]) +$1([yyes_capacity])])]) + + + + # _b4_declare_yyparse_push # ------------------------ # Declaration of yyparse (and dependencies) when using the push parser @@ -231,27 +284,20 @@ enum { YYPUSH_MORE = 4 }; typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; -]b4_pull_if([b4_function_declare([b4_prefix[parse]], [[int]], b4_parse_param) -])b4_function_declare([b4_prefix[push_parse]], [[int]], - [[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([, - [[[int pushed_char]], [[pushed_char]]], - [[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([, - [[b4_api_PREFIX[LTYPE *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [, - b4_parse_param])) -b4_pull_if([b4_function_declare([b4_prefix[pull_parse]], [[int]], - [[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [, - b4_parse_param]))]) -b4_function_declare([b4_prefix[pstate_new]], [b4_prefix[pstate *]], - [[[void]], []]) -b4_function_declare([b4_prefix[pstate_delete]], [[void]], - [[b4_prefix[pstate *ps]], [[ps]]])dnl -]) +]b4_pull_if([[ +int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])[ +int ]b4_prefix[push_parse (]b4_prefix[pstate *ps]b4_pure_if([[, + int pushed_char, ]b4_api_PREFIX[STYPE const *pushed_val]b4_locations_if([[, ]b4_api_PREFIX[LTYPE *pushed_loc]])])b4_user_formals[); +]b4_pull_if([[int ]b4_prefix[pull_parse (]b4_prefix[pstate *ps]b4_user_formals[);]])[ +]b4_prefix[pstate *]b4_prefix[pstate_new (void); +void ]b4_prefix[pstate_delete (]b4_prefix[pstate *ps); +]]) # _b4_declare_yyparse # ------------------- # When not the push parser. m4_define([_b4_declare_yyparse], -[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)]) +[[int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]]) # b4_declare_yyparse @@ -314,6 +360,7 @@ b4_output_begin([b4_parser_file_name])[ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +]b4_disclaimer[ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -321,7 +368,6 @@ b4_output_begin([b4_parser_file_name])[ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -]b4_disclaimer[ ]b4_identification[ ]b4_percent_code_get([[top]])[]dnl m4_if(b4_api_prefix, [yy], [], @@ -334,6 +380,7 @@ m4_if(b4_api_prefix, [yy], [], #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[ #define yypull_parse ]b4_prefix[pull_parse]])[ #define yypstate_new ]b4_prefix[pstate_new +#define yypstate_clear ]b4_prefix[pstate_clear #define yypstate_delete ]b4_prefix[pstate_delete #define yypstate ]b4_prefix[pstate]])[ #define yylex ]b4_prefix[lex @@ -348,65 +395,18 @@ m4_if(b4_api_prefix, [yy], [], ]b4_cast_define[ ]b4_null_define[ -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[ -#endif - ]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])], [m4_ifval(m4_quote(b4_spec_header_file), [/* Use api.header.include to #include this header instead of duplicating it here. */ ])b4_shared_declarations])[ +]b4_declare_symbol_enum[ ]b4_user_post_prologue[ -]b4_percent_code_get[]dnl - -[#ifdef short -# undef short -#endif - +]b4_percent_code_get[ ]b4_c99_int_type_define[ -#ifndef YYPTRDIFF_T -# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ -# define YYPTRDIFF_T __PTRDIFF_TYPE__ -# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ -# elif defined PTRDIFF_MAX -# ifndef ptrdiff_t -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# endif -# define YYPTRDIFF_T ptrdiff_t -# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX -# else -# define YYPTRDIFF_T long -# define YYPTRDIFF_MAXIMUM LONG_MAX -# endif -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned -# endif -#endif - -#define YYSIZE_MAXIMUM \ - YY_CAST (YYPTRDIFF_T, \ - (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ - ? YYPTRDIFF_MAXIMUM \ - : YY_CAST (YYSIZE_T, -1))) - -#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) +]b4_sizes_types_define[ /* Stored state numbers (used for stacks). */ typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t; @@ -425,6 +425,11 @@ typedef int yy_state_fast_t; # define YY_(Msgid) Msgid # endif #endif +]b4_has_translations_if([ +#ifndef N_ +# define N_(Msgid) Msgid +#endif +])[ ]b4_attribute_define[ @@ -437,7 +442,7 @@ typedef int yy_state_fast_t; ]], [[#define YY_ASSERT(E) ((void) (0 && (E)))]])[ -#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[ +#if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ /* The parser invokes alloca or malloc; define the necessary symbols. */]dnl b4_push_if([], [b4_lac_if([], [[ @@ -504,8 +509,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif]b4_lac_if([[ # define YYCOPY_NEEDED 1]])[ -#endif]b4_lac_if([], [[ /* ! defined yyoverflow || YYERROR_VERBOSE */]])[ - +#endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -588,16 +592,17 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES ]b4_states_number[ -#define YYUNDEFTOK ]b4_undef_token_number[ #define YYMAXUTOK ]b4_user_token_number_max[ /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM as returned by yylex, with out-of-bounds checking. */ ]b4_api_token_raw_if(dnl -[[#define YYTRANSLATE(YYX) (YYX)]], -[[#define YYTRANSLATE(YYX) \ - (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) +[[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]], +[[#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : ]b4_symbol_prefix[YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ @@ -611,23 +616,55 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[ #endif -#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[ +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + +]b4_parse_error_bmatch([simple\|verbose], +[[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { ]b4_tname[ }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +}]], +[[static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + static const char *const yy_sname[] = + { + ]b4_symbol_names[ + };]b4_has_translations_if([[ + /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is + internationalizable. */ + static ]b4_int_type_for([b4_translatable])[ yytranslatable[] = + { + ]b4_translatable[ + }; + return (yysymbol < YYNTOKENS && yytranslatable[yysymbol] + ? _(yy_sname[yysymbol]) + : yy_sname[yysymbol]);]], [[ + return yy_sname[yysymbol];]])[ +}]])[ #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = { ]b4_toknum[ }; -# endif +#endif #define YYPACT_NINF (]b4_pact_ninf[) @@ -641,10 +678,10 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = ]b4_parser_tables_define[ +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyclearin (yychar = ]b4_symbol(-2, id)[) #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -655,7 +692,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = #define YYBACKUP(Token, Value) \ do \ - if (yychar == YYEMPTY) \ + if (yychar == ]b4_symbol(-2, id)[) \ { \ yychar = (Token); \ yylval = (Value); \ @@ -671,10 +708,9 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = } \ while (0) -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE ]b4_symbol(1, user_number)[ - +/* Backward compatibility with an undocumented macro. + Use ]b4_symbol(1, id)[ or ]b4_symbol(2, id)[. */ +#define YYERRCODE ]b4_symbol(2, id)[ ]b4_locations_if([[ ]b4_yylloc_default_define[ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) @@ -696,13 +732,13 @@ do { \ ]b4_yy_location_print_define[ -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value]b4_locations_if([, Location])[]b4_user_args[); \ + Kind, Value]b4_locations_if([, Location])[]b4_user_args[); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) @@ -714,9 +750,8 @@ do { \ | TOP (included). | `------------------------------------------------------------------*/ -]b4_function_define([yy_stack_print], [static void], - [[yy_state_t *yybottom], [yybottom]], - [[yy_state_t *yytop], [yytop]])[ +static void +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -738,12 +773,9 @@ do { \ | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -]b4_function_define([yy_reduce_print], [static void], - [[yy_state_t *yyssp], [yyssp]], - [[YYSTYPE *yyvsp], [yyvsp]], - b4_locations_if([[[YYLTYPE *yylsp], [yylsp]], - ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, - b4_parse_param]))[ +static void +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *yylsp,]])[ + int yyrule]b4_user_formals[) { int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; @@ -755,10 +787,9 @@ do { \ { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[+yyssp[yyi + 1 - yynrhs]], - &]b4_rhs_value(yynrhs, yyi + 1)[ - ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl - b4_user_args[); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([, + &]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[); YYFPRINTF (stderr, "\n"); } } @@ -773,8 +804,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !]b4_api_PREFIX[DEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !]b4_api_PREFIX[DEBUG */ @@ -794,7 +825,17 @@ int yydebug; #ifndef YYMAXDEPTH # define YYMAXDEPTH ]b4_stack_depth_max[ -#endif]b4_lac_if([[ +#endif]b4_push_if([[ +/* Parser data structure. */ +struct yypstate + {]b4_declare_parser_state_variables[ + /* Whether this instance has not started parsing yet. */ + int yynew; + };]b4_pure_if([], [[ + +/* Whether the only allowed instance of yypstate is allocated. */ +static char yypstate_allocated = 0;]])])[ +]b4_lac_if([[ /* Given a state stack such that *YYBOTTOM is its bottom, such that *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty @@ -805,7 +846,7 @@ int yydebug; *YYTOP, and *YYCAPACITY to reflect the new capacity and memory location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack using YYSTACK_FREE. Return 0 if successful or if no reallocation is - required. Return 1 if memory is exhausted. */ + required. Return YYENOMEM if memory is exhausted. */ static int yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, #if ]b4_api_PREFIX[DEBUG @@ -830,7 +871,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, { YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix, yydebug_suffix)); - return 1; + return YYENOMEM; } if (YYMAXDEPTH < yyalloc) yyalloc = YYMAXDEPTH; @@ -842,7 +883,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, { YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix, yydebug_suffix)); - return 1; + return YYENOMEM; } if (*yytop != yytop_empty) { @@ -888,23 +929,22 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, current lookahead, then check if that lookahead can eventually be shifted if syntactic actions continue from the current context. Report a syntax error if it cannot. */ -#define YY_LAC_ESTABLISH \ -do { \ - if (!yy_lac_established) \ - { \ - YYDPRINTF ((stderr, \ - "LAC: initial context established for %s\n", \ - yytname[yytoken])); \ - yy_lac_established = 1; \ - { \ - int yy_lac_status = \ - yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken); \ - if (yy_lac_status == 2) \ - goto yyexhaustedlab; \ - if (yy_lac_status == 1) \ - goto yyerrlab; \ - } \ - } \ +#define YY_LAC_ESTABLISH \ +do { \ + if (!yy_lac_established) \ + { \ + YYDPRINTF ((stderr, \ + "LAC: initial context established for %s\n", \ + yysymbol_name (yytoken))); \ + yy_lac_established = 1; \ + switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \ + { \ + case YYENOMEM: \ + goto yyexhaustedlab; \ + case 1: \ + goto yyerrlab; \ + } \ + } \ } while (0) /* Discard any previous initial lookahead context because of Event, @@ -923,9 +963,8 @@ do { \ do { \ if (yy_lac_established) \ { \ - if (yydebug) \ - YYFPRINTF (stderr, "LAC: initial context discarded due to " \ - Event "\n"); \ + YYDPRINTF ((stderr, "LAC: initial context discarded due to " \ + Event "\n")); \ yy_lac_established = 0; \ } \ } while (0) @@ -935,7 +974,7 @@ do { \ /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can eventually (after perhaps some reductions) be shifted, return 1 if - not, or return 2 if memory is exhausted. As preconditions and + not, or return YYENOMEM if memory is exhausted. As preconditions and postconditions: *YYES_CAPACITY is the allocated size of the array to which *YYES points, and either *YYES = YYESA or *YYES points to an array allocated with YYSTACK_ALLOC. yy_lac may overwrite the @@ -943,12 +982,13 @@ do { \ any old *YYES other than YYESA. */ static int yy_lac (yy_state_t *yyesa, yy_state_t **yyes, - YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken) + YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken) { yy_state_t *yyes_prev = yyssp; yy_state_t *yyesp = yyes_prev; - YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken])); - if (yytoken == YYUNDEFTOK) + /* Reduce until we encounter a shift and thereby accept the token. */ + YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken))); + if (yytoken == ]b4_symbol_prefix[YYUNDEF) { YYDPRINTF ((stderr, " Always Err\n")); return 1; @@ -960,6 +1000,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, || (yyrule += yytoken) < 0 || YYLAST < yyrule || yycheck[yyrule] != yytoken) { + /* Use the default action. */ yyrule = yydefact[+*yyesp]; if (yyrule == 0) { @@ -969,6 +1010,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } else { + /* Use the action from yytable. */ yyrule = yytable[yyrule]; if (yytable_value_is_error (yyrule)) { @@ -982,9 +1024,12 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } yyrule = -yyrule; } + /* By now we know we have to simulate a reduce. */ + YYDPRINTF ((stderr, " R%d", yyrule - 1)); { + /* Pop the corresponding number of values from the stack. */ YYPTRDIFF_T yylen = yyr2[yyrule]; - YYDPRINTF ((stderr, " R%d", yyrule - 1)); + /* First pop from the LAC stack as many tokens as possible. */ if (yyesp != yyes_prev) { YYPTRDIFF_T yysize = yyesp - *yyes + 1; @@ -995,13 +1040,15 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } else { - yylen -= yysize; yyesp = yyes_prev; + yylen -= yysize; } } + /* Only afterwards look at the main stack. */ if (yylen) yyesp = yyes_prev -= yylen; } + /* Push the resulting state of the reduction. */ { yy_state_fast_t yystate; { @@ -1027,7 +1074,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, yyes, yyesa, &yyesp, yyes_prev)) { YYDPRINTF ((stderr, "\n")); - return 2; + return YYENOMEM; } YY_IGNORE_USELESS_CAST_BEGIN *++yyesp = YY_CAST (yy_state_t, yystate); @@ -1038,33 +1085,144 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } }]])[ +]b4_parse_error_case([simple], [], +[[/* Context of a parse error. */ +typedef struct +{]b4_push_if([[ + yypstate* yyps;]], [[ + yy_state_t *yyssp;]b4_lac_if([[ + yy_state_t *yyesa; + yy_state_t **yyes; + YYPTRDIFF_T *yyes_capacity;]])])[ + yysymbol_kind_t yytoken;]b4_locations_if([[ + YYLTYPE *yylloc;]])[ +} yypcontext_t; + +/* Put in YYARG at most YYARGN of the expected tokens given the + current YYCTX, and return the number of tokens stored in YYARG. If + YYARG is null, return the number of expected tokens (guaranteed to + be less than YYNTOKENS). Return YYENOMEM on memory exhaustion. + Return 0 if there are more than YYARGN expected tokens, yet fill + YYARG up to YYARGN. */]b4_push_if([[ +static int +yypstate_expected_tokens (yypstate *yyps, + yysymbol_kind_t yyarg[], int yyargn)]], [[ +static int +yypcontext_expected_tokens (const yypcontext_t *yyctx, + yysymbol_kind_t yyarg[], int yyargn)]])[ +{ + /* Actual size of YYARG. */ + int yycount = 0; +]b4_lac_if([[ + int yyx; + for (yyx = 0; yyx < YYNTOKENS; ++yyx) + { + yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx); + if (yysym != ]b4_symbol(1, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF) + switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes, &yyps->yyes_capacity, yyps->yyssp, yysym]], + [[yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym]])[)) + { + case YYENOMEM: + return YYENOMEM; + case 1: + continue; + default: + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = yysym; + } + }]], +[[ int yyn = yypact@{+*]b4_push_if([yyps], [yyctx])[->yyssp@}; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[ + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx); + } + }]])[ + if (yyarg && yycount == 0 && 0 < yyargn) + yyarg[0] = ]b4_symbol(-2, kind)[; + return yycount; +} -#if YYERROR_VERBOSE +]b4_push_if([[ +/* Similar to the previous function. */ +static int +yypcontext_expected_tokens (const yypcontext_t *yyctx, + yysymbol_kind_t yyarg[], int yyargn) +{ + return yypstate_expected_tokens (yyctx->yyps, yyarg, yyargn); +}]])[ +]])[ -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) -# else +]b4_parse_error_bmatch( + [custom], +[[/* The kind of the lookahead of this context. */ +static yysymbol_kind_t +yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED; + +static yysymbol_kind_t +yypcontext_token (const yypcontext_t *yyctx) +{ + return yyctx->yytoken; +} + +]b4_locations_if([[/* The location of the lookahead of this context. */ +static YYLTYPE * +yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED; + +static YYLTYPE * +yypcontext_location (const yypcontext_t *yyctx) +{ + return yyctx->yylloc; +}]])[ + +/* User defined function to report a syntax error. */ +static int +yyreport_syntax_error (const yypcontext_t *yyctx]b4_user_formals[);]], + [detailed\|verbose], +[[#ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) +# else /* Return the length of YYSTR. */ -]b4_function_define([yystrlen], [static YYPTRDIFF_T], - [[const char *yystr], [yystr]])[ +static YYPTRDIFF_T +yystrlen (const char *yystr) { YYPTRDIFF_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } -# endif # endif +#endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else +#ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -]b4_function_define([yystpcpy], [static char *], - [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[ +static char * +yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; @@ -1074,10 +1232,12 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, return yyd - 1; } -# endif # endif +#endif -# ifndef yytnamerr +]b4_parse_error_case( + [verbose], +[[#ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string @@ -1092,7 +1252,6 @@ yytnamerr (char *yyres, const char *yystr) { YYPTRDIFF_T yyn = 0; char const *yyp = yystr; - for (;;) switch (*++yyp) { @@ -1126,34 +1285,15 @@ yytnamerr (char *yyres, const char *yystr) else return yystrlen (yystr); } -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP.]b4_lac_if([[ In order to see if a particular token T is a - valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[ +#endif +]])[ - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store]b4_lac_if([[ or if - yy_lac returned 2]])[. */ static int -yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, - ]b4_lac_if([[yy_state_t *yyesa, yy_state_t **yyes, - YYPTRDIFF_T *yyes_capacity, ]])[yy_state_t *yyssp, int yytoken) +yy_syntax_error_arguments (const yypcontext_t *yyctx, + yysymbol_kind_t yyarg[], int yyargn) { - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat: reported tokens (one for the "unexpected", - one per "expected"). */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Actual size of YYARG. */ int yycount = 0; - /* Cumulated lengths of YYARG. */ - YYPTRDIFF_T yysize = 0; - /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action @@ -1182,70 +1322,59 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, one exception: it will still contain any token that will not be accepted due to an error action in a later state.]])[ */ - if (yytoken != YYEMPTY) + if (yyctx->yytoken != ]b4_symbol(-2, kind)[) { - int yyn = yypact[+*yyssp]; - YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - yysize = yysize0;]b4_lac_if([[ + int yyn;]b4_lac_if([[ YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[ - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - {]b4_lac_if([[ - int yyx; - - for (yyx = 0; yyx < YYNTOKENS; ++yyx) - if (yyx != YYTERROR && yyx != YYUNDEFTOK) - { - { - int yy_lac_status = yy_lac (yyesa, yyes, yyes_capacity, - yyssp, yyx); - if (yy_lac_status == 2) - return 2; - if (yy_lac_status == 1) - continue; - }]], [[ - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - {]])[ - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYPTRDIFF_T yysize1 - = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return 2; - } - } - }]b4_lac_if([[ -# if ]b4_api_PREFIX[DEBUG - else if (yydebug) - YYFPRINTF (stderr, "No expected tokens.\n"); -# endif]])[ + if (yyarg) + yyarg[yycount] = yyctx->yytoken; + ++yycount; + yyn = yypcontext_expected_tokens (yyctx, + yyarg ? yyarg + 1 : yyarg, yyargn - 1); + if (yyn == YYENOMEM) + return YYENOMEM;]b4_lac_if([[ + else if (yyn == 0) + YYDPRINTF ((stderr, "No expected tokens.\n"));]])[ + else + yycount += yyn; } + return yycount; +} + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP.]b4_lac_if([[ In order to see if a particular token T is a + valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[ + + Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the + required number of bytes is too large to store]b4_lac_if([[ or if + yy_lac returned YYENOMEM]])[. */ +static int +yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, + const yypcontext_t *yyctx) +{ + enum { YYARGS_MAX = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat: reported tokens (one for the "unexpected", + one per "expected"). */ + yysymbol_kind_t yyarg[YYARGS_MAX]; + /* Cumulated lengths of YYARG. */ + YYPTRDIFF_T yysize = 0; + + /* Actual size of YYARG. */ + int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX); + if (yycount == YYENOMEM) + return YYENOMEM; switch (yycount) { -# define YYCASE_(N, S) \ +#define YYCASE_(N, S) \ case N: \ yyformat = S; \ - break + break default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); @@ -1253,17 +1382,25 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ +#undef YYCASE_ } + /* Compute error message size. Don't count the "%s"s, but reserve + room for the terminator. */ + yysize = yystrlen (yyformat) - 2 * yycount + 1; { - /* Don't count the "%s"s in the final size, but reserve room for - the terminator. */ - YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return 2; + int yyi; + for (yyi = 0; yyi < yycount; ++yyi) + { + YYPTRDIFF_T yysize1 + = yysize + ]b4_parse_error_case( + [verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]], + [[yystrlen (yysymbol_name (yyarg[yyi]))]]);[ + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else + return YYENOMEM; + } } if (*yymsg_alloc < yysize) @@ -1272,7 +1409,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; + return -1; } /* Avoid sprintf, as that infringes on the user's name space. @@ -1283,8 +1420,9 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); + {]b4_parse_error_case([verbose], [[ + yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[ + yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[ yyformat += 2; } else @@ -1295,32 +1433,22 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, } return 0; } -#endif /* YYERROR_VERBOSE */ +]])[ ]b4_yydestruct_define[ -]b4_pure_if([], [ +]b4_pure_if([], [b4_declare_scanner_communication_variables])[ -b4_declare_scanner_communication_variables])[]b4_push_if([[ +]b4_push_if([b4_pull_if([[ -struct yypstate - {]b4_declare_parser_state_variables[ - /* Used to determine if this is the first time this instance has - been used. */ - int yynew; - };]b4_pure_if([], [[ - -static char yypstate_allocated = 0;]])b4_pull_if([ - -b4_function_define([[yyparse]], [[int]], b4_parse_param)[ +int +yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[) { - return yypull_parse (YY_NULLPTR]m4_ifset([b4_parse_param], - [[, ]b4_args(b4_parse_param)])[); + return yypull_parse (YY_NULLPTR]b4_user_args[); } -]b4_function_define([[yypull_parse]], [[int]], - [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [, - b4_parse_param]))[ +int +yypull_parse (yypstate *yyps]b4_user_formals[) {]b4_pure_if([b4_locations_if([[ static YYLTYPE yyloc_default][]b4_yyloc_default[; YYLTYPE yylloc = yyloc_default;]])])[ @@ -1339,19 +1467,31 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ } } int yystatus; - do {]b4_pure_if([[ - YYSTYPE yylval; + do { +]b4_pure_if([[ YYSTYPE yylval; int ]])[yychar = ]b4_lex[; - yystatus = - yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[); + yystatus = yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[); } while (yystatus == YYPUSH_MORE); if (!yyps) yypstate_delete (yyps_local); return yystatus; }]])[ +]b4_parse_state_variable_macros([b4_pstate_macro_define])[ + /* Initialize the parser data structure. */ -]b4_function_define([[yypstate_new]], [[yypstate *]])[ +static void +yypstate_clear (yypstate *yyps) +{ +]b4_initialize_parser_state_variables[ + /* Initialize the state stack, in case yypcontext_expected_tokens is + called before the first call to yyparse. */ + *yyssp = 0; +} + +/* Initialize the parser data structure. */ +yypstate * +yypstate_new (void) { yypstate *yyps;]b4_pure_if([], [[ if (yypstate_allocated) @@ -1361,63 +1501,44 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ return YY_NULLPTR; yyps->yynew = 1;]b4_pure_if([], [[ yypstate_allocated = 1;]])[ + yypstate_clear (yyps); return yyps; } -]b4_function_define([[yypstate_delete]], [[void]], - [[[yypstate *yyps]], [[yyps]]])[ +void +yypstate_delete (yypstate *yyps) { if (yyps) { #ifndef yyoverflow /* If the stack was reallocated but the parse did not complete, then the stack still needs to be freed. */ - if (!yyps->yynew && yyps->yyss != yyps->yyssa) - YYSTACK_FREE (yyps->yyss); + if (!yyps->yynew && yyss != yyssa) + YYSTACK_FREE (yyss); #endif]b4_lac_if([[ - if (!yyps->yynew && yyps->yyes != yyps->yyesa) - YYSTACK_FREE (yyps->yyes);]])[ + if (!yyps->yynew && yyes != yyesa) + YYSTACK_FREE (yyes);]])[ free (yyps);]b4_pure_if([], [[ yypstate_allocated = 0;]])[ } } -]b4_pure_if([[ -#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[ -#define yystate yyps->yystate -#define yyerrstatus yyps->yyerrstatus -#define yyssa yyps->yyssa -#define yyss yyps->yyss -#define yyssp yyps->yyssp -#define yyvsa yyps->yyvsa -#define yyvs yyps->yyvs -#define yyvsp yyps->yyvsp]b4_locations_if([[ -#define yylsa yyps->yylsa -#define yyls yyps->yyls -#define yylsp yyps->yylsp -#define yyerror_range yyps->yyerror_range]])[ -#define yystacksize yyps->yystacksize]b4_lac_if([[ -#define yyesa yyps->yyesa -#define yyes yyps->yyes -#define yyes_capacity yyps->yyes_capacity]])[ - +]])[ +]b4_push_if([[ /*---------------. | yypush_parse. | `---------------*/ -]b4_function_define([[yypush_parse]], [[int]], - [[[yypstate *yyps]], [[yyps]]]b4_pure_if([, - [[[int yypushed_char]], [[yypushed_char]]], - [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([, - [[[YYLTYPE *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [, - b4_parse_param]))], [[ - - +int +yypush_parse (yypstate *yyps]b4_pure_if([[, + int yypushed_char, YYSTYPE const *yypushed_val]b4_locations_if([[, YYLTYPE *yypushed_loc]])])b4_user_formals[)]], +[[ /*----------. | yyparse. | `----------*/ -]b4_function_define([yyparse], [int], b4_parse_param)])[ +int +yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[ {]b4_pure_if([b4_declare_scanner_communication_variables ])b4_push_if([b4_pure_if([], [[ int yypushed_char = yychar; @@ -1426,51 +1547,43 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ ])], [b4_declare_parser_state_variables ])b4_lac_if([[ + /* Whether LAC context is established. A Boolean. */ int yy_lac_established = 0;]])[ int yyn; + /* The return value of yyparse. */ int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval;]b4_locations_if([[ - YYLTYPE yyloc;]])[ + YYLTYPE yyloc; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[3];]])[ -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ +]b4_parse_error_bmatch([detailed\|verbose], +[[ /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; - YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; -#endif + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;]])[ #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ - int yylen = 0;]b4_push_if([[ - + int yylen = 0; +]b4_push_if([[ if (!yyps->yynew) { yyn = yypact[yystate]; goto yyread_pushed_token; - }]])[ - - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa;]b4_locations_if([[ - yylsp = yyls = yylsa;]])[ - yystacksize = YYINITDEPTH;]b4_lac_if([[ - - yyes = yyesa; - yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[; - if (YYMAXDEPTH < yyes_capacity) - yyes_capacity = YYMAXDEPTH;]])[ + }]], [ +b4_initialize_parser_state_variables])[ YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = ]b4_symbol(-2, id)[; /* Cause a token to be read. */ ]m4_ifdef([b4_initial_action], [ b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [], [b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl @@ -1501,6 +1614,7 @@ yysetstate: YY_IGNORE_USELESS_CAST_BEGIN *yyssp = YY_CAST (yy_state_t, yystate); YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE @@ -1550,7 +1664,7 @@ yysetstate: YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([ YYSTACK_RELOCATE (yyls_alloc, yyls);])[ -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -1590,8 +1704,8 @@ yybackup: /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + if (yychar == ]b4_symbol(-2, id)[) {]b4_push_if([[ if (!yyps->yynew) {]b4_use_push_for_pull_if([], [[ @@ -1607,7 +1721,7 @@ yybackup: yylval = yypushed_val;]b4_locations_if([[ yylloc = yypushed_loc;]])])[ yyread_pushed_token:]])[ - YYDPRINTF ((stderr, "Reading a token: "));]b4_push_if([b4_pure_if([[ + YYDPRINTF ((stderr, "Reading a token\n"));]b4_push_if([b4_pure_if([[ yychar = yypushed_char; if (yypushed_val) yylval = *yypushed_val;]b4_locations_if([[ @@ -1616,11 +1730,23 @@ yyread_pushed_token:]])[ yychar = ]b4_lex[;]])[ } - if (yychar <= YYEOF) + if (yychar <= ]b4_symbol(0, [id])[) { - yychar = yytoken = YYEOF; + yychar = ]b4_symbol(0, [id])[; + yytoken = ]b4_symbol(0, [kind])[; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == ]b4_symbol(1, [id])[) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = ]b4_symbol(2, [id])[; + yytoken = ]b4_symbol(1, [kind])[;]b4_locations_if([[ + yyerror_range[1] = yylloc;]])[ + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1660,7 +1786,7 @@ yyread_pushed_token:]])[ *++yylsp = yylloc;])[ /* Discard the shifted token. */ - yychar = YYEMPTY;]b4_lac_if([[ + yychar = ]b4_symbol(-2, id)[;]b4_lac_if([[ YY_LAC_DISCARD ("shift");]])[ goto yynewstate; @@ -1723,11 +1849,10 @@ yyreduce: case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval;]b4_locations_if([ *++yylsp = yyloc;])[ @@ -1752,69 +1877,76 @@ yyreduce: yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (]b4_yyerror_args[YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \]b4_lac_if([[ - yyesa, &yyes, &yyes_capacity, \]])[ - yyssp, yytoken) - { +]b4_parse_error_case( + [custom], +[[ { + yypcontext_t yyctx + = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[ + if (yychar != ]b4_symbol(-2, id)[) + YY_LAC_ESTABLISH;]])[ + if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param], + [[, ]b4_args(b4_parse_param)])[) == 2) + goto yyexhaustedlab; + }]], + [simple], +[[ yyerror (]b4_yyerror_args[YY_("syntax error"));]], +[[ { + yypcontext_t yyctx + = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[}; char const *yymsgp = YY_("syntax error"); int yysyntax_error_status;]b4_lac_if([[ - if (yychar != YYEMPTY) + if (yychar != ]b4_symbol(-2, id)[) YY_LAC_ESTABLISH;]])[ - yysyntax_error_status = YYSYNTAX_ERROR; + yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); if (yysyntax_error_status == 0) yymsgp = yymsg; - else if (yysyntax_error_status == 1) + else if (yysyntax_error_status == -1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); - if (!yymsg) + yymsg = YY_CAST (char *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); + if (yymsg) { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; + yysyntax_error_status + = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); + yymsgp = yymsg; } else { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = YYENOMEM; } } yyerror (]b4_yyerror_args[yymsgp); - if (yysyntax_error_status == 2) + if (yysyntax_error_status == YYENOMEM) goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif + }]])[ } - -]b4_locations_if([[ yyerror_range[1] = yylloc;]])[ - +]b4_locations_if([[ + yyerror_range[1] = yylloc;]])[ if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ - if (yychar <= YYEOF) + if (yychar <= ]b4_symbol(0, [id])[) { /* Return failure if at end of input. */ - if (yychar == YYEOF) + if (yychar == ]b4_symbol(0, [id])[) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); - yychar = YYEMPTY; + yychar = ]b4_symbol(-2, id)[; } } @@ -1847,13 +1979,14 @@ yyerrorlab: yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += ]b4_symbol(1, kind)[; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(1, kind)[) { yyn = yytable[yyn]; if (0 < yyn) @@ -1867,7 +2000,7 @@ yyerrlab1: ]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[ yydestruct ("Error: popping", - yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); + YY_ACCESSING_SYMBOL (yystate), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1882,13 +2015,11 @@ yyerrlab1: YY_IGNORE_MAYBE_UNINITIALIZED_END ]b4_locations_if([[ yyerror_range[2] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - *++yylsp = yyloc;]])[ + ++yylsp; + YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);]])[ /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1910,7 +2041,7 @@ yyabortlab: goto yyreturn; -#if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[ +#if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1925,7 +2056,7 @@ yyexhaustedlab: | yyreturn -- parsing is finished, return the result. | `-----------------------------------------------------*/ yyreturn: - if (yychar != YYEMPTY) + if (yychar != ]b4_symbol(-2, id)[) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -1940,7 +2071,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[+*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1949,6 +2080,7 @@ yyreturn: #endif]b4_lac_if([[ if (yyes != yyesa) YYSTACK_FREE (yyes);]])b4_push_if([[ + yypstate_clear (yyps); yyps->yynew = 1; @@ -1956,11 +2088,12 @@ yyreturn: | yypushreturn -- ask for the next token. | `-----------------------------------------*/ yypushreturn:]])[ -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif +]b4_parse_error_bmatch([detailed\|verbose], +[[ if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg);]])[ return yyresult; } -]b4_epilogue[]dnl +]b4_push_if([b4_parse_state_variable_macros([b4_macro_undef])])[ +]b4_percent_code_get([[epilogue]])[]dnl +b4_epilogue[]dnl b4_output_end diff --git a/contrib/tools/bison/lib/attribute.h b/contrib/tools/bison/lib/attribute.h new file mode 100644 index 0000000000..2836b99dad --- /dev/null +++ b/contrib/tools/bison/lib/attribute.h @@ -0,0 +1,215 @@ +/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers + + Copyright 2020 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + +/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* + macros used within Gnulib. */ + +/* These attributes can be placed in two ways: + - At the start of a declaration (i.e. even before storage-class + specifiers!); then they apply to all entities that are declared + by the declaration. + - Immediately after the name of an entity being declared by the + declaration; then they apply to that entity only. */ + +#ifndef _GL_ATTRIBUTE_H +#define _GL_ATTRIBUTE_H + + +/* This file defines two types of attributes: + * C2X standard attributes. These have macro names that do not begin with + 'ATTRIBUTE_'. + * Selected GCC attributes; see: + https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html + https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html + These names begin with 'ATTRIBUTE_' to avoid name clashes. */ + + +/* =============== Attributes for specific kinds of functions =============== */ + +/* Attributes for functions that should not be used. */ + +/* Warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ +#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED + +/* If a function call is not optimized way, warn with MSG. */ +/* Applies to: functions. */ +#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg) + +/* If a function call is not optimized way, report an error with MSG. */ +/* Applies to: functions. */ +#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg) + + +/* Attributes for memory-allocating functions. */ + +/* The function returns a pointer to freshly allocated memory. */ +/* Applies to: functions. */ +#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC + +/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function + is the size of the returned memory block. + ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments + to determine the size of the returned memory block. */ +/* Applies to: function, pointer to function, function types. */ +#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args) + + +/* Attributes for variadic functions. */ + +/* The variadic function expects a trailing NULL argument. + ATTRIBUTE_SENTINEL () - The last argument is NULL. + ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ +#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos) + + +/* ================== Attributes for compiler diagnostics ================== */ + +/* Attributes that help the compiler diagnose programmer mistakes. + Some of them may also help for some compiler optimizations. */ + +/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) - + The STRING-INDEXth function argument is a format string of style + ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ +#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec) + +/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL. + ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) + +/* The function's return value is a non-NULL pointer. */ +/* Applies to: functions. */ +#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL + +/* Warn if the caller does not use the return value, + unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ +#define NODISCARD _GL_ATTRIBUTE_NODISCARD + + +/* Attributes that disable false alarms when the compiler diagnoses + programmer "mistakes". */ + +/* Do not warn if the entity is not used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED + +/* The contents of a character array is not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ +#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING + +/* Do not warn if control flow falls through to the immediately + following 'case' or 'default' label. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH + + +/* ================== Attributes for debugging information ================== */ + +/* Attributes regarding debugging information emitted by the compiler. */ + +/* Omit the function from stack traces when debugging. */ +/* Applies to: function. */ +#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL + +/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ +#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE + + +/* ========== Attributes that mainly direct compiler optimizations ========== */ + +/* The function does not throw exceptions. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW + +/* Do not inline the function. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE + +/* Always inline the function, and report an error if the compiler + cannot inline. */ +/* Applies to: function. */ +#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE + +/* The function does not affect observable state, and always returns a value. + Compilers can omit duplicate calls with the same arguments if + observable state is not changed between calls. (This attribute is + looser than ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ +#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE + +/* The function neither depends on nor affects observable state, + and always returns a value. Compilers can omit duplicate calls with + the same arguments. (This attribute is stricter than ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ +#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST + +/* The function is rarely executed. */ +/* Applies to: functions. */ +#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD + +/* If called from some other compilation unit, the function executes + code from that unit only by return or by exception handling, + letting the compiler optimize that unit more aggressively. */ +/* Applies to: functions. */ +#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF + +/* For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ +#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED + + +/* ================ Attributes that make invalid code valid ================ */ + +/* Attributes that prevent fatal compiler optimizations for code that is not + fully ISO C compliant. */ + +/* Pointers to the type may point to the same storage as pointers to + other types, thus disabling strict aliasing optimization. */ +/* Applies to: types. */ +#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS + + +#endif /* _GL_ATTRIBUTE_H */ diff --git a/contrib/tools/bison/lib/bitset.c b/contrib/tools/bison/lib/bitset.c index c0fc13fd52..70752b621b 100644 --- a/contrib/tools/bison/lib/bitset.c +++ b/contrib/tools/bison/lib/bitset.c @@ -94,7 +94,7 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) specified by ATTR. For variable size bitsets, N_BITS is only a hint and may be zero. */ enum bitset_type -bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr) +bitset_type_choose (bitset_bindex n_bits MAYBE_UNUSED, unsigned attr) { /* Check attributes. */ if (attr & BITSET_FIXED && attr & BITSET_VARIABLE) diff --git a/contrib/tools/bison/lib/bitset/array.c b/contrib/tools/bison/lib/bitset/array.c index e611f38bcf..f350b53eb4 100644 --- a/contrib/tools/bison/lib/bitset/array.c +++ b/contrib/tools/bison/lib/bitset/array.c @@ -99,7 +99,7 @@ abitset_small_list (bitset src, bitset_bindex *list, /* Set bit BITNO in bitset DST. */ static void -abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED) +abitset_set (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED) { /* This should never occur for abitsets since we should always hit the cache. It is likely someone is trying to access outside the @@ -110,8 +110,8 @@ abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED) /* Reset bit BITNO in bitset DST. */ static void -abitset_reset (bitset dst ATTRIBUTE_UNUSED, - bitset_bindex bitno ATTRIBUTE_UNUSED) +abitset_reset (bitset dst MAYBE_UNUSED, + bitset_bindex bitno MAYBE_UNUSED) { /* This should never occur for abitsets since we should always hit the cache. It is likely someone is trying to access outside the @@ -121,8 +121,8 @@ abitset_reset (bitset dst ATTRIBUTE_UNUSED, /* Test bit BITNO in bitset SRC. */ static bool -abitset_test (bitset src ATTRIBUTE_UNUSED, - bitset_bindex bitno ATTRIBUTE_UNUSED) +abitset_test (bitset src MAYBE_UNUSED, + bitset_bindex bitno MAYBE_UNUSED) { /* This should never occur for abitsets since we should always hit the cache. */ diff --git a/contrib/tools/bison/lib/bitset/base.h b/contrib/tools/bison/lib/bitset/base.h index 46ec894ece..2ae7b20802 100644 --- a/contrib/tools/bison/lib/bitset/base.h +++ b/contrib/tools/bison/lib/bitset/base.h @@ -25,16 +25,9 @@ #include <stdbool.h> #include <stddef.h> +#include "attribute.h" #include "xalloc.h" -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -#endif - -#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) - /* Currently we support five flavours of bitsets: BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets). Memory for bit array and bitset structure allocated diff --git a/contrib/tools/bison/lib/bitset/list.c b/contrib/tools/bison/lib/bitset/list.c index f453671827..ed975ef001 100644 --- a/contrib/tools/bison/lib/bitset/list.c +++ b/contrib/tools/bison/lib/bitset/list.c @@ -1276,7 +1276,7 @@ struct bitset_vtable lbitset_vtable = { /* Return size of initial structure. */ size_t -lbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) +lbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED) { return sizeof (struct lbitset_struct); } @@ -1284,7 +1284,7 @@ lbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) /* Initialize a bitset. */ bitset -lbitset_init (bitset bset, bitset_bindex n_bits ATTRIBUTE_UNUSED) +lbitset_init (bitset bset, bitset_bindex n_bits MAYBE_UNUSED) { BITSET_NBITS_ (bset) = n_bits; bset->b.vtable = &lbitset_vtable; diff --git a/contrib/tools/bison/lib/bitset/stats.c b/contrib/tools/bison/lib/bitset/stats.c index 222cde0905..10aa5d768d 100644 --- a/contrib/tools/bison/lib/bitset/stats.c +++ b/contrib/tools/bison/lib/bitset/stats.c @@ -202,7 +202,7 @@ bitset_stats_print_1 (FILE *file, const char *name, /* Print all bitset statistics to FILE. */ static void -bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED) +bitset_stats_print (FILE *file, bool verbose MAYBE_UNUSED) { if (!bitset_stats_info) return; diff --git a/contrib/tools/bison/lib/bitset/table.c b/contrib/tools/bison/lib/bitset/table.c index ab68e518d0..56f1a860a4 100644 --- a/contrib/tools/bison/lib/bitset/table.c +++ b/contrib/tools/bison/lib/bitset/table.c @@ -1184,7 +1184,7 @@ struct bitset_vtable tbitset_vtable = { /* Return size of initial structure. */ size_t -tbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) +tbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED) { return sizeof (struct tbitset_struct); } diff --git a/contrib/tools/bison/lib/bitset/vector.c b/contrib/tools/bison/lib/bitset/vector.c index cb60ba4a3a..fe14d67037 100644 --- a/contrib/tools/bison/lib/bitset/vector.c +++ b/contrib/tools/bison/lib/bitset/vector.c @@ -126,7 +126,7 @@ vbitset_set (bitset dst, bitset_bindex bitno) /* Reset bit BITNO in bitset DST. */ static void -vbitset_reset (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED) +vbitset_reset (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED) { /* We must be accessing outside the cache so the bit is zero anyway. */ @@ -135,8 +135,8 @@ vbitset_reset (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED /* Test bit BITNO in bitset SRC. */ static bool -vbitset_test (bitset src ATTRIBUTE_UNUSED, - bitset_bindex bitno ATTRIBUTE_UNUSED) +vbitset_test (bitset src MAYBE_UNUSED, + bitset_bindex bitno MAYBE_UNUSED) { /* We must be accessing outside the cache so the bit is zero anyway. */ @@ -978,7 +978,7 @@ struct bitset_vtable vbitset_vtable = { size_t -vbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) +vbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED) { return sizeof (struct vbitset_struct); } diff --git a/contrib/tools/bison/lib/careadlinkat.c b/contrib/tools/bison/lib/careadlinkat.c index 1effdb7845..1aa04363da 100644 --- a/contrib/tools/bison/lib/careadlinkat.c +++ b/contrib/tools/bison/lib/careadlinkat.c @@ -72,23 +72,38 @@ careadlinkat (int fd, char const *filename, SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; char stack_buf[1024]; +#if (defined GCC_LINT || defined lint) && _GL_GNUC_PREREQ (10, 1) + /* Pacify preadlinkat without creating a pointer to the stack + that a broken gcc -Wreturn-local-addr would cry wolf about. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044 + This workaround differs from the mainline code, but + no other way to pacify GCC 10.1.0 is known; even an explicit + #pragma does not pacify GCC. When the GCC bug is fixed this + workaround should be limited to the broken GCC versions. */ +# define WORK_AROUND_GCC_BUG_95044 +#endif + if (! alloc) alloc = &stdlib_allocator; - if (! buffer_size) + if (!buffer) { +#ifdef WORK_AROUND_GCC_BUG_95044 + buffer = alloc->allocate (sizeof stack_buf); +#else /* Allocate the initial buffer on the stack. This way, in the common case of a symlink of small size, we get away with a single small malloc() instead of a big malloc() followed by a shrinking realloc(). */ buffer = stack_buf; +#endif buffer_size = sizeof stack_buf; } buf = buffer; buf_size = buffer_size; - do + while (buf) { /* Attempt to read the link into the current buffer. */ ssize_t link_length = preadlinkat (fd, filename, buf, buf_size); @@ -117,19 +132,19 @@ careadlinkat (int fd, char const *filename, if (buf == stack_buf) { - char *b = (char *) alloc->allocate (link_size); + char *b = alloc->allocate (link_size); buf_size = link_size; if (! b) break; - memcpy (b, buf, link_size); - buf = b; + return memcpy (b, buf, link_size); } - else if (link_size < buf_size && buf != buffer && alloc->reallocate) + + if (link_size < buf_size && buf != buffer && alloc->reallocate) { /* Shrink BUF before returning it. */ - char *b = (char *) alloc->reallocate (buf, link_size); + char *b = alloc->reallocate (buf, link_size); if (b) - buf = b; + return b; } return buf; @@ -138,8 +153,8 @@ careadlinkat (int fd, char const *filename, if (buf != buffer) alloc->free (buf); - if (buf_size <= buf_size_max / 2) - buf_size *= 2; + if (buf_size < buf_size_max / 2) + buf_size = 2 * buf_size + 1; else if (buf_size < buf_size_max) buf_size = buf_size_max; else if (buf_size_max < SIZE_MAX) @@ -149,9 +164,8 @@ careadlinkat (int fd, char const *filename, } else break; - buf = (char *) alloc->allocate (buf_size); + buf = alloc->allocate (buf_size); } - while (buf); if (alloc->die) alloc->die (buf_size); diff --git a/contrib/tools/bison/lib/config-linux.h b/contrib/tools/bison/lib/config-linux.h index 5d1714a49f..7849bfbaea 100644 --- a/contrib/tools/bison/lib/config-linux.h +++ b/contrib/tools/bison/lib/config-linux.h @@ -187,9 +187,15 @@ /* Define to 1 when the gnulib module fsync should be tested. */ #define GNULIB_TEST_FSYNC 1 +/* Define to 1 when the gnulib module getdelim should be tested. */ +/* #undef GNULIB_TEST_GETDELIM */ + /* Define to 1 when the gnulib module getdtablesize should be tested. */ #define GNULIB_TEST_GETDTABLESIZE 1 +/* Define to 1 when the gnulib module getline should be tested. */ +#define GNULIB_TEST_GETLINE 1 + /* Define to 1 when the gnulib module getopt-posix should be tested. */ #define GNULIB_TEST_GETOPT_POSIX 1 @@ -507,6 +513,10 @@ don't. */ #define HAVE_DECL_GETC_UNLOCKED 1 +/* Define to 1 if you have the declaration of `getdelim', and to 0 if you + don't. */ +#define HAVE_DECL_GETDELIM 1 + /* Define to 1 if you have the declaration of `getdtablesize', and to 0 if you don't. */ #define HAVE_DECL_GETDTABLESIZE 1 @@ -515,6 +525,10 @@ don't. */ #define HAVE_DECL_GETHRTIME 0 +/* Define to 1 if you have the declaration of `getline', and to 0 if you + don't. */ +#define HAVE_DECL_GETLINE 1 + /* Define to 1 if you have the declaration of `iswblank', and to 0 if you don't. */ #define HAVE_DECL_ISWBLANK 1 @@ -615,6 +629,9 @@ /* Define to 1 if you have the <features.h> header file. */ #define HAVE_FEATURES_H 1 +/* Define to 1 if you have the `flockfile' function. */ +/* #undef HAVE_FLOCKFILE */ + /* Define if the frexpl function is available in libc. */ #define HAVE_FREXPL_IN_LIBC 1 @@ -624,9 +641,15 @@ /* Define to 1 if you have the `fsync' function. */ #define HAVE_FSYNC 1 +/* Define to 1 if you have the `funlockfile' function. */ +/* #undef HAVE_FUNLOCKFILE */ + /* Define to 1 if you have the `getcwd' function. */ #define HAVE_GETCWD 1 +/* Define to 1 if you have the `getdelim' function. */ +#define HAVE_GETDELIM 1 + /* Define to 1 if you have the `getdtablesize' function. */ #define HAVE_GETDTABLESIZE 1 @@ -806,6 +829,15 @@ /* Define to 1 if you have the `rawmemchr' function. */ /* #undef HAVE_RAWMEMCHR */ +/* Define if you have the readline library. */ +/* #undef HAVE_READLINE */ + +/* Define to 1 if you have the <readline/history.h> header file. */ +/* #undef HAVE_READLINE_HISTORY_H */ + +/* Define to 1 if you have the <readline/readline.h> header file. */ +/* #undef HAVE_READLINE_READLINE_H */ + /* Define to 1 if you have the `readlink' function. */ #define HAVE_READLINK 1 @@ -1097,7 +1129,7 @@ #define HAVE___XPG_STRERROR_R 1 /* Define to the value of ${prefix}, as a string. */ -#define INSTALLPREFIX "/var/empty/bison-3.5.4" +#define INSTALLPREFIX "/var/empty/bison-3.6.4" /* Define as the bit index in the word where to find bit 0 of the exponent of 'long double'. */ @@ -1226,7 +1258,7 @@ #define PACKAGE_NAME "GNU Bison" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 3.5.4" +#define PACKAGE_STRING "GNU Bison 3.6.4" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bison" @@ -1235,7 +1267,7 @@ #define PACKAGE_URL "https://www.gnu.org/software/bison/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.5.4" +#define PACKAGE_VERSION "3.6.4" /* Define if <inttypes.h> exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -1450,7 +1482,7 @@ /* #undef USE_WINDOWS_THREADS */ /* Version number of package */ -#define VERSION "3.5.4" +#define VERSION "3.6.4" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ @@ -1488,6 +1520,15 @@ /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ +/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define _GL_GNUC_PREREQ(major, minor) \ + ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) +#else +# define _GL_GNUC_PREREQ(major, minor) 0 +#endif + + /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ @@ -1515,12 +1556,12 @@ # define _Noreturn [[noreturn]] # elif ((!defined __cplusplus || defined __clang__) \ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ + || _GL_GNUC_PREREQ (4, 7) \ || (defined __apple_build_version__ \ ? 6000000 <= __apple_build_version__ \ : 3 < __clang_major__ + (5 <= __clang_minor__)))) /* _Noreturn works as-is. */ -# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# elif _GL_GNUC_PREREQ (2, 8) || 0x5110 <= __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__)) # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) # define _Noreturn __declspec (noreturn) @@ -1577,6 +1618,206 @@ #define _GL_ASYNC_SAFE +/* Attributes. */ +#ifdef __has_attribute +# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) +#else +# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr +# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) +# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) +# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) +# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) +# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) +# ifdef _ICC +# define _GL_ATTR_may_alias 0 +# else +# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) +# endif +# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) +# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) +# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) +# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) +# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) +# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) +#endif + + +#if _GL_HAS_ATTRIBUTE (alloc_size) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +#else +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) +#endif + +#if _GL_HAS_ATTRIBUTE (always_inline) +# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) +#else +# define _GL_ATTRIBUTE_ALWAYS_INLINE +#endif + +#if _GL_HAS_ATTRIBUTE (artificial) +# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) +#else +# define _GL_ATTRIBUTE_ARTIFICIAL +#endif + +/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at + <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. */ +#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ +# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) +#else +# define _GL_ATTRIBUTE_COLD +#endif + +#if _GL_HAS_ATTRIBUTE (const) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +#else +# define _GL_ATTRIBUTE_CONST +#endif + +#if 201710L < __STDC_VERSION__ +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +#elif _GL_HAS_ATTRIBUTE (deprecated) +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +#else +# define _GL_ATTRIBUTE_DEPRECATED +#endif + +#if _GL_HAS_ATTRIBUTE (error) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) +#else +# define _GL_ATTRIBUTE_ERROR(msg) +# define _GL_ATTRIBUTE_WARNING(msg) +#endif + +#if _GL_HAS_ATTRIBUTE (externally_visible) +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) +#else +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +#endif + +/* FALLTHROUGH is special, because it always expands to something. */ +#if 201710L < __STDC_VERSION__ +# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] +#elif _GL_HAS_ATTRIBUTE (fallthrough) +# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) +#else +# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) +#endif + +#if _GL_HAS_ATTRIBUTE (format) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) +#endif + +#if _GL_HAS_ATTRIBUTE (leaf) +# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) +#else +# define _GL_ATTRIBUTE_LEAF +#endif + +#if _GL_HAS_ATTRIBUTE (may_alias) +# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) +#else +# define _GL_ATTRIBUTE_MAY_ALIAS +#endif + +#if 201710L < __STDC_VERSION__ +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +#elif _GL_HAS_ATTRIBUTE (unused) +# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +#else +# define _GL_ATTRIBUTE_MAYBE_UNUSED +#endif +/* Earlier spellings of this macro. */ +#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED +#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED + +#if _GL_HAS_ATTRIBUTE (malloc) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +#else +# define _GL_ATTRIBUTE_MALLOC +#endif + +#if 201710L < __STDC_VERSION__ +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +#elif _GL_HAS_ATTRIBUTE (warn_unused_result) +# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) +#else +# define _GL_ATTRIBUTE_NODISCARD +#endif + +#if _GL_HAS_ATTRIBUTE (noinline) +# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) +#else +# define _GL_ATTRIBUTE_NOINLINE +#endif + +#if _GL_HAS_ATTRIBUTE (nonnull) +# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) +#else +# define _GL_ATTRIBUTE_NONNULL(args) +#endif + +#if _GL_HAS_ATTRIBUTE (nonstring) +# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +#else +# define _GL_ATTRIBUTE_NONSTRING +#endif + +/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ + +#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +#else +# define _GL_ATTRIBUTE_NOTHROW +#endif + +#if _GL_HAS_ATTRIBUTE (packed) +# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) +#else +# define _GL_ATTRIBUTE_PACKED +#endif + +#if _GL_HAS_ATTRIBUTE (pure) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE +#endif + +#if _GL_HAS_ATTRIBUTE (returns_nonnull) +# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) +#else +# define _GL_ATTRIBUTE_RETURNS_NONNULL +#endif + +#if _GL_HAS_ATTRIBUTE (sentinel) +# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) +#else +# define _GL_ATTRIBUTE_SENTINEL(pos) +#endif + + +/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */ +#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5) +# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED +#else +# define _GL_UNUSED_LABEL +#endif + + /* Please see the Gnulib manual for how to use these macros. Suppress extern inline with HP-UX cc, as it appears to be broken; see @@ -1746,49 +1987,5 @@ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef uid_t */ - -/* Define as a marker that can be attached to declarations that might not - be used. This helps to reduce warnings, such as from - GCC -Wunused-parameter. */ -#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_UNUSED __attribute__ ((__unused__)) -#else -# define _GL_UNUSED -#endif -/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name - is a misnomer outside of parameter lists. */ -#define _UNUSED_PARAMETER_ _GL_UNUSED - -/* gcc supports the "unused" attribute on possibly unused labels, and - g++ has since version 4.5. Note to support C++ as well as C, - _GL_UNUSED_LABEL should be used with a trailing ; */ -#if !defined __cplusplus || __GNUC__ > 4 \ - || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define _GL_UNUSED_LABEL _GL_UNUSED -#else -# define _GL_UNUSED_LABEL -#endif - -/* The __pure__ attribute was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* The __const__ attribute was added in gcc 2.95. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) -#else -# define _GL_ATTRIBUTE_CONST /* empty */ -#endif - -/* The __malloc__ attribute was added in gcc 3. */ -#if 3 <= __GNUC__ -# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -#else -# define _GL_ATTRIBUTE_MALLOC /* empty */ -#endif - #undef HAVE_THREADS_H #define _GL_ATTRIBUTE_FORMAT_PRINTF(...) diff --git a/contrib/tools/bison/lib/config-win.h b/contrib/tools/bison/lib/config-win.h index ef3a3edc5b..69bab546f4 100644 --- a/contrib/tools/bison/lib/config-win.h +++ b/contrib/tools/bison/lib/config-win.h @@ -1226,7 +1226,7 @@ char *strsignal (int signum); /* #undef PACKAGE_PACKAGER_VERSION */ /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 3.5.4" +#define PACKAGE_STRING "GNU Bison 3.6.4" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "m4" @@ -1235,7 +1235,7 @@ char *strsignal (int signum); #define PACKAGE_URL "http://www.gnu.org/software/m4/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.5.4" +#define PACKAGE_VERSION "3.6.4" /* Define if <inttypes.h> exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -1398,7 +1398,7 @@ char *strsignal (int signum); /* #undef USE_WINDOWS_THREADS */ /* Version number of package */ -#define VERSION "3.5.4" +#define VERSION "3.6.4" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ @@ -1704,9 +1704,17 @@ char *strsignal (int signum); #define M4 "/var/empty/gnum4-1.4.19/bin/m4" #define M4_GNU_OPTION "--gnu" #define PACKAGE_COPYRIGHT_YEAR 2013 -#define _GL_ATTRIBUTE_MALLOC -#define HAVE_DECL___ARGV 1 + +#define _GL_ASYNC_SAFE +#define _GL_ATTRIBUTE_ALLOC_SIZE(...) +#define _GL_ATTRIBUTE_FALLTHROUGH +#define _GL_ATTRIBUTE_FORMAT(...) #define _GL_ATTRIBUTE_FORMAT_PRINTF(...) +#define _GL_ATTRIBUTE_MALLOC +#define _GL_ATTRIBUTE_MAYBE_UNUSED +#define _GL_ATTRIBUTE_NODISCARD +#define _GL_GNUC_PREREQ(...) 0 + +#define HAVE_DECL___ARGV 1 #define HAVE_ISNANL_IN_LIBC 1 #define HAVE_ISNAND_IN_LIBC 1 -#define _GL_ASYNC_SAFE diff --git a/contrib/tools/bison/lib/configmake-linux.h b/contrib/tools/bison/lib/configmake-linux.h index 7dc40e17b9..ff9df1240f 100644 --- a/contrib/tools/bison/lib/configmake-linux.h +++ b/contrib/tools/bison/lib/configmake-linux.h @@ -2,30 +2,30 @@ #if HAVE_WINSOCK2_H # include <winsock2.h> /* avoid mingw pollution on DATADIR */ #endif -#define PREFIX "/var/empty/bison-3.5.4" -#define EXEC_PREFIX "/var/empty/bison-3.5.4" -#define BINDIR "/var/empty/bison-3.5.4/bin" -#define SBINDIR "/var/empty/bison-3.5.4/sbin" -#define LIBEXECDIR "/var/empty/bison-3.5.4/libexec" -#define DATAROOTDIR "/var/empty/bison-3.5.4/share" -#define DATADIR "/var/empty/bison-3.5.4/share" -#define SYSCONFDIR "/var/empty/bison-3.5.4/etc" -#define SHAREDSTATEDIR "/var/empty/bison-3.5.4/com" -#define LOCALSTATEDIR "/var/empty/bison-3.5.4/var" -#define RUNSTATEDIR "/var/empty/bison-3.5.4/var/run" -#define INCLUDEDIR "/var/empty/bison-3.5.4/include" +#define PREFIX "/var/empty/bison-3.6.4" +#define EXEC_PREFIX "/var/empty/bison-3.6.4" +#define BINDIR "/var/empty/bison-3.6.4/bin" +#define SBINDIR "/var/empty/bison-3.6.4/sbin" +#define LIBEXECDIR "/var/empty/bison-3.6.4/libexec" +#define DATAROOTDIR "/var/empty/bison-3.6.4/share" +#define DATADIR "/var/empty/bison-3.6.4/share" +#define SYSCONFDIR "/var/empty/bison-3.6.4/etc" +#define SHAREDSTATEDIR "/var/empty/bison-3.6.4/com" +#define LOCALSTATEDIR "/var/empty/bison-3.6.4/var" +#define RUNSTATEDIR "/var/empty/bison-3.6.4/var/run" +#define INCLUDEDIR "/var/empty/bison-3.6.4/include" #define OLDINCLUDEDIR "/usr/include" -#define DOCDIR "/var/empty/bison-3.5.4/share/doc/bison" -#define INFODIR "/var/empty/bison-3.5.4/share/info" -#define HTMLDIR "/var/empty/bison-3.5.4/share/doc/bison" -#define DVIDIR "/var/empty/bison-3.5.4/share/doc/bison" -#define PDFDIR "/var/empty/bison-3.5.4/share/doc/bison" -#define PSDIR "/var/empty/bison-3.5.4/share/doc/bison" -#define LIBDIR "/var/empty/bison-3.5.4/lib" -#define LISPDIR "/var/empty/bison-3.5.4/share/emacs/site-lisp" -#define LOCALEDIR "/var/empty/bison-3.5.4/share/locale" -#define MANDIR "/var/empty/bison-3.5.4/share/man" -#define PKGDATADIR "/var/empty/bison-3.5.4/share/bison" -#define PKGINCLUDEDIR "/var/empty/bison-3.5.4/include/bison" -#define PKGLIBDIR "/var/empty/bison-3.5.4/lib/bison" -#define PKGLIBEXECDIR "/var/empty/bison-3.5.4/libexec/bison" +#define DOCDIR "/var/empty/bison-3.6.4/share/doc/bison" +#define INFODIR "/var/empty/bison-3.6.4/share/info" +#define HTMLDIR "/var/empty/bison-3.6.4/share/doc/bison" +#define DVIDIR "/var/empty/bison-3.6.4/share/doc/bison" +#define PDFDIR "/var/empty/bison-3.6.4/share/doc/bison" +#define PSDIR "/var/empty/bison-3.6.4/share/doc/bison" +#define LIBDIR "/var/empty/bison-3.6.4/lib" +#define LISPDIR "/var/empty/bison-3.6.4/share/emacs/site-lisp" +#define LOCALEDIR "/var/empty/bison-3.6.4/share/locale" +#define MANDIR "/var/empty/bison-3.6.4/share/man" +#define PKGDATADIR "/var/empty/bison-3.6.4/share/bison" +#define PKGINCLUDEDIR "/var/empty/bison-3.6.4/include/bison" +#define PKGLIBDIR "/var/empty/bison-3.6.4/lib/bison" +#define PKGLIBEXECDIR "/var/empty/bison-3.6.4/libexec/bison" diff --git a/contrib/tools/bison/lib/dirname.h b/contrib/tools/bison/lib/dirname.h index 8c12d93b51..5379e8e3d2 100644 --- a/contrib/tools/bison/lib/dirname.h +++ b/contrib/tools/bison/lib/dirname.h @@ -21,7 +21,7 @@ # include <stdbool.h> # include <stddef.h> -# include "dosname.h" +# include "filename.h" # ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' diff --git a/contrib/tools/bison/lib/dosname.h b/contrib/tools/bison/lib/dosname.h deleted file mode 100644 index 5782960094..0000000000 --- a/contrib/tools/bison/lib/dosname.h +++ /dev/null @@ -1,52 +0,0 @@ -/* File names on MS-DOS/Windows systems. - - Copyright (C) 2000-2001, 2004-2006, 2009-2020 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - - From Paul Eggert and Jim Meyering. */ - -#ifndef _DOSNAME_H -#define _DOSNAME_H - -#if (defined _WIN32 || defined __CYGWIN__ \ - || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__) - /* This internal macro assumes ASCII, but all hosts that support drive - letters use ASCII. */ -# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ - <= 'z' - 'a') -# define FILE_SYSTEM_PREFIX_LEN(Filename) \ - (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) -# ifndef __CYGWIN__ -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 -# endif -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -#else -# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 -# define ISSLASH(C) ((C) == '/') -#endif - -#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 -#endif - -#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) -# else -# define IS_ABSOLUTE_FILE_NAME(F) \ - (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0) -#endif -#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) - -#endif /* DOSNAME_H_ */ diff --git a/contrib/tools/bison/lib/error.h b/contrib/tools/bison/lib/error.h index bad47a16dd..a351606f81 100644 --- a/contrib/tools/bison/lib/error.h +++ b/contrib/tools/bison/lib/error.h @@ -19,18 +19,6 @@ #ifndef _ERROR_H #define _ERROR_H 1 -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - /* On mingw, the flavor of printf depends on whether the extensions module * is in use; the check for <stdio.h> determines the witness macro. */ #ifndef _GL_ATTRIBUTE_SPEC_PRINTF diff --git a/contrib/tools/bison/lib/filename.h b/contrib/tools/bison/lib/filename.h index d4c70203e6..4598fb1d63 100644 --- a/contrib/tools/bison/lib/filename.h +++ b/contrib/tools/bison/lib/filename.h @@ -14,38 +14,94 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ +/* From Paul Eggert and Jim Meyering. */ + #ifndef _FILENAME_H #define _FILENAME_H +#include <string.h> + #ifdef __cplusplus extern "C" { #endif -/* Pathname support. - ISSLASH(C) tests whether C is a directory separator character. - IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, - it may be concatenated to a directory pathname. - IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. +/* Filename support. + ISSLASH(C) tests whether C is a directory separator + character. + HAS_DEVICE(Filename) tests whether Filename contains a device + specification. + FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification + at the beginning of Filename, + index of the part consisting of + alternating components and slashes. + FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + 1 when a non-empty device specification + can be followed by an empty or relative + part, + 0 when a non-empty device specification + must be followed by a slash, + 0 when device specification don't exist. + IS_ABSOLUTE_FILE_NAME(Filename) + tests whether Filename is independent of + any notion of "current directory". + IS_RELATIVE_FILE_NAME(Filename) + tests whether Filename may be concatenated + to a directory filename. + Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a + relative file name! + IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device + or directory specification. */ -#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ +#if defined _WIN32 || defined __CYGWIN__ \ + || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__ /* Native Windows, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') -# define HAS_DEVICE(P) \ - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ - && (P)[1] == ':') -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) -# define IS_PATH_WITH_DIR(P) \ - (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) -# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) + /* Internal macro: Tests whether a character is a drive letter. */ +# define _IS_DRIVE_LETTER(C) \ + (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z')) + /* Help the compiler optimizing it. This assumes ASCII. */ +# undef _IS_DRIVE_LETTER +# define _IS_DRIVE_LETTER(C) \ + (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a') +# define HAS_DEVICE(Filename) \ + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':') +# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0) +# ifdef __CYGWIN__ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +# else + /* On native Windows, OS/2, DOS, the system has the notion of a + "current directory" on each drive. */ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 +# endif +# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define IS_ABSOLUTE_FILE_NAME(Filename) \ + ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)]) +# else +# define IS_ABSOLUTE_FILE_NAME(Filename) \ + (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)) +# endif +# define IS_RELATIVE_FILE_NAME(Filename) \ + (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))) +# define IS_FILE_NAME_WITH_DIR(Filename) \ + (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \ + || HAS_DEVICE (Filename)) #else /* Unix */ # define ISSLASH(C) ((C) == '/') -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) -# define FILE_SYSTEM_PREFIX_LEN(P) 0 +# define HAS_DEVICE(Filename) ((void) (Filename), 0) +# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0) +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0]) +# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0])) +# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL) #endif +/* Deprecated macros. For backward compatibility with old users of the + 'filename' module. */ +#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME +#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR + #ifdef __cplusplus } diff --git a/contrib/tools/bison/lib/gl_list.h b/contrib/tools/bison/lib/gl_list.h index 39d14401f9..53d6e5da61 100644 --- a/contrib/tools/bison/lib/gl_list.h +++ b/contrib/tools/bison/lib/gl_list.h @@ -74,7 +74,11 @@ extern "C" { gl_list_next_node O(1) O(1) O(log n) O(1) O(log n) gl_list_previous_node O(1) O(1) O(log n) O(1) O(log n) gl_list_get_at O(1) O(n) O(log n) O(n) O(log n) + gl_list_get_first O(1) O(1) O(log n) O(1) O(log n) + gl_list_get_last O(1) O(1) O(log n) O(1) O(log n) gl_list_set_at O(1) O(n) O(log n) O(n) O((log n)²)/O(log n) + gl_list_set_first O(1) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) + gl_list_set_last O(1) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) gl_list_search O(n) O(n) O(n) O(n)/O(1) O(log n)/O(1) gl_list_search_from O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) gl_list_search_from_to O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) @@ -88,6 +92,8 @@ extern "C" { gl_list_add_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) gl_list_remove_node O(n) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) gl_list_remove_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) + gl_list_remove_first O(n)/O(1) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) + gl_list_remove_last O(1) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) gl_list_remove O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) gl_list_iterator O(1) O(1) O(log n) O(1) O(log n) gl_list_iterator_from_to O(1) O(n) O(log n) O(n) O(log n) @@ -191,10 +197,7 @@ extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, /* Likewise. Returns 0 upon success, -1 upon out-of-memory. */ extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Returns the node immediately after the given node in the list, or NULL if the given node is the last (rightmost) one in the list. */ @@ -208,6 +211,14 @@ extern gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node POSITION must be >= 0 and < gl_list_size (list). */ extern const void * gl_list_get_at (gl_list_t list, size_t position); +/* Returns the element at the first position in the list. + The list must be non-empty. */ +extern const void * gl_list_get_first (gl_list_t list); + +/* Returns the element at the last position in the list. + The list must be non-empty. */ +extern const void * gl_list_get_last (gl_list_t list); + /* Replaces the element at a given position in the list. POSITION must be >= 0 and < gl_list_size (list). Returns its node. */ @@ -217,10 +228,25 @@ extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, /* Likewise. Returns NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; + +/* Replaces the element at the first position in the list. + Returns its node. + The list must be non-empty. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_set_first (gl_list_t list, const void *elt); +/* Likewise. Returns NULL upon out-of-memory. */ +extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt) + _GL_ATTRIBUTE_NODISCARD; + +/* Replaces the element at the last position in the list. + Returns its node. + The list must be non-empty. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_set_last (gl_list_t list, const void *elt); +/* Likewise. Returns NULL upon out-of-memory. */ +extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt) + _GL_ATTRIBUTE_NODISCARD; /* Searches whether an element is already in the list. Returns its node if found, or NULL if not present in the list. */ @@ -263,10 +289,7 @@ extern size_t gl_list_indexof_from_to (gl_list_t list, extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt); /* Likewise. Returns NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Adds an element as the last element of the list. Returns its node. */ @@ -274,10 +297,7 @@ extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt); /* Likewise. Returns NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Adds an element before a given element node of the list. Returns its node. */ @@ -288,10 +308,7 @@ extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, extern gl_list_node_t gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Adds an element after a given element node of the list. Returns its node. */ @@ -301,10 +318,7 @@ extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, /* Likewise. Returns NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Adds an element at a given position in the list. POSITION must be >= 0 and <= gl_list_size (list). */ @@ -314,10 +328,7 @@ extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, /* Likewise. Returns NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Removes an element from the list. Returns true. */ @@ -328,6 +339,14 @@ extern bool gl_list_remove_node (gl_list_t list, gl_list_node_t node); Returns true. */ extern bool gl_list_remove_at (gl_list_t list, size_t position); +/* Removes the element at the first position from the list. + Returns true if it was found and removed, or false if the list was empty. */ +extern bool gl_list_remove_first (gl_list_t list); + +/* Removes the element at the last position from the list. + Returns true if it was found and removed, or false if the list was empty. */ +extern bool gl_list_remove_last (gl_list_t list); + /* Searches and removes an element from the list. Returns true if it was found and removed. */ extern bool gl_list_remove (gl_list_t list, const void *elt); @@ -453,10 +472,7 @@ extern gl_list_node_t gl_sortedlist_add (gl_list_t list, extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif - ; + _GL_ATTRIBUTE_NODISCARD; /* Searches and removes an element from the list. The list is assumed to be sorted with COMPAR. @@ -593,10 +609,7 @@ gl_list_node_value (gl_list_t list, gl_list_node_t node) ->node_value (list, node); } -GL_LIST_INLINE int -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt) { @@ -625,16 +638,37 @@ gl_list_get_at (gl_list_t list, size_t position) ->get_at (list, position); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE const void * +gl_list_get_first (gl_list_t list) +{ + return gl_list_get_at (list, 0); +} + +GL_LIST_INLINE const void * +gl_list_get_last (gl_list_t list) +{ + return gl_list_get_at (list, gl_list_size (list) - 1); +} + +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_set_at (list, position, elt); } +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t +gl_list_nx_set_first (gl_list_t list, const void *elt) +{ + return gl_list_nx_set_at (list, 0, elt); +} + +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t +gl_list_nx_set_last (gl_list_t list, const void *elt) +{ + return gl_list_nx_set_at (list, gl_list_size (list) - 1, elt); +} + GL_LIST_INLINE gl_list_node_t gl_list_search (gl_list_t list, const void *elt) { @@ -683,50 +717,35 @@ gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, ->indexof_from_to (list, start_index, end_index, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_first (list, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_last (list, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_before (list, node, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_after (list, node, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -748,6 +767,26 @@ gl_list_remove_at (gl_list_t list, size_t position) } GL_LIST_INLINE bool +gl_list_remove_first (gl_list_t list) +{ + size_t size = gl_list_size (list); + if (size > 0) + return gl_list_remove_at (list, 0); + else + return false; +} + +GL_LIST_INLINE bool +gl_list_remove_last (gl_list_t list) +{ + size_t size = gl_list_size (list); + if (size > 0) + return gl_list_remove_at (list, size - 1); + else + return false; +} + +GL_LIST_INLINE bool gl_list_remove (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -817,10 +856,7 @@ gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, elt); } -GL_LIST_INLINE gl_list_node_t -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - __attribute__ ((__warn_unused_result__)) -#endif +GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable diff --git a/contrib/tools/bison/lib/gl_xlist.h b/contrib/tools/bison/lib/gl_xlist.h index ef6b93f6a5..7bf9c23953 100644 --- a/contrib/tools/bison/lib/gl_xlist.h +++ b/contrib/tools/bison/lib/gl_xlist.h @@ -52,6 +52,8 @@ extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt); extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, const void *elt); +extern gl_list_node_t gl_list_set_first (gl_list_t list, const void *elt); +extern gl_list_node_t gl_list_set_last (gl_list_t list, const void *elt); extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt); extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt); extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, @@ -114,6 +116,24 @@ gl_list_set_at (gl_list_t list, size_t position, const void *elt) } GL_XLIST_INLINE gl_list_node_t +gl_list_set_first (gl_list_t list, const void *elt) +{ + gl_list_node_t result = gl_list_nx_set_first (list, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_set_last (gl_list_t list, const void *elt) +{ + gl_list_node_t result = gl_list_nx_set_last (list, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt) { gl_list_node_t result = gl_list_nx_add_first (list, elt); diff --git a/contrib/tools/bison/lib/hash.h b/contrib/tools/bison/lib/hash.h index 2ff4266a4f..ae08ce8678 100644 --- a/contrib/tools/bison/lib/hash.h +++ b/contrib/tools/bison/lib/hash.h @@ -27,24 +27,6 @@ # include <stdio.h> # include <stdbool.h> -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The warn_unused_result attribute appeared first in gcc-3.4.0. */ -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) -# else -# define _GL_ATTRIBUTE_WUR /* empty */ -# endif - -# ifndef _GL_ATTRIBUTE_DEPRECATED -/* The __attribute__((__deprecated__)) feature - is available in gcc versions 3.1 and newer. */ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) -# define _GL_ATTRIBUTE_DEPRECATED /* empty */ -# else -# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) -# endif -# endif - typedef size_t (*Hash_hasher) (const void *, size_t); typedef bool (*Hash_comparator) (const void *, const void *); typedef void (*Hash_data_freer) (void *); @@ -88,16 +70,16 @@ size_t hash_string (const char *, size_t) _GL_ATTRIBUTE_PURE; void hash_reset_tuning (Hash_tuning *); Hash_table *hash_initialize (size_t, const Hash_tuning *, Hash_hasher, Hash_comparator, - Hash_data_freer) _GL_ATTRIBUTE_WUR; + Hash_data_freer) _GL_ATTRIBUTE_NODISCARD; Hash_table *hash_xinitialize (size_t, const Hash_tuning *, Hash_hasher, Hash_comparator, - Hash_data_freer) _GL_ATTRIBUTE_WUR; + Hash_data_freer) _GL_ATTRIBUTE_NODISCARD; void hash_clear (Hash_table *); void hash_free (Hash_table *); /* Insertion and deletion. */ -bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR; -void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR; +bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_NODISCARD; +void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_NODISCARD; int hash_insert_if_absent (Hash_table *table, const void *entry, const void **matched_ent); diff --git a/contrib/tools/bison/lib/mbrtowc.c b/contrib/tools/bison/lib/mbrtowc.c index 08e181bc3b..29ad9e8677 100644 --- a/contrib/tools/bison/lib/mbrtowc.c +++ b/contrib/tools/bison/lib/mbrtowc.c @@ -50,18 +50,11 @@ # endif +# include "attribute.h" # include "verify.h" # error #include "lc-charset-dispatch.h" # error #include "mbtowc-lock.h" -# ifndef FALLTHROUGH -# if __GNUC__ < 7 -# define FALLTHROUGH ((void) 0) -# else -# define FALLTHROUGH __attribute__ ((__fallthrough__)) -# endif -# endif - verify (sizeof (mbstate_t) >= 4); static char internal_state[4]; diff --git a/contrib/tools/bison/lib/open.c b/contrib/tools/bison/lib/open.c index 487194f665..bb180fde29 100644 --- a/contrib/tools/bison/lib/open.c +++ b/contrib/tools/bison/lib/open.c @@ -110,7 +110,9 @@ open (const char *filename, int flags, ...) directories, - if O_WRONLY or O_RDWR is specified, open() must fail because the file does not contain a '.' directory. */ - if (flags & (O_CREAT | O_WRONLY | O_RDWR)) + if ((flags & O_CREAT) + || (flags & O_ACCMODE) == O_RDWR + || (flags & O_ACCMODE) == O_WRONLY) { size_t len = strlen (filename); if (len > 0 && filename[len - 1] == '/') diff --git a/contrib/tools/bison/lib/quotearg.c b/contrib/tools/bison/lib/quotearg.c index c78fc1670f..b13574d2fd 100644 --- a/contrib/tools/bison/lib/quotearg.c +++ b/contrib/tools/bison/lib/quotearg.c @@ -29,6 +29,7 @@ #include "quotearg.h" #include "quote.h" +#include "attribute.h" #include "minmax.h" #include "xalloc.h" #include "c-strcaseeq.h" @@ -54,14 +55,6 @@ #define INT_BITS (sizeof (int) * CHAR_BIT) -#ifndef FALLTHROUGH -# if __GNUC__ < 7 -# define FALLTHROUGH ((void) 0) -# else -# define FALLTHROUGH __attribute__ ((__fallthrough__)) -# endif -#endif - struct quoting_options { /* Basic quoting style. */ diff --git a/contrib/tools/bison/lib/readline.c b/contrib/tools/bison/lib/readline.c new file mode 100644 index 0000000000..ec042219d9 --- /dev/null +++ b/contrib/tools/bison/lib/readline.c @@ -0,0 +1,55 @@ +/* readline.c --- Simple implementation of readline. + Copyright (C) 2005-2007, 2009-2020 Free Software Foundation, Inc. + Written by Simon Josefsson + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* This module is intended to be used when the application only needs + the readline interface. If you need more functions from the + readline library, it is recommended to require the readline library + (or improve this module) rather than #if-protect part of your + application (doing so would add assumptions of this module into + your application). The application should use #include + "readline.h", that header file will include <readline/readline.h> + if the real library is present on the system. */ + +/* Get specification. */ +#include "readline.h" + +#include <stdio.h> +#include <string.h> + +char * +readline (const char *prompt) +{ + char *out = NULL; + size_t size = 0; + + if (prompt) + { + fputs (prompt, stdout); + fflush (stdout); + } + + if (getline (&out, &size, stdin) < 0) + return NULL; + + while (*out && (out[strlen (out) - 1] == '\r' + || out[strlen (out) - 1] == '\n')) + out[strlen (out) - 1] = '\0'; + + return out; +} diff --git a/contrib/tools/bison/lib/readline.h b/contrib/tools/bison/lib/readline.h new file mode 100644 index 0000000000..0d9a00308c --- /dev/null +++ b/contrib/tools/bison/lib/readline.h @@ -0,0 +1,34 @@ +/* readline.h --- Simple implementation of readline. + Copyright (C) 2005, 2009-2020 Free Software Foundation, Inc. + Written by Simon Josefsson + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#ifndef GL_READLINE_H +#define GL_READLINE_H + +#if HAVE_READLINE_READLINE_H +/* <readline/readline.h> makes use of the FILE type without including + <stdio.h> itself. */ +# include <stdio.h> +# include <readline/readline.h> +#else +/* Prints a prompt PROMPT and then reads and returns a single line of + text from the user. If PROMPT is NULL or the empty string, no + prompt is displayed. The returned line is allocated with malloc; + the caller should free the line when it has finished with it. */ +extern char *readline (const char *prompt); +#endif + +#endif /* GL_READLINE_H */ diff --git a/contrib/tools/bison/lib/vasnprintf.c b/contrib/tools/bison/lib/vasnprintf.c index e3a1e9fa75..62f8fbf4db 100644 --- a/contrib/tools/bison/lib/vasnprintf.c +++ b/contrib/tools/bison/lib/vasnprintf.c @@ -41,7 +41,14 @@ DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. - DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ + DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. + ENABLE_WCHAR_FALLBACK Set to 1 to avoid EILSEQ during conversion of wide + characters (wchar_t) and wide character strings + (wchar_t[]) to multibyte sequences. The fallback is the + hexadecimal escape syntax (\unnnn or \Unnnnnnnn) or, + if wchar_t is not Unicode encoded, \wnnnn or \Wnnnnnnnn. + */ /* Tell glibc's <stdio.h> to provide a prototype for snprintf(). This must come before <config.h> because <config.h> may include @@ -87,6 +94,7 @@ /* Checked size_t computations. */ #include "xsize.h" +#include "attribute.h" #include "verify.h" #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL @@ -118,14 +126,6 @@ # include "fpucw.h" #endif -#ifndef FALLTHROUGH -# if __GNUC__ < 7 -# define FALLTHROUGH ((void) 0) -# else -# define FALLTHROUGH __attribute__ ((__fallthrough__)) -# endif -#endif - /* Default parameters. */ #ifndef VASNPRINTF # if WIDE_CHAR_VERSION @@ -277,6 +277,74 @@ local_wcsnlen (const wchar_t *s, size_t maxlen) # endif #endif +#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || (ENABLE_WCHAR_FALLBACK && HAVE_WINT_T)) && !WIDE_CHAR_VERSION +# if ENABLE_WCHAR_FALLBACK +static size_t +wctomb_fallback (char *s, wchar_t wc) +{ + static char hex[16] = "0123456789ABCDEF"; + + s[0] = '\\'; + if (sizeof (wchar_t) > 2 && wc > 0xffff) + { +# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__) + s[1] = 'U'; +# else + s[1] = 'W'; +# endif + s[2] = hex[(wc & 0xf0000000U) >> 28]; + s[3] = hex[(wc & 0xf000000U) >> 24]; + s[4] = hex[(wc & 0xf00000U) >> 20]; + s[5] = hex[(wc & 0xf0000U) >> 16]; + s[6] = hex[(wc & 0xf000U) >> 12]; + s[7] = hex[(wc & 0xf00U) >> 8]; + s[8] = hex[(wc & 0xf0U) >> 4]; + s[9] = hex[wc & 0xfU]; + return 10; + } + else + { +# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__) + s[1] = 'u'; +# else + s[1] = 'w'; +# endif + s[2] = hex[(wc & 0xf000U) >> 12]; + s[3] = hex[(wc & 0xf00U) >> 8]; + s[4] = hex[(wc & 0xf0U) >> 4]; + s[5] = hex[wc & 0xfU]; + return 6; + } +} +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t +static size_t +local_wcrtomb (char *s, wchar_t wc, mbstate_t *ps) +{ + size_t count = wcrtomb (s, wc, ps); + if (count == (size_t)(-1)) + count = wctomb_fallback (s, wc); + return count; +} +# else +static int +local_wctomb (char *s, wchar_t wc) +{ + int count = wctomb (s, wc); + if (count < 0) + count = wctomb_fallback (s, wc); + return count; +} +# define local_wcrtomb(S, WC, PS) local_wctomb ((S), (WC)) +# endif +# else +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t +# define local_wcrtomb(S, WC, PS) wcrtomb ((S), (WC), (PS)) +# else +# define local_wcrtomb(S, WC, PS) wctomb ((S), (WC)) +# endif +# endif +#endif + #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL /* Determine the decimal-point character according to the current locale. */ # ifndef decimal_point_char_defined @@ -1677,7 +1745,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, case 'c': # if HAVE_WINT_T && !WIDE_CHAR_VERSION if (type == TYPE_WIDE_CHAR) - tmp_length = MB_CUR_MAX; + { + tmp_length = MB_CUR_MAX; +# if ENABLE_WCHAR_FALLBACK + if (tmp_length < (sizeof (wchar_t) > 2 ? 10 : 6)) + tmp_length = (sizeof (wchar_t) > 2 ? 10 : 6); +# endif + } else # endif tmp_length = 1; @@ -2394,7 +2468,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } #endif -#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T else if (dp->conversion == 's' # if WIDE_CHAR_VERSION && a.arg[dp->arg_index].type != TYPE_WIDE_STRING @@ -2669,11 +2743,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (*arg_end == 0) /* Found the terminating null wide character. */ break; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg_end, &state); -# else - count = wctomb (cbuf, *arg_end); -# endif + count = local_wcrtomb (cbuf, *arg_end, &state); if (count < 0) { /* Cannot convert. */ @@ -2714,11 +2784,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (*arg_end == 0) /* Found the terminating null wide character. */ break; -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg_end, &state); -# else - count = wctomb (cbuf, *arg_end); -# endif + count = local_wcrtomb (cbuf, *arg_end, &state); if (count < 0) { /* Cannot convert. */ @@ -2763,11 +2829,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (*arg == 0) abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif + count = local_wcrtomb (cbuf, *arg, &state); if (count <= 0) /* Inconsistency. */ abort (); @@ -2844,11 +2906,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (*arg == 0) abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif + count = local_wcrtomb (cbuf, *arg, &state); if (count <= 0) /* Inconsistency. */ abort (); @@ -2873,11 +2931,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (*arg == 0) abort (); -# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t - count = wcrtomb (cbuf, *arg, &state); -# else - count = wctomb (cbuf, *arg); -# endif + count = local_wcrtomb (cbuf, *arg, &state); if (count <= 0) { /* Cannot convert. */ @@ -2913,6 +2967,210 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # endif } #endif +#if ENABLE_WCHAR_FALLBACK && HAVE_WINT_T && !WIDE_CHAR_VERSION + else if (dp->conversion == 'c' + && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR) + { + /* Implement the 'lc' directive ourselves, in order to provide + the fallback that avoids EILSEQ. */ + int flags = dp->flags; + int has_width; + size_t width; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + /* %lc in vasnprintf. See the specification of fprintf. */ + { + wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char; + size_t characters; +# if !DCHAR_IS_TCHAR + /* This code assumes that TCHAR_T is 'char'. */ + verify (sizeof (TCHAR_T) == 1); + TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */ + DCHAR_T *tmpdst; + size_t tmpdst_len; +# endif + size_t w; + +# if DCHAR_IS_TCHAR + if (has_width) +# endif + { + /* Count the number of bytes. */ + characters = 0; + if (arg != 0) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count < 0) + /* Inconsistency. */ + abort (); + characters = count; + } + } +# if DCHAR_IS_TCHAR + else + { + /* The number of bytes doesn't matter. */ + characters = 0; + } +# endif + +# if !DCHAR_IS_TCHAR + /* Convert the string into a piece of temporary memory. */ + if (characters > 0) /* implies arg != 0 */ + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (tmpsrc, cbuf, count); + } + + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, characters, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + { + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } +# endif + + if (has_width) + { +# if ENABLE_UNISTDIO + /* Outside POSIX, it's preferable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, characters); +# else + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = characters; +# endif + } + else + /* w doesn't matter. */ + w = 0; + + if (w < width && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_TCHAR + if (has_width) + { + /* We know the number of bytes in advance. */ + ENSURE_ALLOCATION (xsum (length, characters)); + if (characters > 0) /* implies arg != 0 */ + { + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); +# endif + + count = local_wcrtomb (result + length, arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + length += count; + } + } + else + { + if (arg != 0) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + ENSURE_ALLOCATION (xsum (length, count)); + memcpy (result + length, cbuf, count); + length += count; + } + } +# else + ENSURE_ALLOCATION (xsum (length, tmpdst_len)); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + length += tmpdst_len; +# endif + + if (w < width && (dp->flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } +#endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'a' || dp->conversion == 'A') # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) diff --git a/contrib/tools/bison/lib/vasnprintf.h b/contrib/tools/bison/lib/vasnprintf.h index f63399a5e6..1608014262 100644 --- a/contrib/tools/bison/lib/vasnprintf.h +++ b/contrib/tools/bison/lib/vasnprintf.h @@ -23,18 +23,6 @@ /* Get size_t. */ #include <stddef.h> -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/contrib/tools/bison/lib/xalloc.h b/contrib/tools/bison/lib/xalloc.h index 19c64acb41..24273ffbe3 100644 --- a/contrib/tools/bison/lib/xalloc.h +++ b/contrib/tools/bison/lib/xalloc.h @@ -36,13 +36,6 @@ extern "C" { #endif -#if ! defined __clang__ && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) -#else -# define _GL_ATTRIBUTE_ALLOC_SIZE(args) -#endif - /* This function is always triggered when memory is exhausted. It must be defined by the application, either explicitly or by using gnulib's xalloc-die module. This is the diff --git a/contrib/tools/bison/lib/xmalloc.c b/contrib/tools/bison/lib/xmalloc.c index 486873602e..69c4e7dfae 100644 --- a/contrib/tools/bison/lib/xmalloc.c +++ b/contrib/tools/bison/lib/xmalloc.c @@ -24,14 +24,26 @@ #include <stdlib.h> #include <string.h> -/* 1 if calloc is known to be compatible with GNU calloc. This - matters if we are not also using the calloc module, which defines - HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ +/* 1 if calloc, malloc and realloc are known to be compatible with GNU. + This matters if we are not also using the calloc-gnu, malloc-gnu + and realloc-gnu modules, which define HAVE_CALLOC_GNU, + HAVE_MALLOC_GNU and HAVE_REALLOC_GNU and support the GNU API even + on non-GNU platforms. */ #if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) enum { HAVE_GNU_CALLOC = 1 }; #else enum { HAVE_GNU_CALLOC = 0 }; #endif +#if defined HAVE_MALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) +enum { HAVE_GNU_MALLOC = 1 }; +#else +enum { HAVE_GNU_MALLOC = 0 }; +#endif +#if defined HAVE_REALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) +enum { HAVE_GNU_REALLOC = 1 }; +#else +enum { HAVE_GNU_REALLOC = 0 }; +#endif /* Allocate N bytes of memory dynamically, with error checking. */ @@ -39,7 +51,7 @@ void * xmalloc (size_t n) { void *p = malloc (n); - if (!p && n != 0) + if (!p && (HAVE_GNU_MALLOC || n)) xalloc_die (); return p; } @@ -50,18 +62,17 @@ xmalloc (size_t n) void * xrealloc (void *p, size_t n) { - if (!n && p) + if (!HAVE_GNU_REALLOC && !n && p) { - /* The GNU and C99 realloc behaviors disagree here. Act like - GNU, even if the underlying realloc is C99. */ + /* The GNU and C99 realloc behaviors disagree here. Act like GNU. */ free (p); return NULL; } - p = realloc (p, n); - if (!p && n) + void *r = realloc (p, n); + if (!r && (n || (HAVE_GNU_REALLOC && !p))) xalloc_die (); - return p; + return r; } /* If P is null, allocate a block of at least *PN bytes; otherwise, diff --git a/contrib/tools/bison/lib/xsize.h b/contrib/tools/bison/lib/xsize.h index 45d4166179..26ef20b64b 100644 --- a/contrib/tools/bison/lib/xsize.h +++ b/contrib/tools/bison/lib/xsize.h @@ -27,6 +27,9 @@ # include <stdint.h> #endif +/* Get ATTRIBUTE_PURE. */ +#include "attribute.h" + #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif @@ -56,10 +59,7 @@ _GL_INLINE_HEADER_BEGIN ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) /* Sum of two sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif +XSIZE_INLINE size_t ATTRIBUTE_PURE xsum (size_t size1, size_t size2) { size_t sum = size1 + size2; @@ -67,30 +67,21 @@ xsum (size_t size1, size_t size2) } /* Sum of three sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif +XSIZE_INLINE size_t ATTRIBUTE_PURE xsum3 (size_t size1, size_t size2, size_t size3) { return xsum (xsum (size1, size2), size3); } /* Sum of four sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif +XSIZE_INLINE size_t ATTRIBUTE_PURE xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) { return xsum (xsum (xsum (size1, size2), size3), size4); } /* Maximum of two sizes, with overflow check. */ -XSIZE_INLINE size_t -#if __GNUC__ >= 3 -__attribute__ ((__pure__)) -#endif +XSIZE_INLINE size_t ATTRIBUTE_PURE xmax (size_t size1, size_t size2) { /* No explicit check is needed here, because for any n: diff --git a/contrib/tools/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make index 41aec50a87..85c4aade38 100644 --- a/contrib/tools/bison/lib/ya.make +++ b/contrib/tools/bison/lib/ya.make @@ -83,6 +83,7 @@ SRCS( printf-parse.c progname.c quotearg.c + readline.c setlocale_null.c sig-handler.c spawn-pipe.c diff --git a/contrib/tools/bison/src/complain.c b/contrib/tools/bison/src/complain.c index f15c6b8bd1..6a78d40e7f 100644 --- a/contrib/tools/bison/src/complain.c +++ b/contrib/tools/bison/src/complain.c @@ -23,6 +23,7 @@ #include "system.h" #include <argmatch.h> +#include <c-ctype.h> #include <progname.h> #include <stdarg.h> #include <sys/stat.h> @@ -263,6 +264,20 @@ severity_prefix (severity s) } +static void +severity_print (severity s, FILE *out) +{ + if (s != severity_disabled) + { + const char* style = severity_style (s); + begin_use_class (style, out); + fprintf (out, "%s:", severity_prefix (s)); + end_use_class (style, out); + fputc (' ', out); + } +} + + /*-----------. | complain. | `-----------*/ @@ -409,7 +424,6 @@ warnings_print_categories (warnings warn_flags, FILE *out) * * \param loc the location, defaulting to the current file, * or the program name. - * \param indent optional indentation for the error message. * \param flags the category for this message. * \param sever to decide the prefix to put before the message * (e.g., "warning"). @@ -421,33 +435,21 @@ warnings_print_categories (warnings warn_flags, FILE *out) */ static void -error_message (const location *loc, int *indent, warnings flags, +error_message (const location *loc, warnings flags, severity sever, const char *message, va_list args) { - int pos = 0; + const char* style = flags & note ? "note" : severity_style (sever); if (loc) - pos += location_print (*loc, stderr); + location_print (*loc, stderr); else - pos += fprintf (stderr, "%s", grammar_file ? grammar_file : program_name); - pos += fprintf (stderr, ": "); - - if (indent) - { - if (*indent) - sever = severity_disabled; - if (!*indent) - *indent = pos; - else if (*indent > pos) - fprintf (stderr, "%*s", *indent - pos, ""); - } - - const char* style = severity_style (sever); + fprintf (stderr, "%s", grammar_file ? grammar_file : program_name); + fprintf (stderr, ": "); if (sever != severity_disabled) { begin_use_class (style, stderr); - fprintf (stderr, "%s:", severity_prefix (sever)); + fprintf (stderr, "%s:", flags & note ? _("note") : severity_prefix (sever)); end_use_class (style, stderr); fputc (' ', stderr); } @@ -458,34 +460,32 @@ error_message (const location *loc, int *indent, warnings flags, if (! (flags & silent) && sever != severity_disabled) warnings_print_categories (flags, stderr); - { - size_t l = strlen (message); - if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ') - { - putc ('\n', stderr); - flush (stderr); - if (loc && feature_flag & feature_caret && !(flags & no_caret)) - location_caret (*loc, style, stderr); - } - } + size_t l = strlen (message); + if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ') + { + putc ('\n', stderr); + flush (stderr); + if (loc && !(flags & no_caret)) + location_caret (*loc, style, stderr); + } flush (stderr); } /** Raise a complaint (fatal error, error or just warning). */ static void -complains (const location *loc, int *indent, warnings flags, +complains (const location *loc, warnings flags, const char *message, va_list args) { - severity s = warning_severity (flags); if ((flags & complaint) && complaint_status < status_complaint) complaint_status = status_complaint; + severity s = warning_severity (flags); if (severity_warning <= s) { if (severity_error <= s && ! complaint_status) complaint_status = status_warning_as_error; - error_message (loc, indent, flags, s, message, args); + error_message (loc, flags, s, message, args); } if (flags & fatal) @@ -497,41 +497,39 @@ complain (location const *loc, warnings flags, const char *message, ...) { va_list args; va_start (args, message); - complains (loc, NULL, flags, message, args); + complains (loc, flags, message, args); va_end (args); } void -complain_indent (location const *loc, warnings flags, int *indent, - const char *message, ...) +subcomplain (location const *loc, warnings flags, const char *message, ...) { va_list args; va_start (args, message); - complains (loc, indent, flags, message, args); + complains (loc, flags | note | silent, message, args); va_end (args); } void -complain_args (location const *loc, warnings w, int *indent, +complain_args (location const *loc, warnings w, int argc, char *argv[]) { switch (argc) { case 1: - complain_indent (loc, w, indent, "%s", _(argv[0])); + complain (loc, w, "%s", _(argv[0])); break; case 2: - complain_indent (loc, w, indent, _(argv[0]), argv[1]); + complain (loc, w, _(argv[0]), argv[1]); break; case 3: - complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2]); + complain (loc, w, _(argv[0]), argv[1], argv[2]); break; case 4: - complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3]); + complain (loc, w, _(argv[0]), argv[1], argv[2], argv[3]); break; case 5: - complain_indent (loc, w, indent, _(argv[0]), argv[1], argv[2], argv[3], - argv[4]); + complain (loc, w, _(argv[0]), argv[1], argv[2], argv[3], argv[4]); break; default: complain (loc, fatal, "too many arguments for complains"); @@ -555,8 +553,7 @@ deprecated_directive (location const *loc, char const *old, char const *upd) complain (loc, Wdeprecated, _("deprecated directive: %s, use %s"), quote (old), quote_n (1, upd)); - if (feature_flag & feature_caret) - location_caret_suggestion (*loc, upd, stderr); + location_caret_suggestion (*loc, upd, stderr); /* Register updates only if -Wdeprecated is enabled. */ fixits_register (loc, upd); } @@ -566,13 +563,11 @@ void duplicate_directive (char const *directive, location first, location second) { - int i = 0; if (feature_flag & feature_caret) - complain_indent (&second, Wother, &i, _("duplicate directive")); + complain (&second, Wother, _("duplicate directive")); else - complain_indent (&second, Wother, &i, _("duplicate directive: %s"), quote (directive)); - i += SUB_INDENT; - complain_indent (&first, Wother, &i, _("previous declaration")); + complain (&second, Wother, _("duplicate directive: %s"), quote (directive)); + subcomplain (&first, Wother, _("previous declaration")); fixits_register (&second, ""); } @@ -580,11 +575,57 @@ void duplicate_rule_directive (char const *directive, location first, location second) { - int i = 0; - complain_indent (&second, complaint, &i, - _("only one %s allowed per rule"), directive); - i += SUB_INDENT; - complain_indent (&first, complaint, &i, - _("previous declaration")); + complain (&second, complaint, _("only one %s allowed per rule"), directive); + subcomplain (&first, complaint, _("previous declaration")); fixits_register (&second, ""); } + +void +syntax_error (location loc, + int argc, const char* argv[]) +{ + if (complaint_status < status_complaint) + complaint_status = status_complaint; + assert (argc <= 5); + const char *format = NULL; + switch (argc) + { +#define CASE(N, S) \ + case N: \ + format = S; \ + break + default: /* Avoid compiler warnings. */ + CASE (0, _("syntax error")); + CASE (1, _("unexpected %0$s")); + CASE (2, _("expected %1$s before %0$s")); + CASE (3, _("expected %1$s or %2$s before %0$s")); + CASE (4, _("expected %1$s or %2$s or %3$s before %0$s")); + CASE (5, _("expected %1$s or %2$s or %3$s or %4$s before %0$s")); +#undef CASE + } + location_print (loc, stderr); + fputs (": ", stderr); + severity_print (severity_error, stderr); + + while (*format) + if (format[0] == '%' + && c_isdigit (format[1]) + && format[2] == '$' + && format[3] == 's' + && (format[1] - '0') < argc) + { + int i = format[1] - '0'; + const char *style = i == 0 ? "unexpected" : "expected"; + begin_use_class (style, stderr); + fputs (argv[i], stderr); + end_use_class (style, stderr); + format += 4; + } + else + { + fputc (*format, stderr); + ++format; + } + fputc ('\n', stderr); + location_caret (loc, "error", stderr); +} diff --git a/contrib/tools/bison/src/complain.h b/contrib/tools/bison/src/complain.h index 9cb6a60657..65204ce038 100644 --- a/contrib/tools/bison/src/complain.h +++ b/contrib/tools/bison/src/complain.h @@ -21,9 +21,6 @@ # include "location.h" -/* Sub-messages indent. */ -# define SUB_INDENT (4) - /*---------------. | Error stream. | `---------------*/ @@ -119,6 +116,7 @@ typedef enum fatal = 1 << 12, /**< All fatal errors. */ silent = 1 << 13, /**< Do not display the warning type. */ no_caret = 1 << 14, /**< Do not display caret location. */ + note = 1 << 15, /**< Display as a note. */ /**< All above warnings. */ Weverything = ~complaint & ~fatal & ~silent, @@ -137,13 +135,13 @@ void complain (location const *loc, warnings flags, char const *message, ...) __attribute__ ((__format__ (__printf__, 3, 4))); /** Likewise, but with an \a argc/argv interface. */ -void complain_args (location const *loc, warnings w, int *indent, +void complain_args (location const *loc, warnings w, int argc, char *arg[]); -/** Make a complaint with location and some indentation. */ -void complain_indent (location const *loc, warnings flags, int *indent, - char const *message, ...) - __attribute__ ((__format__ (__printf__, 4, 5))); +/** Make a subcomplain with location and note. */ +void subcomplain (location const *loc, warnings flags, + char const *message, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); /** GNU Bison extension not valid with POSIX Yacc. */ @@ -161,6 +159,11 @@ void duplicate_directive (char const *directive, void duplicate_rule_directive (char const *directive, location first, location second); +/** Report a syntax error, where argv[0] is the unexpected + token, and argv[1...argc] are the expected ones. */ +void syntax_error (location loc, + int argc, const char* argv[]); + /** Warnings treated as errors shouldn't stop the execution as regular errors should (because due to their nature, it is safe to go on). Thus, there are three possible execution statuses. */ diff --git a/contrib/tools/bison/src/fixits.c b/contrib/tools/bison/src/fixits.c index 37a0b7dd99..2c900254d3 100644 --- a/contrib/tools/bison/src/fixits.c +++ b/contrib/tools/bison/src/fixits.c @@ -124,10 +124,11 @@ fixits_run (void) FILE *out = xfopen (input, "w"); size_t line = 1; size_t offset = 1; - fixit const *f = NULL; + void const *p = NULL; gl_list_iterator_t iter = gl_list_iterator (fixits); - while (gl_list_iterator_next (&iter, (const void**) &f, NULL)) + while (gl_list_iterator_next (&iter, &p, NULL)) { + fixit const *f = p; /* Look for the correct line. */ while (line < f->location.start.line) { diff --git a/contrib/tools/bison/src/getargs.c b/contrib/tools/bison/src/getargs.c index 6f19a4ea8c..55884d345b 100644 --- a/contrib/tools/bison/src/getargs.c +++ b/contrib/tools/bison/src/getargs.c @@ -257,7 +257,8 @@ static const argmatch_trace_doc argmatch_trace_docs[] = { "sets", "grammar sets: firsts, nullable etc." }, { "muscles", "m4 definitions passed to the skeleton" }, { "tools", "m4 invocation" }, - { "m4", "m4 traces" }, + { "m4-early", "m4 traces starting from the start" }, + { "m4", "m4 traces starting from the skeleton evaluation" }, { "skeleton", "skeleton postprocessing" }, { "time", "time consumption" }, { "ielr", "IELR conversion" }, @@ -279,6 +280,7 @@ static const argmatch_trace_arg argmatch_trace_args[] = { "sets", trace_sets }, { "muscles", trace_muscles }, { "tools", trace_tools }, + { "m4-early", trace_m4_early }, { "m4", trace_m4 }, { "skeleton", trace_skeleton }, { "time", trace_time }, diff --git a/contrib/tools/bison/src/getargs.h b/contrib/tools/bison/src/getargs.h index 397419262e..c1629ab558 100644 --- a/contrib/tools/bison/src/getargs.h +++ b/contrib/tools/bison/src/getargs.h @@ -100,11 +100,12 @@ enum trace trace_grammar = 1 << 7, /**< Reading, reducing the grammar. */ trace_time = 1 << 8, /**< Time consumption. */ trace_skeleton = 1 << 9, /**< Skeleton postprocessing. */ - trace_m4 = 1 << 10, /**< M4 traces. */ - trace_muscles = 1 << 11, /**< M4 definitions of the muscles. */ - trace_ielr = 1 << 12, /**< IELR conversion. */ - trace_closure = 1 << 13, /**< Input/output of closure(). */ - trace_locations = 1 << 14, /**< Full display of locations. */ + trace_m4_early = 1 << 10, /**< M4 early traces. */ + trace_m4 = 1 << 11, /**< M4 traces. */ + trace_muscles = 1 << 12, /**< M4 definitions of the muscles. */ + trace_ielr = 1 << 13, /**< IELR conversion. */ + trace_closure = 1 << 14, /**< Input/output of closure(). */ + trace_locations = 1 << 15, /**< Full display of locations. */ trace_all = ~0 /**< All of the above. */ }; /** What debug items bison displays during its run. */ diff --git a/contrib/tools/bison/src/lalr.c b/contrib/tools/bison/src/lalr.c index 8b8724d04f..ee6c7cf6c2 100644 --- a/contrib/tools/bison/src/lalr.c +++ b/contrib/tools/bison/src/lalr.c @@ -92,7 +92,7 @@ goto_print (goto_number i, FILE *out) const state_number dst = to_state[i]; symbol_number var = states[dst]->accessing_symbol; fprintf (out, - "goto[%ld] = (%d, %s, %d)", i, src, symbols[var]->tag, dst); + "goto[%zu] = (%d, %s, %d)", i, src, symbols[var]->tag, dst); } void diff --git a/contrib/tools/bison/src/location.c b/contrib/tools/bison/src/location.c index 5631b10bfa..3a31e0e710 100644 --- a/contrib/tools/bison/src/location.c +++ b/contrib/tools/bison/src/location.c @@ -402,6 +402,8 @@ caret_set_column (int col) void location_caret (location loc, const char *style, FILE *out) { + if (!(feature_flag & feature_caret)) + return; if (!loc.start.line) return; if (!caret_set_file (loc.start.file)) @@ -500,6 +502,8 @@ location_caret (location loc, const char *style, FILE *out) void location_caret_suggestion (location loc, const char *s, FILE *out) { + if (!(feature_flag & feature_caret)) + return; const char *style = "fixit-insert"; fprintf (out, " | %*s", loc.start.column - 1 - caret_info.skip diff --git a/contrib/tools/bison/src/location.h b/contrib/tools/bison/src/location.h index cb3025c6a8..d351cb0e3f 100644 --- a/contrib/tools/bison/src/location.h +++ b/contrib/tools/bison/src/location.h @@ -124,12 +124,12 @@ void caret_init (void); left-over by the usage of location_caret. */ void caret_free (void); -/* Quote the line containing LOC onto OUT. Highlight the part of LOC - with the color STYLE. */ +/* If -fcaret is enabled, quote the line containing LOC onto OUT. + Highlight the part of LOC with the color STYLE. */ void location_caret (location loc, const char* style, FILE *out); -/* Display a suggestion of replacement for LOC with S. To call after - location_caret. */ +/* If -fcaret is enabled, display a suggestion of replacement for LOC + with S. To call after location_caret. */ void location_caret_suggestion (location loc, const char *s, FILE *out); /* Return -1, 0, 1, depending whether a is before, equal, or diff --git a/contrib/tools/bison/src/muscle-tab.c b/contrib/tools/bison/src/muscle-tab.c index 5778b8f319..21443f4fe7 100644 --- a/contrib/tools/bison/src/muscle-tab.c +++ b/contrib/tools/bison/src/muscle-tab.c @@ -524,15 +524,13 @@ muscle_percent_define_insert (char const *var, location variable_loc, = atoi (muscle_find_const (how_name)); if (how_old == MUSCLE_PERCENT_DEFINE_F) goto end; - int i = 0; /* If assigning the same value, make it a warning. */ warnings warn = STREQ (value, current_value) ? Wother : complaint; - complain_indent (&variable_loc, warn, &i, - _("%%define variable %s redefined"), - quote (variable)); - i += SUB_INDENT; + complain (&variable_loc, warn, + _("%%define variable %s redefined"), + quote (variable)); location loc = muscle_percent_define_get_loc (variable); - complain_indent (&loc, warn, &i, _("previous definition")); + subcomplain (&loc, warn, _("previous definition")); fixits_register (&variable_loc, ""); warned = true; } @@ -738,14 +736,12 @@ muscle_percent_define_check_values (char const * const *values) if (!*values) { location loc = muscle_percent_define_get_loc (*variablep); - int i = 0; - complain_indent (&loc, complaint, &i, - _("invalid value for %%define variable %s: %s"), - quote (*variablep), quote_n (1, value)); - i += SUB_INDENT; + complain (&loc, complaint, + _("invalid value for %%define variable %s: %s"), + quote (*variablep), quote_n (1, value)); for (values = variablep + 1; *values; ++values) - complain_indent (&loc, complaint | no_caret | silent, &i, - _("accepted value: %s"), quote (*values)); + subcomplain (&loc, complaint | no_caret | silent, + _("accepted value: %s"), quote (*values)); } else while (*values) diff --git a/contrib/tools/bison/src/output.c b/contrib/tools/bison/src/output.c index 5eccea4941..e63c325492 100644 --- a/contrib/tools/bison/src/output.c +++ b/contrib/tools/bison/src/output.c @@ -50,6 +50,10 @@ static struct obstack format_obstack; | result of formatting the FIRST and then TABLE_DATA[BEGIN..END[ (of | | TYPE), and to the muscle NAME_max, the max value of the | | TABLE_DATA. | +| | +| For the typical case of outputting a complete table from 0, pass | +| TABLE[0] as FIRST, and 1 as BEGIN. For instance | +| muscle_insert_base_table ("pact", base, base[0], 1, nstates); | `-------------------------------------------------------------------*/ @@ -132,42 +136,130 @@ string_output (FILE *out, char const *string) } +/* Store in BUFFER a copy of SRC where trigraphs are escaped, return + the size of the result (including the final NUL). If called with + BUFFERSIZE = 0, returns the needed size for BUFFER. */ +static ptrdiff_t +escape_trigraphs (char *buffer, ptrdiff_t buffersize, const char *src) +{ +#define STORE(c) \ + do \ + { \ + if (res < buffersize) \ + buffer[res] = (c); \ + ++res; \ + } \ + while (0) + ptrdiff_t res = 0; + for (ptrdiff_t i = 0, len = strlen (src); i < len; ++i) + { + if (i + 2 < len + && src[i] == '?' && src[i+1] == '?') + { + switch (src[i+2]) + { + case '!': case '\'': + case '(': case ')': case '-': case '/': + case '<': case '=': case '>': + i += 1; + STORE ('?'); + STORE ('"'); + STORE ('"'); + STORE ('?'); + continue; + } + } + STORE (src[i]); + } + STORE ('\0'); +#undef STORE + return res; +} + +/* Same as xstrdup, except that trigraphs are escaped. */ +static char * +xescape_trigraphs (const char *src) +{ + ptrdiff_t bufsize = escape_trigraphs (NULL, 0, src); + char *buf = xcharalloc (bufsize); + escape_trigraphs (buf, bufsize, src); + return buf; +} + +/* The tag to show in the generated parsers. Use "end of file" rather + than "$end". But keep "$end" in the reports, it's shorter and more + consistent. Support i18n if the user already uses it. */ +static const char * +symbol_tag (const symbol *sym) +{ + const bool eof_is_user_defined + = !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end"); + + if (!eof_is_user_defined && sym->content == endtoken->content) + return "\"end of file\""; + else if (sym->content == undeftoken->content) + return "\"invalid token\""; + else + return sym->tag; +} + /* Generate the b4_<MUSCLE_NAME> (e.g., b4_tname) table with the symbol names (aka tags). */ static void prepare_symbol_names (char const *muscle_name) { + // Whether to add a pair of quotes around the name. + const bool quote = STREQ (muscle_name, "tname"); + bool has_translations = false; + /* We assume that the table will be output starting at column 2. */ - int j = 2; + int col = 2; struct quoting_options *qo = clone_quoting_options (0); set_quoting_style (qo, c_quoting_style); set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS); for (int i = 0; i < nsyms; i++) { - char *cp = quotearg_alloc (symbols[i]->tag, -1, qo); + const char *tag = symbol_tag (symbols[i]); + bool translatable = !quote && symbols[i]->translatable; + if (translatable) + has_translations = true; + + char *cp + = tag[0] == '"' && !quote + ? xescape_trigraphs (tag) + : quotearg_alloc (tag, -1, qo); /* Width of the next token, including the two quotes, the comma and the space. */ - int width = strlen (cp) + 2; + int width + = strlen (cp) + 2 + + (translatable ? strlen ("N_()") : 0); - if (j + width > 75) + if (col + width > 75) { obstack_sgrow (&format_obstack, "\n "); - j = 1; + col = 1; } if (i) obstack_1grow (&format_obstack, ' '); + if (translatable) + obstack_sgrow (&format_obstack, "]b4_symbol_translate(["); obstack_escape (&format_obstack, cp); + if (translatable) + obstack_sgrow (&format_obstack, "])["); free (cp); obstack_1grow (&format_obstack, ','); - j += width; + col += width; } free (qo); obstack_sgrow (&format_obstack, " ]b4_null["); /* Finish table and store. */ muscle_insert (muscle_name, obstack_finish0 (&format_obstack)); + + /* Announce whether translation support is needed. */ + MUSCLE_INSERT_BOOL ("has_translations_flag", has_translations); } @@ -182,7 +274,6 @@ prepare_symbols (void) MUSCLE_INSERT_INT ("tokens_number", ntokens); MUSCLE_INSERT_INT ("nterms_number", nvars); MUSCLE_INSERT_INT ("symbols_number", nsyms); - MUSCLE_INSERT_INT ("undef_token_number", undeftoken->content->number); MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number); muscle_insert_symbol_number_table ("translate", @@ -192,6 +283,27 @@ prepare_symbols (void) /* tname -- token names. */ prepare_symbol_names ("tname"); + prepare_symbol_names ("symbol_names"); + + /* translatable -- whether a token is translatable. */ + { + bool translatable = false; + for (int i = 0; i < ntokens; ++i) + if (symbols[i]->translatable) + { + translatable = true; + break; + } + if (translatable) + { + int *values = xnmalloc (nsyms, sizeof *values); + for (int i = 0; i < ntokens; ++i) + values[i] = symbols[i]->translatable; + muscle_insert_int_table ("translatable", values, + values[0], 1, ntokens); + free (values); + } + } /* Output YYTOKNUM. */ { @@ -451,14 +563,13 @@ prepare_symbol_definitions (void) /* Its tag. Typically for documentation purpose. */ SET_KEY ("tag"); - MUSCLE_INSERT_STRING (key, sym->tag); + MUSCLE_INSERT_STRING (key, symbol_tag (sym)); SET_KEY ("user_number"); MUSCLE_INSERT_INT (key, sym->content->user_token_number); SET_KEY ("is_token"); - MUSCLE_INSERT_INT (key, - i < ntokens && sym != errtoken && sym != undeftoken); + MUSCLE_INSERT_INT (key, i < ntokens); SET_KEY ("number"); MUSCLE_INSERT_INT (key, sym->content->number); @@ -504,9 +615,7 @@ prepare_symbol_definitions (void) static void prepare_actions (void) { - /* Figure out the actions for the specified state, indexed by - lookahead token type. */ - + /* Figure out the actions for the specified state. */ muscle_insert_rule_number_table ("defact", yydefact, yydefact[0], 1, nstates); @@ -578,6 +687,7 @@ output_skeleton (void) char *skeldir = xpath_join (datadir, "skeletons"); char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4"); char *m4bison = xpath_join (skeldir, "bison.m4"); + char *traceon = xpath_join (skeldir, "traceon.m4"); char *skel = (IS_PATH_WITH_DIR (skeleton) ? xstrdup (skeleton) : xpath_join (skeldir, skeleton)); @@ -589,21 +699,10 @@ output_skeleton (void) /* Create an m4 subprocess connected to us via two pipes. */ - if (trace_flag & trace_tools) - fprintf (stderr, "running: %s %s - %s %s\n", - m4, m4sugar, m4bison, skel); - - /* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a - position-dependent manner. Keep it as the first argument so that all - files are traced. - - See the thread starting at - <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html> - for details. */ int filter_fd[2]; pid_t pid; { - char const *argv[10]; + char const *argv[11]; int i = 0; argv[i++] = m4; @@ -621,15 +720,29 @@ output_skeleton (void) argv[i++] = "-I"; argv[i++] = datadir; - if (trace_flag & trace_m4) + /* Some future version of GNU M4 (most likely 1.6) may treat the + -dV in a position-dependent manner. See the thread starting at + <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html> + for details. */ + if (trace_flag & trace_m4_early) argv[i++] = "-dV"; argv[i++] = m4sugar; argv[i++] = "-"; argv[i++] = m4bison; + if (trace_flag & trace_m4) + argv[i++] = traceon; argv[i++] = skel; argv[i++] = NULL; aver (i <= ARRAY_CARDINALITY (argv)); + if (trace_flag & trace_tools) + { + fputs ("running:", stderr); + for (int j = 0; argv[j]; ++j) + fprintf (stderr, " %s", argv[j]); + fputc ('\n', stderr); + } + /* The ugly cast is because gnulib gets the const-ness wrong. */ pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true, true, filter_fd); @@ -638,6 +751,7 @@ output_skeleton (void) free (skeldir); free (m4sugar); free (m4bison); + free (traceon); free (skel); if (trace_flag & trace_muscles) diff --git a/contrib/tools/bison/src/parse-gram.c b/contrib/tools/bison/src/parse-gram.c index 33f9553f03..9b1543cc67 100644 --- a/contrib/tools/bison/src/parse-gram.c +++ b/contrib/tools/bison/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.5.4. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison implementation for Yacc-like parsers in C @@ -34,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -41,14 +45,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.5.4" +#define YYBISON_VERSION "3.6.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -68,7 +69,7 @@ /* On column 0 to please syntax-check. */ #include <config.h> -#line 72 "src/parse-gram.c" +#line 73 "src/parse-gram.c" /* Substitute the type names. */ #define YYSTYPE GRAM_STYPE #define YYLTYPE GRAM_LTYPE @@ -101,15 +102,117 @@ # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - #include "parse-gram.h" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_STRING = 3, /* "string" */ + YYSYMBOL_TSTRING = 4, /* "translatable string" */ + YYSYMBOL_PERCENT_TOKEN = 5, /* "%token" */ + YYSYMBOL_PERCENT_NTERM = 6, /* "%nterm" */ + YYSYMBOL_PERCENT_TYPE = 7, /* "%type" */ + YYSYMBOL_PERCENT_DESTRUCTOR = 8, /* "%destructor" */ + YYSYMBOL_PERCENT_PRINTER = 9, /* "%printer" */ + YYSYMBOL_PERCENT_LEFT = 10, /* "%left" */ + YYSYMBOL_PERCENT_RIGHT = 11, /* "%right" */ + YYSYMBOL_PERCENT_NONASSOC = 12, /* "%nonassoc" */ + YYSYMBOL_PERCENT_PRECEDENCE = 13, /* "%precedence" */ + YYSYMBOL_PERCENT_PREC = 14, /* "%prec" */ + YYSYMBOL_PERCENT_DPREC = 15, /* "%dprec" */ + YYSYMBOL_PERCENT_MERGE = 16, /* "%merge" */ + YYSYMBOL_PERCENT_CODE = 17, /* "%code" */ + YYSYMBOL_PERCENT_DEFAULT_PREC = 18, /* "%default-prec" */ + YYSYMBOL_PERCENT_DEFINE = 19, /* "%define" */ + YYSYMBOL_PERCENT_DEFINES = 20, /* "%defines" */ + YYSYMBOL_PERCENT_ERROR_VERBOSE = 21, /* "%error-verbose" */ + YYSYMBOL_PERCENT_EXPECT = 22, /* "%expect" */ + YYSYMBOL_PERCENT_EXPECT_RR = 23, /* "%expect-rr" */ + YYSYMBOL_PERCENT_FLAG = 24, /* "%<flag>" */ + YYSYMBOL_PERCENT_FILE_PREFIX = 25, /* "%file-prefix" */ + YYSYMBOL_PERCENT_GLR_PARSER = 26, /* "%glr-parser" */ + YYSYMBOL_PERCENT_INITIAL_ACTION = 27, /* "%initial-action" */ + YYSYMBOL_PERCENT_LANGUAGE = 28, /* "%language" */ + YYSYMBOL_PERCENT_NAME_PREFIX = 29, /* "%name-prefix" */ + YYSYMBOL_PERCENT_NO_DEFAULT_PREC = 30, /* "%no-default-prec" */ + YYSYMBOL_PERCENT_NO_LINES = 31, /* "%no-lines" */ + YYSYMBOL_PERCENT_NONDETERMINISTIC_PARSER = 32, /* "%nondeterministic-parser" */ + YYSYMBOL_PERCENT_OUTPUT = 33, /* "%output" */ + YYSYMBOL_PERCENT_PURE_PARSER = 34, /* "%pure-parser" */ + YYSYMBOL_PERCENT_REQUIRE = 35, /* "%require" */ + YYSYMBOL_PERCENT_SKELETON = 36, /* "%skeleton" */ + YYSYMBOL_PERCENT_START = 37, /* "%start" */ + YYSYMBOL_PERCENT_TOKEN_TABLE = 38, /* "%token-table" */ + YYSYMBOL_PERCENT_VERBOSE = 39, /* "%verbose" */ + YYSYMBOL_PERCENT_YACC = 40, /* "%yacc" */ + YYSYMBOL_BRACED_CODE = 41, /* "{...}" */ + YYSYMBOL_BRACED_PREDICATE = 42, /* "%?{...}" */ + YYSYMBOL_BRACKETED_ID = 43, /* "[identifier]" */ + YYSYMBOL_CHAR = 44, /* "character literal" */ + YYSYMBOL_COLON = 45, /* ":" */ + YYSYMBOL_EPILOGUE = 46, /* "epilogue" */ + YYSYMBOL_EQUAL = 47, /* "=" */ + YYSYMBOL_ID = 48, /* "identifier" */ + YYSYMBOL_ID_COLON = 49, /* "identifier:" */ + YYSYMBOL_PERCENT_PERCENT = 50, /* "%%" */ + YYSYMBOL_PIPE = 51, /* "|" */ + YYSYMBOL_PROLOGUE = 52, /* "%{...%}" */ + YYSYMBOL_SEMICOLON = 53, /* ";" */ + YYSYMBOL_TAG = 54, /* "<tag>" */ + YYSYMBOL_TAG_ANY = 55, /* "<*>" */ + YYSYMBOL_TAG_NONE = 56, /* "<>" */ + YYSYMBOL_INT = 57, /* "integer literal" */ + YYSYMBOL_PERCENT_PARAM = 58, /* "%param" */ + YYSYMBOL_PERCENT_UNION = 59, /* "%union" */ + YYSYMBOL_PERCENT_EMPTY = 60, /* "%empty" */ + YYSYMBOL_YYACCEPT = 61, /* $accept */ + YYSYMBOL_input = 62, /* input */ + YYSYMBOL_prologue_declarations = 63, /* prologue_declarations */ + YYSYMBOL_prologue_declaration = 64, /* prologue_declaration */ + YYSYMBOL_65_1 = 65, /* $@1 */ + YYSYMBOL_params = 66, /* params */ + YYSYMBOL_grammar_declaration = 67, /* grammar_declaration */ + YYSYMBOL_code_props_type = 68, /* code_props_type */ + YYSYMBOL_union_name = 69, /* union_name */ + YYSYMBOL_symbol_declaration = 70, /* symbol_declaration */ + YYSYMBOL_71_2 = 71, /* $@2 */ + YYSYMBOL_72_3 = 72, /* $@3 */ + YYSYMBOL_precedence_declarator = 73, /* precedence_declarator */ + YYSYMBOL_74_tag_opt = 74, /* tag.opt */ + YYSYMBOL_generic_symlist = 75, /* generic_symlist */ + YYSYMBOL_generic_symlist_item = 76, /* generic_symlist_item */ + YYSYMBOL_tag = 77, /* tag */ + YYSYMBOL_nterm_decls = 78, /* nterm_decls */ + YYSYMBOL_token_decls = 79, /* token_decls */ + YYSYMBOL_80_token_decl_1 = 80, /* token_decl.1 */ + YYSYMBOL_token_decl = 81, /* token_decl */ + YYSYMBOL_82_int_opt = 82, /* int.opt */ + YYSYMBOL_alias = 83, /* alias */ + YYSYMBOL_token_decls_for_prec = 84, /* token_decls_for_prec */ + YYSYMBOL_85_token_decl_for_prec_1 = 85, /* token_decl_for_prec.1 */ + YYSYMBOL_token_decl_for_prec = 86, /* token_decl_for_prec */ + YYSYMBOL_symbol_decls = 87, /* symbol_decls */ + YYSYMBOL_88_symbol_decl_1 = 88, /* symbol_decl.1 */ + YYSYMBOL_grammar = 89, /* grammar */ + YYSYMBOL_rules_or_grammar_declaration = 90, /* rules_or_grammar_declaration */ + YYSYMBOL_rules = 91, /* rules */ + YYSYMBOL_92_4 = 92, /* $@4 */ + YYSYMBOL_93_rhses_1 = 93, /* rhses.1 */ + YYSYMBOL_rhs = 94, /* rhs */ + YYSYMBOL_95_named_ref_opt = 95, /* named_ref.opt */ + YYSYMBOL_variable = 96, /* variable */ + YYSYMBOL_value = 97, /* value */ + YYSYMBOL_id = 98, /* id */ + YYSYMBOL_id_colon = 99, /* id_colon */ + YYSYMBOL_symbol = 100, /* symbol */ + YYSYMBOL_string_as_id = 101, /* string_as_id */ + YYSYMBOL_102_epilogue_opt = 102 /* epilogue.opt */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + /* Unqualified %code blocks. */ @@ -201,7 +304,7 @@ /* Add style to semantic values in traces. */ static void tron (FILE *yyo); static void troff (FILE *yyo); -#line 261 "src/parse-gram.y" +#line 255 "src/parse-gram.y" /** Add a lex-param and/or a parse-param. * @@ -212,7 +315,7 @@ static void add_param (param_type type, char *decl, location loc); static param_type current_param = param_none; -#line 216 "src/parse-gram.c" +#line 319 "src/parse-gram.c" #ifdef short # undef short @@ -310,6 +413,7 @@ typedef int yytype_uint16; #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + /* Stored state numbers (used for stacks). */ typedef yytype_uint8 yy_state_t; @@ -328,6 +432,11 @@ typedef int yy_state_fast_t; # endif #endif +#ifndef N_ +# define N_(Msgid) Msgid +#endif + + #ifndef YY_ATTRIBUTE_PURE # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) @@ -427,8 +536,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # define YYCOPY_NEEDED 1 -#endif - +#endif /* 1 */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -499,76 +607,96 @@ union yyalloc #define YYLAST 234 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 60 +#define YYNTOKENS 61 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 42 /* YYNRULES -- Number of rules. */ -#define YYNRULES 122 +#define YYNRULES 123 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 166 +#define YYNSTATES 167 -#define YYUNDEFTOK 2 -#define YYMAXUTOK 314 +#define YYMAXUTOK 315 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM as returned by yylex, with out-of-bounds checking. */ -#define YYTRANSLATE(YYX) (YYX) +#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX) #if GRAM_DEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 293, 293, 302, 303, 307, 308, 314, 318, 323, - 324, 329, 330, 331, 332, 333, 338, 343, 344, 345, - 346, 347, 348, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 360, 361, 370, 371, 375, 386, 390, 394, - 402, 412, 413, 423, 424, 430, 443, 443, 448, 448, - 453, 457, 467, 468, 469, 470, 474, 475, 480, 481, - 485, 486, 490, 491, 492, 505, 514, 518, 522, 530, - 531, 535, 548, 549, 561, 565, 569, 577, 579, 584, - 591, 601, 605, 609, 617, 622, 634, 635, 641, 642, - 643, 650, 650, 658, 659, 660, 665, 668, 670, 672, - 674, 676, 678, 680, 682, 684, 689, 690, 699, 723, - 724, 725, 726, 738, 740, 767, 772, 773, 778, 787, - 788, 792, 793 + 0, 287, 287, 296, 297, 301, 302, 308, 312, 317, + 318, 323, 324, 325, 326, 327, 332, 337, 338, 339, + 340, 341, 342, 342, 343, 344, 345, 346, 347, 348, + 349, 350, 354, 355, 364, 365, 369, 380, 384, 388, + 396, 406, 407, 417, 418, 424, 437, 437, 442, 442, + 447, 451, 461, 462, 463, 464, 468, 469, 474, 475, + 479, 480, 484, 485, 486, 499, 508, 512, 516, 524, + 525, 529, 542, 543, 548, 549, 550, 568, 572, 576, + 584, 586, 591, 598, 608, 612, 616, 624, 629, 641, + 642, 648, 649, 650, 657, 657, 665, 666, 667, 672, + 675, 677, 679, 681, 683, 685, 687, 689, 691, 696, + 697, 706, 730, 731, 732, 733, 745, 747, 771, 776, + 777, 782, 790, 791 }; #endif -#if GRAM_DEBUG || YYERROR_VERBOSE || 1 -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if 1 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) { - "\"end of file\"", "error", "$undefined", "\"string\"", "\"%token\"", - "\"%nterm\"", "\"%type\"", "\"%destructor\"", "\"%printer\"", - "\"%left\"", "\"%right\"", "\"%nonassoc\"", "\"%precedence\"", - "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%code\"", - "\"%default-prec\"", "\"%define\"", "\"%defines\"", "\"%error-verbose\"", - "\"%expect\"", "\"%expect-rr\"", "\"%<flag>\"", "\"%file-prefix\"", - "\"%glr-parser\"", "\"%initial-action\"", "\"%language\"", - "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"", - "\"%nondeterministic-parser\"", "\"%output\"", "\"%pure-parser\"", - "\"%require\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"", - "\"%verbose\"", "\"%yacc\"", "\"{...}\"", "\"%?{...}\"", - "\"[identifier]\"", "\"character literal\"", "\":\"", "\"epilogue\"", - "\"=\"", "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"|\"", - "\"%{...%}\"", "\";\"", "\"<tag>\"", "\"<*>\"", "\"<>\"", "\"integer\"", - "\"%param\"", "\"%union\"", "\"%empty\"", "$accept", "input", + static const char *const yy_sname[] = + { + N_("end of file"), N_("error"), N_("invalid token"), N_("string"), + N_("translatable string"), "%token", "%nterm", "%type", "%destructor", + "%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec", + "%dprec", "%merge", "%code", "%default-prec", "%define", "%defines", + "%error-verbose", "%expect", "%expect-rr", "%<flag>", "%file-prefix", + "%glr-parser", "%initial-action", "%language", "%name-prefix", + "%no-default-prec", "%no-lines", "%nondeterministic-parser", "%output", + "%pure-parser", "%require", "%skeleton", "%start", "%token-table", + "%verbose", "%yacc", "{...}", "%?{...}", N_("[identifier]"), + N_("character literal"), ":", N_("epilogue"), "=", N_("identifier"), + N_("identifier:"), "%%", "|", "%{...%}", ";", N_("<tag>"), "<*>", "<>", + N_("integer literal"), "%param", "%union", "%empty", "$accept", "input", "prologue_declarations", "prologue_declaration", "$@1", "params", "grammar_declaration", "code_props_type", "union_name", "symbol_declaration", "$@2", "$@3", "precedence_declarator", "tag.opt", "generic_symlist", "generic_symlist_item", "tag", "nterm_decls", - "token_decls", "token_decl.1", "token_decl", "int.opt", + "token_decls", "token_decl.1", "token_decl", "int.opt", "alias", "token_decls_for_prec", "token_decl_for_prec.1", "token_decl_for_prec", "symbol_decls", "symbol_decl.1", "grammar", "rules_or_grammar_declaration", "rules", "$@4", "rhses.1", "rhs", "named_ref.opt", "variable", "value", "id", "id_colon", "symbol", - "string_as_id", "string_as_id.opt", "epilogue.opt", YY_NULLPTR -}; + "string_as_id", "epilogue.opt", YY_NULLPTR + }; + /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is + internationalizable. */ + static yytype_int8 yytranslatable[] = + { + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, + 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, + 0 + }; + return (yysymbol < YYNTOKENS && yytranslatable[yysymbol] + ? _(yy_sname[yysymbol]) + : yy_sname[yysymbol]); +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_int16 yytoknum[] = @@ -578,16 +706,17 @@ static const yytype_int16 yytoknum[] = 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314 + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315 }; -# endif +#endif -#define YYPACT_NINF (-130) +#define YYPACT_NINF (-80) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-122) +#define YYTABLE_NINF (-123) #define yytable_value_is_error(Yyn) \ 0 @@ -596,23 +725,23 @@ static const yytype_int16 yytoknum[] = STATE-NUM. */ static const yytype_int16 yypact[] = { - -130, 36, 110, -130, -22, -130, -130, 2, -130, -130, - -130, -130, -130, -130, -19, -130, -9, 40, -130, -17, - -2, -130, 57, -130, 21, 66, 77, -130, -130, -130, - 78, -130, 87, 92, 44, -130, -130, -130, 165, -130, - -130, -130, 50, -130, -130, 58, -130, 29, -130, 15, - 15, -130, -130, -130, 44, 47, 44, -130, -130, -130, - -130, 61, -130, 30, -130, -130, -130, -130, -130, -130, - -130, -130, -130, -130, -130, 51, -130, 53, 8, -130, - -130, 64, 67, -130, 68, 20, 44, 56, 44, -130, - 69, -130, -37, 59, -37, -130, 69, -130, 59, 44, - 44, -130, -130, -130, -130, -130, -130, -130, -130, 79, - -130, -130, -130, -130, -130, 111, -130, -130, -130, -130, - 20, -130, -130, -130, 44, 44, -130, -130, -130, -37, - -37, -130, 147, 44, -130, 108, -130, -130, 44, -37, - -130, -130, -130, -21, 175, -130, -130, 44, 97, 101, - 99, 100, -130, -130, -130, 117, 64, 175, -130, -130, - -130, -130, -130, 64, -130, -130 + -80, 5, 120, -80, -17, -80, -80, 23, -80, -80, + -80, -80, -80, -80, -7, -80, 10, 58, -80, 6, + 34, -80, 82, -80, 54, 95, 101, -80, -80, -80, + 103, -80, 105, 107, 24, -80, -80, -80, 175, -80, + -80, -80, 64, -80, -80, 75, -80, 61, -80, -15, + -15, -80, -80, -80, 24, 63, 24, -80, -80, -80, + -80, 77, -80, 46, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, 67, -80, 69, 7, -80, + -80, 80, 93, -80, 94, -1, 24, 108, 24, -80, + 79, -80, -38, 109, -38, -80, 79, -80, 109, 24, + 24, -80, -80, -80, -80, -80, -80, -80, -80, 115, + -80, -80, -80, -80, -80, 123, -80, -80, -80, -80, + -1, -80, -80, -80, 24, 24, -80, -80, -80, -38, + -38, -80, 28, 24, -80, 121, -80, -80, 24, -38, + -80, -80, -80, -80, -23, 59, -80, -80, 24, 110, + 111, 112, 114, -80, -80, -80, 127, 80, 59, -80, + -80, -80, -80, -80, 80, -80, -80 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -625,38 +754,38 @@ static const yytype_int8 yydefact[] = 0, 7, 0, 15, 0, 0, 0, 38, 19, 20, 0, 24, 0, 0, 0, 27, 28, 29, 0, 6, 31, 22, 43, 4, 5, 0, 34, 0, 30, 0, - 0, 118, 114, 113, 0, 50, 81, 116, 84, 117, - 39, 0, 108, 109, 10, 12, 13, 14, 16, 17, - 18, 21, 25, 26, 35, 0, 115, 0, 0, 86, - 88, 106, 0, 44, 0, 0, 0, 51, 74, 77, - 72, 80, 0, 49, 66, 69, 72, 47, 65, 82, - 0, 85, 40, 111, 112, 110, 8, 90, 89, 0, - 87, 2, 107, 91, 33, 23, 45, 62, 63, 64, - 36, 58, 61, 60, 75, 0, 78, 73, 79, 67, - 0, 70, 119, 83, 122, 0, 32, 59, 76, 68, - 120, 71, 96, 92, 93, 96, 95, 0, 0, 0, - 0, 0, 99, 57, 100, 0, 106, 94, 101, 102, - 103, 104, 105, 106, 97, 98 + 0, 121, 117, 116, 0, 50, 84, 119, 87, 120, + 39, 0, 111, 112, 10, 12, 13, 14, 16, 17, + 18, 21, 25, 26, 35, 0, 118, 0, 0, 89, + 91, 109, 0, 44, 0, 0, 0, 51, 77, 80, + 72, 83, 0, 49, 66, 69, 72, 47, 65, 85, + 0, 88, 40, 114, 115, 113, 8, 93, 92, 0, + 90, 2, 110, 94, 33, 23, 45, 62, 63, 64, + 36, 58, 61, 60, 78, 0, 81, 73, 82, 67, + 0, 70, 74, 86, 123, 0, 32, 59, 79, 68, + 76, 71, 75, 99, 95, 96, 99, 98, 0, 0, + 0, 0, 0, 102, 57, 103, 0, 109, 97, 104, + 105, 106, 107, 108, 109, 100, 101 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -130, -130, -130, -130, -130, -130, 156, -130, -130, -130, - -130, -130, -130, -130, -130, 43, -130, -130, 114, -66, - -35, 83, -130, -84, -53, -130, -47, -130, 82, -130, - -130, -130, 35, -129, -130, -130, -46, -130, -34, -36, - -130, -130 + -80, -80, -80, -80, -80, -80, 172, -80, -80, -80, + -80, -80, -80, -80, -80, 55, -80, -80, 139, -54, + -59, 81, -80, -80, -65, -79, -80, -31, -80, 113, + -80, -80, -80, 44, -67, -80, -80, -46, -80, -34, + -36, -80 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 1, 2, 43, 82, 115, 77, 45, 84, 46, - 50, 49, 47, 155, 120, 121, 122, 97, 93, 94, - 95, 128, 87, 88, 89, 55, 56, 78, 79, 80, - 135, 143, 144, 113, 63, 106, 57, 81, 58, 59, - 141, 111 + 50, 49, 47, 156, 120, 121, 122, 97, 93, 94, + 95, 128, 141, 87, 88, 89, 55, 56, 78, 79, + 80, 135, 144, 145, 113, 63, 106, 57, 81, 58, + 59, 111 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -664,57 +793,57 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 74, 90, 124, 96, 96, 51, 52, 99, -121, 75, + 74, 90, 51, 96, 96, 3, 52, -122, 75, 126, 53, 91, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 60, 101, 51, 14, 15, 129, 164, 61, 145, - 48, 146, 51, 103, 165, 126, 3, 27, 62, 65, - 90, 138, 90, 64, 34, 52, 96, 51, 96, 53, - 91, 123, 91, 133, 66, 54, 76, 109, 52, 131, - 67, 68, 53, 52, 139, 101, 42, 53, 92, 69, - 104, 126, 52, 117, 118, 119, 53, 105, 90, 90, - 70, 71, 86, 96, 96, 126, 123, 52, 91, 91, - 72, 53, 90, 96, 131, 73, 140, 83, 85, 101, - 100, 102, 91, 107, 131, 108, 112, 114, 116, 125, - 156, 4, 130, 158, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 156, 134, 127, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 51, 136, 142, 159, 160, 161, 162, 163, 44, 38, - 110, 39, 40, 137, 98, 0, 75, 41, 42, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 51, 132, - 157, 14, 15, 0, 0, 0, 0, 0, 147, 148, - 149, 0, 0, 0, 27, 0, 150, 151, 0, 0, - 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 76, 0, -56, 152, 0, 52, 0, - 0, 0, 53, 42, 0, 0, 0, 0, 153, 0, - 0, 0, 0, 0, 154 + 13, 124, 101, 99, 14, 15, 51, 51, 146, 52, + 147, 51, 140, 53, 60, 131, 48, 27, 129, 92, + 90, 61, 90, 52, 34, 126, 96, 53, 96, 103, + 91, 123, 91, 117, 118, 119, 76, 109, 62, 126, + 138, 64, 51, 65, 51, 101, 42, 52, 52, 133, + 131, 53, 53, 148, 149, 150, 139, 54, 90, 90, + 131, 151, 152, 96, 96, 67, 123, 104, 91, 91, + 165, 66, 90, 96, 105, 68, 142, 166, 69, 101, + -56, 153, 91, 52, 70, 52, 71, 53, 72, 53, + 73, 157, 83, 154, 159, 86, 85, 100, 102, 155, + 107, 4, 108, 112, 157, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 114, 116, 127, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 134, 125, 130, 136, 161, 143, 160, 164, 162, + 38, 163, 39, 40, 44, 137, 75, 132, 41, 42, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 98, + 158, 110, 14, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 42 }; static const yytype_int16 yycheck[] = { - 34, 47, 86, 49, 50, 3, 43, 54, 0, 1, - 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 40, 56, 3, 16, 17, 92, 156, 47, 50, - 52, 52, 3, 3, 163, 88, 0, 29, 47, 56, - 86, 125, 88, 3, 36, 43, 92, 3, 94, 47, - 86, 85, 88, 100, 56, 53, 48, 49, 43, 94, - 3, 40, 47, 43, 130, 99, 58, 47, 53, 3, - 40, 124, 43, 53, 54, 55, 47, 47, 124, 125, - 3, 3, 53, 129, 130, 138, 120, 43, 124, 125, - 3, 47, 138, 139, 129, 3, 132, 47, 40, 133, - 53, 40, 138, 52, 139, 52, 42, 40, 40, 53, - 144, 1, 53, 147, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 157, 45, 56, 16, 17, 18, 19, + 34, 47, 3, 49, 50, 0, 44, 0, 1, 88, + 48, 47, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 86, 56, 54, 17, 18, 3, 3, 51, 44, + 53, 3, 4, 48, 41, 94, 53, 30, 92, 54, + 86, 48, 88, 44, 37, 124, 92, 48, 94, 3, + 86, 85, 88, 54, 55, 56, 49, 50, 48, 138, + 125, 3, 3, 57, 3, 99, 59, 44, 44, 100, + 129, 48, 48, 14, 15, 16, 130, 54, 124, 125, + 139, 22, 23, 129, 130, 3, 120, 41, 124, 125, + 157, 57, 138, 139, 48, 41, 132, 164, 3, 133, + 41, 42, 138, 44, 3, 44, 3, 48, 3, 48, + 3, 145, 48, 54, 148, 54, 41, 54, 41, 60, + 53, 1, 53, 43, 158, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 41, 41, 57, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 3, 40, 44, 56, 53, 56, 56, 40, 2, 49, - 78, 51, 52, 120, 50, -1, 1, 57, 58, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 3, 96, - 145, 16, 17, -1, -1, -1, -1, -1, 13, 14, - 15, -1, -1, -1, 29, -1, 21, 22, -1, -1, - -1, 36, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 48, -1, 40, 41, -1, 43, -1, - -1, -1, 47, 58, -1, -1, -1, -1, 53, -1, + 40, 46, 54, 54, 41, 54, 45, 57, 41, 57, + 50, 57, 52, 53, 2, 120, 1, 96, 58, 59, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 50, + 146, 78, 17, 18, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, + -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59 }; @@ -722,41 +851,41 @@ static const yytype_int16 yycheck[] = symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { - 0, 61, 62, 0, 1, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 49, 51, - 52, 57, 58, 63, 66, 67, 69, 72, 52, 71, - 70, 3, 43, 47, 53, 85, 86, 96, 98, 99, - 40, 47, 47, 94, 3, 56, 56, 3, 40, 3, - 3, 3, 3, 3, 98, 1, 48, 66, 87, 88, - 89, 97, 64, 47, 68, 40, 53, 82, 83, 84, - 96, 99, 53, 78, 79, 80, 96, 77, 78, 86, - 53, 98, 40, 3, 40, 47, 95, 52, 52, 49, - 88, 101, 42, 93, 40, 65, 40, 53, 54, 55, - 74, 75, 76, 98, 83, 53, 84, 56, 81, 79, - 53, 80, 81, 86, 45, 90, 40, 75, 83, 79, - 99, 100, 44, 91, 92, 50, 52, 13, 14, 15, - 21, 22, 41, 53, 59, 73, 98, 92, 98, 56, - 53, 56, 56, 40, 93, 93 + 0, 62, 63, 0, 1, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 50, 52, + 53, 58, 59, 64, 67, 68, 70, 73, 53, 72, + 71, 3, 44, 48, 54, 87, 88, 98, 100, 101, + 41, 48, 48, 96, 3, 57, 57, 3, 41, 3, + 3, 3, 3, 3, 100, 1, 49, 67, 89, 90, + 91, 99, 65, 48, 69, 41, 54, 84, 85, 86, + 98, 101, 54, 79, 80, 81, 98, 78, 79, 88, + 54, 100, 41, 3, 41, 48, 97, 53, 53, 50, + 90, 102, 43, 95, 41, 66, 41, 54, 55, 56, + 75, 76, 77, 100, 85, 54, 86, 57, 82, 80, + 54, 81, 82, 88, 46, 92, 41, 76, 85, 80, + 4, 83, 101, 45, 93, 94, 51, 53, 14, 15, + 16, 22, 23, 42, 54, 60, 74, 100, 94, 100, + 57, 54, 57, 57, 41, 95, 95 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_int8 yyr1[] = { - 0, 60, 61, 62, 62, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 64, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 65, 65, 66, 66, 66, 66, 66, 66, - 66, 67, 67, 68, 68, 66, 70, 69, 71, 69, - 69, 69, 72, 72, 72, 72, 73, 73, 74, 74, - 75, 75, 76, 76, 76, 77, 78, 78, 78, 79, - 79, 80, 81, 81, 82, 82, 82, 83, 83, 84, - 84, 85, 85, 85, 86, 86, 87, 87, 88, 88, - 88, 90, 89, 91, 91, 91, 92, 92, 92, 92, - 92, 92, 92, 92, 92, 92, 93, 93, 94, 95, - 95, 95, 95, 96, 96, 97, 98, 98, 99, 100, - 100, 101, 101 + 0, 61, 62, 63, 63, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 65, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 66, 66, 67, 67, 67, 67, 67, 67, + 67, 68, 68, 69, 69, 67, 71, 70, 72, 70, + 70, 70, 73, 73, 73, 73, 74, 74, 75, 75, + 76, 76, 77, 77, 77, 78, 79, 79, 79, 80, + 80, 81, 82, 82, 83, 83, 83, 84, 84, 84, + 85, 85, 86, 86, 87, 87, 87, 88, 88, 89, + 89, 90, 90, 90, 92, 91, 93, 93, 93, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 95, + 95, 96, 97, 97, 97, 97, 98, 98, 99, 100, + 100, 101, 102, 102 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -769,19 +898,19 @@ static const yytype_int8 yyr2[] = 3, 1, 1, 0, 1, 3, 0, 3, 0, 3, 2, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, - 2, 3, 0, 1, 1, 2, 3, 1, 2, 2, - 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, - 2, 0, 5, 1, 3, 2, 0, 3, 4, 2, - 2, 3, 3, 3, 3, 3, 0, 1, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 1, 0, 2 + 2, 3, 0, 1, 0, 1, 1, 1, 2, 3, + 1, 2, 2, 1, 1, 2, 3, 1, 2, 1, + 2, 1, 2, 2, 0, 5, 1, 3, 2, 0, + 3, 4, 2, 2, 3, 3, 3, 3, 3, 0, + 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 2 }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyclearin (yychar = GRAM_EMPTY) #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -792,7 +921,7 @@ static const yytype_int8 yyr2[] = #define YYBACKUP(Token, Value) \ do \ - if (yychar == YYEMPTY) \ + if (yychar == GRAM_EMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ @@ -808,10 +937,9 @@ static const yytype_int8 yyr2[] = } \ while (0) -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +/* Backward compatibility with an undocumented macro. + Use GRAM_error or GRAM_UNDEF. */ +#define YYERRCODE GRAM_UNDEF /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends @@ -859,8 +987,8 @@ do { \ This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ -#ifndef YY_LOCATION_PRINT -# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL +# ifndef YY_LOCATION_PRINT +# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ @@ -890,22 +1018,22 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) return res; } -# define YY_LOCATION_PRINT(File, Loc) \ +# define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +# endif /* !defined YY_LOCATION_PRINT */ -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, Location); \ + Kind, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) @@ -916,7 +1044,8 @@ do { \ `-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { FILE *yyoutput = yyo; YYUSE (yyoutput); @@ -924,115 +1053,121 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YY if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif /* "%code pre-printer" blocks. */ -#line 213 "src/parse-gram.y" +#line 207 "src/parse-gram.y" tron (yyo); -#line 935 "src/parse-gram.c" +#line 1064 "src/parse-gram.c" YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - switch (yytype) + switch (yykind) { case 3: /* "string" */ -#line 220 "src/parse-gram.y" +#line 214 "src/parse-gram.y" { fputs (((*yyvaluep).STRING), yyo); } -#line 942 "src/parse-gram.c" +#line 1071 "src/parse-gram.c" break; - case 20: /* "%error-verbose" */ -#line 227 "src/parse-gram.y" + case 4: /* "translatable string" */ +#line 214 "src/parse-gram.y" + { fputs (((*yyvaluep).TSTRING), yyo); } +#line 1077 "src/parse-gram.c" + break; + + case 21: /* "%error-verbose" */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).PERCENT_ERROR_VERBOSE), yyo); } -#line 948 "src/parse-gram.c" +#line 1083 "src/parse-gram.c" break; - case 23: /* "%<flag>" */ -#line 230 "src/parse-gram.y" + case 24: /* "%<flag>" */ +#line 224 "src/parse-gram.y" { fprintf (yyo, "%%%s", ((*yyvaluep).PERCENT_FLAG)); } -#line 954 "src/parse-gram.c" +#line 1089 "src/parse-gram.c" break; - case 24: /* "%file-prefix" */ -#line 227 "src/parse-gram.y" + case 25: /* "%file-prefix" */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).PERCENT_FILE_PREFIX), yyo); } -#line 960 "src/parse-gram.c" +#line 1095 "src/parse-gram.c" break; - case 28: /* "%name-prefix" */ -#line 227 "src/parse-gram.y" + case 29: /* "%name-prefix" */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).PERCENT_NAME_PREFIX), yyo); } -#line 966 "src/parse-gram.c" +#line 1101 "src/parse-gram.c" break; - case 33: /* "%pure-parser" */ -#line 227 "src/parse-gram.y" + case 34: /* "%pure-parser" */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).PERCENT_PURE_PARSER), yyo); } -#line 972 "src/parse-gram.c" +#line 1107 "src/parse-gram.c" break; - case 40: /* "{...}" */ -#line 220 "src/parse-gram.y" + case 41: /* "{...}" */ +#line 214 "src/parse-gram.y" { fputs (((*yyvaluep).BRACED_CODE), yyo); } -#line 978 "src/parse-gram.c" +#line 1113 "src/parse-gram.c" break; - case 41: /* "%?{...}" */ -#line 220 "src/parse-gram.y" + case 42: /* "%?{...}" */ +#line 214 "src/parse-gram.y" { fputs (((*yyvaluep).BRACED_PREDICATE), yyo); } -#line 984 "src/parse-gram.c" +#line 1119 "src/parse-gram.c" break; - case 42: /* "[identifier]" */ -#line 228 "src/parse-gram.y" + case 43: /* "[identifier]" */ +#line 222 "src/parse-gram.y" { fprintf (yyo, "[%s]", ((*yyvaluep).BRACKETED_ID)); } -#line 990 "src/parse-gram.c" +#line 1125 "src/parse-gram.c" break; - case 43: /* "character literal" */ -#line 217 "src/parse-gram.y" + case 44: /* "character literal" */ +#line 211 "src/parse-gram.y" { fputs (char_name (((*yyvaluep).CHAR)), yyo); } -#line 996 "src/parse-gram.c" +#line 1131 "src/parse-gram.c" break; - case 45: /* "epilogue" */ -#line 220 "src/parse-gram.y" + case 46: /* "epilogue" */ +#line 214 "src/parse-gram.y" { fputs (((*yyvaluep).EPILOGUE), yyo); } -#line 1002 "src/parse-gram.c" +#line 1137 "src/parse-gram.c" break; - case 47: /* "identifier" */ -#line 227 "src/parse-gram.y" + case 48: /* "identifier" */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).ID), yyo); } -#line 1008 "src/parse-gram.c" +#line 1143 "src/parse-gram.c" break; - case 48: /* "identifier:" */ -#line 229 "src/parse-gram.y" + case 49: /* "identifier:" */ +#line 223 "src/parse-gram.y" { fprintf (yyo, "%s:", ((*yyvaluep).ID_COLON)); } -#line 1014 "src/parse-gram.c" +#line 1149 "src/parse-gram.c" break; - case 51: /* "%{...%}" */ -#line 220 "src/parse-gram.y" + case 52: /* "%{...%}" */ +#line 214 "src/parse-gram.y" { fputs (((*yyvaluep).PROLOGUE), yyo); } -#line 1020 "src/parse-gram.c" +#line 1155 "src/parse-gram.c" break; - case 53: /* "<tag>" */ -#line 231 "src/parse-gram.y" + case 54: /* "<tag>" */ +#line 225 "src/parse-gram.y" { fprintf (yyo, "<%s>", ((*yyvaluep).TAG)); } -#line 1026 "src/parse-gram.c" +#line 1161 "src/parse-gram.c" break; - case 56: /* "integer" */ -#line 234 "src/parse-gram.y" + case 57: /* "integer literal" */ +#line 228 "src/parse-gram.y" { fprintf (yyo, "%d", ((*yyvaluep).INT)); } -#line 1032 "src/parse-gram.c" +#line 1167 "src/parse-gram.c" break; - case 57: /* "%param" */ -#line 273 "src/parse-gram.y" + case 58: /* "%param" */ +#line 267 "src/parse-gram.y" { switch (((*yyvaluep).PERCENT_PARAM)) { @@ -1045,107 +1180,113 @@ tron (yyo); case param_none: aver (false); break; } } -#line 1049 "src/parse-gram.c" +#line 1184 "src/parse-gram.c" break; - case 67: /* code_props_type */ -#line 410 "src/parse-gram.y" + case 68: /* code_props_type */ +#line 404 "src/parse-gram.y" { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_props_type))); } -#line 1055 "src/parse-gram.c" +#line 1190 "src/parse-gram.c" break; - case 73: /* tag.opt */ -#line 227 "src/parse-gram.y" - { fputs (((*yyvaluep).yytype_73), yyo); } -#line 1061 "src/parse-gram.c" + case 74: /* tag.opt */ +#line 221 "src/parse-gram.y" + { fputs (((*yyvaluep).yykind_74), yyo); } +#line 1196 "src/parse-gram.c" break; - case 74: /* generic_symlist */ -#line 243 "src/parse-gram.y" + case 75: /* generic_symlist */ +#line 237 "src/parse-gram.y" { symbol_list_syms_print (((*yyvaluep).generic_symlist), yyo); } -#line 1067 "src/parse-gram.c" +#line 1202 "src/parse-gram.c" break; - case 75: /* generic_symlist_item */ -#line 243 "src/parse-gram.y" + case 76: /* generic_symlist_item */ +#line 237 "src/parse-gram.y" { symbol_list_syms_print (((*yyvaluep).generic_symlist_item), yyo); } -#line 1073 "src/parse-gram.c" +#line 1208 "src/parse-gram.c" break; - case 76: /* tag */ -#line 231 "src/parse-gram.y" + case 77: /* tag */ +#line 225 "src/parse-gram.y" { fprintf (yyo, "<%s>", ((*yyvaluep).tag)); } -#line 1079 "src/parse-gram.c" +#line 1214 "src/parse-gram.c" break; - case 77: /* nterm_decls */ -#line 243 "src/parse-gram.y" + case 78: /* nterm_decls */ +#line 237 "src/parse-gram.y" { symbol_list_syms_print (((*yyvaluep).nterm_decls), yyo); } -#line 1085 "src/parse-gram.c" +#line 1220 "src/parse-gram.c" break; - case 78: /* token_decls */ -#line 243 "src/parse-gram.y" + case 79: /* token_decls */ +#line 237 "src/parse-gram.y" { symbol_list_syms_print (((*yyvaluep).token_decls), yyo); } -#line 1091 "src/parse-gram.c" +#line 1226 "src/parse-gram.c" break; - case 79: /* token_decl.1 */ -#line 243 "src/parse-gram.y" - { symbol_list_syms_print (((*yyvaluep).yytype_79), yyo); } -#line 1097 "src/parse-gram.c" + case 80: /* token_decl.1 */ +#line 237 "src/parse-gram.y" + { symbol_list_syms_print (((*yyvaluep).yykind_80), yyo); } +#line 1232 "src/parse-gram.c" break; - case 80: /* token_decl */ -#line 237 "src/parse-gram.y" + case 81: /* token_decl */ +#line 231 "src/parse-gram.y" { fprintf (yyo, "%s", ((*yyvaluep).token_decl) ? ((*yyvaluep).token_decl)->tag : "<NULL>"); } -#line 1103 "src/parse-gram.c" +#line 1238 "src/parse-gram.c" break; - case 81: /* int.opt */ -#line 234 "src/parse-gram.y" - { fprintf (yyo, "%d", ((*yyvaluep).yytype_81)); } -#line 1109 "src/parse-gram.c" + case 82: /* int.opt */ +#line 228 "src/parse-gram.y" + { fprintf (yyo, "%d", ((*yyvaluep).yykind_82)); } +#line 1244 "src/parse-gram.c" break; - case 82: /* token_decls_for_prec */ -#line 243 "src/parse-gram.y" - { symbol_list_syms_print (((*yyvaluep).token_decls_for_prec), yyo); } -#line 1115 "src/parse-gram.c" + case 83: /* alias */ +#line 231 "src/parse-gram.y" + { fprintf (yyo, "%s", ((*yyvaluep).alias) ? ((*yyvaluep).alias)->tag : "<NULL>"); } +#line 1250 "src/parse-gram.c" break; - case 83: /* token_decl_for_prec.1 */ -#line 243 "src/parse-gram.y" - { symbol_list_syms_print (((*yyvaluep).yytype_83), yyo); } -#line 1121 "src/parse-gram.c" + case 84: /* token_decls_for_prec */ +#line 237 "src/parse-gram.y" + { symbol_list_syms_print (((*yyvaluep).token_decls_for_prec), yyo); } +#line 1256 "src/parse-gram.c" break; - case 84: /* token_decl_for_prec */ + case 85: /* token_decl_for_prec.1 */ #line 237 "src/parse-gram.y" + { symbol_list_syms_print (((*yyvaluep).yykind_85), yyo); } +#line 1262 "src/parse-gram.c" + break; + + case 86: /* token_decl_for_prec */ +#line 231 "src/parse-gram.y" { fprintf (yyo, "%s", ((*yyvaluep).token_decl_for_prec) ? ((*yyvaluep).token_decl_for_prec)->tag : "<NULL>"); } -#line 1127 "src/parse-gram.c" +#line 1268 "src/parse-gram.c" break; - case 85: /* symbol_decls */ -#line 243 "src/parse-gram.y" + case 87: /* symbol_decls */ +#line 237 "src/parse-gram.y" { symbol_list_syms_print (((*yyvaluep).symbol_decls), yyo); } -#line 1133 "src/parse-gram.c" +#line 1274 "src/parse-gram.c" break; - case 86: /* symbol_decl.1 */ -#line 243 "src/parse-gram.y" - { symbol_list_syms_print (((*yyvaluep).yytype_86), yyo); } -#line 1139 "src/parse-gram.c" + case 88: /* symbol_decl.1 */ +#line 237 "src/parse-gram.y" + { symbol_list_syms_print (((*yyvaluep).yykind_88), yyo); } +#line 1280 "src/parse-gram.c" break; - case 94: /* variable */ -#line 227 "src/parse-gram.y" + case 96: /* variable */ +#line 221 "src/parse-gram.y" { fputs (((*yyvaluep).variable), yyo); } -#line 1145 "src/parse-gram.c" +#line 1286 "src/parse-gram.c" break; - case 95: /* value */ -#line 713 "src/parse-gram.y" + case 97: /* value */ +#line 720 "src/parse-gram.y" { switch (((*yyvaluep).value).kind) { @@ -1154,37 +1295,31 @@ tron (yyo); case muscle_string: fprintf (yyo, "\"%s\"", ((*yyvaluep).value).chars); break; } } -#line 1158 "src/parse-gram.c" +#line 1299 "src/parse-gram.c" break; - case 96: /* id */ -#line 237 "src/parse-gram.y" + case 98: /* id */ +#line 231 "src/parse-gram.y" { fprintf (yyo, "%s", ((*yyvaluep).id) ? ((*yyvaluep).id)->tag : "<NULL>"); } -#line 1164 "src/parse-gram.c" +#line 1305 "src/parse-gram.c" break; - case 97: /* id_colon */ -#line 238 "src/parse-gram.y" + case 99: /* id_colon */ +#line 232 "src/parse-gram.y" { fprintf (yyo, "%s:", ((*yyvaluep).id_colon)->tag); } -#line 1170 "src/parse-gram.c" +#line 1311 "src/parse-gram.c" break; - case 98: /* symbol */ -#line 237 "src/parse-gram.y" + case 100: /* symbol */ +#line 231 "src/parse-gram.y" { fprintf (yyo, "%s", ((*yyvaluep).symbol) ? ((*yyvaluep).symbol)->tag : "<NULL>"); } -#line 1176 "src/parse-gram.c" +#line 1317 "src/parse-gram.c" break; - case 99: /* string_as_id */ -#line 237 "src/parse-gram.y" + case 101: /* string_as_id */ +#line 231 "src/parse-gram.y" { fprintf (yyo, "%s", ((*yyvaluep).string_as_id) ? ((*yyvaluep).string_as_id)->tag : "<NULL>"); } -#line 1182 "src/parse-gram.c" - break; - - case 100: /* string_as_id.opt */ -#line 237 "src/parse-gram.y" - { fprintf (yyo, "%s", ((*yyvaluep).yytype_100) ? ((*yyvaluep).yytype_100)->tag : "<NULL>"); } -#line 1188 "src/parse-gram.c" +#line 1323 "src/parse-gram.c" break; default: @@ -1192,10 +1327,10 @@ tron (yyo); } YY_IGNORE_MAYBE_UNINITIALIZED_END /* "%code post-printer" blocks. */ -#line 214 "src/parse-gram.y" +#line 208 "src/parse-gram.y" troff (yyo); -#line 1199 "src/parse-gram.c" +#line 1334 "src/parse-gram.c" } @@ -1204,14 +1339,15 @@ troff (yyo); `---------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { YYFPRINTF (yyo, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); YY_LOCATION_PRINT (yyo, *yylocationp); YYFPRINTF (yyo, ": "); - yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp); + yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp); YYFPRINTF (yyo, ")"); } @@ -1244,7 +1380,8 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, + int yyrule) { int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; @@ -1256,9 +1393,9 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[+yyssp[yyi + 1 - yynrhs]], - &yyvsp[(yyi + 1) - (yynrhs)] - , &(yylsp[(yyi + 1) - (yynrhs)]) ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)], + &(yylsp[(yyi + 1) - (yynrhs)])); YYFPRINTF (stderr, "\n"); } } @@ -1273,8 +1410,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !GRAM_DEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !GRAM_DEBUG */ @@ -1296,6 +1433,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + /* Given a state stack such that *YYBOTTOM is its bottom, such that *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty stack, and such that *YYCAPACITY is the maximum number of elements it @@ -1305,7 +1443,7 @@ int yydebug; *YYTOP, and *YYCAPACITY to reflect the new capacity and memory location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack using YYSTACK_FREE. Return 0 if successful or if no reallocation is - required. Return 1 if memory is exhausted. */ + required. Return YYENOMEM if memory is exhausted. */ static int yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, #if GRAM_DEBUG @@ -1330,7 +1468,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, { YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix, yydebug_suffix)); - return 1; + return YYENOMEM; } if (YYMAXDEPTH < yyalloc) yyalloc = YYMAXDEPTH; @@ -1342,7 +1480,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, { YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix, yydebug_suffix)); - return 1; + return YYENOMEM; } if (*yytop != yytop_empty) { @@ -1383,23 +1521,22 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, current lookahead, then check if that lookahead can eventually be shifted if syntactic actions continue from the current context. Report a syntax error if it cannot. */ -#define YY_LAC_ESTABLISH \ -do { \ - if (!yy_lac_established) \ - { \ - YYDPRINTF ((stderr, \ - "LAC: initial context established for %s\n", \ - yytname[yytoken])); \ - yy_lac_established = 1; \ - { \ - int yy_lac_status = \ - yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken); \ - if (yy_lac_status == 2) \ - goto yyexhaustedlab; \ - if (yy_lac_status == 1) \ - goto yyerrlab; \ - } \ - } \ +#define YY_LAC_ESTABLISH \ +do { \ + if (!yy_lac_established) \ + { \ + YYDPRINTF ((stderr, \ + "LAC: initial context established for %s\n", \ + yysymbol_name (yytoken))); \ + yy_lac_established = 1; \ + switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \ + { \ + case YYENOMEM: \ + goto yyexhaustedlab; \ + case 1: \ + goto yyerrlab; \ + } \ + } \ } while (0) /* Discard any previous initial lookahead context because of Event, @@ -1418,9 +1555,8 @@ do { \ do { \ if (yy_lac_established) \ { \ - if (yydebug) \ - YYFPRINTF (stderr, "LAC: initial context discarded due to " \ - Event "\n"); \ + YYDPRINTF ((stderr, "LAC: initial context discarded due to " \ + Event "\n")); \ yy_lac_established = 0; \ } \ } while (0) @@ -1430,7 +1566,7 @@ do { \ /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can eventually (after perhaps some reductions) be shifted, return 1 if - not, or return 2 if memory is exhausted. As preconditions and + not, or return YYENOMEM if memory is exhausted. As preconditions and postconditions: *YYES_CAPACITY is the allocated size of the array to which *YYES points, and either *YYES = YYESA or *YYES points to an array allocated with YYSTACK_ALLOC. yy_lac may overwrite the @@ -1438,12 +1574,13 @@ do { \ any old *YYES other than YYESA. */ static int yy_lac (yy_state_t *yyesa, yy_state_t **yyes, - YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken) + YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken) { yy_state_t *yyes_prev = yyssp; yy_state_t *yyesp = yyes_prev; - YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken])); - if (yytoken == YYUNDEFTOK) + /* Reduce until we encounter a shift and thereby accept the token. */ + YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken))); + if (yytoken == YYSYMBOL_YYUNDEF) { YYDPRINTF ((stderr, " Always Err\n")); return 1; @@ -1455,6 +1592,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, || (yyrule += yytoken) < 0 || YYLAST < yyrule || yycheck[yyrule] != yytoken) { + /* Use the default action. */ yyrule = yydefact[+*yyesp]; if (yyrule == 0) { @@ -1464,6 +1602,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } else { + /* Use the action from yytable. */ yyrule = yytable[yyrule]; if (yytable_value_is_error (yyrule)) { @@ -1477,9 +1616,12 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } yyrule = -yyrule; } + /* By now we know we have to simulate a reduce. */ + YYDPRINTF ((stderr, " R%d", yyrule - 1)); { + /* Pop the corresponding number of values from the stack. */ YYPTRDIFF_T yylen = yyr2[yyrule]; - YYDPRINTF ((stderr, " R%d", yyrule - 1)); + /* First pop from the LAC stack as many tokens as possible. */ if (yyesp != yyes_prev) { YYPTRDIFF_T yysize = yyesp - *yyes + 1; @@ -1490,13 +1632,15 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } else { - yylen -= yysize; yyesp = yyes_prev; + yylen -= yysize; } } + /* Only afterwards look at the main stack. */ if (yylen) yyesp = yyes_prev -= yylen; } + /* Push the resulting state of the reduction. */ { yy_state_fast_t yystate; { @@ -1522,7 +1666,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, yyes, yyesa, &yyesp, yyes_prev)) { YYDPRINTF ((stderr, "\n")); - return 2; + return YYENOMEM; } YY_IGNORE_USELESS_CAST_BEGIN *++yyesp = YY_CAST (yy_state_t, yystate); @@ -1533,312 +1677,151 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes, } } - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) -# else -/* Return the length of YYSTR. */ -static YYPTRDIFF_T -yystrlen (const char *yystr) +/* Context of a parse error. */ +typedef struct { - YYPTRDIFF_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) + yy_state_t *yyssp; + yy_state_t *yyesa; + yy_state_t **yyes; + YYPTRDIFF_T *yyes_capacity; + yysymbol_kind_t yytoken; + YYLTYPE *yylloc; +} yypcontext_t; + +/* Put in YYARG at most YYARGN of the expected tokens given the + current YYCTX, and return the number of tokens stored in YYARG. If + YYARG is null, return the number of expected tokens (guaranteed to + be less than YYNTOKENS). Return YYENOMEM on memory exhaustion. + Return 0 if there are more than YYARGN expected tokens, yet fill + YYARG up to YYARGN. */ +static int +yypcontext_expected_tokens (const yypcontext_t *yyctx, + yysymbol_kind_t yyarg[], int yyargn) { - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif + /* Actual size of YYARG. */ + int yycount = 0; -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYPTRDIFF_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') + int yyx; + for (yyx = 0; yyx < YYNTOKENS; ++yyx) { - YYPTRDIFF_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) + yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx); + if (yysym != YYSYMBOL_YYerror && yysym != YYSYMBOL_YYUNDEF) + switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym)) { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - else - goto append; - - append: + case YYENOMEM: + return YYENOMEM; + case 1: + continue; default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = yysym; } - do_not_strip_quotes: ; } - - if (yyres) - return yystpcpy (yyres, yystr) - yyres; - else - return yystrlen (yystr); + if (yyarg && yycount == 0 && 0 < yyargn) + yyarg[0] = YYSYMBOL_YYEMPTY; + return yycount; } -# endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. In order to see if a particular token T is a - valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T). - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store or if - yy_lac returned 2. */ -static int -yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, - yy_state_t *yyesa, yy_state_t **yyes, - YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken) -{ - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat: reported tokens (one for the "unexpected", - one per "expected"). */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Actual size of YYARG. */ - int yycount = 0; - /* Cumulated lengths of YYARG. */ - YYPTRDIFF_T yysize = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - In the first two cases, it might appear that the current syntax - error should have been detected in the previous state when yy_lac - was invoked. However, at that time, there might have been a - different syntax error that discarded a different initial context - during error recovery, leaving behind the current lookahead. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[+*yyssp]; - YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - yysize = yysize0; - YYDPRINTF ((stderr, "Constructing syntax error message\n")); - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - int yyx; - for (yyx = 0; yyx < YYNTOKENS; ++yyx) - if (yyx != YYTERROR && yyx != YYUNDEFTOK) - { - { - int yy_lac_status = yy_lac (yyesa, yyes, yyes_capacity, - yyssp, yyx); - if (yy_lac_status == 2) - return 2; - if (yy_lac_status == 1) - continue; - } - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYPTRDIFF_T yysize1 - = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return 2; - } - } - } -# if GRAM_DEBUG - else if (yydebug) - YYFPRINTF (stderr, "No expected tokens.\n"); -# endif - } - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } +/* The kind of the lookahead of this context. */ +static yysymbol_kind_t +yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED; - { - /* Don't count the "%s"s in the final size, but reserve room for - the terminator. */ - YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return 2; - } +static yysymbol_kind_t +yypcontext_token (const yypcontext_t *yyctx) +{ + return yyctx->yytoken; +} - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } +/* The location of the lookahead of this context. */ +static YYLTYPE * +yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED; - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - ++yyp; - ++yyformat; - } - } - return 0; +static YYLTYPE * +yypcontext_location (const yypcontext_t *yyctx) +{ + return yyctx->yylloc; } -#endif /* YYERROR_VERBOSE */ + +/* User defined function to report a syntax error. */ +static int +yyreport_syntax_error (const yypcontext_t *yyctx); /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) { YYUSE (yyvaluep); YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - switch (yytype) + switch (yykind) { - case 74: /* generic_symlist */ -#line 242 "src/parse-gram.y" + case 75: /* generic_symlist */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).generic_symlist)); } -#line 1794 "src/parse-gram.c" +#line 1777 "src/parse-gram.c" break; - case 75: /* generic_symlist_item */ -#line 242 "src/parse-gram.y" + case 76: /* generic_symlist_item */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).generic_symlist_item)); } -#line 1800 "src/parse-gram.c" +#line 1783 "src/parse-gram.c" break; - case 77: /* nterm_decls */ -#line 242 "src/parse-gram.y" + case 78: /* nterm_decls */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).nterm_decls)); } -#line 1806 "src/parse-gram.c" +#line 1789 "src/parse-gram.c" break; - case 78: /* token_decls */ -#line 242 "src/parse-gram.y" + case 79: /* token_decls */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).token_decls)); } -#line 1812 "src/parse-gram.c" +#line 1795 "src/parse-gram.c" break; - case 79: /* token_decl.1 */ -#line 242 "src/parse-gram.y" - { symbol_list_free (((*yyvaluep).yytype_79)); } -#line 1818 "src/parse-gram.c" + case 80: /* token_decl.1 */ +#line 236 "src/parse-gram.y" + { symbol_list_free (((*yyvaluep).yykind_80)); } +#line 1801 "src/parse-gram.c" break; - case 82: /* token_decls_for_prec */ -#line 242 "src/parse-gram.y" + case 84: /* token_decls_for_prec */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).token_decls_for_prec)); } -#line 1824 "src/parse-gram.c" +#line 1807 "src/parse-gram.c" break; - case 83: /* token_decl_for_prec.1 */ -#line 242 "src/parse-gram.y" - { symbol_list_free (((*yyvaluep).yytype_83)); } -#line 1830 "src/parse-gram.c" + case 85: /* token_decl_for_prec.1 */ +#line 236 "src/parse-gram.y" + { symbol_list_free (((*yyvaluep).yykind_85)); } +#line 1813 "src/parse-gram.c" break; - case 85: /* symbol_decls */ -#line 242 "src/parse-gram.y" + case 87: /* symbol_decls */ +#line 236 "src/parse-gram.y" { symbol_list_free (((*yyvaluep).symbol_decls)); } -#line 1836 "src/parse-gram.c" +#line 1819 "src/parse-gram.c" break; - case 86: /* symbol_decl.1 */ -#line 242 "src/parse-gram.y" - { symbol_list_free (((*yyvaluep).yytype_86)); } -#line 1842 "src/parse-gram.c" + case 88: /* symbol_decl.1 */ +#line 236 "src/parse-gram.y" + { symbol_list_free (((*yyvaluep).yykind_88)); } +#line 1825 "src/parse-gram.c" break; default: @@ -1850,6 +1833,8 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio + + /*----------. | yyparse. | `----------*/ @@ -1890,6 +1875,9 @@ YYLTYPE yylloc = yyloc_default; Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ + /* Their size. */ + YYPTRDIFF_T yystacksize; + /* The state stack. */ yy_state_t yyssa[YYINITDEPTH]; yy_state_t *yyss; @@ -1905,31 +1893,26 @@ YYLTYPE yylloc = yyloc_default; YYLTYPE *yyls; YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; - - YYPTRDIFF_T yystacksize; - yy_state_t yyesa[20]; yy_state_t *yyes; YYPTRDIFF_T yyes_capacity; + /* Whether LAC context is established. A Boolean. */ int yy_lac_established = 0; int yyn; + /* The return value of yyparse. */ int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; -#endif + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[3]; + + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) @@ -1937,22 +1920,24 @@ YYLTYPE yylloc = yyloc_default; Keep to zero when no symbol should be popped. */ int yylen = 0; + yynerrs = 0; + yystate = 0; + yyerrstatus = 0; + + yystacksize = YYINITDEPTH; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yylsp = yyls = yylsa; - yystacksize = YYINITDEPTH; yyes = yyesa; yyes_capacity = 20; if (YYMAXDEPTH < yyes_capacity) yyes_capacity = YYMAXDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = GRAM_EMPTY; /* Cause a token to be read. */ /* User initialization code. */ #line 136 "src/parse-gram.y" @@ -1963,7 +1948,7 @@ YYLTYPE yylloc = yyloc_default; boundary_set (&yylloc.end, grammar_file, 1, 1, 1); } -#line 1967 "src/parse-gram.c" +#line 1952 "src/parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -1987,6 +1972,7 @@ yysetstate: YY_IGNORE_USELESS_CAST_BEGIN *yyssp = YY_CAST (yy_state_t, yystate); YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE @@ -2036,7 +2022,7 @@ yysetstate: YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -2076,18 +2062,30 @@ yybackup: /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + if (yychar == GRAM_EMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (&yylval, &yylloc); } - if (yychar <= YYEOF) + if (yychar <= GRAM_EOF) { - yychar = yytoken = YYEOF; + yychar = GRAM_EOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == GRAM_error) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = GRAM_UNDEF; + yytoken = YYSYMBOL_YYerror; + yyerror_range[1] = yylloc; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -2126,7 +2124,7 @@ yybackup: *++yylsp = yylloc; /* Discard the shifted token. */ - yychar = YYEMPTY; + yychar = GRAM_EMPTY; YY_LAC_DISCARD ("shift"); goto yynewstate; @@ -2167,195 +2165,195 @@ yyreduce: switch (yyn) { case 6: -#line 309 "src/parse-gram.y" +#line 303 "src/parse-gram.y" { muscle_code_grow (union_seen ? "post_prologue" : "pre_prologue", translate_code ((yyvsp[0].PROLOGUE), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2177 "src/parse-gram.c" +#line 2175 "src/parse-gram.c" break; case 7: -#line 315 "src/parse-gram.y" +#line 309 "src/parse-gram.y" { muscle_percent_define_ensure ((yyvsp[0].PERCENT_FLAG), (yylsp[0]), true); } -#line 2185 "src/parse-gram.c" +#line 2183 "src/parse-gram.c" break; case 8: -#line 319 "src/parse-gram.y" +#line 313 "src/parse-gram.y" { muscle_percent_define_insert ((yyvsp[-1].variable), (yyloc), (yyvsp[0].value).kind, (yyvsp[0].value).chars, MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2194 "src/parse-gram.c" +#line 2192 "src/parse-gram.c" break; case 9: -#line 323 "src/parse-gram.y" +#line 317 "src/parse-gram.y" { defines_flag = true; } -#line 2200 "src/parse-gram.c" +#line 2198 "src/parse-gram.c" break; case 10: -#line 325 "src/parse-gram.y" +#line 319 "src/parse-gram.y" { defines_flag = true; spec_header_file = xstrdup ((yyvsp[0].STRING)); } -#line 2209 "src/parse-gram.c" +#line 2207 "src/parse-gram.c" break; case 11: -#line 329 "src/parse-gram.y" +#line 323 "src/parse-gram.y" { handle_error_verbose (&(yyloc), (yyvsp[0].PERCENT_ERROR_VERBOSE)); } -#line 2215 "src/parse-gram.c" +#line 2213 "src/parse-gram.c" break; case 12: -#line 330 "src/parse-gram.y" +#line 324 "src/parse-gram.y" { expected_sr_conflicts = (yyvsp[0].INT); } -#line 2221 "src/parse-gram.c" +#line 2219 "src/parse-gram.c" break; case 13: -#line 331 "src/parse-gram.y" +#line 325 "src/parse-gram.y" { expected_rr_conflicts = (yyvsp[0].INT); } -#line 2227 "src/parse-gram.c" +#line 2225 "src/parse-gram.c" break; case 14: -#line 332 "src/parse-gram.y" +#line 326 "src/parse-gram.y" { handle_file_prefix (&(yyloc), &(yylsp[-1]), (yyvsp[-1].PERCENT_FILE_PREFIX), (yyvsp[0].STRING)); } -#line 2233 "src/parse-gram.c" +#line 2231 "src/parse-gram.c" break; case 15: -#line 334 "src/parse-gram.y" +#line 328 "src/parse-gram.y" { nondeterministic_parser = true; glr_parser = true; } -#line 2242 "src/parse-gram.c" +#line 2240 "src/parse-gram.c" break; case 16: -#line 339 "src/parse-gram.y" +#line 333 "src/parse-gram.y" { muscle_code_grow ("initial_action", translate_code ((yyvsp[0].BRACED_CODE), (yylsp[0]), false), (yylsp[0])); code_scanner_last_string_free (); } -#line 2251 "src/parse-gram.c" +#line 2249 "src/parse-gram.c" break; case 17: -#line 343 "src/parse-gram.y" +#line 337 "src/parse-gram.y" { language_argmatch ((yyvsp[0].STRING), grammar_prio, (yylsp[-1])); } -#line 2257 "src/parse-gram.c" +#line 2255 "src/parse-gram.c" break; case 18: -#line 344 "src/parse-gram.y" +#line 338 "src/parse-gram.y" { handle_name_prefix (&(yyloc), (yyvsp[-1].PERCENT_NAME_PREFIX), (yyvsp[0].STRING)); } -#line 2263 "src/parse-gram.c" +#line 2261 "src/parse-gram.c" break; case 19: -#line 345 "src/parse-gram.y" +#line 339 "src/parse-gram.y" { no_lines_flag = true; } -#line 2269 "src/parse-gram.c" +#line 2267 "src/parse-gram.c" break; case 20: -#line 346 "src/parse-gram.y" +#line 340 "src/parse-gram.y" { nondeterministic_parser = true; } -#line 2275 "src/parse-gram.c" +#line 2273 "src/parse-gram.c" break; case 21: -#line 347 "src/parse-gram.y" +#line 341 "src/parse-gram.y" { spec_outfile = (yyvsp[0].STRING); } -#line 2281 "src/parse-gram.c" +#line 2279 "src/parse-gram.c" break; case 22: -#line 348 "src/parse-gram.y" +#line 342 "src/parse-gram.y" { current_param = (yyvsp[0].PERCENT_PARAM); } -#line 2287 "src/parse-gram.c" +#line 2285 "src/parse-gram.c" break; case 23: -#line 348 "src/parse-gram.y" +#line 342 "src/parse-gram.y" { current_param = param_none; } -#line 2293 "src/parse-gram.c" +#line 2291 "src/parse-gram.c" break; case 24: -#line 349 "src/parse-gram.y" +#line 343 "src/parse-gram.y" { handle_pure_parser (&(yyloc), (yyvsp[0].PERCENT_PURE_PARSER)); } -#line 2299 "src/parse-gram.c" +#line 2297 "src/parse-gram.c" break; case 25: -#line 350 "src/parse-gram.y" +#line 344 "src/parse-gram.y" { handle_require (&(yylsp[0]), (yyvsp[0].STRING)); } -#line 2305 "src/parse-gram.c" +#line 2303 "src/parse-gram.c" break; case 26: -#line 351 "src/parse-gram.y" +#line 345 "src/parse-gram.y" { handle_skeleton (&(yylsp[0]), (yyvsp[0].STRING)); } -#line 2311 "src/parse-gram.c" +#line 2309 "src/parse-gram.c" break; case 27: -#line 352 "src/parse-gram.y" +#line 346 "src/parse-gram.y" { token_table_flag = true; } -#line 2317 "src/parse-gram.c" +#line 2315 "src/parse-gram.c" break; case 28: -#line 353 "src/parse-gram.y" +#line 347 "src/parse-gram.y" { report_flag |= report_states; } -#line 2323 "src/parse-gram.c" +#line 2321 "src/parse-gram.c" break; case 29: -#line 354 "src/parse-gram.y" +#line 348 "src/parse-gram.y" { handle_yacc (&(yyloc)); } -#line 2329 "src/parse-gram.c" +#line 2327 "src/parse-gram.c" break; case 30: -#line 355 "src/parse-gram.y" +#line 349 "src/parse-gram.y" { current_class = unknown_sym; yyerrok; } -#line 2335 "src/parse-gram.c" +#line 2333 "src/parse-gram.c" break; case 32: -#line 360 "src/parse-gram.y" +#line 354 "src/parse-gram.y" { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); } -#line 2341 "src/parse-gram.c" +#line 2339 "src/parse-gram.c" break; case 33: -#line 361 "src/parse-gram.y" +#line 355 "src/parse-gram.y" { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); } -#line 2347 "src/parse-gram.c" +#line 2345 "src/parse-gram.c" break; case 35: -#line 372 "src/parse-gram.y" +#line 366 "src/parse-gram.y" { grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2355 "src/parse-gram.c" +#line 2353 "src/parse-gram.c" break; case 36: -#line 376 "src/parse-gram.y" +#line 370 "src/parse-gram.y" { code_props code; code_props_symbol_action_init (&code, (yyvsp[-1].BRACED_CODE), (yylsp[-1])); @@ -2366,27 +2364,27 @@ yyreduce: symbol_list_free ((yyvsp[0].generic_symlist)); } } -#line 2370 "src/parse-gram.c" +#line 2368 "src/parse-gram.c" break; case 37: -#line 387 "src/parse-gram.y" +#line 381 "src/parse-gram.y" { default_prec = true; } -#line 2378 "src/parse-gram.c" +#line 2376 "src/parse-gram.c" break; case 38: -#line 391 "src/parse-gram.y" +#line 385 "src/parse-gram.y" { default_prec = false; } -#line 2386 "src/parse-gram.c" +#line 2384 "src/parse-gram.c" break; case 39: -#line 395 "src/parse-gram.y" +#line 389 "src/parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ @@ -2394,453 +2392,475 @@ yyreduce: translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2398 "src/parse-gram.c" +#line 2396 "src/parse-gram.c" break; case 40: -#line 403 "src/parse-gram.y" +#line 397 "src/parse-gram.y" { muscle_percent_code_grow ((yyvsp[-1].ID), (yylsp[-1]), translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2407 "src/parse-gram.c" +#line 2405 "src/parse-gram.c" break; case 41: -#line 412 "src/parse-gram.y" +#line 406 "src/parse-gram.y" { (yyval.code_props_type) = destructor; } -#line 2413 "src/parse-gram.c" +#line 2411 "src/parse-gram.c" break; case 42: -#line 413 "src/parse-gram.y" +#line 407 "src/parse-gram.y" { (yyval.code_props_type) = printer; } -#line 2419 "src/parse-gram.c" +#line 2417 "src/parse-gram.c" break; case 43: -#line 423 "src/parse-gram.y" +#line 417 "src/parse-gram.y" {} -#line 2425 "src/parse-gram.c" +#line 2423 "src/parse-gram.c" break; case 44: -#line 424 "src/parse-gram.y" +#line 418 "src/parse-gram.y" { muscle_percent_define_insert ("api.value.union.name", (yylsp[0]), muscle_keyword, (yyvsp[0].ID), MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2433 "src/parse-gram.c" +#line 2431 "src/parse-gram.c" break; case 45: -#line 431 "src/parse-gram.y" +#line 425 "src/parse-gram.y" { union_seen = true; muscle_code_grow ("union_members", translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2443 "src/parse-gram.c" +#line 2441 "src/parse-gram.c" break; case 46: -#line 443 "src/parse-gram.y" +#line 437 "src/parse-gram.y" { current_class = nterm_sym; } -#line 2449 "src/parse-gram.c" +#line 2447 "src/parse-gram.c" break; case 47: -#line 444 "src/parse-gram.y" +#line 438 "src/parse-gram.y" { current_class = unknown_sym; symbol_list_free ((yyvsp[0].nterm_decls)); } -#line 2458 "src/parse-gram.c" +#line 2456 "src/parse-gram.c" break; case 48: -#line 448 "src/parse-gram.y" +#line 442 "src/parse-gram.y" { current_class = token_sym; } -#line 2464 "src/parse-gram.c" +#line 2462 "src/parse-gram.c" break; case 49: -#line 449 "src/parse-gram.y" +#line 443 "src/parse-gram.y" { current_class = unknown_sym; symbol_list_free ((yyvsp[0].token_decls)); } -#line 2473 "src/parse-gram.c" +#line 2471 "src/parse-gram.c" break; case 50: -#line 454 "src/parse-gram.y" +#line 448 "src/parse-gram.y" { symbol_list_free ((yyvsp[0].symbol_decls)); } -#line 2481 "src/parse-gram.c" +#line 2479 "src/parse-gram.c" break; case 51: -#line 458 "src/parse-gram.y" +#line 452 "src/parse-gram.y" { ++current_prec; for (symbol_list *list = (yyvsp[0].token_decls_for_prec); list; list = list->next) symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-1].precedence_declarator), (yylsp[-1])); symbol_list_free ((yyvsp[0].token_decls_for_prec)); } -#line 2492 "src/parse-gram.c" +#line 2490 "src/parse-gram.c" break; case 52: -#line 467 "src/parse-gram.y" +#line 461 "src/parse-gram.y" { (yyval.precedence_declarator) = left_assoc; } -#line 2498 "src/parse-gram.c" +#line 2496 "src/parse-gram.c" break; case 53: -#line 468 "src/parse-gram.y" +#line 462 "src/parse-gram.y" { (yyval.precedence_declarator) = right_assoc; } -#line 2504 "src/parse-gram.c" +#line 2502 "src/parse-gram.c" break; case 54: -#line 469 "src/parse-gram.y" +#line 463 "src/parse-gram.y" { (yyval.precedence_declarator) = non_assoc; } -#line 2510 "src/parse-gram.c" +#line 2508 "src/parse-gram.c" break; case 55: -#line 470 "src/parse-gram.y" +#line 464 "src/parse-gram.y" { (yyval.precedence_declarator) = precedence_assoc; } -#line 2516 "src/parse-gram.c" +#line 2514 "src/parse-gram.c" break; case 56: -#line 474 "src/parse-gram.y" - { (yyval.yytype_73) = NULL; } -#line 2522 "src/parse-gram.c" +#line 468 "src/parse-gram.y" + { (yyval.yykind_74) = NULL; } +#line 2520 "src/parse-gram.c" break; case 57: -#line 475 "src/parse-gram.y" - { (yyval.yytype_73) = (yyvsp[0].TAG); } -#line 2528 "src/parse-gram.c" +#line 469 "src/parse-gram.y" + { (yyval.yykind_74) = (yyvsp[0].TAG); } +#line 2526 "src/parse-gram.c" break; case 59: -#line 481 "src/parse-gram.y" +#line 475 "src/parse-gram.y" { (yyval.generic_symlist) = symbol_list_append ((yyvsp[-1].generic_symlist), (yyvsp[0].generic_symlist_item)); } -#line 2534 "src/parse-gram.c" +#line 2532 "src/parse-gram.c" break; case 60: -#line 485 "src/parse-gram.y" +#line 479 "src/parse-gram.y" { (yyval.generic_symlist_item) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2540 "src/parse-gram.c" +#line 2538 "src/parse-gram.c" break; case 61: -#line 486 "src/parse-gram.y" +#line 480 "src/parse-gram.y" { (yyval.generic_symlist_item) = symbol_list_type_new ((yyvsp[0].tag), (yylsp[0])); } -#line 2546 "src/parse-gram.c" +#line 2544 "src/parse-gram.c" break; case 63: -#line 491 "src/parse-gram.y" +#line 485 "src/parse-gram.y" { (yyval.tag) = uniqstr_new ("*"); } -#line 2552 "src/parse-gram.c" +#line 2550 "src/parse-gram.c" break; case 64: -#line 492 "src/parse-gram.y" +#line 486 "src/parse-gram.y" { (yyval.tag) = uniqstr_new (""); } -#line 2558 "src/parse-gram.c" +#line 2556 "src/parse-gram.c" break; case 66: -#line 515 "src/parse-gram.y" +#line 509 "src/parse-gram.y" { - (yyval.token_decls) = (yyvsp[0].yytype_79); + (yyval.token_decls) = (yyvsp[0].yykind_80); } -#line 2566 "src/parse-gram.c" +#line 2564 "src/parse-gram.c" break; case 67: -#line 519 "src/parse-gram.y" +#line 513 "src/parse-gram.y" { - (yyval.token_decls) = symbol_list_type_set ((yyvsp[0].yytype_79), (yyvsp[-1].TAG), (yylsp[-1])); + (yyval.token_decls) = symbol_list_type_set ((yyvsp[0].yykind_80), (yyvsp[-1].TAG), (yylsp[-1])); } -#line 2574 "src/parse-gram.c" +#line 2572 "src/parse-gram.c" break; case 68: -#line 523 "src/parse-gram.y" +#line 517 "src/parse-gram.y" { - (yyval.token_decls) = symbol_list_append ((yyvsp[-2].token_decls), symbol_list_type_set ((yyvsp[0].yytype_79), (yyvsp[-1].TAG), (yylsp[-1]))); + (yyval.token_decls) = symbol_list_append ((yyvsp[-2].token_decls), symbol_list_type_set ((yyvsp[0].yykind_80), (yyvsp[-1].TAG), (yylsp[-1]))); } -#line 2582 "src/parse-gram.c" +#line 2580 "src/parse-gram.c" break; case 69: -#line 530 "src/parse-gram.y" - { (yyval.yytype_79) = symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0])); } -#line 2588 "src/parse-gram.c" +#line 524 "src/parse-gram.y" + { (yyval.yykind_80) = symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0])); } +#line 2586 "src/parse-gram.c" break; case 70: -#line 531 "src/parse-gram.y" - { (yyval.yytype_79) = symbol_list_append ((yyvsp[-1].yytype_79), symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0]))); } -#line 2594 "src/parse-gram.c" +#line 525 "src/parse-gram.y" + { (yyval.yykind_80) = symbol_list_append ((yyvsp[-1].yykind_80), symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0]))); } +#line 2592 "src/parse-gram.c" break; case 71: -#line 536 "src/parse-gram.y" +#line 530 "src/parse-gram.y" { (yyval.token_decl) = (yyvsp[-2].id); symbol_class_set ((yyvsp[-2].id), current_class, (yylsp[-2]), true); - if (0 <= (yyvsp[-1].yytype_81)) - symbol_user_token_number_set ((yyvsp[-2].id), (yyvsp[-1].yytype_81), (yylsp[-1])); - if ((yyvsp[0].yytype_100)) - symbol_make_alias ((yyvsp[-2].id), (yyvsp[0].yytype_100), (yylsp[0])); + if (0 <= (yyvsp[-1].yykind_82)) + symbol_user_token_number_set ((yyvsp[-2].id), (yyvsp[-1].yykind_82), (yylsp[-1])); + if ((yyvsp[0].alias)) + symbol_make_alias ((yyvsp[-2].id), (yyvsp[0].alias), (yylsp[0])); } -#line 2607 "src/parse-gram.c" +#line 2605 "src/parse-gram.c" break; case 72: -#line 548 "src/parse-gram.y" - { (yyval.yytype_81) = -1; } -#line 2613 "src/parse-gram.c" +#line 542 "src/parse-gram.y" + { (yyval.yykind_82) = -1; } +#line 2611 "src/parse-gram.c" break; case 74: -#line 562 "src/parse-gram.y" - { - (yyval.token_decls_for_prec) = (yyvsp[0].yytype_83); - } -#line 2621 "src/parse-gram.c" +#line 548 "src/parse-gram.y" + { (yyval.alias) = NULL; } +#line 2617 "src/parse-gram.c" break; case 75: -#line 566 "src/parse-gram.y" - { - (yyval.token_decls_for_prec) = symbol_list_type_set ((yyvsp[0].yytype_83), (yyvsp[-1].TAG), (yylsp[-1])); - } -#line 2629 "src/parse-gram.c" +#line 549 "src/parse-gram.y" + { (yyval.alias) = (yyvsp[0].string_as_id); } +#line 2623 "src/parse-gram.c" break; case 76: -#line 570 "src/parse-gram.y" +#line 551 "src/parse-gram.y" { - (yyval.token_decls_for_prec) = symbol_list_append ((yyvsp[-2].token_decls_for_prec), symbol_list_type_set ((yyvsp[0].yytype_83), (yyvsp[-1].TAG), (yylsp[-1]))); + (yyval.alias) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].TSTRING)), (yylsp[0])); + symbol_class_set ((yyval.alias), token_sym, (yylsp[0]), false); + (yyval.alias)->translatable = true; } -#line 2637 "src/parse-gram.c" +#line 2633 "src/parse-gram.c" break; case 77: -#line 578 "src/parse-gram.y" - { (yyval.yytype_83) = symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0])); } -#line 2643 "src/parse-gram.c" +#line 569 "src/parse-gram.y" + { + (yyval.token_decls_for_prec) = (yyvsp[0].yykind_85); + } +#line 2641 "src/parse-gram.c" break; case 78: -#line 580 "src/parse-gram.y" - { (yyval.yytype_83) = symbol_list_append ((yyvsp[-1].yytype_83), symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0]))); } +#line 573 "src/parse-gram.y" + { + (yyval.token_decls_for_prec) = symbol_list_type_set ((yyvsp[0].yykind_85), (yyvsp[-1].TAG), (yylsp[-1])); + } #line 2649 "src/parse-gram.c" break; case 79: +#line 577 "src/parse-gram.y" + { + (yyval.token_decls_for_prec) = symbol_list_append ((yyvsp[-2].token_decls_for_prec), symbol_list_type_set ((yyvsp[0].yykind_85), (yyvsp[-1].TAG), (yylsp[-1]))); + } +#line 2657 "src/parse-gram.c" + break; + + case 80: #line 585 "src/parse-gram.y" + { (yyval.yykind_85) = symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0])); } +#line 2663 "src/parse-gram.c" + break; + + case 81: +#line 587 "src/parse-gram.y" + { (yyval.yykind_85) = symbol_list_append ((yyvsp[-1].yykind_85), symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0]))); } +#line 2669 "src/parse-gram.c" + break; + + case 82: +#line 592 "src/parse-gram.y" { (yyval.token_decl_for_prec) = (yyvsp[-1].id); symbol_class_set ((yyvsp[-1].id), token_sym, (yylsp[-1]), false); - if (0 <= (yyvsp[0].yytype_81)) - symbol_user_token_number_set ((yyvsp[-1].id), (yyvsp[0].yytype_81), (yylsp[0])); + if (0 <= (yyvsp[0].yykind_82)) + symbol_user_token_number_set ((yyvsp[-1].id), (yyvsp[0].yykind_82), (yylsp[0])); } -#line 2660 "src/parse-gram.c" +#line 2680 "src/parse-gram.c" break; - case 81: -#line 602 "src/parse-gram.y" + case 84: +#line 609 "src/parse-gram.y" { - (yyval.symbol_decls) = (yyvsp[0].yytype_86); + (yyval.symbol_decls) = (yyvsp[0].yykind_88); } -#line 2668 "src/parse-gram.c" +#line 2688 "src/parse-gram.c" break; - case 82: -#line 606 "src/parse-gram.y" + case 85: +#line 613 "src/parse-gram.y" { - (yyval.symbol_decls) = symbol_list_type_set ((yyvsp[0].yytype_86), (yyvsp[-1].TAG), (yylsp[-1])); + (yyval.symbol_decls) = symbol_list_type_set ((yyvsp[0].yykind_88), (yyvsp[-1].TAG), (yylsp[-1])); } -#line 2676 "src/parse-gram.c" +#line 2696 "src/parse-gram.c" break; - case 83: -#line 610 "src/parse-gram.y" + case 86: +#line 617 "src/parse-gram.y" { - (yyval.symbol_decls) = symbol_list_append ((yyvsp[-2].symbol_decls), symbol_list_type_set ((yyvsp[0].yytype_86), (yyvsp[-1].TAG), (yylsp[-1]))); + (yyval.symbol_decls) = symbol_list_append ((yyvsp[-2].symbol_decls), symbol_list_type_set ((yyvsp[0].yykind_88), (yyvsp[-1].TAG), (yylsp[-1]))); } -#line 2684 "src/parse-gram.c" +#line 2704 "src/parse-gram.c" break; - case 84: -#line 618 "src/parse-gram.y" + case 87: +#line 625 "src/parse-gram.y" { symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false); - (yyval.yytype_86) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); + (yyval.yykind_88) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2693 "src/parse-gram.c" +#line 2713 "src/parse-gram.c" break; - case 85: -#line 623 "src/parse-gram.y" + case 88: +#line 630 "src/parse-gram.y" { symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false); - (yyval.yytype_86) = symbol_list_append ((yyvsp[-1].yytype_86), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); + (yyval.yykind_88) = symbol_list_append ((yyvsp[-1].yykind_88), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } -#line 2702 "src/parse-gram.c" +#line 2722 "src/parse-gram.c" break; - case 90: -#line 644 "src/parse-gram.y" + case 93: +#line 651 "src/parse-gram.y" { yyerrok; } -#line 2710 "src/parse-gram.c" +#line 2730 "src/parse-gram.c" break; - case 91: -#line 650 "src/parse-gram.y" - { current_lhs ((yyvsp[-1].id_colon), (yylsp[-1]), (yyvsp[0].yytype_93)); } -#line 2716 "src/parse-gram.c" + case 94: +#line 657 "src/parse-gram.y" + { current_lhs ((yyvsp[-1].id_colon), (yylsp[-1]), (yyvsp[0].yykind_95)); } +#line 2736 "src/parse-gram.c" break; - case 92: -#line 651 "src/parse-gram.y" + case 95: +#line 658 "src/parse-gram.y" { /* Free the current lhs. */ current_lhs (0, (yylsp[-4]), 0); } -#line 2725 "src/parse-gram.c" +#line 2745 "src/parse-gram.c" break; - case 93: -#line 658 "src/parse-gram.y" + case 96: +#line 665 "src/parse-gram.y" { grammar_current_rule_end ((yylsp[0])); } -#line 2731 "src/parse-gram.c" +#line 2751 "src/parse-gram.c" break; - case 94: -#line 659 "src/parse-gram.y" + case 97: +#line 666 "src/parse-gram.y" { grammar_current_rule_end ((yylsp[0])); } -#line 2737 "src/parse-gram.c" +#line 2757 "src/parse-gram.c" break; - case 96: -#line 666 "src/parse-gram.y" + case 99: +#line 673 "src/parse-gram.y" { grammar_current_rule_begin (current_lhs_symbol, current_lhs_loc, current_lhs_named_ref); } -#line 2744 "src/parse-gram.c" +#line 2764 "src/parse-gram.c" break; - case 97: -#line 669 "src/parse-gram.y" - { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].yytype_93)); } -#line 2750 "src/parse-gram.c" + case 100: +#line 676 "src/parse-gram.y" + { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].yykind_95)); } +#line 2770 "src/parse-gram.c" break; - case 98: -#line 671 "src/parse-gram.y" - { grammar_current_rule_action_append ((yyvsp[-1].BRACED_CODE), (yylsp[-1]), (yyvsp[0].yytype_93), (yyvsp[-2].yytype_73)); } -#line 2756 "src/parse-gram.c" + case 101: +#line 678 "src/parse-gram.y" + { grammar_current_rule_action_append ((yyvsp[-1].BRACED_CODE), (yylsp[-1]), (yyvsp[0].yykind_95), (yyvsp[-2].yykind_74)); } +#line 2776 "src/parse-gram.c" break; - case 99: -#line 673 "src/parse-gram.y" + case 102: +#line 680 "src/parse-gram.y" { grammar_current_rule_predicate_append ((yyvsp[0].BRACED_PREDICATE), (yylsp[0])); } -#line 2762 "src/parse-gram.c" +#line 2782 "src/parse-gram.c" break; - case 100: -#line 675 "src/parse-gram.y" + case 103: +#line 682 "src/parse-gram.y" { grammar_current_rule_empty_set ((yylsp[0])); } -#line 2768 "src/parse-gram.c" +#line 2788 "src/parse-gram.c" break; - case 101: -#line 677 "src/parse-gram.y" + case 104: +#line 684 "src/parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2774 "src/parse-gram.c" +#line 2794 "src/parse-gram.c" break; - case 102: -#line 679 "src/parse-gram.y" + case 105: +#line 686 "src/parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[0].INT), (yylsp[0])); } -#line 2780 "src/parse-gram.c" +#line 2800 "src/parse-gram.c" break; - case 103: -#line 681 "src/parse-gram.y" + case 106: +#line 688 "src/parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[0].TAG), (yylsp[0])); } -#line 2786 "src/parse-gram.c" +#line 2806 "src/parse-gram.c" break; - case 104: -#line 683 "src/parse-gram.y" + case 107: +#line 690 "src/parse-gram.y" { grammar_current_rule_expect_sr ((yyvsp[0].INT), (yylsp[0])); } -#line 2792 "src/parse-gram.c" +#line 2812 "src/parse-gram.c" break; - case 105: -#line 685 "src/parse-gram.y" + case 108: +#line 692 "src/parse-gram.y" { grammar_current_rule_expect_rr ((yyvsp[0].INT), (yylsp[0])); } -#line 2798 "src/parse-gram.c" +#line 2818 "src/parse-gram.c" break; - case 106: -#line 689 "src/parse-gram.y" - { (yyval.yytype_93) = NULL; } -#line 2804 "src/parse-gram.c" + case 109: +#line 696 "src/parse-gram.y" + { (yyval.yykind_95) = NULL; } +#line 2824 "src/parse-gram.c" break; - case 107: -#line 690 "src/parse-gram.y" - { (yyval.yytype_93) = named_ref_new ((yyvsp[0].BRACKETED_ID), (yylsp[0])); } -#line 2810 "src/parse-gram.c" + case 110: +#line 697 "src/parse-gram.y" + { (yyval.yykind_95) = named_ref_new ((yyvsp[0].BRACKETED_ID), (yylsp[0])); } +#line 2830 "src/parse-gram.c" break; - case 109: -#line 723 "src/parse-gram.y" + case 112: +#line 730 "src/parse-gram.y" { (yyval.value).kind = muscle_keyword; (yyval.value).chars = ""; } -#line 2816 "src/parse-gram.c" +#line 2836 "src/parse-gram.c" break; - case 110: -#line 724 "src/parse-gram.y" + case 113: +#line 731 "src/parse-gram.y" { (yyval.value).kind = muscle_keyword; (yyval.value).chars = (yyvsp[0].ID); } -#line 2822 "src/parse-gram.c" +#line 2842 "src/parse-gram.c" break; - case 111: -#line 725 "src/parse-gram.y" + case 114: +#line 732 "src/parse-gram.y" { (yyval.value).kind = muscle_string; (yyval.value).chars = (yyvsp[0].STRING); } -#line 2828 "src/parse-gram.c" +#line 2848 "src/parse-gram.c" break; - case 112: -#line 726 "src/parse-gram.y" + case 115: +#line 733 "src/parse-gram.y" { (yyval.value).kind = muscle_code; (yyval.value).chars = strip_braces ((yyvsp[0].BRACED_CODE)); } -#line 2834 "src/parse-gram.c" +#line 2854 "src/parse-gram.c" break; - case 113: -#line 739 "src/parse-gram.y" + case 116: +#line 746 "src/parse-gram.y" { (yyval.id) = symbol_from_uniqstr ((yyvsp[0].ID), (yylsp[0])); } -#line 2840 "src/parse-gram.c" +#line 2860 "src/parse-gram.c" break; - case 114: -#line 741 "src/parse-gram.y" + case 117: +#line 748 "src/parse-gram.y" { const char *var = "api.token.raw"; if (current_class == nterm_sym) @@ -2851,54 +2871,45 @@ yyreduce: } if (muscle_percent_define_ifdef (var)) { - int indent = 0; - complain_indent (&(yylsp[0]), complaint, &indent, - _("character literals cannot be used together" - " with %s"), var); - indent += SUB_INDENT; + complain (&(yylsp[0]), complaint, + _("character literals cannot be used together" + " with %s"), var); location loc = muscle_percent_define_get_loc (var); - complain_indent (&loc, complaint, &indent, - _("definition of %s"), var); + subcomplain (&loc, complaint, _("definition of %s"), var); } (yyval.id) = symbol_get (char_name ((yyvsp[0].CHAR)), (yylsp[0])); symbol_class_set ((yyval.id), token_sym, (yylsp[0]), false); symbol_user_token_number_set ((yyval.id), (yyvsp[0].CHAR), (yylsp[0])); } -#line 2868 "src/parse-gram.c" +#line 2885 "src/parse-gram.c" break; - case 115: -#line 767 "src/parse-gram.y" + case 118: +#line 771 "src/parse-gram.y" { (yyval.id_colon) = symbol_from_uniqstr ((yyvsp[0].ID_COLON), (yylsp[0])); } -#line 2874 "src/parse-gram.c" +#line 2891 "src/parse-gram.c" break; - case 118: -#line 779 "src/parse-gram.y" + case 121: +#line 783 "src/parse-gram.y" { (yyval.string_as_id) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].STRING)), (yylsp[0])); symbol_class_set ((yyval.string_as_id), token_sym, (yylsp[0]), false); } -#line 2883 "src/parse-gram.c" +#line 2900 "src/parse-gram.c" break; - case 119: -#line 787 "src/parse-gram.y" - { (yyval.yytype_100) = NULL; } -#line 2889 "src/parse-gram.c" - break; - - case 122: -#line 794 "src/parse-gram.y" + case 123: +#line 792 "src/parse-gram.y" { muscle_code_grow ("epilogue", translate_code ((yyvsp[0].EPILOGUE), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2898 "src/parse-gram.c" +#line 2909 "src/parse-gram.c" break; -#line 2902 "src/parse-gram.c" +#line 2913 "src/parse-gram.c" default: break; } @@ -2916,11 +2927,10 @@ yyreduce: case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; @@ -2945,69 +2955,38 @@ yyreduce: yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == GRAM_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (&yylloc, YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyesa, &yyes, &yyes_capacity, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - if (yychar != YYEMPTY) + yypcontext_t yyctx + = {yyssp, yyesa, &yyes, &yyes_capacity, yytoken, &yylloc}; + if (yychar != GRAM_EMPTY) YY_LAC_ESTABLISH; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (&yylloc, yymsgp); - if (yysyntax_error_status == 2) + if (yyreport_syntax_error (&yyctx) == 2) goto yyexhaustedlab; } -# undef YYSYNTAX_ERROR -#endif } yyerror_range[1] = yylloc; - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ - if (yychar <= YYEOF) + if (yychar <= GRAM_EOF) { /* Return failure if at end of input. */ - if (yychar == YYEOF) + if (yychar == GRAM_EOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); - yychar = YYEMPTY; + yychar = GRAM_EMPTY; } } @@ -3040,13 +3019,14 @@ yyerrorlab: yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -3060,7 +3040,7 @@ yyerrlab1: yyerror_range[1] = *yylsp; yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -3075,13 +3055,11 @@ yyerrlab1: YY_IGNORE_MAYBE_UNINITIALIZED_END yyerror_range[2] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - *++yylsp = yyloc; + ++yylsp; + YYLLOC_DEFAULT (*yylsp, yyerror_range, 2); /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -3118,7 +3096,7 @@ yyexhaustedlab: | yyreturn -- parsing is finished, return the result. | `-----------------------------------------------------*/ yyreturn: - if (yychar != YYEMPTY) + if (yychar != GRAM_EMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -3133,7 +3111,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[+*yyssp], yyvsp, yylsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -3142,13 +3120,37 @@ yyreturn: #endif if (yyes != yyesa) YYSTACK_FREE (yyes); -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 800 "src/parse-gram.y" + +#line 798 "src/parse-gram.y" + + +int +yyreport_syntax_error (const yypcontext_t *ctx) +{ + int res = 0; + /* Arguments of format: reported tokens (one for the "unexpected", + one per "expected"). */ + enum { ARGS_MAX = 5 }; + const char *argv[ARGS_MAX]; + int argc = 0; + yysymbol_kind_t unexpected = yypcontext_token (ctx); + if (unexpected != YYSYMBOL_YYEMPTY) + { + argv[argc++] = yysymbol_name (unexpected); + yysymbol_kind_t expected[ARGS_MAX - 1]; + int nexpected = yypcontext_expected_tokens (ctx, expected, ARGS_MAX - 1); + if (nexpected < 0) + res = nexpected; + else + for (int i = 0; i < nexpected; ++i) + argv[argc++] = yysymbol_name (expected[i]); + } + syntax_error (*yypcontext_location (ctx), argc, argv); + return res; +} /* Return the location of the left-hand side of a rule whose @@ -3373,9 +3375,9 @@ handle_require (location const *loc, char const *version) return; } - /* Pretend to be at least 3.5, to check features published in that - version while developping it. */ - const char* api_version = "3.5"; + /* Pretend to be at least that version, to check features published + in that version while developping it. */ + const char* api_version = "3.6"; const char* package_version = 0 < strverscmp (api_version, PACKAGE_VERSION) ? api_version : PACKAGE_VERSION; diff --git a/contrib/tools/bison/src/parse-gram.h b/contrib/tools/bison/src/parse-gram.h index 3a36b3c273..3193d5af99 100644 --- a/contrib/tools/bison/src/parse-gram.h +++ b/contrib/tools/bison/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.5.4. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison interface for Yacc-like parsers in C @@ -31,8 +31,9 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ #ifndef YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED # define YY_GRAM_SRC_PARSE_GRAM_H_INCLUDED @@ -56,7 +57,7 @@ extern int gram_debug; #include "symlist.h" #include "symtab.h" -#line 251 "src/parse-gram.y" +#line 245 "src/parse-gram.y" typedef enum { @@ -65,7 +66,7 @@ extern int gram_debug; param_parse = 1 << 1, param_both = param_lex | param_parse } param_type; -#line 703 "src/parse-gram.y" +#line 710 "src/parse-gram.y" #include "muscle-tab.h" typedef struct @@ -74,162 +75,127 @@ extern int gram_debug; muscle_kind kind; } value_type; -#line 78 "src/parse-gram.h" +#line 79 "src/parse-gram.h" -/* Token type. */ +/* Token kinds. */ #ifndef GRAM_TOKENTYPE # define GRAM_TOKENTYPE enum gram_tokentype { - GRAM_EOF = 0, - STRING = 3, - PERCENT_TOKEN = 4, - PERCENT_NTERM = 5, - PERCENT_TYPE = 6, - PERCENT_DESTRUCTOR = 7, - PERCENT_PRINTER = 8, - PERCENT_LEFT = 9, - PERCENT_RIGHT = 10, - PERCENT_NONASSOC = 11, - PERCENT_PRECEDENCE = 12, - PERCENT_PREC = 13, - PERCENT_DPREC = 14, - PERCENT_MERGE = 15, - PERCENT_CODE = 16, - PERCENT_DEFAULT_PREC = 17, - PERCENT_DEFINE = 18, - PERCENT_DEFINES = 19, - PERCENT_ERROR_VERBOSE = 20, - PERCENT_EXPECT = 21, - PERCENT_EXPECT_RR = 22, - PERCENT_FLAG = 23, - PERCENT_FILE_PREFIX = 24, - PERCENT_GLR_PARSER = 25, - PERCENT_INITIAL_ACTION = 26, - PERCENT_LANGUAGE = 27, - PERCENT_NAME_PREFIX = 28, - PERCENT_NO_DEFAULT_PREC = 29, - PERCENT_NO_LINES = 30, - PERCENT_NONDETERMINISTIC_PARSER = 31, - PERCENT_OUTPUT = 32, - PERCENT_PURE_PARSER = 33, - PERCENT_REQUIRE = 34, - PERCENT_SKELETON = 35, - PERCENT_START = 36, - PERCENT_TOKEN_TABLE = 37, - PERCENT_VERBOSE = 38, - PERCENT_YACC = 39, - BRACED_CODE = 40, - BRACED_PREDICATE = 41, - BRACKETED_ID = 42, - CHAR = 43, - COLON = 44, - EPILOGUE = 45, - EQUAL = 46, - ID = 47, - ID_COLON = 48, - PERCENT_PERCENT = 49, - PIPE = 50, - PROLOGUE = 51, - SEMICOLON = 52, - TAG = 53, - TAG_ANY = 54, - TAG_NONE = 55, - INT = 56, - PERCENT_PARAM = 57, - PERCENT_UNION = 58, - PERCENT_EMPTY = 59 + GRAM_EMPTY = -2, + GRAM_EOF = 0, /* "end of file" */ + GRAM_error = 1, /* error */ + GRAM_UNDEF = 2, /* "invalid token" */ + STRING = 3, /* "string" */ + TSTRING = 4, /* "translatable string" */ + PERCENT_TOKEN = 5, /* "%token" */ + PERCENT_NTERM = 6, /* "%nterm" */ + PERCENT_TYPE = 7, /* "%type" */ + PERCENT_DESTRUCTOR = 8, /* "%destructor" */ + PERCENT_PRINTER = 9, /* "%printer" */ + PERCENT_LEFT = 10, /* "%left" */ + PERCENT_RIGHT = 11, /* "%right" */ + PERCENT_NONASSOC = 12, /* "%nonassoc" */ + PERCENT_PRECEDENCE = 13, /* "%precedence" */ + PERCENT_PREC = 14, /* "%prec" */ + PERCENT_DPREC = 15, /* "%dprec" */ + PERCENT_MERGE = 16, /* "%merge" */ + PERCENT_CODE = 17, /* "%code" */ + PERCENT_DEFAULT_PREC = 18, /* "%default-prec" */ + PERCENT_DEFINE = 19, /* "%define" */ + PERCENT_DEFINES = 20, /* "%defines" */ + PERCENT_ERROR_VERBOSE = 21, /* "%error-verbose" */ + PERCENT_EXPECT = 22, /* "%expect" */ + PERCENT_EXPECT_RR = 23, /* "%expect-rr" */ + PERCENT_FLAG = 24, /* "%<flag>" */ + PERCENT_FILE_PREFIX = 25, /* "%file-prefix" */ + PERCENT_GLR_PARSER = 26, /* "%glr-parser" */ + PERCENT_INITIAL_ACTION = 27, /* "%initial-action" */ + PERCENT_LANGUAGE = 28, /* "%language" */ + PERCENT_NAME_PREFIX = 29, /* "%name-prefix" */ + PERCENT_NO_DEFAULT_PREC = 30, /* "%no-default-prec" */ + PERCENT_NO_LINES = 31, /* "%no-lines" */ + PERCENT_NONDETERMINISTIC_PARSER = 32, /* "%nondeterministic-parser" */ + PERCENT_OUTPUT = 33, /* "%output" */ + PERCENT_PURE_PARSER = 34, /* "%pure-parser" */ + PERCENT_REQUIRE = 35, /* "%require" */ + PERCENT_SKELETON = 36, /* "%skeleton" */ + PERCENT_START = 37, /* "%start" */ + PERCENT_TOKEN_TABLE = 38, /* "%token-table" */ + PERCENT_VERBOSE = 39, /* "%verbose" */ + PERCENT_YACC = 40, /* "%yacc" */ + BRACED_CODE = 41, /* "{...}" */ + BRACED_PREDICATE = 42, /* "%?{...}" */ + BRACKETED_ID = 43, /* "[identifier]" */ + CHAR = 44, /* "character literal" */ + COLON = 45, /* ":" */ + EPILOGUE = 46, /* "epilogue" */ + EQUAL = 47, /* "=" */ + ID = 48, /* "identifier" */ + ID_COLON = 49, /* "identifier:" */ + PERCENT_PERCENT = 50, /* "%%" */ + PIPE = 51, /* "|" */ + PROLOGUE = 52, /* "%{...%}" */ + SEMICOLON = 53, /* ";" */ + TAG = 54, /* "<tag>" */ + TAG_ANY = 55, /* "<*>" */ + TAG_NONE = 56, /* "<>" */ + INT = 57, /* "integer literal" */ + PERCENT_PARAM = 58, /* "%param" */ + PERCENT_UNION = 59, /* "%union" */ + PERCENT_EMPTY = 60 /* "%empty" */ }; + typedef enum gram_tokentype gram_token_kind_t; #endif /* Value type. */ #if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED union GRAM_STYPE { - - /* precedence_declarator */ - assoc precedence_declarator; - /* "string" */ - char* STRING; - /* "{...}" */ - char* BRACED_CODE; - /* "%?{...}" */ - char* BRACED_PREDICATE; - /* "epilogue" */ - char* EPILOGUE; - /* "%{...%}" */ - char* PROLOGUE; - /* code_props_type */ - code_props_type code_props_type; - /* "integer" */ - int INT; - /* int.opt */ - int yytype_81; - /* named_ref.opt */ - named_ref* yytype_93; - /* "%param" */ - param_type PERCENT_PARAM; - /* token_decl */ - symbol* token_decl; - /* token_decl_for_prec */ - symbol* token_decl_for_prec; - /* id */ - symbol* id; - /* id_colon */ - symbol* id_colon; - /* symbol */ - symbol* symbol; - /* string_as_id */ - symbol* string_as_id; - /* string_as_id.opt */ - symbol* yytype_100; - /* generic_symlist */ - symbol_list* generic_symlist; - /* generic_symlist_item */ - symbol_list* generic_symlist_item; - /* nterm_decls */ - symbol_list* nterm_decls; - /* token_decls */ - symbol_list* token_decls; - /* token_decl.1 */ - symbol_list* yytype_79; - /* token_decls_for_prec */ - symbol_list* token_decls_for_prec; - /* token_decl_for_prec.1 */ - symbol_list* yytype_83; - /* symbol_decls */ - symbol_list* symbol_decls; - /* symbol_decl.1 */ - symbol_list* yytype_86; - /* "%error-verbose" */ - uniqstr PERCENT_ERROR_VERBOSE; - /* "%<flag>" */ - uniqstr PERCENT_FLAG; - /* "%file-prefix" */ - uniqstr PERCENT_FILE_PREFIX; - /* "%name-prefix" */ - uniqstr PERCENT_NAME_PREFIX; - /* "%pure-parser" */ - uniqstr PERCENT_PURE_PARSER; - /* "[identifier]" */ - uniqstr BRACKETED_ID; - /* "identifier" */ - uniqstr ID; - /* "identifier:" */ - uniqstr ID_COLON; - /* "<tag>" */ - uniqstr TAG; - /* tag.opt */ - uniqstr yytype_73; - /* tag */ - uniqstr tag; - /* variable */ - uniqstr variable; - /* "character literal" */ - unsigned char CHAR; - /* value */ - value_type value; -#line 233 "src/parse-gram.h" + assoc precedence_declarator; /* precedence_declarator */ + char* STRING; /* "string" */ + char* TSTRING; /* "translatable string" */ + char* BRACED_CODE; /* "{...}" */ + char* BRACED_PREDICATE; /* "%?{...}" */ + char* EPILOGUE; /* "epilogue" */ + char* PROLOGUE; /* "%{...%}" */ + code_props_type code_props_type; /* code_props_type */ + int INT; /* "integer literal" */ + int yykind_82; /* int.opt */ + named_ref* yykind_95; /* named_ref.opt */ + param_type PERCENT_PARAM; /* "%param" */ + symbol* token_decl; /* token_decl */ + symbol* alias; /* alias */ + symbol* token_decl_for_prec; /* token_decl_for_prec */ + symbol* id; /* id */ + symbol* id_colon; /* id_colon */ + symbol* symbol; /* symbol */ + symbol* string_as_id; /* string_as_id */ + symbol_list* generic_symlist; /* generic_symlist */ + symbol_list* generic_symlist_item; /* generic_symlist_item */ + symbol_list* nterm_decls; /* nterm_decls */ + symbol_list* token_decls; /* token_decls */ + symbol_list* yykind_80; /* token_decl.1 */ + symbol_list* token_decls_for_prec; /* token_decls_for_prec */ + symbol_list* yykind_85; /* token_decl_for_prec.1 */ + symbol_list* symbol_decls; /* symbol_decls */ + symbol_list* yykind_88; /* symbol_decl.1 */ + uniqstr PERCENT_ERROR_VERBOSE; /* "%error-verbose" */ + uniqstr PERCENT_FLAG; /* "%<flag>" */ + uniqstr PERCENT_FILE_PREFIX; /* "%file-prefix" */ + uniqstr PERCENT_NAME_PREFIX; /* "%name-prefix" */ + uniqstr PERCENT_PURE_PARSER; /* "%pure-parser" */ + uniqstr BRACKETED_ID; /* "[identifier]" */ + uniqstr ID; /* "identifier" */ + uniqstr ID_COLON; /* "identifier:" */ + uniqstr TAG; /* "<tag>" */ + uniqstr yykind_74; /* tag.opt */ + uniqstr tag; /* tag */ + uniqstr variable; /* variable */ + unsigned char CHAR; /* "character literal" */ + value_type value; /* value */ + +#line 199 "src/parse-gram.h" }; typedef union GRAM_STYPE GRAM_STYPE; diff --git a/contrib/tools/bison/src/reader.c b/contrib/tools/bison/src/reader.c index 80d307c6c2..bffca16d83 100644 --- a/contrib/tools/bison/src/reader.c +++ b/contrib/tools/bison/src/reader.c @@ -124,16 +124,13 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc) aver (merge_function != NULL && merger_find == merger); if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type)) { - int indent = 0; - complain_indent (&declaration_loc, complaint, &indent, - _("result type clash on merge function %s: " - "<%s> != <%s>"), - quote (merge_function->name), type, - merge_function->type); - indent += SUB_INDENT; - complain_indent (&merge_function->type_declaration_loc, complaint, - &indent, - _("previous declaration")); + complain (&declaration_loc, complaint, + _("result type clash on merge function %s: " + "<%s> != <%s>"), + quote (merge_function->name), type, + merge_function->type); + subcomplain (&merge_function->type_declaration_loc, complaint, + _("previous declaration")); } merge_function->type = uniqstr_new (type); merge_function->type_declaration_loc = declaration_loc; @@ -781,11 +778,16 @@ check_and_convert_grammar (void) /* If the user did not define her ENDTOKEN, do it now. */ if (!endtoken) { - endtoken = symbol_get ("$end", empty_loc); + endtoken = symbol_get ("YYEOF", empty_loc); endtoken->content->class = token_sym; endtoken->content->number = 0; /* Value specified by POSIX. */ endtoken->content->user_token_number = 0; + { + symbol *alias = symbol_get ("$end", empty_loc); + symbol_class_set (alias, token_sym, empty_loc, false); + symbol_make_alias (endtoken, alias, empty_loc); + } } /* Report any undefined symbols and consider them nonterminals. */ @@ -820,9 +822,9 @@ check_and_convert_grammar (void) /* Assign the symbols their symbol numbers. */ symbols_pack (); - /* Scan rule actions after invoking symbol_check_alias_consistency (in - symbols_pack above) so that token types are set correctly before the rule - action type checking. + /* Scan rule actions after invoking symbol_check_alias_consistency + (in symbols_pack above) so that token types are set correctly + before the rule action type checking. Before invoking grammar_rule_check_and_complete (in packgram below) on any rule, make sure all actions have already been diff --git a/contrib/tools/bison/src/scan-code.c b/contrib/tools/bison/src/scan-code.c index 99d287b31f..86e264fbee 100644 --- a/contrib/tools/bison/src/scan-code.c +++ b/contrib/tools/bison/src/scan-code.c @@ -2699,14 +2699,14 @@ static void show_sub_message (warnings warning, const char* cp, bool explicit_bracketing, int midrule_rhs_index, char dollar_or_at, - int indent, const variant *var) + const variant *var) { const char *at_spec = get_at_spec (var->symbol_index); if (var->err == 0) - complain_indent (&var->loc, warning, &indent, - _("refers to: %c%s at %s"), dollar_or_at, - var->id, at_spec); + subcomplain (&var->loc, warning, + _("refers to: %c%s at %s"), dollar_or_at, + var->id, at_spec); else { const char *id; @@ -2753,8 +2753,8 @@ show_sub_message (warnings warning, _(", cannot be accessed from midrule action at $%d"), midrule_rhs_index); - complain_indent (&id_loc, warning, &indent, "%s", - obstack_finish0 (&msg_buf)); + subcomplain (&id_loc, warning, "%s", + obstack_finish0 (&msg_buf)); obstack_free (&msg_buf, 0); } } @@ -2762,14 +2762,13 @@ show_sub_message (warnings warning, static void show_sub_messages (warnings warning, const char* cp, bool explicit_bracketing, - int midrule_rhs_index, char dollar_or_at, - int indent) + int midrule_rhs_index, char dollar_or_at) { for (int i = 0; i < variant_count; ++i) show_sub_message (warning | silent, cp, explicit_bracketing, midrule_rhs_index, dollar_or_at, - indent, &variant_table[i]); + &variant_table[i]); } /* Returned from "parse_ref" when the reference @@ -2870,47 +2869,44 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, { int len = (explicit_bracketing || !ref_tail_fields) ? cp_end - cp : ref_tail_fields - cp; - int indent = 0; - complain_indent (text_loc, complaint, &indent, - _("invalid reference: %s"), quote (text)); - indent += SUB_INDENT; + complain (text_loc, complaint, + _("invalid reference: %s"), quote (text)); if (len == 0) { location sym_loc = *text_loc; sym_loc.start.column += 1; sym_loc.end = sym_loc.start; - complain_indent (&sym_loc, complaint, &indent, - _("syntax error after '%c', expecting integer, " - "letter, '_', '[', or '$'"), - dollar_or_at); + subcomplain (&sym_loc, complaint, + _("syntax error after '%c', expecting integer, " + "letter, '_', '[', or '$'"), + dollar_or_at); } else if (midrule_rhs_index) - complain_indent (&rule->rhs_loc, complaint, &indent, - _("symbol not found in production before $%d: " - "%.*s"), - midrule_rhs_index, len, cp); + subcomplain (&rule->rhs_loc, complaint, + _("symbol not found in production before $%d: " + "%.*s"), + midrule_rhs_index, len, cp); else - complain_indent (&rule->rhs_loc, complaint, &indent, - _("symbol not found in production: %.*s"), - len, cp); + subcomplain (&rule->rhs_loc, complaint, + _("symbol not found in production: %.*s"), + len, cp); if (variant_count > 0) show_sub_messages (complaint, cp, explicit_bracketing, midrule_rhs_index, - dollar_or_at, indent); + dollar_or_at); return INVALID_REF; } case 1: { - int indent = 0; if (variant_count > 1) { - complain_indent (text_loc, Wother, &indent, - _("misleading reference: %s"), quote (text)); + complain (text_loc, Wother, + _("misleading reference: %s"), quote (text)); show_sub_messages (Wother, cp, explicit_bracketing, midrule_rhs_index, - dollar_or_at, indent + SUB_INDENT); + dollar_or_at); } { int symbol_index = @@ -2921,12 +2917,11 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, case 2: default: { - int indent = 0; - complain_indent (text_loc, complaint, &indent, - _("ambiguous reference: %s"), quote (text)); + complain (text_loc, complaint, + _("ambiguous reference: %s"), quote (text)); show_sub_messages (complaint, cp, explicit_bracketing, midrule_rhs_index, - dollar_or_at, indent + SUB_INDENT); + dollar_or_at); return INVALID_REF; } } diff --git a/contrib/tools/bison/src/scan-gram.c b/contrib/tools/bison/src/scan-gram.c index a34ddb8f5f..2c439869ac 100644 --- a/contrib/tools/bison/src/scan-gram.c +++ b/contrib/tools/bison/src/scan-gram.c @@ -691,8 +691,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 127 -#define YY_END_OF_BUFFER 128 +#define YY_NUM_RULES 130 +#define YY_END_OF_BUFFER 131 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -700,74 +700,75 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[600] = +static const flex_int16_t yy_accept[608] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 91, 91, 111, 111, 111, 111, 0, 0, - 0, 0, 128, 78, 2, 2, 2, 69, 78, 68, - 78, 1, 64, 78, 65, 65, 60, 63, 75, 61, - 64, 77, 71, 62, 78, 88, 88, 88, 126, 126, - 93, 126, 92, 126, 126, 126, 126, 126, 126, 126, - 126, 79, 95, 126, 94, 82, 2, 2, 1, 82, - 81, 80, 82, 97, 97, 98, 96, 79, 117, 126, - 116, 126, 126, 126, 120, 123, 124, 126, 90, 126, - - 126, 115, 126, 114, 126, 113, 126, 112, 85, 2, - 2, 1, 83, 85, 85, 84, 85, 86, 2, 2, - 1, 86, 86, 78, 2, 76, 59, 0, 59, 59, + 0, 0, 0, 0, 92, 92, 114, 114, 114, 114, + 0, 0, 0, 0, 131, 79, 2, 2, 2, 69, + 79, 68, 79, 1, 64, 79, 65, 65, 60, 63, + 76, 61, 64, 78, 64, 72, 62, 79, 89, 89, + 89, 129, 129, 98, 129, 97, 129, 129, 129, 129, + 129, 129, 129, 129, 80, 94, 129, 93, 96, 129, + 83, 2, 2, 1, 83, 82, 81, 83, 100, 100, + 101, 99, 80, 120, 129, 119, 129, 129, 129, 123, + + 126, 127, 129, 91, 129, 129, 118, 129, 117, 129, + 116, 129, 115, 86, 2, 2, 1, 84, 86, 86, + 85, 86, 87, 2, 2, 1, 87, 87, 79, 2, + 77, 59, 0, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 70, 64, 64, 4, - 3, 67, 65, 67, 0, 74, 0, 88, 87, 93, - 110, 110, 108, 99, 110, 101, 102, 103, 104, 105, - 106, 110, 107, 110, 126, 0, 0, 0, 0, 0, - 0, 95, 97, 97, 98, 125, 118, 119, 0, 121, - 0, 120, 122, 0, 89, 0, 90, 0, 91, 0, - - 115, 111, 111, 111, 111, 111, 113, 85, 83, 59, - 0, 0, 72, 59, 59, 59, 59, 59, 59, 59, + 59, 71, 64, 64, 4, 3, 67, 65, 67, 0, + 75, 0, 0, 89, 88, 98, 113, 113, 111, 102, + 113, 104, 105, 106, 107, 108, 109, 113, 110, 113, + 129, 0, 0, 0, 0, 0, 0, 94, 95, 100, + 100, 101, 128, 121, 122, 0, 124, 0, 123, 125, + + 0, 90, 0, 91, 0, 92, 0, 118, 114, 114, + 114, 114, 114, 116, 86, 84, 59, 0, 0, 73, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 3, 67, 66, 73, 0, 99, - 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 3, 67, 66, 74, 70, 0, 102, 0, 0, + 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 0, 99, 0, 0, 59, 7, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 21, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 33, 59, 59, - 59, 59, 59, 59, 40, 59, 43, 59, 59, 46, - 0, 0, 0, 59, 8, 59, 59, 59, 13, 14, - 59, 59, 59, 59, 59, 59, 59, 59, 59, 24, - 59, 59, 59, 59, 59, 59, 59, 29, 59, 31, - 59, 59, 59, 59, 59, 37, 59, 39, 41, 44, - - 59, 0, 0, 109, 6, 59, 10, 59, 59, 59, - 15, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 30, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 0, 59, 11, 59, 59, + 59, 0, 102, 0, 0, 59, 7, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 0, 57, 59, - 59, 35, 59, 36, 59, 59, 59, 45, 5, 0, - 0, 59, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 59, 20, 59, 59, 59, 59, 26, 59, 56, - 27, 59, 59, 59, 59, 38, 59, 59, 0, 59, - - 59, 59, 59, 59, 16, 52, 59, 59, 59, 59, - 22, 23, 59, 59, 59, 59, 59, 59, 59, 59, - 59, 0, 0, 59, 59, 12, 59, 59, 59, 59, - 19, 59, 59, 59, 59, 59, 59, 34, 59, 59, - 59, 0, 59, 59, 59, 59, 17, 59, 59, 49, - 59, 59, 59, 32, 47, 42, 58, 9, 50, 59, - 59, 0, 53, 59, 59, 49, 49, 59, 59, 59, - 48, 51, 59, 59, 49, 59, 59, 59, 59, 18, - 59, 59, 59, 59, 25, 55, 59, 59, 59, 59, - 59, 54, 59, 59, 59, 59, 59, 28, 0 - + 21, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 33, 59, 59, 59, 59, + 59, 59, 40, 59, 43, 59, 59, 46, 0, 0, + 0, 59, 8, 59, 59, 59, 13, 14, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 24, 59, 59, + 59, 59, 59, 59, 59, 29, 59, 31, 59, 59, + + 59, 59, 59, 37, 59, 39, 41, 44, 59, 0, + 0, 112, 6, 59, 10, 59, 59, 59, 15, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 30, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 0, 59, 11, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 0, 57, 59, 59, 35, + 59, 36, 59, 59, 59, 45, 5, 0, 0, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 20, 59, 59, 59, 59, 26, 59, 56, 27, 59, + + 59, 59, 59, 38, 59, 59, 0, 59, 59, 59, + 59, 59, 16, 52, 59, 59, 59, 59, 22, 23, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 0, + 0, 59, 59, 12, 59, 59, 59, 59, 19, 59, + 59, 59, 59, 59, 59, 34, 59, 59, 59, 0, + 59, 59, 59, 59, 17, 59, 59, 49, 59, 59, + 59, 32, 47, 42, 58, 9, 50, 59, 59, 0, + 53, 59, 59, 49, 49, 59, 59, 59, 48, 51, + 59, 59, 49, 59, 59, 59, 59, 18, 59, 59, + 59, 59, 25, 55, 59, 59, 59, 59, 59, 54, + + 59, 59, 59, 59, 59, 28, 0 } ; static const YY_CHAR yy_ec[256] = @@ -775,351 +776,355 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 6, 7, 8, 9, 7, 10, 7, 11, 7, - 7, 12, 7, 13, 14, 15, 16, 17, 18, 18, - 18, 18, 18, 18, 18, 19, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 27, 27, 27, 27, 27, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 29, 28, 28, 30, 28, 28, - 31, 32, 33, 26, 34, 26, 35, 36, 37, 38, - - 39, 40, 41, 42, 43, 28, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 28, 56, - 57, 28, 58, 59, 60, 26, 61, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 1, 6, 7, 8, 9, 7, 10, 7, 11, 12, + 13, 14, 7, 15, 16, 17, 18, 19, 20, 20, + 20, 20, 20, 20, 20, 21, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 29, 29, 29, 29, 29, + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 31, 30, 30, 32, 30, 30, + 33, 34, 35, 28, 36, 28, 37, 38, 39, 40, + + 41, 42, 43, 44, 45, 30, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 30, 58, + 59, 30, 60, 61, 62, 28, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 1, 1, 65, 65, 65, 65, 65, 65, 65, - - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 66, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 68, 67, 67, 69, - 70, 70, 70, 71, 1, 1, 1, 1, 1, 1, + 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 1, 1, 67, 67, 67, 67, 67, 67, 67, + + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 68, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 70, 69, 69, 71, + 72, 72, 72, 73, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[73] = +static const YY_CHAR yy_meta[75] = { 0, 1, 2, 3, 2, 2, 2, 1, 4, 1, 4, - 4, 4, 4, 5, 6, 2, 7, 7, 7, 8, - 9, 10, 9, 10, 8, 8, 7, 7, 7, 7, - 11, 8, 12, 7, 7, 7, 7, 7, 7, 7, + 4, 1, 1, 4, 4, 5, 6, 2, 7, 7, + 7, 8, 9, 10, 9, 10, 8, 8, 7, 7, + 7, 7, 11, 8, 12, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, - 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, - 1, 8 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 9, + 9, 9, 8, 8, 8, 8, 1, 1, 1, 1, + 1, 1, 1, 8 } ; -static const flex_int16_t yy_base[618] = +static const flex_int16_t yy_base[626] = { 0, - 0, 1341, 68, 69, 81, 153, 85, 89, 99, 105, - 102, 109, 157, 161, 231, 301, 179, 194, 371, 441, - 195, 247, 241, 253, 266, 267, 273, 319, 513, 1340, - 344, 362, 1348, 0, 1351, 1351, 1344, 1351, 576, 1351, - 1351, 1351, 634, 63, 278, 59, 0, 1351, 71, 1351, - 0, 1351, 1351, 1351, 1301, 1351, 1342, 1328, 1351, 1351, - 1351, 1340, 1351, 702, 65, 1278, 75, 36, 0, 116, - 1279, 1351, 1351, 1337, 1351, 1351, 1351, 1336, 1351, 75, - 1351, 1351, 1293, 1323, 108, 1314, 1351, 1321, 1351, 1274, - 1351, 143, 159, 255, 1351, 1351, 1351, 154, 1351, 1330, - - 338, 1351, 1329, 1351, 392, 1351, 1328, 1351, 0, 1351, - 1327, 0, 0, 176, 1351, 1351, 1284, 1351, 1351, 1325, - 1351, 192, 1282, 0, 1351, 1351, 0, 350, 1283, 1277, - 157, 184, 1281, 1278, 1275, 253, 1282, 267, 1266, 177, - 170, 201, 344, 1272, 1279, 1282, 1351, 0, 0, 1351, - 0, 0, 318, 398, 1292, 1351, 1272, 1351, 1351, 1351, - 1351, 1311, 1351, 117, 441, 1351, 1351, 1351, 1351, 1351, - 1351, 447, 1351, 471, 1351, 322, 326, 342, 347, 350, - 356, 1351, 1299, 224, 1290, 1351, 1351, 1351, 489, 1351, - 590, 1351, 1351, 634, 1351, 712, 1351, 719, 1279, 1307, - - 1351, 1351, 741, 1277, 1305, 757, 1351, 0, 0, 0, - 762, 1304, 1351, 1259, 1267, 228, 1253, 1254, 1251, 1252, - 61, 1249, 1256, 1251, 254, 1260, 1245, 1249, 393, 1255, - 1240, 1241, 243, 1240, 1240, 1248, 1249, 1252, 1235, 1241, - 1235, 1240, 1231, 1244, 0, 0, 0, 1351, 1233, 123, - 752, 758, 786, 359, 391, 407, 778, 416, 1276, 804, - 294, 1275, 812, 348, 1274, 825, 284, 1273, 830, 835, - 1272, 840, 845, 464, 1271, 1238, 1233, 1217, 286, 1217, - 1230, 1215, 1219, 1227, 1226, 1225, 1249, 1209, 1220, 1207, - 1245, 1223, 1216, 1217, 156, 245, 222, 1204, 1205, 279, - - 1216, 1205, 1212, 1196, 1207, 1203, 1196, 1200, 1206, 1205, - 1195, 1206, 1204, 1201, 1351, 835, 841, 1188, 0, 1197, - 1183, 1189, 1184, 1197, 1176, 1181, 1194, 1216, 1191, 1179, - 1184, 1172, 0, 1176, 1171, 1184, 416, 1183, 1178, 1181, - 1176, 1166, 1178, 1170, 1161, 1168, 1174, 1173, 1158, 427, - 1167, 1156, 1169, 1154, 0, 1159, 0, 1158, 1156, 0, - 1197, 865, 871, 1145, 0, 1156, 1161, 1145, 0, 0, - 428, 1145, 1148, 573, 1161, 1160, 1159, 1158, 1149, 0, - 1142, 1150, 1142, 1148, 1140, 1134, 1132, 0, 1131, 0, - 1169, 1144, 1142, 1131, 1128, 0, 1125, 0, 574, 0, - - 1125, 485, 895, 1351, 0, 1123, 1123, 1137, 1118, 1117, - 575, 1120, 1122, 1118, 1123, 1126, 1115, 1117, 1113, 1128, - 1123, 1126, 1121, 1111, 1119, 913, 1108, 1117, 1104, 1119, - 1114, 1104, 1098, 1097, 1110, 639, 678, 0, 1095, 1108, - 1107, 1094, 1093, 1104, 1088, 1080, 1103, 1065, 1068, 1053, - 1060, 1031, 999, 996, 997, 1010, 993, 921, 1351, 1008, - 995, 0, 928, 0, 931, 942, 941, 0, 1351, 972, - 966, 924, 923, 922, 918, 917, 916, 914, 924, 904, - 917, 920, 0, 897, 890, 889, 883, 0, 876, 0, - 0, 874, 848, 854, 835, 0, 850, 849, 861, 810, - - 806, 805, 819, 783, 0, 0, 769, 762, 751, 764, - 0, 0, 757, 746, 733, 735, 739, 734, 733, 709, - 707, 743, 594, 709, 702, 0, 692, 691, 680, 681, - 0, 680, 676, 694, 695, 679, 665, 0, 643, 654, - 626, 229, 618, 613, 595, 594, 935, 547, 555, 943, - 541, 463, 462, 0, 0, 0, 0, 0, 0, 461, - 458, 948, 1351, 716, 427, 957, 861, 421, 405, 395, - 0, 0, 405, 392, 891, 387, 363, 347, 356, 0, - 340, 335, 326, 318, 0, 0, 325, 293, 314, 255, - 244, 0, 227, 192, 124, 124, 69, 0, 1351, 980, - - 992, 1004, 1016, 1028, 1040, 1047, 1050, 1057, 1063, 1075, - 1087, 1097, 1104, 1107, 1114, 1122, 1129 + 0, 1358, 70, 71, 85, 159, 89, 90, 99, 100, + 110, 163, 105, 110, 172, 184, 231, 242, 251, 269, + 289, 316, 303, 325, 204, 209, 307, 349, 350, 353, + 427, 1357, 195, 364, 1365, 0, 1368, 1368, 1361, 1368, + 492, 1368, 1368, 1368, 552, 63, 59, 103, 0, 1368, + 73, 1368, 0, 1368, 1351, 1368, 1368, 1315, 1368, 1358, + 1342, 1368, 1368, 1368, 1356, 1368, 622, 73, 1292, 76, + 18, 0, 80, 1293, 1368, 1368, 1353, 1368, 1368, 1342, + 1368, 1368, 1351, 1368, 190, 1368, 1368, 1306, 1336, 104, + 1327, 1368, 1334, 1368, 1287, 1368, 203, 101, 137, 1368, + + 1368, 1368, 185, 1368, 1345, 342, 1368, 1344, 1368, 391, + 1368, 1343, 1368, 0, 1368, 1342, 0, 0, 226, 1368, + 1368, 1297, 1368, 1368, 1340, 1368, 243, 1295, 0, 1368, + 1368, 0, 502, 1296, 1290, 135, 215, 1294, 1291, 1288, + 234, 1295, 283, 1279, 211, 241, 63, 229, 1285, 1292, + 1295, 1368, 0, 0, 1368, 0, 0, 381, 647, 1305, + 1368, 1322, 1284, 1368, 1368, 1368, 1368, 1325, 1368, 154, + 653, 1368, 1368, 1368, 1368, 1368, 1368, 677, 1368, 683, + 1368, 339, 342, 345, 348, 351, 354, 1368, 1368, 1311, + 285, 1302, 1368, 1368, 1368, 508, 1368, 552, 1368, 1368, + + 632, 1368, 641, 1368, 705, 1291, 1321, 1368, 1368, 724, + 1289, 1319, 729, 1368, 0, 0, 0, 734, 1318, 1368, + 1271, 1279, 616, 1265, 1266, 1263, 1264, 158, 1261, 1268, + 1263, 193, 1272, 1257, 1261, 273, 1267, 1252, 1253, 290, + 1252, 1252, 1260, 1261, 1264, 1247, 1253, 1247, 1252, 1243, + 1256, 0, 0, 0, 1368, 1368, 1245, 276, 722, 728, + 758, 451, 461, 511, 750, 357, 1290, 769, 264, 1289, + 778, 364, 1288, 786, 594, 1287, 799, 804, 1286, 809, + 814, 628, 1285, 1250, 1245, 1229, 335, 1229, 1242, 1227, + 1231, 1239, 1238, 1237, 1261, 1221, 1232, 1219, 1257, 1235, + + 1228, 1229, 345, 520, 151, 1216, 1217, 466, 1228, 1217, + 1224, 1208, 1219, 1215, 1208, 1212, 1218, 1217, 1207, 1218, + 1216, 1213, 1368, 802, 808, 1200, 0, 1209, 1195, 1201, + 1196, 1209, 1188, 1193, 1206, 1228, 1203, 1191, 1196, 1184, + 0, 1188, 1183, 1196, 326, 1195, 1190, 1193, 1188, 1178, + 1190, 1182, 1173, 1180, 1186, 1185, 1170, 616, 1179, 1168, + 1181, 1166, 0, 1171, 0, 1170, 1168, 0, 1211, 832, + 838, 1157, 0, 1168, 1173, 1157, 0, 0, 645, 1157, + 1160, 647, 1173, 1172, 1171, 1170, 1161, 0, 1154, 1162, + 1154, 1160, 1152, 1146, 1144, 0, 1143, 0, 1181, 1156, + + 1154, 1143, 1140, 0, 1137, 0, 818, 0, 1137, 680, + 862, 1368, 0, 1135, 1135, 1149, 1130, 1129, 819, 1132, + 1134, 1130, 1135, 1138, 1127, 1129, 1125, 1140, 1135, 1138, + 1133, 1123, 1131, 860, 1120, 1129, 1116, 1131, 1126, 1116, + 1110, 1109, 1122, 887, 820, 0, 1107, 1120, 1119, 1106, + 1105, 1116, 1100, 1101, 1138, 1112, 1115, 1102, 1109, 1093, + 1094, 1091, 1092, 1106, 1091, 892, 1368, 1106, 1093, 0, + 1088, 0, 1091, 1102, 1101, 0, 1368, 1134, 1128, 1084, + 1083, 1083, 1079, 1078, 1077, 1076, 1086, 1072, 1085, 1088, + 0, 1076, 1069, 1080, 1074, 0, 1073, 0, 0, 1062, + + 1042, 1043, 1027, 0, 1040, 1039, 1055, 976, 975, 974, + 987, 984, 0, 0, 976, 969, 904, 917, 0, 0, + 910, 893, 892, 895, 896, 890, 883, 876, 869, 907, + 881, 846, 819, 0, 788, 783, 774, 774, 0, 771, + 767, 852, 889, 775, 745, 0, 733, 744, 735, 418, + 719, 711, 692, 691, 907, 689, 668, 916, 654, 618, + 620, 0, 0, 0, 0, 0, 0, 616, 614, 924, + 1368, 898, 601, 933, 940, 597, 595, 586, 0, 0, + 597, 580, 948, 573, 572, 530, 533, 0, 531, 527, + 518, 471, 0, 0, 383, 348, 370, 311, 281, 0, + + 292, 228, 157, 92, 53, 0, 1368, 958, 970, 982, + 994, 1006, 1018, 1025, 1028, 1035, 1041, 1053, 1065, 1075, + 1082, 1085, 1092, 1100, 1107 } ; -static const flex_int16_t yy_def[618] = +static const flex_int16_t yy_def[626] = { 0, - 599, 1, 600, 600, 601, 601, 6, 6, 602, 602, - 603, 603, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 599, 29, - 604, 604, 599, 605, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 606, 606, 605, 599, 599, 599, - 607, 599, 599, 599, 605, 599, 599, 599, 599, 599, - 599, 599, 599, 608, 599, 599, 599, 599, 609, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 610, 610, 599, 599, 610, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - - 599, 599, 599, 599, 611, 599, 599, 599, 612, 599, - 599, 612, 613, 599, 599, 599, 612, 599, 599, 599, - 599, 599, 599, 605, 599, 599, 614, 599, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 599, 43, 607, 599, - 615, 616, 606, 616, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 610, 610, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - - 599, 599, 599, 599, 599, 599, 599, 612, 613, 614, - 599, 599, 599, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 615, 616, 154, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 611, 599, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 599, 599, 599, 599, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 599, 599, 599, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - - 614, 599, 599, 599, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 599, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 599, 599, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 599, 599, - 599, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 617, 614, - - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 617, 617, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 617, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 599, 599, 614, 614, 599, 599, 614, 614, 614, - 614, 614, 614, 614, 599, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 614, 614, - 614, 614, 614, 614, 614, 614, 614, 614, 0, 599, - - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599 + 607, 1, 608, 608, 609, 609, 6, 6, 6, 6, + 610, 610, 611, 611, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 607, 31, 612, 612, 607, 613, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 614, 614, 613, 607, + 607, 607, 615, 607, 615, 607, 607, 613, 607, 607, + 607, 607, 607, 607, 607, 607, 616, 607, 607, 607, + 607, 617, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 618, 618, + 607, 607, 618, 607, 607, 607, 607, 607, 607, 607, + + 607, 607, 607, 607, 607, 607, 607, 607, 607, 619, + 607, 607, 607, 620, 607, 607, 620, 621, 607, 607, + 607, 620, 607, 607, 607, 607, 607, 607, 613, 607, + 607, 622, 607, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 607, 45, 615, 607, 623, 624, 614, 624, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 618, + 618, 607, 607, 607, 607, 607, 607, 607, 607, 607, + + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 620, 621, 622, 607, 607, 607, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 623, 624, 159, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 619, 607, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 607, 607, 607, 607, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 607, 607, + 607, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + + 622, 622, 622, 622, 622, 622, 622, 622, 622, 607, + 607, 607, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 607, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 607, 607, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 607, 607, 607, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + + 622, 622, 622, 622, 622, 622, 625, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 625, + 625, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 625, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 607, + 607, 622, 622, 607, 607, 622, 622, 622, 622, 622, + 622, 622, 607, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + + 622, 622, 622, 622, 622, 622, 0, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607 } ; -static const flex_int16_t yy_nxt[1424] = +static const flex_int16_t yy_nxt[1443] = { 0, - 34, 35, 36, 35, 37, 35, 34, 38, 34, 39, - 40, 41, 42, 34, 43, 44, 45, 46, 46, 47, - 48, 49, 50, 41, 34, 34, 51, 51, 51, 51, - 52, 34, 34, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 53, 54, 41, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 57, 57, 150, 153, 153, 153, 151, 58, - 58, 59, 155, 61, 59, 62, 150, 73, 63, 74, - 151, 73, 60, 74, 156, 75, 60, 178, 178, 75, - - 77, 36, 77, 78, 77, 285, 77, 36, 77, 78, - 77, 79, 64, 83, 80, 85, 286, 79, 81, 598, - 80, 184, 85, 86, 81, 87, 175, 175, 175, 82, - 86, 183, 87, 250, 250, 82, 177, 177, 177, 315, - 315, 59, 59, 59, 59, 65, 66, 67, 68, 69, - 70, 71, 72, 59, 187, 61, 59, 62, 188, 59, - 63, 60, 597, 59, 89, 60, 90, 91, 89, 195, - 90, 91, 92, 88, 189, 596, 92, 180, 180, 180, - 88, 59, 190, 60, 64, 196, 89, 150, 60, 91, - 191, 151, 60, 338, 92, 216, 59, 59, 60, 60, - - 339, 89, 60, 150, 91, 217, 98, 151, 235, 92, - 60, 232, 236, 59, 59, 59, 59, 65, 66, 67, - 68, 69, 70, 71, 72, 60, 60, 233, 59, 218, - 234, 469, 59, 59, 219, 60, 523, 184, 89, 220, - 93, 91, 595, 99, 237, 100, 92, 183, 60, 59, - 59, 60, 94, 238, 60, 99, 342, 100, 98, 343, - 60, 594, 60, 278, 192, 59, 59, 279, 102, 102, - 103, 103, 101, 104, 104, 106, 193, 107, 60, 280, - 60, 301, 340, 108, 101, 302, 194, 224, 95, 341, - 96, 225, 593, 290, 153, 153, 153, 105, 105, 195, - - 226, 228, 59, 59, 105, 60, 592, 154, 89, 291, - 93, 91, 59, 346, 229, 196, 92, 190, 59, 230, - 321, 106, 94, 107, 59, 191, 60, 591, 322, 108, - 347, 590, 60, 154, 153, 153, 153, 59, 59, 198, - 199, 198, 200, 198, 59, 119, 36, 119, 120, 119, - 105, 211, 211, 211, 212, 211, 121, 192, 95, 122, - 96, 589, 588, 119, 36, 119, 120, 119, 587, 193, - 123, 586, 59, 59, 121, 60, 585, 122, 89, 194, - 93, 91, 239, 175, 175, 175, 92, 175, 175, 175, - 59, 240, 94, 203, 204, 203, 205, 203, 584, 583, - - 241, 582, 60, 175, 175, 175, 295, 213, 254, 254, - 254, 255, 255, 255, 247, 247, 247, 256, 256, 256, - 175, 175, 175, 206, 247, 581, 296, 187, 95, 381, - 97, 188, 247, 247, 247, 247, 247, 247, 580, 297, - 394, 409, 59, 59, 579, 60, 578, 189, 89, 381, - 93, 91, 175, 175, 175, 577, 92, 251, 251, 251, - 394, 410, 94, 252, 252, 252, 599, 251, 175, 175, - 175, 576, 60, 252, 574, 251, 251, 251, 251, 251, - 251, 252, 252, 252, 252, 252, 252, 253, 253, 253, - 257, 258, 257, 259, 257, 206, 572, 253, 95, 571, - - 97, 436, 436, 436, 570, 253, 253, 253, 253, 253, - 253, 569, 59, 109, 110, 36, 110, 111, 110, 109, - 109, 109, 109, 109, 109, 112, 109, 113, 114, 115, - 115, 115, 109, 109, 109, 109, 109, 109, 109, 113, - 113, 113, 113, 109, 109, 116, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 126, 413, 433, 442, 568, - 127, 260, 261, 260, 262, 260, 469, 565, 542, 564, - - 128, 523, 127, 127, 127, 127, 413, 434, 443, 127, - 127, 129, 130, 131, 132, 133, 134, 127, 135, 127, - 136, 137, 138, 139, 140, 127, 141, 142, 143, 144, - 145, 127, 146, 147, 124, 263, 264, 263, 265, 263, - 124, 469, 124, 470, 471, 561, 560, 148, 148, 559, - 149, 149, 149, 124, 558, 436, 436, 436, 124, 124, - 149, 149, 149, 149, 557, 124, 124, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 472, 556, 555, 124, 124, 124, 124, 124, 124, - - 124, 124, 124, 124, 124, 124, 162, 551, 552, 163, - 554, 473, 163, 266, 267, 266, 268, 266, 164, 164, - 198, 199, 198, 200, 198, 553, 163, 552, 552, 573, - 165, 550, 549, 163, 548, 547, 166, 167, 546, 545, - 544, 168, 270, 204, 270, 271, 270, 543, 169, 573, - 523, 541, 170, 540, 171, 172, 173, 174, 273, 274, - 273, 275, 273, 211, 211, 211, 212, 211, 316, 316, - 316, 539, 538, 537, 317, 317, 317, 536, 316, 257, - 258, 257, 259, 257, 317, 535, 316, 316, 316, 316, - 316, 316, 317, 317, 317, 317, 317, 317, 534, 533, - - 532, 531, 253, 253, 253, 260, 261, 260, 262, 260, - 530, 529, 253, 263, 264, 263, 265, 263, 528, 213, - 253, 253, 253, 253, 253, 253, 266, 267, 266, 268, - 266, 198, 199, 198, 200, 198, 270, 204, 270, 271, - 270, 270, 204, 270, 271, 270, 273, 274, 273, 275, - 273, 362, 362, 362, 527, 526, 525, 363, 363, 363, - 524, 362, 575, 575, 575, 575, 575, 363, 523, 362, - 362, 362, 362, 362, 362, 363, 363, 363, 363, 363, - 363, 403, 403, 403, 521, 520, 519, 404, 404, 404, - 518, 403, 575, 575, 575, 575, 575, 404, 517, 403, - - 403, 403, 403, 403, 403, 404, 404, 404, 404, 404, - 404, 252, 252, 252, 458, 458, 458, 458, 458, 516, - 515, 252, 458, 458, 458, 458, 458, 514, 513, 252, - 252, 252, 252, 252, 252, 459, 562, 562, 562, 562, - 562, 512, 511, 459, 566, 566, 566, 566, 566, 562, - 562, 562, 562, 562, 510, 509, 508, 563, 566, 566, - 566, 566, 566, 507, 506, 567, 505, 504, 503, 502, - 563, 501, 500, 499, 469, 498, 497, 496, 495, 567, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 60, 60, 60, 60, 60, 60, 60, 60, - - 60, 60, 60, 60, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 118, 118, + 36, 37, 38, 37, 39, 37, 36, 40, 36, 41, + 42, 36, 36, 43, 44, 36, 45, 46, 47, 48, + 48, 49, 50, 51, 52, 43, 36, 36, 53, 53, + 53, 53, 54, 36, 36, 55, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 56, + 57, 43, 36, 36, 36, 36, 36, 36, 36, 36, + 36, 36, 36, 36, 60, 60, 155, 158, 158, 158, + 156, 184, 184, 61, 61, 62, 160, 64, 62, 65, + 159, 76, 76, 77, 77, 66, 78, 78, 161, 63, + + 63, 79, 79, 63, 63, 606, 80, 80, 244, 63, + 63, 82, 38, 82, 83, 82, 159, 245, 67, 191, + 90, 158, 158, 158, 84, 90, 197, 85, 91, 190, + 92, 86, 605, 91, 198, 92, 181, 181, 181, 183, + 183, 183, 87, 186, 186, 186, 199, 62, 62, 62, + 62, 68, 69, 70, 71, 72, 73, 74, 75, 62, + 200, 64, 62, 65, 82, 38, 82, 83, 82, 66, + 201, 88, 258, 258, 62, 223, 63, 84, 93, 94, + 85, 95, 96, 93, 86, 224, 62, 350, 63, 97, + 351, 94, 67, 95, 96, 87, 124, 38, 124, 125, + + 124, 97, 202, 155, 293, 63, 104, 156, 105, 126, + 604, 104, 127, 105, 63, 294, 194, 63, 203, 63, + 195, 62, 62, 62, 62, 68, 69, 70, 71, 72, + 73, 74, 75, 62, 298, 63, 196, 106, 94, 155, + 98, 96, 106, 156, 62, 62, 63, 239, 97, 94, + 299, 98, 96, 62, 99, 63, 155, 62, 94, 97, + 156, 96, 225, 240, 63, 99, 241, 226, 97, 246, + 231, 62, 227, 63, 232, 63, 94, 62, 247, 96, + 603, 242, 62, 233, 63, 243, 97, 248, 303, 197, + 100, 62, 101, 63, 323, 323, 94, 198, 98, 96, + + 191, 100, 63, 101, 62, 62, 97, 63, 304, 107, + 190, 108, 99, 63, 109, 62, 103, 63, 62, 235, + 63, 305, 63, 94, 62, 98, 96, 62, 602, 63, + 309, 601, 236, 97, 310, 63, 63, 237, 103, 99, + 110, 389, 62, 205, 206, 205, 207, 205, 100, 63, + 102, 107, 111, 108, 112, 111, 109, 112, 63, 63, + 113, 389, 62, 113, 600, 124, 38, 124, 125, 124, + 194, 329, 128, 199, 195, 100, 62, 102, 126, 330, + 62, 127, 110, 110, 346, 599, 110, 200, 598, 62, + 196, 347, 210, 211, 210, 212, 210, 201, 62, 158, + + 158, 158, 181, 181, 181, 181, 181, 181, 181, 181, + 181, 262, 262, 262, 263, 263, 263, 264, 264, 264, + 477, 597, 62, 62, 213, 531, 62, 114, 115, 38, + 115, 116, 115, 114, 114, 114, 114, 114, 114, 114, + 114, 117, 114, 118, 119, 120, 120, 120, 114, 114, + 114, 114, 114, 114, 114, 118, 118, 118, 118, 114, + 114, 121, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 124, 494, 493, 492, 124, 124, 491, 124, 490, 489, - 488, 124, 152, 152, 149, 149, 149, 161, 161, 161, - 161, 161, 161, 161, 161, 161, 161, 161, 161, 179, - 179, 179, 179, 179, 179, 183, 183, 183, 183, 183, - 183, 183, 183, 183, 487, 183, 183, 202, 202, 202, - 202, 202, 202, 202, 202, 202, 202, 208, 486, 485, - - 208, 208, 484, 483, 208, 208, 208, 208, 209, 209, - 209, 210, 210, 210, 245, 245, 482, 245, 245, 245, - 245, 245, 245, 245, 245, 245, 246, 246, 246, 522, - 522, 481, 522, 522, 522, 522, 522, 522, 522, 522, - 522, 480, 479, 478, 477, 476, 475, 474, 468, 467, - 466, 465, 464, 463, 462, 461, 460, 457, 456, 455, - 454, 453, 452, 451, 450, 449, 448, 447, 446, 445, - 444, 441, 440, 439, 438, 437, 435, 432, 431, 430, - 429, 428, 427, 426, 425, 424, 423, 422, 421, 420, - 419, 418, 417, 416, 415, 414, 412, 411, 408, 407, - - 406, 405, 402, 401, 400, 399, 398, 397, 396, 395, - 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, - 383, 382, 380, 379, 378, 377, 376, 375, 374, 373, - 372, 371, 370, 369, 368, 367, 366, 365, 364, 361, - 360, 359, 358, 357, 356, 355, 354, 353, 352, 351, - 350, 349, 348, 345, 344, 337, 336, 335, 334, 333, - 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, - 320, 319, 318, 274, 204, 267, 264, 261, 258, 314, - 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, - 303, 300, 299, 298, 294, 293, 292, 289, 288, 287, - - 284, 283, 282, 281, 277, 276, 211, 204, 272, 199, - 269, 185, 184, 161, 249, 248, 244, 243, 242, 231, - 227, 223, 222, 221, 215, 214, 157, 125, 157, 125, - 207, 201, 197, 186, 184, 185, 184, 157, 125, 182, - 181, 176, 160, 159, 158, 157, 125, 599, 117, 55, - 33, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599 + 118, 118, 118, 118, 118, 118, 114, 114, 114, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + + 114, 131, 354, 218, 218, 218, 219, 218, 132, 265, + 266, 265, 267, 265, 181, 181, 181, 596, 133, 355, + 132, 132, 132, 132, 181, 181, 181, 132, 132, 134, + 135, 136, 137, 138, 139, 132, 140, 132, 141, 142, + 143, 144, 145, 132, 146, 147, 148, 149, 150, 132, + 151, 152, 129, 268, 269, 268, 270, 268, 129, 348, + 129, 220, 595, 129, 129, 594, 349, 153, 153, 593, + 154, 154, 154, 129, 181, 181, 181, 592, 129, 129, + 154, 154, 154, 154, 591, 129, 129, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 202, 590, 589, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 168, 203, 588, 169, + 607, 402, 169, 271, 272, 271, 273, 271, 587, 586, + 170, 170, 274, 275, 274, 276, 274, 585, 169, 584, + 582, 402, 171, 286, 580, 169, 579, 287, 172, 173, + 417, 213, 421, 174, 578, 254, 254, 254, 577, 288, + 175, 259, 259, 259, 176, 254, 177, 178, 179, 180, + 418, 259, 421, 254, 254, 254, 254, 254, 254, 259, + 259, 259, 259, 259, 259, 260, 260, 260, 444, 444, + + 444, 261, 261, 261, 576, 260, 205, 206, 205, 207, + 205, 261, 573, 260, 260, 260, 260, 260, 260, 261, + 261, 261, 261, 261, 261, 278, 211, 278, 279, 278, + 281, 282, 281, 283, 281, 218, 218, 218, 219, 218, + 324, 324, 324, 572, 569, 568, 325, 325, 325, 567, + 324, 265, 266, 265, 267, 265, 325, 566, 324, 324, + 324, 324, 324, 324, 325, 325, 325, 325, 325, 325, + 268, 269, 268, 270, 268, 565, 261, 261, 261, 271, + 272, 271, 273, 271, 564, 563, 261, 274, 275, 274, + 276, 274, 562, 220, 261, 261, 261, 261, 261, 261, + + 205, 206, 205, 207, 205, 278, 211, 278, 279, 278, + 278, 211, 278, 279, 278, 281, 282, 281, 283, 281, + 370, 370, 370, 561, 558, 557, 371, 371, 371, 556, + 370, 555, 554, 441, 450, 480, 371, 553, 370, 370, + 370, 370, 370, 370, 371, 371, 371, 371, 371, 371, + 411, 411, 411, 442, 451, 481, 412, 412, 412, 552, + 411, 466, 466, 466, 466, 466, 412, 559, 411, 411, + 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, + 260, 260, 260, 477, 467, 550, 551, 560, 531, 477, + 260, 478, 479, 466, 466, 466, 466, 466, 260, 260, + + 260, 260, 260, 260, 560, 444, 444, 444, 570, 570, + 570, 570, 570, 581, 531, 549, 467, 574, 574, 574, + 574, 574, 548, 547, 560, 570, 570, 570, 570, 570, + 546, 571, 545, 581, 574, 574, 574, 574, 574, 544, + 575, 583, 583, 583, 583, 583, 543, 542, 571, 583, + 583, 583, 583, 583, 541, 540, 539, 575, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 89, 89, 89, 89, 89, 89, + + 89, 89, 89, 89, 89, 89, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 129, 538, + 537, 536, 129, 129, 535, 129, 534, 533, 532, 129, + 157, 157, 154, 154, 154, 167, 167, 167, 167, 167, + 167, 167, 167, 167, 167, 167, 167, 185, 185, 185, + 185, 185, 185, 190, 190, 190, 190, 190, 190, 190, + 190, 190, 531, 190, 190, 209, 209, 209, 209, 209, + 209, 209, 209, 209, 209, 215, 529, 528, 215, 215, + 527, 526, 215, 215, 215, 215, 216, 216, 216, 217, + 217, 217, 252, 252, 525, 252, 252, 252, 252, 252, + + 252, 252, 252, 252, 253, 253, 253, 530, 530, 524, + 530, 530, 530, 530, 530, 530, 530, 530, 530, 523, + 522, 521, 520, 519, 518, 517, 516, 515, 514, 513, + 512, 511, 510, 509, 508, 507, 477, 506, 505, 504, + 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, + 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, + 483, 482, 476, 475, 474, 473, 472, 471, 470, 469, + 468, 465, 464, 463, 462, 461, 460, 459, 458, 457, + 456, 455, 454, 453, 452, 449, 448, 447, 446, 445, + 443, 440, 439, 438, 437, 436, 435, 434, 433, 432, + + 431, 430, 429, 428, 427, 426, 425, 424, 423, 422, + 420, 419, 416, 415, 414, 413, 410, 409, 408, 407, + 406, 405, 404, 403, 401, 400, 399, 398, 397, 396, + 395, 394, 393, 392, 391, 390, 388, 387, 386, 385, + 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, + 374, 373, 372, 369, 368, 367, 366, 365, 364, 363, + 362, 361, 360, 359, 358, 357, 356, 353, 352, 345, + 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, + 334, 333, 332, 331, 328, 327, 326, 282, 211, 275, + 272, 269, 266, 322, 321, 320, 319, 318, 317, 316, + + 315, 314, 313, 312, 311, 308, 307, 306, 302, 301, + 300, 297, 296, 295, 292, 291, 290, 289, 285, 284, + 218, 211, 280, 206, 277, 192, 191, 167, 257, 256, + 255, 251, 250, 249, 238, 234, 230, 229, 228, 222, + 221, 163, 130, 163, 130, 214, 208, 204, 193, 191, + 192, 191, 163, 130, 189, 188, 187, 182, 166, 165, + 164, 163, 162, 130, 607, 122, 58, 35, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607 } ; -static const flex_int16_t yy_chk[1424] = +static const flex_int16_t yy_chk[1443] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1128,156 +1133,158 @@ static const flex_int16_t yy_chk[1424] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 4, 44, 46, 46, 46, 44, 3, - 4, 5, 49, 5, 5, 5, 80, 7, 5, 7, - 80, 8, 7, 8, 49, 7, 8, 68, 68, 8, - - 9, 9, 9, 9, 9, 221, 10, 10, 10, 10, - 10, 9, 5, 10, 9, 11, 221, 10, 9, 597, - 10, 85, 12, 11, 10, 11, 65, 65, 65, 9, - 12, 85, 12, 164, 164, 10, 67, 67, 67, 250, - 250, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 6, 92, 6, 6, 6, 92, 13, - 6, 13, 596, 14, 13, 14, 13, 13, 14, 98, - 14, 14, 13, 11, 92, 595, 14, 70, 70, 70, - 12, 17, 93, 17, 6, 98, 17, 114, 13, 17, - 93, 114, 14, 295, 17, 131, 18, 21, 18, 21, - - 295, 18, 21, 122, 18, 131, 21, 122, 141, 18, - 17, 140, 141, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 18, 21, 140, 13, 132, - 140, 542, 14, 15, 132, 15, 542, 184, 15, 132, - 15, 15, 594, 23, 142, 23, 15, 184, 23, 22, - 17, 22, 15, 142, 22, 24, 297, 24, 22, 297, - 24, 593, 15, 216, 94, 18, 21, 216, 25, 26, - 25, 26, 23, 25, 26, 27, 94, 27, 22, 216, - 27, 233, 296, 27, 24, 233, 94, 136, 15, 296, - 15, 136, 591, 225, 45, 45, 45, 25, 26, 267, - - 136, 138, 15, 16, 27, 16, 590, 45, 16, 225, - 16, 16, 23, 300, 138, 267, 16, 261, 22, 138, - 279, 28, 16, 28, 24, 261, 28, 589, 279, 28, - 300, 588, 16, 45, 153, 153, 153, 25, 26, 101, - 101, 101, 101, 101, 27, 31, 31, 31, 31, 31, - 28, 128, 128, 128, 128, 128, 31, 264, 16, 31, - 16, 587, 584, 32, 32, 32, 32, 32, 583, 264, - 32, 582, 16, 19, 32, 19, 581, 32, 19, 264, - 19, 19, 143, 176, 176, 176, 19, 177, 177, 177, - 28, 143, 19, 105, 105, 105, 105, 105, 579, 578, - - 143, 577, 19, 178, 178, 178, 229, 128, 179, 179, - 179, 180, 180, 180, 154, 154, 154, 181, 181, 181, - 254, 254, 254, 105, 154, 576, 229, 258, 19, 337, - 19, 258, 154, 154, 154, 154, 154, 154, 574, 229, - 350, 371, 19, 20, 573, 20, 570, 258, 20, 337, - 20, 20, 255, 255, 255, 569, 20, 165, 165, 165, - 350, 371, 20, 172, 172, 172, 274, 165, 256, 256, - 256, 568, 20, 172, 565, 165, 165, 165, 165, 165, - 165, 172, 172, 172, 172, 172, 172, 174, 174, 174, - 189, 189, 189, 189, 189, 274, 561, 174, 20, 560, - - 20, 402, 402, 402, 553, 174, 174, 174, 174, 174, - 174, 552, 20, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 39, 374, 399, 411, 551, - 39, 191, 191, 191, 191, 191, 523, 549, 523, 548, - - 39, 523, 39, 39, 39, 39, 374, 399, 411, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 43, 194, 194, 194, 194, 194, - 43, 436, 43, 436, 436, 546, 545, 43, 43, 544, - 43, 43, 43, 43, 543, 436, 436, 436, 43, 43, - 43, 43, 43, 43, 541, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 437, 540, 539, 43, 43, 43, 43, 43, 43, - - 43, 43, 43, 43, 43, 43, 64, 534, 535, 64, - 537, 437, 64, 196, 196, 196, 196, 196, 64, 64, - 198, 198, 198, 198, 198, 536, 64, 534, 535, 564, - 64, 533, 532, 64, 530, 529, 64, 64, 528, 527, - 525, 64, 203, 203, 203, 203, 203, 524, 64, 564, - 522, 521, 64, 520, 64, 64, 64, 64, 206, 206, - 206, 206, 206, 211, 211, 211, 211, 211, 251, 251, - 251, 519, 518, 517, 252, 252, 252, 516, 251, 257, - 257, 257, 257, 257, 252, 515, 251, 251, 251, 251, - 251, 251, 252, 252, 252, 252, 252, 252, 514, 513, - - 510, 509, 253, 253, 253, 260, 260, 260, 260, 260, - 508, 507, 253, 263, 263, 263, 263, 263, 504, 211, - 253, 253, 253, 253, 253, 253, 266, 266, 266, 266, - 266, 269, 269, 269, 269, 269, 270, 270, 270, 270, - 270, 272, 272, 272, 272, 272, 273, 273, 273, 273, - 273, 316, 316, 316, 503, 502, 501, 317, 317, 317, - 500, 316, 567, 567, 567, 567, 567, 317, 499, 316, - 316, 316, 316, 316, 316, 317, 317, 317, 317, 317, - 317, 362, 362, 362, 498, 497, 495, 363, 363, 363, - 494, 362, 575, 575, 575, 575, 575, 363, 493, 362, - - 362, 362, 362, 362, 362, 363, 363, 363, 363, 363, - 363, 403, 403, 403, 426, 426, 426, 426, 426, 492, - 489, 403, 458, 458, 458, 458, 458, 487, 486, 403, - 403, 403, 403, 403, 403, 426, 547, 547, 547, 547, - 547, 485, 484, 458, 550, 550, 550, 550, 550, 562, - 562, 562, 562, 562, 482, 481, 480, 547, 566, 566, - 566, 566, 566, 479, 478, 550, 477, 476, 475, 474, - 562, 473, 472, 471, 470, 467, 466, 465, 463, 566, - 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, - 600, 600, 601, 601, 601, 601, 601, 601, 601, 601, - - 601, 601, 601, 601, 602, 602, 602, 602, 602, 602, - 602, 602, 602, 602, 602, 602, 603, 603, 603, 603, - 603, 603, 603, 603, 603, 603, 603, 603, 604, 604, - 604, 604, 604, 604, 604, 604, 604, 604, 604, 604, - 605, 461, 460, 457, 605, 605, 456, 605, 455, 454, - 453, 605, 606, 606, 607, 607, 607, 608, 608, 608, - 608, 608, 608, 608, 608, 608, 608, 608, 608, 609, - 609, 609, 609, 609, 609, 610, 610, 610, 610, 610, - 610, 610, 610, 610, 452, 610, 610, 611, 611, 611, - 611, 611, 611, 611, 611, 611, 611, 612, 451, 450, - - 612, 612, 449, 448, 612, 612, 612, 612, 613, 613, - 613, 614, 614, 614, 615, 615, 447, 615, 615, 615, - 615, 615, 615, 615, 615, 615, 616, 616, 616, 617, - 617, 446, 617, 617, 617, 617, 617, 617, 617, 617, - 617, 445, 444, 443, 442, 441, 440, 439, 435, 434, - 433, 432, 431, 430, 429, 428, 427, 425, 424, 423, - 422, 421, 420, 419, 418, 417, 416, 415, 414, 413, - 412, 410, 409, 408, 407, 406, 401, 397, 395, 394, - 393, 392, 391, 389, 387, 386, 385, 384, 383, 382, - 381, 379, 378, 377, 376, 375, 373, 372, 368, 367, - - 366, 364, 361, 359, 358, 356, 354, 353, 352, 351, - 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, - 339, 338, 336, 335, 334, 332, 331, 330, 329, 328, - 327, 326, 325, 324, 323, 322, 321, 320, 318, 314, - 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, - 303, 302, 301, 299, 298, 294, 293, 292, 291, 290, - 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, - 278, 277, 276, 275, 271, 268, 265, 262, 259, 249, - 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, - 234, 232, 231, 230, 228, 227, 226, 224, 223, 222, - - 220, 219, 218, 217, 215, 214, 212, 205, 204, 200, - 199, 185, 183, 162, 157, 155, 146, 145, 144, 139, - 137, 135, 134, 133, 130, 129, 123, 120, 117, 111, - 107, 103, 100, 90, 88, 86, 84, 83, 78, 74, - 71, 66, 62, 58, 57, 55, 37, 33, 30, 2, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599 + 1, 1, 1, 1, 3, 4, 46, 47, 47, 47, + 46, 71, 71, 3, 4, 5, 51, 5, 5, 5, + 47, 7, 8, 7, 8, 5, 7, 8, 51, 7, + + 8, 9, 10, 9, 10, 605, 9, 10, 147, 9, + 10, 11, 11, 11, 11, 11, 47, 147, 5, 90, + 13, 48, 48, 48, 11, 14, 98, 11, 13, 90, + 13, 11, 604, 14, 98, 14, 68, 68, 68, 70, + 70, 70, 11, 73, 73, 73, 99, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, + 99, 6, 6, 6, 12, 12, 12, 12, 12, 6, + 99, 12, 170, 170, 15, 136, 15, 12, 13, 15, + 12, 15, 15, 14, 12, 136, 16, 305, 16, 15, + 305, 16, 6, 16, 16, 12, 33, 33, 33, 33, + + 33, 16, 103, 85, 228, 15, 25, 85, 25, 33, + 603, 26, 33, 26, 25, 228, 97, 16, 103, 26, + 97, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 17, 232, 17, 97, 25, 17, 119, + 17, 17, 26, 119, 18, 15, 18, 145, 17, 18, + 232, 18, 18, 19, 17, 19, 127, 16, 19, 18, + 127, 19, 137, 145, 17, 18, 145, 137, 19, 148, + 141, 20, 137, 20, 141, 18, 20, 25, 148, 20, + 602, 146, 26, 141, 19, 146, 20, 148, 236, 269, + 17, 21, 17, 21, 258, 258, 21, 269, 21, 21, + + 191, 18, 20, 18, 17, 23, 21, 23, 236, 27, + 191, 27, 21, 23, 27, 18, 23, 27, 22, 143, + 22, 236, 21, 22, 19, 22, 22, 24, 601, 24, + 240, 599, 143, 22, 240, 24, 23, 143, 24, 22, + 27, 345, 20, 106, 106, 106, 106, 106, 21, 22, + 21, 28, 29, 28, 29, 30, 28, 30, 24, 28, + 29, 345, 21, 30, 598, 34, 34, 34, 34, 34, + 266, 287, 34, 272, 266, 22, 23, 22, 34, 287, + 27, 34, 28, 29, 303, 597, 30, 272, 596, 22, + 266, 303, 110, 110, 110, 110, 110, 272, 24, 158, + + 158, 158, 182, 182, 182, 183, 183, 183, 184, 184, + 184, 185, 185, 185, 186, 186, 186, 187, 187, 187, + 550, 595, 28, 29, 110, 550, 30, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + + 31, 41, 308, 133, 133, 133, 133, 133, 41, 196, + 196, 196, 196, 196, 262, 262, 262, 592, 41, 308, + 41, 41, 41, 41, 263, 263, 263, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 45, 198, 198, 198, 198, 198, 45, 304, + 45, 133, 591, 45, 45, 590, 304, 45, 45, 589, + 45, 45, 45, 45, 264, 264, 264, 587, 45, 45, + 45, 45, 45, 45, 586, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 275, 585, 584, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 67, 275, 582, 67, + 282, 358, 67, 201, 201, 201, 201, 201, 581, 578, + 67, 67, 203, 203, 203, 203, 203, 577, 67, 576, + 573, 358, 67, 223, 569, 67, 568, 223, 67, 67, + 379, 282, 382, 67, 561, 159, 159, 159, 560, 223, + 67, 171, 171, 171, 67, 159, 67, 67, 67, 67, + 379, 171, 382, 159, 159, 159, 159, 159, 159, 171, + 171, 171, 171, 171, 171, 178, 178, 178, 410, 410, + + 410, 180, 180, 180, 559, 178, 205, 205, 205, 205, + 205, 180, 557, 178, 178, 178, 178, 178, 178, 180, + 180, 180, 180, 180, 180, 210, 210, 210, 210, 210, + 213, 213, 213, 213, 213, 218, 218, 218, 218, 218, + 259, 259, 259, 556, 554, 553, 260, 260, 260, 552, + 259, 265, 265, 265, 265, 265, 260, 551, 259, 259, + 259, 259, 259, 259, 260, 260, 260, 260, 260, 260, + 268, 268, 268, 268, 268, 549, 261, 261, 261, 271, + 271, 271, 271, 271, 548, 547, 261, 274, 274, 274, + 274, 274, 545, 218, 261, 261, 261, 261, 261, 261, + + 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, + 280, 280, 280, 280, 280, 281, 281, 281, 281, 281, + 324, 324, 324, 544, 541, 540, 325, 325, 325, 538, + 324, 537, 536, 407, 419, 445, 325, 535, 324, 324, + 324, 324, 324, 324, 325, 325, 325, 325, 325, 325, + 370, 370, 370, 407, 419, 445, 371, 371, 371, 533, + 370, 434, 434, 434, 434, 434, 371, 542, 370, 370, + 370, 370, 370, 370, 371, 371, 371, 371, 371, 371, + 411, 411, 411, 531, 434, 531, 532, 542, 531, 444, + 411, 444, 444, 466, 466, 466, 466, 466, 411, 411, + + 411, 411, 411, 411, 543, 444, 444, 444, 555, 555, + 555, 555, 555, 572, 530, 529, 466, 558, 558, 558, + 558, 558, 528, 527, 543, 570, 570, 570, 570, 570, + 526, 555, 525, 572, 574, 574, 574, 574, 574, 524, + 558, 575, 575, 575, 575, 575, 523, 522, 570, 583, + 583, 583, 583, 583, 521, 518, 517, 574, 608, 608, + 608, 608, 608, 608, 608, 608, 608, 608, 608, 608, + 609, 609, 609, 609, 609, 609, 609, 609, 609, 609, + 609, 609, 610, 610, 610, 610, 610, 610, 610, 610, + 610, 610, 610, 610, 611, 611, 611, 611, 611, 611, + + 611, 611, 611, 611, 611, 611, 612, 612, 612, 612, + 612, 612, 612, 612, 612, 612, 612, 612, 613, 516, + 515, 512, 613, 613, 511, 613, 510, 509, 508, 613, + 614, 614, 615, 615, 615, 616, 616, 616, 616, 616, + 616, 616, 616, 616, 616, 616, 616, 617, 617, 617, + 617, 617, 617, 618, 618, 618, 618, 618, 618, 618, + 618, 618, 507, 618, 618, 619, 619, 619, 619, 619, + 619, 619, 619, 619, 619, 620, 506, 505, 620, 620, + 503, 502, 620, 620, 620, 620, 621, 621, 621, 622, + 622, 622, 623, 623, 501, 623, 623, 623, 623, 623, + + 623, 623, 623, 623, 624, 624, 624, 625, 625, 500, + 625, 625, 625, 625, 625, 625, 625, 625, 625, 497, + 495, 494, 493, 492, 490, 489, 488, 487, 486, 485, + 484, 483, 482, 481, 480, 479, 478, 475, 474, 473, + 471, 469, 468, 465, 464, 463, 462, 461, 460, 459, + 458, 457, 456, 455, 454, 453, 452, 451, 450, 449, + 448, 447, 443, 442, 441, 440, 439, 438, 437, 436, + 435, 433, 432, 431, 430, 429, 428, 427, 426, 425, + 424, 423, 422, 421, 420, 418, 417, 416, 415, 414, + 409, 405, 403, 402, 401, 400, 399, 397, 395, 394, + + 393, 392, 391, 390, 389, 387, 386, 385, 384, 383, + 381, 380, 376, 375, 374, 372, 369, 367, 366, 364, + 362, 361, 360, 359, 357, 356, 355, 354, 353, 352, + 351, 350, 349, 348, 347, 346, 344, 343, 342, 340, + 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, + 329, 328, 326, 322, 321, 320, 319, 318, 317, 316, + 315, 314, 313, 312, 311, 310, 309, 307, 306, 302, + 301, 300, 299, 298, 297, 296, 295, 294, 293, 292, + 291, 290, 289, 288, 286, 285, 284, 283, 279, 276, + 273, 270, 267, 257, 251, 250, 249, 248, 247, 246, + + 245, 244, 243, 242, 241, 239, 238, 237, 235, 234, + 233, 231, 230, 229, 227, 226, 225, 224, 222, 221, + 219, 212, 211, 207, 206, 192, 190, 168, 163, 162, + 160, 151, 150, 149, 144, 142, 140, 139, 138, 135, + 134, 128, 125, 122, 116, 112, 108, 105, 95, 93, + 91, 89, 88, 83, 80, 77, 74, 69, 65, 61, + 60, 58, 55, 39, 35, 32, 2, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 607 } ; static yy_state_type yy_last_accepting_state; @@ -1286,22 +1293,22 @@ static char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 1; -static const flex_int16_t yy_rule_linenum[127] = +static const flex_int16_t yy_rule_linenum[130] = { 0, - 198, 201, 202, 203, 209, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, - 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, - 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, - 262, 263, 264, 265, 266, 267, 271, 275, 279, 282, - 283, 284, 285, 286, 287, 288, 289, 290, 292, 296, - 297, 298, 299, 301, 308, 309, 313, 318, 321, 324, - 327, 335, 342, 343, 344, 350, 357, 364, 384, 394, - 409, 415, 434, 447, 463, 478, 495, 496, 507, 518, - 519, 531, 540, 550, 569, 581, 595, 596, 607, 617, - - 627, 628, 629, 630, 631, 632, 633, 636, 638, 646, - 664, 669, 670, 676, 677, 688, 694, 700, 706, 722, - 723, 727, 734, 750, 770, 809 + 215, 218, 219, 220, 226, 244, 245, 246, 247, 248, + 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 288, 292, 296, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 309, 314, + 315, 316, 317, 319, 326, 327, 331, 337, 340, 341, + 344, 347, 355, 362, 363, 364, 370, 377, 384, 405, + 419, 434, 440, 459, 473, 492, 508, 525, 526, 537, + 548, 549, 561, 570, 575, 584, 594, 618, 630, 644, + + 645, 656, 661, 666, 667, 668, 669, 670, 671, 672, + 675, 677, 681, 700, 705, 706, 712, 713, 724, 730, + 736, 742, 758, 759, 763, 770, 786, 806, 845 } ; /* The intent behind this definition is that it'll catch @@ -1363,7 +1370,7 @@ static boundary scanner_cursor; #define YY_USER_ACTION location_compute (loc, &scanner_cursor, yytext, yyleng); -/* Report that yytext is an extension, and evaluate to its token type. */ +/* Report that yytext is an extension, and evaluate to its token kind. */ #define BISON_DIRECTIVE(Directive) \ (bison_directive (loc, yytext), PERCENT_ ## Directive) @@ -1395,6 +1402,23 @@ static boundary scanner_cursor; unput (Msg[i - 1]); \ } while (0) + +#define STRING_GROW_ESCAPE(Char) \ + do { \ + long c = Char; \ + if (0 < c && c <= UCHAR_MAX) \ + obstack_1grow (&obstack_for_string, c); \ + else \ + { \ + complain (loc, complaint, \ + _("invalid number after \\-escape: %s"), \ + yytext + 1); \ + /* Avoid additional errors about empty char literal. */ \ + obstack_1grow (&obstack_for_string, '?'); \ + } \ + } while (0) + + /* The current file name. Might change with #line. */ static uniqstr current_file = NULL; @@ -1419,11 +1443,11 @@ static int convert_ucn_to_byte (char const *hex_text); static void unexpected_eof (boundary, char const *); static void unexpected_newline (boundary, char const *); -#line 1422 "src/scan-gram.c" -#line 112 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 1446 "src/scan-gram.c" +#line 129 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* A C-like comment in directives/rules. */ - /* Strings and characters in directives/rules. */ + /* Characters and strings in directives/rules. */ /* A identifier was just read in directives/rules. Special state to capture the sequence 'identifier :'. */ @@ -1451,24 +1475,25 @@ static void unexpected_newline (boundary, char const *); white space between the backslash and the newline. */ /* An equal sign, with optional leading whitespaces. This is used in some deprecated constructs. */ -#line 1454 "src/scan-gram.c" +#line 1478 "src/scan-gram.c" #define INITIAL 0 #define SC_YACC_COMMENT 1 -#define SC_ESCAPED_STRING 2 -#define SC_ESCAPED_CHARACTER 3 -#define SC_AFTER_IDENTIFIER 4 -#define SC_TAG 5 -#define SC_PROLOGUE 6 -#define SC_BRACED_CODE 7 -#define SC_EPILOGUE 8 -#define SC_PREDICATE 9 -#define SC_COMMENT 10 -#define SC_LINE_COMMENT 11 -#define SC_STRING 12 -#define SC_CHARACTER 13 -#define SC_BRACKETED_ID 14 -#define SC_RETURN_BRACKETED_ID 15 +#define SC_ESCAPED_CHARACTER 2 +#define SC_ESCAPED_STRING 3 +#define SC_ESCAPED_TSTRING 4 +#define SC_AFTER_IDENTIFIER 5 +#define SC_TAG 6 +#define SC_PROLOGUE 7 +#define SC_BRACED_CODE 8 +#define SC_EPILOGUE 9 +#define SC_PREDICATE 10 +#define SC_COMMENT 11 +#define SC_LINE_COMMENT 12 +#define SC_STRING 13 +#define SC_CHARACTER 14 +#define SC_BRACKETED_ID 15 +#define SC_RETURN_BRACKETED_ID 16 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -1749,7 +1774,7 @@ YY_DECL { /* %% [7.0] user's declarations go here */ -#line 159 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 176 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Nesting level. Either for nested braces, or nested angle brackets @@ -1786,7 +1811,7 @@ YY_DECL | Scanning white space. | `-----------------------*/ -#line 1789 "src/scan-gram.c" +#line 1814 "src/scan-gram.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1816,13 +1841,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 600 ) + if ( yy_current_state >= 608 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 599 ); + while ( yy_current_state != 607 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1841,13 +1866,13 @@ do_action: /* This label is used only to access EOF actions. */ { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 127 ) + else if ( yy_act < 130 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 127 ) + else if ( yy_act == 130 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); - else if ( yy_act == 128 ) + else if ( yy_act == 131 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -1866,23 +1891,23 @@ do_action: /* This label is used only to access EOF actions. */ /* Comments and white space. */ case 1: YY_RULE_SETUP -#line 198 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 215 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, Wother, _("stray ',' treated as white space")); } YY_BREAK case 2: /* rule 2 can match eol */ -#line 202 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 219 "/Users/akim/src/gnu/bison/src/scan-gram.l" case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 202 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 219 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case 4: YY_RULE_SETUP -#line 203 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 220 "/Users/akim/src/gnu/bison/src/scan-gram.l" { token_start = loc->start; context_state = YY_START; @@ -1892,7 +1917,7 @@ YY_RULE_SETUP case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 209 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 226 "/Users/akim/src/gnu/bison/src/scan-gram.l" { handle_syncline (yytext + sizeof "#line " - 1, *loc); } @@ -1910,221 +1935,221 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP -#line 227 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 244 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (NONASSOC); YY_BREAK case 7: YY_RULE_SETUP -#line 228 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 245 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (CODE); YY_BREAK case 8: YY_RULE_SETUP -#line 229 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 246 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_FLAG ("parse.trace"); YY_BREAK case 9: YY_RULE_SETUP -#line 230 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 247 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (DEFAULT_PREC); YY_BREAK case 10: YY_RULE_SETUP -#line 231 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 248 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (DEFINE); YY_BREAK case 11: YY_RULE_SETUP -#line 232 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 249 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (DEFINES); YY_BREAK case 12: YY_RULE_SETUP -#line 233 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 250 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (DESTRUCTOR); YY_BREAK case 13: YY_RULE_SETUP -#line 234 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 251 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (DPREC); YY_BREAK case 14: YY_RULE_SETUP -#line 235 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 252 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (EMPTY); YY_BREAK case 15: YY_RULE_SETUP -#line 236 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 253 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (EXPECT); YY_BREAK case 16: YY_RULE_SETUP -#line 237 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 254 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (EXPECT_RR); YY_BREAK case 17: YY_RULE_SETUP -#line 238 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 255 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext)); YY_BREAK case 18: YY_RULE_SETUP -#line 239 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 256 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (INITIAL_ACTION); YY_BREAK case 19: YY_RULE_SETUP -#line 240 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 257 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (GLR_PARSER); YY_BREAK case 20: YY_RULE_SETUP -#line 241 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 258 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (LANGUAGE); YY_BREAK case 21: YY_RULE_SETUP -#line 242 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 259 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_LEFT; YY_BREAK case 22: YY_RULE_SETUP -#line 243 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 260 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM (lex); YY_BREAK case 23: YY_RULE_SETUP -#line 244 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 261 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_FLAG ("locations"); YY_BREAK case 24: YY_RULE_SETUP -#line 245 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 262 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (MERGE); YY_BREAK case 25: YY_RULE_SETUP -#line 246 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 263 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (NO_DEFAULT_PREC); YY_BREAK case 26: YY_RULE_SETUP -#line 247 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 264 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (NO_LINES); YY_BREAK case 27: YY_RULE_SETUP -#line 248 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 265 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_NONASSOC; YY_BREAK case 28: YY_RULE_SETUP -#line 249 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 266 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (NONDETERMINISTIC_PARSER); YY_BREAK case 29: YY_RULE_SETUP -#line 250 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 267 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (NTERM); YY_BREAK case 30: YY_RULE_SETUP -#line 251 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 268 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (OUTPUT); YY_BREAK case 31: YY_RULE_SETUP -#line 252 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 269 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM (both); YY_BREAK case 32: YY_RULE_SETUP -#line 253 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 270 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_PERCENT_PARAM (parse); YY_BREAK case 33: YY_RULE_SETUP -#line 254 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 271 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_PREC; YY_BREAK case 34: YY_RULE_SETUP -#line 255 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 272 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (PRECEDENCE); YY_BREAK case 35: YY_RULE_SETUP -#line 256 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 273 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (PRINTER); YY_BREAK case 36: YY_RULE_SETUP -#line 257 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 274 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (REQUIRE); YY_BREAK case 37: YY_RULE_SETUP -#line 258 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 275 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_RIGHT; YY_BREAK case 38: YY_RULE_SETUP -#line 259 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 276 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (SKELETON); YY_BREAK case 39: YY_RULE_SETUP -#line 260 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 277 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_START; YY_BREAK case 40: YY_RULE_SETUP -#line 261 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 278 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (TOKEN); YY_BREAK case 41: YY_RULE_SETUP -#line 262 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 279 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TOKEN; YY_BREAK case 42: YY_RULE_SETUP -#line 263 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 280 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (TOKEN_TABLE); YY_BREAK case 43: YY_RULE_SETUP -#line 264 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 281 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_TYPE; YY_BREAK case 44: YY_RULE_SETUP -#line 265 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 282 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_UNION; YY_BREAK case 45: YY_RULE_SETUP -#line 266 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 283 "/Users/akim/src/gnu/bison/src/scan-gram.l" return BISON_DIRECTIVE (VERBOSE); YY_BREAK case 46: YY_RULE_SETUP -#line 267 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 284 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PERCENT_YACC; YY_BREAK /* Deprecated since Bison 2.3b (2008-05-27), but the warning is issued only since Bison 3.4. */ case 47: YY_RULE_SETUP -#line 271 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 288 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_PURE_PARSER, uniqstr_new (yytext)); YY_BREAK /* Deprecated since Bison 3.0 (2013-07-25), but the warning is issued only since Bison 3.3. */ case 48: YY_RULE_SETUP -#line 275 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 292 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext)); YY_BREAK /* Deprecated since Bison 2.6 (2012-07-19), but the warning is @@ -2132,87 +2157,88 @@ RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext)); case 49: /* rule 49 can match eol */ YY_RULE_SETUP -#line 279 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 296 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_NAME_PREFIX, uniqstr_new (yytext)); YY_BREAK /* Deprecated since Bison 2.7.90, 2012. */ case 50: YY_RULE_SETUP -#line 282 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 299 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%default-prec"); YY_BREAK case 51: YY_RULE_SETUP -#line 283 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 300 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext)); YY_BREAK case 52: YY_RULE_SETUP -#line 284 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 301 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%expect-rr"); YY_BREAK case 53: /* rule 53 can match eol */ YY_RULE_SETUP -#line 285 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 302 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext)); YY_BREAK case 54: YY_RULE_SETUP -#line 286 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 303 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%output \"y.tab.c\""); YY_BREAK case 55: YY_RULE_SETUP -#line 287 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 304 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%no-default-prec"); YY_BREAK case 56: YY_RULE_SETUP -#line 288 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 305 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%no-lines"); YY_BREAK case 57: /* rule 57 can match eol */ YY_RULE_SETUP -#line 289 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 306 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%output"); YY_BREAK case 58: YY_RULE_SETUP -#line 290 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 307 "/Users/akim/src/gnu/bison/src/scan-gram.l" DEPRECATED ("%token-table"); YY_BREAK case 59: YY_RULE_SETUP -#line 292 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 309 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, _("invalid directive: %s"), quote (yytext)); + return GRAM_error; } YY_BREAK case 60: YY_RULE_SETUP -#line 296 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 314 "/Users/akim/src/gnu/bison/src/scan-gram.l" return COLON; YY_BREAK case 61: YY_RULE_SETUP -#line 297 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 315 "/Users/akim/src/gnu/bison/src/scan-gram.l" return EQUAL; YY_BREAK case 62: YY_RULE_SETUP -#line 298 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 316 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PIPE; YY_BREAK case 63: YY_RULE_SETUP -#line 299 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 317 "/Users/akim/src/gnu/bison/src/scan-gram.l" return SEMICOLON; YY_BREAK case 64: YY_RULE_SETUP -#line 301 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 319 "/Users/akim/src/gnu/bison/src/scan-gram.l" { val->ID = uniqstr_new (yytext); id_loc = *loc; @@ -2222,45 +2248,51 @@ YY_RULE_SETUP YY_BREAK case 65: YY_RULE_SETUP -#line 308 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 326 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (INT, scan_integer (yytext, 10, *loc)); YY_BREAK case 66: YY_RULE_SETUP -#line 309 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 327 "/Users/akim/src/gnu/bison/src/scan-gram.l" RETURN_VALUE (INT, scan_integer (yytext, 16, *loc)); YY_BREAK /* Identifiers may not start with a digit. Yet, don't silently accept "1FOO" as "1 FOO". */ case 67: YY_RULE_SETUP -#line 313 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 331 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, _("invalid identifier: %s"), quote (yytext)); + return GRAM_error; } YY_BREAK /* Characters. */ case 68: YY_RULE_SETUP -#line 318 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 337 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER; YY_BREAK /* Strings. */ case 69: YY_RULE_SETUP -#line 321 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 340 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_STRING; YY_BREAK -/* Prologue. */ case 70: YY_RULE_SETUP -#line 324 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 341 "/Users/akim/src/gnu/bison/src/scan-gram.l" +token_start = loc->start; BEGIN SC_ESCAPED_TSTRING; + YY_BREAK +/* Prologue. */ +case 71: +YY_RULE_SETUP +#line 344 "/Users/akim/src/gnu/bison/src/scan-gram.l" code_start = loc->start; BEGIN SC_PROLOGUE; YY_BREAK /* Code in between braces. */ -case 71: +case 72: YY_RULE_SETUP -#line 327 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 347 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; nesting = 0; @@ -2269,10 +2301,10 @@ YY_RULE_SETUP } YY_BREAK /* Semantic predicate. */ -case 72: -/* rule 72 can match eol */ +case 73: +/* rule 73 can match eol */ YY_RULE_SETUP -#line 335 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 355 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; code_start = loc->start; @@ -2280,28 +2312,28 @@ YY_RULE_SETUP } YY_BREAK /* A type. */ -case 73: +case 74: YY_RULE_SETUP -#line 342 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 362 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_ANY; YY_BREAK -case 74: +case 75: YY_RULE_SETUP -#line 343 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 363 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_NONE; YY_BREAK -case 75: +case 76: YY_RULE_SETUP -#line 344 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 364 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; token_start = loc->start; BEGIN SC_TAG; } YY_BREAK -case 76: +case 77: YY_RULE_SETUP -#line 350 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 370 "/Users/akim/src/gnu/bison/src/scan-gram.l" { static int percent_percent_count; if (++percent_percent_count == 2) @@ -2309,9 +2341,9 @@ YY_RULE_SETUP return PERCENT_PERCENT; } YY_BREAK -case 77: +case 78: YY_RULE_SETUP -#line 357 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 377 "/Users/akim/src/gnu/bison/src/scan-gram.l" { bracketed_id_str = NULL; bracketed_id_start = loc->start; @@ -2319,17 +2351,18 @@ YY_RULE_SETUP BEGIN SC_BRACKETED_ID; } YY_BREAK -case 78: +case 79: YY_RULE_SETUP -#line 364 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 384 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", ngettext ("invalid character", "invalid characters", yyleng), quote_mem (yytext, yyleng)); + return GRAM_error; } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 370 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 391 "/Users/akim/src/gnu/bison/src/scan-gram.l" { loc->start = loc->end = scanner_cursor; yyterminate (); @@ -2342,10 +2375,14 @@ case YY_STATE_EOF(INITIAL): `--------------------------------------------------------------*/ -case 79: +case 80: YY_RULE_SETUP -#line 384 "/Users/akim/src/gnu/bison/src/scan-gram.l" -complain (loc, complaint, _("invalid null character")); +#line 405 "/Users/akim/src/gnu/bison/src/scan-gram.l" +{ + complain (loc, complaint, _("invalid null character")); + STRING_FREE; + return GRAM_error; + } YY_BREAK /*-----------------------------------------------------------------. @@ -2353,9 +2390,9 @@ complain (loc, complaint, _("invalid null character")); `-----------------------------------------------------------------*/ -case 80: +case 81: YY_RULE_SETUP -#line 394 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 419 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { @@ -2372,9 +2409,9 @@ YY_RULE_SETUP } } YY_BREAK -case 81: +case 82: YY_RULE_SETUP -#line 409 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 434 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); @@ -2382,9 +2419,9 @@ YY_RULE_SETUP return ID_COLON; } YY_BREAK -case 82: +case 83: YY_RULE_SETUP -#line 415 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 440 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); @@ -2393,7 +2430,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_AFTER_IDENTIFIER): -#line 421 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 446 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); *loc = id_loc; @@ -2406,15 +2443,16 @@ case YY_STATE_EOF(SC_AFTER_IDENTIFIER): `--------------------------------*/ -case 83: +case 84: YY_RULE_SETUP -#line 434 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 459 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { complain (loc, complaint, _("unexpected identifier in bracketed name: %s"), quote (yytext)); + return GRAM_error; } else { @@ -2423,9 +2461,9 @@ YY_RULE_SETUP } } YY_BREAK -case 84: +case 85: YY_RULE_SETUP -#line 447 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 473 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; if (bracketed_id_str) @@ -2439,21 +2477,25 @@ YY_RULE_SETUP } } else - complain (loc, complaint, _("an identifier expected")); + { + complain (loc, complaint, _("an identifier expected")); + return GRAM_error; + } } YY_BREAK -case 85: +case 86: YY_RULE_SETUP -#line 463 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 492 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", ngettext ("invalid character in bracketed name", "invalid characters in bracketed name", yyleng), quote_mem (yytext, yyleng)); + return GRAM_error; } YY_BREAK case YY_STATE_EOF(SC_BRACKETED_ID): -#line 470 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 500 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; unexpected_eof (bracketed_id_start, "]"); @@ -2462,9 +2504,9 @@ case YY_STATE_EOF(SC_BRACKETED_ID): -case 86: +case 87: YY_RULE_SETUP -#line 478 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 508 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; val->BRACKETED_ID = bracketed_id_str; @@ -2480,19 +2522,19 @@ YY_RULE_SETUP `---------------------------------------------------------------*/ -case 87: +case 88: YY_RULE_SETUP -#line 495 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 525 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK -case 88: -/* rule 88 can match eol */ +case 89: +/* rule 89 can match eol */ YY_RULE_SETUP -#line 496 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 526 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case YY_STATE_EOF(SC_YACC_COMMENT): -#line 497 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 527 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2501,14 +2543,14 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `------------------------------------------------------------*/ -case 89: -/* rule 89 can match eol */ +case 90: +/* rule 90 can match eol */ YY_RULE_SETUP -#line 507 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 537 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_COMMENT): -#line 508 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 538 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2517,20 +2559,20 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `--------------------------------------------------------------*/ -case 90: -/* rule 90 can match eol */ +case 91: +/* rule 91 can match eol */ YY_RULE_SETUP -#line 518 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 548 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 91: -/* rule 91 can match eol */ +case 92: +/* rule 92 can match eol */ YY_RULE_SETUP -#line 519 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 549 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_LINE_COMMENT): -#line 520 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 550 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK @@ -2540,9 +2582,9 @@ BEGIN context_state; `------------------------------------------------*/ -case 92: +case 93: YY_RULE_SETUP -#line 531 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 561 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; BEGIN INITIAL; @@ -2553,13 +2595,38 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_ESCAPED_STRING): -#line 539 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 569 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK -case 93: -/* rule 93 can match eol */ +case 94: +/* rule 94 can match eol */ +YY_RULE_SETUP +#line 570 "/Users/akim/src/gnu/bison/src/scan-gram.l" +unexpected_newline (token_start, "\""); + YY_BREAK + + + +case 95: +YY_RULE_SETUP +#line 575 "/Users/akim/src/gnu/bison/src/scan-gram.l" +{ + STRING_FINISH; + BEGIN INITIAL; + loc->start = token_start; + complain (loc, Wyacc, + _("POSIX Yacc does not support string literals")); + RETURN_VALUE (TSTRING, last_string); + } + YY_BREAK +case YY_STATE_EOF(SC_ESCAPED_TSTRING): +#line 583 "/Users/akim/src/gnu/bison/src/scan-gram.l" +unexpected_eof (token_start, "\""); + YY_BREAK +case 96: +/* rule 96 can match eol */ YY_RULE_SETUP -#line 540 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 584 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK @@ -2569,37 +2636,42 @@ unexpected_newline (token_start, "\""); `----------------------------------------------------------*/ -case 94: +case 97: YY_RULE_SETUP -#line 550 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 594 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; + BEGIN INITIAL; loc->start = token_start; val->CHAR = last_string[0]; - /* FIXME: Eventually, make these errors. */ if (last_string[0] == '\0') - { - complain (loc, Wother, _("empty character literal")); - /* '\0' seems dangerous even if we are about to complain. */ - val->CHAR = '\''; - } + { + complain (loc, complaint, _("empty character literal")); + STRING_FREE; + return GRAM_error; + } else if (last_string[1] != '\0') - complain (loc, Wother, - _("extra characters in character literal")); - STRING_FREE; - BEGIN INITIAL; - return CHAR; + { + complain (loc, complaint, _("extra characters in character literal")); + STRING_FREE; + return GRAM_error; + } + else + { + STRING_FREE; + return CHAR; + } } YY_BREAK -case 95: -/* rule 95 can match eol */ +case 98: +/* rule 98 can match eol */ YY_RULE_SETUP -#line 569 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 618 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 570 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 619 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK @@ -2608,9 +2680,9 @@ unexpected_eof (token_start, "'"); `--------------------------------------------------------------*/ -case 96: +case 99: YY_RULE_SETUP -#line 581 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 630 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) @@ -2625,19 +2697,19 @@ YY_RULE_SETUP STRING_GROW; } YY_BREAK -case 97: -/* rule 97 can match eol */ +case 100: +/* rule 100 can match eol */ YY_RULE_SETUP -#line 595 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 644 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 98: +case 101: YY_RULE_SETUP -#line 596 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 645 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting += yyleng; YY_BREAK case YY_STATE_EOF(SC_TAG): -#line 598 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 647 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, ">"); YY_BREAK @@ -2646,89 +2718,74 @@ unexpected_eof (token_start, ">"); `----------------------------*/ -case 99: +case 102: YY_RULE_SETUP -#line 607 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 656 "/Users/akim/src/gnu/bison/src/scan-gram.l" { verify (UCHAR_MAX < ULONG_MAX); - long c = strtol (yytext + 1, NULL, 8); - if (0 < c && c <= UCHAR_MAX) - obstack_1grow (&obstack_for_string, c); - else - complain (loc, complaint, _("invalid number after \\-escape: %s"), - yytext+1); + STRING_GROW_ESCAPE (strtol (yytext + 1, NULL, 8)); } YY_BREAK -case 100: +case 103: YY_RULE_SETUP -#line 617 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 661 "/Users/akim/src/gnu/bison/src/scan-gram.l" { verify (UCHAR_MAX < ULONG_MAX); - long c = strtol (yytext + 2, NULL, 16); - if (0 < c && c <= UCHAR_MAX) - obstack_1grow (&obstack_for_string, c); - else - complain (loc, complaint, _("invalid number after \\-escape: %s"), - yytext+1); + STRING_GROW_ESCAPE (strtol (yytext + 2, NULL, 16)); } YY_BREAK -case 101: +case 104: YY_RULE_SETUP -#line 627 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 666 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\a'); YY_BREAK -case 102: +case 105: YY_RULE_SETUP -#line 628 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 667 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\b'); YY_BREAK -case 103: +case 106: YY_RULE_SETUP -#line 629 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 668 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\f'); YY_BREAK -case 104: +case 107: YY_RULE_SETUP -#line 630 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 669 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\n'); YY_BREAK -case 105: +case 108: YY_RULE_SETUP -#line 631 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 670 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\r'); YY_BREAK -case 106: +case 109: YY_RULE_SETUP -#line 632 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 671 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\t'); YY_BREAK -case 107: +case 110: YY_RULE_SETUP -#line 633 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 672 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\v'); YY_BREAK /* \\[\"\'?\\] would be shorter, but it confuses xgettext. */ -case 108: +case 111: YY_RULE_SETUP -#line 636 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 675 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, yytext[1]); YY_BREAK -case 109: +case 112: YY_RULE_SETUP -#line 638 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 677 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - int c = convert_ucn_to_byte (yytext); - if (c <= 0) - complain (loc, complaint, _("invalid number after \\-escape: %s"), - yytext+1); - else - obstack_1grow (&obstack_for_string, c); + STRING_GROW_ESCAPE (convert_ucn_to_byte (yytext)); } YY_BREAK -case 110: -/* rule 110 can match eol */ +case 113: +/* rule 113 can match eol */ YY_RULE_SETUP -#line 646 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 681 "/Users/akim/src/gnu/bison/src/scan-gram.l" { char const *p = yytext + 1; /* Quote only if escaping won't make the character visible. */ @@ -2738,6 +2795,7 @@ YY_RULE_SETUP p = quotearg_style_mem (escape_quoting_style, p, 1); complain (loc, complaint, _("invalid character after \\-escape: %s"), p); + obstack_1grow (&obstack_for_string, '?'); } YY_BREAK @@ -2746,46 +2804,46 @@ YY_RULE_SETUP `--------------------------------------------*/ -case 111: -/* rule 111 can match eol */ +case 114: +/* rule 114 can match eol */ YY_RULE_SETUP -#line 664 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 700 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 112: +case 115: YY_RULE_SETUP -#line 669 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 705 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 113: -/* rule 113 can match eol */ +case 116: +/* rule 116 can match eol */ YY_RULE_SETUP -#line 670 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 706 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 671 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 707 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK -case 114: +case 117: YY_RULE_SETUP -#line 676 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 712 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 115: -/* rule 115 can match eol */ +case 118: +/* rule 118 can match eol */ YY_RULE_SETUP -#line 677 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 713 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 678 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 714 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK @@ -2794,9 +2852,9 @@ unexpected_eof (token_start, "\""); `---------------------------------------------------*/ -case 116: +case 119: YY_RULE_SETUP -#line 688 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 724 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2804,9 +2862,9 @@ YY_RULE_SETUP BEGIN SC_CHARACTER; } YY_BREAK -case 117: +case 120: YY_RULE_SETUP -#line 694 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 730 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2814,10 +2872,10 @@ YY_RULE_SETUP BEGIN SC_STRING; } YY_BREAK -case 118: -/* rule 118 can match eol */ +case 121: +/* rule 121 can match eol */ YY_RULE_SETUP -#line 700 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 736 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2825,10 +2883,10 @@ YY_RULE_SETUP BEGIN SC_COMMENT; } YY_BREAK -case 119: -/* rule 119 can match eol */ +case 122: +/* rule 122 can match eol */ YY_RULE_SETUP -#line 706 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 742 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2842,37 +2900,37 @@ YY_RULE_SETUP `-----------------------------------------------------------*/ -case 120: -/* rule 120 can match eol */ +case 123: +/* rule 123 can match eol */ YY_RULE_SETUP -#line 722 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 758 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting++; YY_BREAK -case 121: -/* rule 121 can match eol */ +case 124: +/* rule 124 can match eol */ YY_RULE_SETUP -#line 723 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 759 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting--; YY_BREAK /* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly (as '<' '<%'). */ -case 122: -/* rule 122 can match eol */ +case 125: +/* rule 125 can match eol */ YY_RULE_SETUP -#line 727 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 763 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_BRACED_CODE): case YY_STATE_EOF(SC_PREDICATE): -#line 729 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 765 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "}"); YY_BREAK -case 123: +case 126: YY_RULE_SETUP -#line 734 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 770 "/Users/akim/src/gnu/bison/src/scan-gram.l" { obstack_1grow (&obstack_for_string, '}'); @@ -2889,9 +2947,9 @@ YY_RULE_SETUP -case 124: +case 127: YY_RULE_SETUP -#line 750 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 786 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) @@ -2911,9 +2969,9 @@ YY_RULE_SETUP `--------------------------------------------------------------*/ -case 125: +case 128: YY_RULE_SETUP -#line 770 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 806 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2922,7 +2980,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 777 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 813 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "%}"); YY_BREAK @@ -2933,7 +2991,7 @@ unexpected_eof (code_start, "%}"); case YY_STATE_EOF(SC_EPILOGUE): -#line 788 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 824 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; @@ -2953,19 +3011,19 @@ case YY_STATE_EOF(SC_EPILOGUE): Add a fallthrough "|." so that non UTF-8 input is still accepted and does not jam the scanner. */ -case 126: -/* rule 126 can match eol */ +case 129: +/* rule 129 can match eol */ YY_RULE_SETUP -#line 809 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 845 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 127: +case 130: YY_RULE_SETUP -#line 812 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 848 "/Users/akim/src/gnu/bison/src/scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2968 "src/scan-gram.c" +#line 3026 "src/scan-gram.c" case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): yyterminate(); @@ -3278,7 +3336,7 @@ static int yy_get_next_buffer (void) for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 72); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 74); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -3287,7 +3345,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 600 ) + if ( yy_current_state >= 608 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -3311,7 +3369,7 @@ static int yy_get_next_buffer (void) /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ char *yy_cp = (yy_c_buf_p); - YY_CHAR yy_c = 72; + YY_CHAR yy_c = 74; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -3320,11 +3378,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 600 ) + if ( yy_current_state >= 608 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 599); + yy_is_jam = (yy_current_state == 607); return yy_is_jam ? 0 : yy_current_state; } @@ -4117,7 +4175,7 @@ void yyfree (void * ptr ) /* %ok-for-header */ -#line 812 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 848 "/Users/akim/src/gnu/bison/src/scan-gram.l" diff --git a/contrib/tools/bison/src/scan-skel.c b/contrib/tools/bison/src/scan-skel.c index ec42cd8e0d..bda7bd2100 100644 --- a/contrib/tools/bison/src/scan-skel.c +++ b/contrib/tools/bison/src/scan-skel.c @@ -1,5 +1,6 @@ +#line 1 "src/scan-skel.c" -#line 2 "lex.skel_.c" +#line 3 "src/scan-skel.c" #define YY_INT_ALIGNED short int @@ -836,7 +837,7 @@ char *yytext; #line 1 "src/scan-skel.l" /* Scan Bison Skeletons. -*- C -*- - Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2001-2015, 2018-2020 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -854,24 +855,24 @@ char *yytext; along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 #line 24 "src/scan-skel.l" -/* Work around a bug in flex 2.5.31. See Debian bug 333231 - <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ -#undef skel_wrap -#define skel_wrap() 1 - -#define FLEX_PREFIX(Id) skel_ ## Id -#include <src/flex-scanner.h> - -#include <error.h> #include <dirname.h> +#include <error.h> #include <path-join.h> #include <quotearg.h> #include <src/complain.h> -#include <src/getargs.h> #include <src/files.h> +#include <src/getargs.h> #include <src/scan-skel.h> +#define FLEX_PREFIX(Id) skel_ ## Id +#include <src/flex-scanner.h> + +/* Work around a bug in flex 2.5.31. See Debian bug 333231 + <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ +#undef skel_wrap +#define skel_wrap() 1 + #define YY_DECL static int skel_lex (void) YY_DECL; @@ -883,9 +884,9 @@ static void at_output (int argc, char *argv[], char **name, int *lineno); static void fail_for_at_directive_too_many_args (char const *at_directive_name); static void fail_for_at_directive_too_few_args (char const *at_directive_name); static void fail_for_invalid_at (char const *at); -#line 886 "lex.skel_.c" +#line 887 "src/scan-skel.c" -#line 888 "lex.skel_.c" +#line 889 "src/scan-skel.c" #define INITIAL 0 #define SC_AT_DIRECTIVE_ARGS 1 @@ -1182,7 +1183,7 @@ YY_DECL at_directive at_ptr = NULL; -#line 1185 "lex.skel_.c" +#line 1186 "src/scan-skel.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1431,7 +1432,7 @@ YY_RULE_SETUP #line 145 "src/scan-skel.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1434 "lex.skel_.c" +#line 1435 "src/scan-skel.c" case YY_END_OF_BUFFER: { @@ -2586,7 +2587,7 @@ flag (const char *arg) else if (STREQ (arg, "fatal")) return fatal; else if (STREQ (arg, "note")) - return silent | complaint | no_caret; + return silent | complaint | no_caret | note; else if (STREQ (arg, "warn")) return Wother; else @@ -2606,29 +2607,23 @@ at_basename (int argc, char *argv[], char **out_namep, int *out_linenop) static void at_complain (int argc, char *argv[], char **out_namep, int *out_linenop) { - static unsigned indent; - warnings w = flag (argv[1]); - location loc; - location *locp = NULL; + if (argc < 4) + fail_for_at_directive_too_few_args (argv[0]); (void) out_namep; (void) out_linenop; - if (argc < 4) - fail_for_at_directive_too_few_args (argv[0]); + warnings w = flag (argv[1]); + + location loc; + location *locp = NULL; if (argv[2] && argv[2][0]) { boundary_set_from_string (&loc.start, argv[2]); boundary_set_from_string (&loc.end, argv[3]); locp = &loc; } - if (w & silent) - indent += SUB_INDENT; - else - indent = 0; - complain_args (locp, w, &indent, argc - 4, argv + 4); - if (w & silent) - indent -= SUB_INDENT; + complain_args (locp, w, argc - 4, argv + 4); } static void diff --git a/contrib/tools/bison/src/state.h b/contrib/tools/bison/src/state.h index 8fd9088ab3..a087dc8373 100644 --- a/contrib/tools/bison/src/state.h +++ b/contrib/tools/bison/src/state.h @@ -67,7 +67,10 @@ Conflict resolution can decide that certain tokens in certain states should explicitly be errors (for implementing %nonassoc). For each state, the tokens that are errors for this reason are - recorded in an errs structure, which holds the token numbers. + recorded in an errs structure. The generated parser does not + depend on this errs structure, it is used only in the reports + (*.output, etc.) to describe conflicted actions that have been + discarded. There is at least one goto transition present in state zero. It leads to a next-to-final state whose accessing_symbol is the diff --git a/contrib/tools/bison/src/symtab.c b/contrib/tools/bison/src/symtab.c index b4106ea0b0..c9ac27f482 100644 --- a/contrib/tools/bison/src/symtab.c +++ b/contrib/tools/bison/src/symtab.c @@ -65,6 +65,20 @@ static bool *used_assoc = NULL; bool tag_seen = false; +/* Whether SYM was defined by the user. */ + +static bool +symbol_is_user_defined (symbol *sym) +{ + const bool eof_is_user_defined + = !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end"); + return sym->tag[0] != '$' + && (eof_is_user_defined || (sym != endtoken && sym->alias != errtoken)) + && sym != errtoken && sym->alias != errtoken + && sym != undeftoken && sym->alias != undeftoken; +} + + /*--------------------------. | Create a new sym_content. | `--------------------------*/ @@ -111,6 +125,7 @@ symbol_new (uniqstr tag, location loc) res->tag = tag; res->location = loc; + res->translatable = false; res->location_of_lhs = false; res->alias = NULL; res->content = sym_content_new (res); @@ -151,9 +166,9 @@ symbol_free (void *ptr) /* If needed, swap first and second so that first has the earliest location (according to location_cmp). - Many symbol features (e.g., user token numbers) are not assigned - during the parsing, but in a second step, via a traversal of the - symbol table sorted on tag. + Many symbol features (e.g., token codes) are not assigned during + parsing, but in a second step, via a traversal of the symbol table + sorted on tag. However, error messages make more sense if we keep the first declaration first. @@ -278,6 +293,7 @@ is_identifier (uniqstr s) /*-----------------------------------------------. | Get the identifier associated to this symbol. | `-----------------------------------------------*/ + uniqstr symbol_id_get (symbol const *sym) { @@ -296,42 +312,29 @@ static void complain_symbol_redeclared (symbol *s, const char *what, location first, location second) { - int i = 0; locations_sort (&first, &second); - complain_indent (&second, complaint, &i, - _("%s redeclaration for %s"), what, s->tag); - i += SUB_INDENT; - complain_indent (&first, complaint, &i, - _("previous declaration")); + complain (&second, complaint, _("%s redeclaration for %s"), what, s->tag); + subcomplain (&first, complaint, _("previous declaration")); } static void complain_semantic_type_redeclared (semantic_type *s, const char *what, location first, location second) { - int i = 0; locations_sort (&first, &second); - complain_indent (&second, complaint, &i, - _("%s redeclaration for <%s>"), what, s->tag); - i += SUB_INDENT; - complain_indent (&first, complaint, &i, - _("previous declaration")); + complain (&second, complaint, _("%s redeclaration for <%s>"), what, s->tag); + subcomplain (&first, complaint, _("previous declaration")); } static void complain_class_redeclared (symbol *sym, symbol_class class, location second) { - int i = 0; - complain_indent (&second, complaint, &i, - class == token_sym - ? _("symbol %s redeclared as a token") - : _("symbol %s redeclared as a nonterminal"), sym->tag); + complain (&second, complaint, + class == token_sym + ? _("symbol %s redeclared as a token") + : _("symbol %s redeclared as a nonterminal"), sym->tag); if (!location_empty (sym->location)) - { - i += SUB_INDENT; - complain_indent (&sym->location, complaint, &i, - _("previous definition")); - } + subcomplain (&sym->location, complaint, _("previous definition")); } static const symbol * @@ -431,6 +434,7 @@ symbol_code_props_set (symbol *sym, code_props_type kind, sym->content->props[kind] = *code; } + /*-----------------------------------------------------. | Set the DESTRUCTOR or PRINTER associated with TYPE. | `-----------------------------------------------------*/ @@ -469,7 +473,7 @@ symbol_code_props_get (symbol *sym, code_props_type kind) } /* Apply default code props's only to user-defined symbols. */ - if (sym->tag[0] != '$' && sym != errtoken) + if (symbol_is_user_defined (sym)) { code_props *code = &semantic_type_get (sym->content->type_name ? "*" : "", NULL)->props[kind]; @@ -547,12 +551,10 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) { if (s->status == declared) { - int i = 0; - complain_indent (&loc, Wother, &i, - _("symbol %s redeclared"), sym->tag); - i += SUB_INDENT; - complain_indent (&sym->location, Wother, &i, - _("previous declaration")); + complain (&loc, Wother, + _("symbol %s redeclared"), sym->tag); + subcomplain (&sym->location, Wother, + _("previous declaration")); } else { @@ -574,13 +576,13 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) int *user_token_numberp = &sym->content->user_token_number; if (sym->content->class != token_sym) complain (&loc, complaint, - _("nonterminals cannot be given an explicit number")); + _("nonterminals cannot be given a token code")); else if (*user_token_numberp != USER_NUMBER_UNDEFINED && *user_token_numberp != user_token_number) - complain (&loc, complaint, _("redefining user token number of %s"), + complain (&loc, complaint, _("redefining code of token %s"), sym->tag); else if (user_token_number == INT_MAX) - complain (&loc, complaint, _("user token number of %s too large"), + complain (&loc, complaint, _("code of token %s too large"), sym->tag); else { @@ -723,49 +725,47 @@ symbol_make_alias (symbol *sym, symbol *str, location loc) `-------------------------------------------------------------------*/ static void -symbol_pack (symbol *this) +symbol_pack (symbol *sym) { - aver (this->content->number != NUMBER_UNDEFINED); - if (this->content->class == nterm_sym) - this->content->number += ntokens; + aver (sym->content->number != NUMBER_UNDEFINED); + if (sym->content->class == nterm_sym) + sym->content->number += ntokens; - symbols[this->content->number] = this->content->symbol; + symbols[sym->content->number] = sym->content->symbol; } static void complain_user_token_number_redeclared (int num, symbol *first, symbol *second) { - int i = 0; symbols_sort (&first, &second); - complain_indent (&second->location, complaint, &i, - _("user token number %d redeclaration for %s"), - num, second->tag); - i += SUB_INDENT; - complain_indent (&first->location, complaint, &i, - _("previous declaration for %s"), - first->tag); + complain (&second->location, complaint, + _("code %d reassigned to token %s"), + num, second->tag); + subcomplain (&first->location, complaint, + _("previous declaration for %s"), + first->tag); } -/*--------------------------------------------------. -| Put THIS in TOKEN_TRANSLATIONS if it is a token. | -`--------------------------------------------------*/ +/*-------------------------------------------------. +| Put SYM in TOKEN_TRANSLATIONS if it is a token. | +`-------------------------------------------------*/ static void -symbol_translation (symbol *this) +symbol_translation (symbol *sym) { /* Nonterminal? */ - if (this->content->class == token_sym - && !this->is_alias) + if (sym->content->class == token_sym + && !sym->is_alias) { /* A token which translation has already been set?*/ - if (token_translations[this->content->user_token_number] + if (token_translations[sym->content->user_token_number] != undeftoken->content->number) complain_user_token_number_redeclared - (this->content->user_token_number, - symbols[token_translations[this->content->user_token_number]], this); + (sym->content->user_token_number, + symbols[token_translations[sym->content->user_token_number]], sym); else - token_translations[this->content->user_token_number] - = this->content->number; + token_translations[sym->content->user_token_number] + = sym->content->number; } } @@ -847,16 +847,26 @@ symbols_new (void) accept->content->class = nterm_sym; accept->content->number = nvars++; - /* Construct the error token */ - errtoken = symbol_get ("error", empty_loc); + /* Construct the YYerror/"error" token */ + errtoken = symbol_get ("YYerror", empty_loc); errtoken->content->class = token_sym; errtoken->content->number = ntokens++; + { + symbol *alias = symbol_get ("error", empty_loc); + symbol_class_set (alias, token_sym, empty_loc, false); + symbol_make_alias (errtoken, alias, empty_loc); + } - /* Construct a token that represents all undefined literal tokens. - It is always token number 2. */ - undeftoken = symbol_get ("$undefined", empty_loc); + /* Construct the YYUNDEF/"$undefined" token that represents all + undefined literal tokens. It is always symbol number 2. */ + undeftoken = symbol_get ("YYUNDEF", empty_loc); undeftoken->content->class = token_sym; undeftoken->content->number = ntokens++; + { + symbol *alias = symbol_get ("$undefined", empty_loc); + symbol_class_set (alias, token_sym, empty_loc, false); + symbol_make_alias (undeftoken, alias, empty_loc); + } semantic_type_table = hash_xinitialize (HT_INITIAL_CAPACITY, NULL, @@ -959,7 +969,7 @@ dummy_symbol_get (location loc) } bool -symbol_is_dummy (const symbol *sym) +symbol_is_dummy (symbol const *sym) { return sym->tag[0] == '@' || (sym->tag[0] == '$' && sym->tag[1] == '@'); } @@ -1034,17 +1044,17 @@ symbols_token_translations_init (void) { bool num_256_available_p = true; - /* Find the highest user token number, and whether 256, the POSIX - preferred user token number for the error token, is used. */ + /* Find the highest token code, and whether 256, the POSIX preferred + token code for the error token, is used. */ max_user_token_number = 0; for (int i = 0; i < ntokens; ++i) { - sym_content *this = symbols[i]->content; - if (this->user_token_number != USER_NUMBER_UNDEFINED) + sym_content *sym = symbols[i]->content; + if (sym->user_token_number != USER_NUMBER_UNDEFINED) { - if (this->user_token_number > max_user_token_number) - max_user_token_number = this->user_token_number; - if (this->user_token_number == 256) + if (sym->user_token_number > max_user_token_number) + max_user_token_number = sym->user_token_number; + if (sym->user_token_number == 256) num_256_available_p = false; } } @@ -1060,17 +1070,17 @@ symbols_token_translations_init (void) for (int i = 0; i < ntokens; ++i) { - sym_content *this = symbols[i]->content; - if (this->user_token_number == USER_NUMBER_UNDEFINED) + sym_content *sym = symbols[i]->content; + if (sym->user_token_number == USER_NUMBER_UNDEFINED) { IGNORE_TYPE_LIMITS_BEGIN if (INT_ADD_WRAPV (max_user_token_number, 1, &max_user_token_number)) complain (NULL, fatal, _("token number too large")); IGNORE_TYPE_LIMITS_END - this->user_token_number = max_user_token_number; + sym->user_token_number = max_user_token_number; } - if (this->user_token_number > max_user_token_number) - max_user_token_number = this->user_token_number; + if (sym->user_token_number > max_user_token_number) + max_user_token_number = sym->user_token_number; } token_translations = xnmalloc (max_user_token_number + 1, @@ -1085,6 +1095,21 @@ symbols_token_translations_init (void) } +/* Whether some symbol requires internationalization. */ +static bool +has_translations (void) +{ + for (const void *entry = hash_get_first (symbol_table); + entry; + entry = hash_get_next (symbol_table, entry)) + { + const symbol *sym = (const symbol *) entry; + if (sym->translatable) + return true; + } + return false; +} + /*----------------------------------------------------------------. | Assign symbol numbers, and write definition of token names into | | FDEFINES. Set up vectors SYMBOL_TABLE, TAGS of symbols. | @@ -1127,6 +1152,18 @@ symbols_pack (void) complain (&startsymbol_loc, fatal, _("the start symbol %s is a token"), startsymbol->tag); + + // If some user tokens are internationalized, the internal ones + // should be too. + if (has_translations ()) + { + const bool eof_is_user_defined + = !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end"); + if (!eof_is_user_defined) + endtoken->alias->translatable = true; + undeftoken->alias->translatable = true; + errtoken->alias->translatable = true; + } } /*---------------------------------. diff --git a/contrib/tools/bison/src/symtab.h b/contrib/tools/bison/src/symtab.h index f3421774df..d16c027082 100644 --- a/contrib/tools/bison/src/symtab.h +++ b/contrib/tools/bison/src/symtab.h @@ -97,6 +97,9 @@ struct symbol /** The "defining" location. */ location location; + /** Whether this symbol is translatable. */ + bool translatable; + /** Whether \a location is about the first uses as left-hand side symbol of a rule (true), or simply the first occurrence (e.g., in a %type, or as a rhs symbol of a rule). The former type of @@ -117,6 +120,8 @@ struct symbol struct sym_content { + /** The main symbol that denotes this content (it contains the + possible alias). */ symbol *symbol; /** Its \c \%type. @@ -179,7 +184,7 @@ symbol *dummy_symbol_get (location loc); void symbol_print (symbol const *s, FILE *f); /** Is this a dummy nonterminal? */ -bool symbol_is_dummy (const symbol *sym); +bool symbol_is_dummy (symbol const *sym); /** The name of the code_props type: "\%destructor" or "\%printer". */ char const *code_props_type_string (code_props_type kind); diff --git a/contrib/tools/bison/src/tables.c b/contrib/tools/bison/src/tables.c index b6a8404ae6..b165f0fbdc 100644 --- a/contrib/tools/bison/src/tables.c +++ b/contrib/tools/bison/src/tables.c @@ -412,7 +412,7 @@ save_row (state_number s) /*------------------------------------------------------------------. | Figure out the actions for the specified state, indexed by | -| lookahead token type. | +| lookahead token kind. | | | | The YYDEFACT table is output now. The detailed info is saved for | | putting into YYTABLE later. | diff --git a/contrib/tools/bison/ya.make b/contrib/tools/bison/ya.make index c5fdd1053e..abcbd4c4f5 100644 --- a/contrib/tools/bison/ya.make +++ b/contrib/tools/bison/ya.make @@ -11,9 +11,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(3.5.4) +VERSION(3.6.4) -ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.5.4.tar.gz) +ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.6.4.tar.gz) PEERDIR( contrib/tools/bison/lib @@ -30,7 +30,7 @@ NO_RUNTIME() CFLAGS( -DEXEEXT=\"\" - -DINSTALLDIR=\"/var/empty/bison-3.5.4/bin\" + -DINSTALLDIR=\"/var/empty/bison-3.6.4/bin\" ) SRCS( |