diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-06-29 21:48:22 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-06-29 21:59:59 +0300 |
commit | b21e05a2e32e36ae9cc9826acf98084ca4b52d7d (patch) | |
tree | 20d654fb0156f50e150944fc8108a3cada8ca6ec /contrib | |
parent | 0cf48e974f5542c3e65398c01b9b6baf8aa6c260 (diff) | |
download | ydb-b21e05a2e32e36ae9cc9826acf98084ca4b52d7d.tar.gz |
Update contrib/tools/bison to 3.3.2
6215035f251de2d87363064fb4f07a2b14a3b4c8
Diffstat (limited to 'contrib')
279 files changed, 7374 insertions, 6699 deletions
diff --git a/contrib/tools/bison/AUTHORS b/contrib/tools/bison/AUTHORS index b0ddb15045..63946aa317 100644 --- a/contrib/tools/bison/AUTHORS +++ b/contrib/tools/bison/AUTHORS @@ -24,7 +24,7 @@ and nasty bugs. ----- -Copyright (C) 1998-2015, 2018 Free Software Foundation, Inc. +Copyright (C) 1998-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/NEWS b/contrib/tools/bison/NEWS index 56cac0418a..30e31ff584 100644 --- a/contrib/tools/bison/NEWS +++ b/contrib/tools/bison/NEWS @@ -1,5 +1,334 @@ GNU Bison NEWS +* Noteworthy changes in release 3.3.2 (2019-02-03) [stable] + +** Bug fixes + + Bison 3.3 failed to generate parsers for grammars with unused nonterminal + symbols. + +* Noteworthy changes in release 3.3.1 (2019-01-27) [stable] + +** Changes + + The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison + extensions into errors. It now makes them simple warnings (-Wyacc). + +* Noteworthy changes in release 3.3 (2019-01-26) [stable] + + A new mailing list was created, Bison Announce. It is low traffic, and is + only about announcing new releases and important messages (e.g., polls + about major decisions to make). + + https://lists.gnu.org/mailman/listinfo/bison-announce + +** Backward incompatible changes + + Support for DJGPP, which has been unmaintained and untested for years, is + removed. + +** Deprecated features + + A new feature, --update (see below) helps adjusting existing grammars to + deprecations. + +*** Deprecated directives + + The %error-verbose directive is deprecated in favor of '%define + parse.error verbose' since Bison 3.0, but no warning was issued. + + The '%name-prefix "xx"' directive is deprecated in favor of '%define + api.prefix {xx}' since Bison 3.0, but no warning was issued. These + directives are slightly different, you might need to adjust your code. + %name-prefix renames only symbols with external linkage, while api.prefix + also renames types and macros, including YYDEBUG, YYTOKENTYPE, + yytokentype, YYSTYPE, YYLTYPE, etc. + + Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix + {xx}' will typically have to update YY_DECL from + + #define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc) + + to + + #define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc) + +*** Deprecated %define variable names + + The following variables, mostly related to parsers in Java, have been + renamed for consistency. Backward compatibility is ensured, but upgrading + is recommended. + + abstract -> api.parser.abstract + annotations -> api.parser.annotations + extends -> api.parser.extends + final -> api.parser.final + implements -> api.parser.implements + parser_class_name -> api.parser.class + public -> api.parser.public + strictfp -> api.parser.strictfp + +** New features + +*** Generation of fix-its for IDEs/Editors + + When given the new option -ffixit (aka -fdiagnostics-parseable-fixits), + bison now generates machine readable editing instructions to fix some + issues. Currently, this is mostly limited to updating deprecated + directives and removing duplicates. For instance: + + $ cat foo.y + %error-verbose + %define parser_class_name "Parser" + %define api.parser.class "Parser" + %% + exp:; + + See the "fix-it:" lines below: + + $ bison -ffixit foo.y + foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated] + %error-verbose + ^~~~~~~~~~~~~~ + fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose" + foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated] + %define parser_class_name "Parser" + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}" + foo.y:3.1-33: error: %define variable 'api.parser.class' redefined + %define api.parser.class "Parser" + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + foo.y:2.1-34: previous definition + %define parser_class_name "Parser" + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + fix-it:"foo.y":{3:1-3:34}:"" + foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother] + + This uses the same output format as GCC and Clang. + +*** Updating grammar files + + Fixes can be applied on the fly. The previous example ends with the + suggestion to re-run bison with the option -u/--update, which results in a + cleaner grammar file. + + $ bison --update foo.y + [...] + bison: file 'foo.y' was updated (backup: 'foo.y~') + + $ cat foo.y + %define parse.error verbose + %define api.parser.class {Parser} + %% + exp:; + +*** Bison is now relocatable + + If you pass '--enable-relocatable' to 'configure', Bison is relocatable. + + A relocatable program can be moved or copied to a different location on + the file system. It can also be used through mount points for network + sharing. It is possible to make symbolic links to the installed and moved + programs, and invoke them through the symbolic link. + +*** %expect and %expect-rr modifiers on individual rules + + One can now document (and check) which rules participate in shift/reduce + and reduce/reduce conflicts. This is particularly important GLR parsers, + where conflicts are a normal occurrence. For example, + + %glr-parser + %expect 1 + %% + + ... + + argument_list: + arguments %expect 1 + | arguments ',' + | %empty + ; + + arguments: + expression + | argument_list ',' expression + ; + + ... + + Looking at the output from -v, one can see that the shift-reduce conflict + here is due to the fact that the parser does not know whether to reduce + arguments to argument_list until it sees the token _after_ the following + ','. By marking the rule with %expect 1 (because there is a conflict in + one state), we document the source of the 1 overall shift-reduce conflict. + + In GLR parsers, we can use %expect-rr in a rule for reduce/reduce + conflicts. In this case, we mark each of the conflicting rules. For + example, + + %glr-parser + %expect-rr 1 + + %% + + stmt: + target_list '=' expr ';' + | expr_list ';' + ; + + target_list: + target + | target ',' target_list + ; + + target: + ID %expect-rr 1 + ; + + expr_list: + expr + | expr ',' expr_list + ; + + expr: + ID %expect-rr 1 + | ... + ; + + In a statement such as + + x, y = 3, 4; + + the parser must reduce x to a target or an expr, but does not know which + until it sees the '='. So we notate the two possible reductions to + indicate that each conflicts in one rule. + + This feature needs user feedback, and might evolve in the future. + +*** C++: Actual token constructors + + When variants and token constructors are enabled, in addition to the + type-safe named token constructors (make_ID, make_INT, etc.), we now + generate genuine constructors for symbol_type. + + For instance with these declarations + + %token ':' + <std::string> ID + <int> INT; + + you may use these constructors: + + symbol_type (int token, const std::string&); + symbol_type (int token, const int&); + symbol_type (int token); + + Correct matching between token types and value types is checked via + 'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named + constructors are preferable, as they offer better type safety (for + instance 'make_ID (42)' would not even compile), but symbol_type + constructors may help when token types are discovered at run-time, e.g., + + [a-z]+ { + if (auto i = lookup_keyword (yytext)) + return yy::parser::symbol_type (i); + else + return yy::parser::make_ID (yytext); + } + +*** C++: Variadic emplace + + If your application requires C++11 and you don't use symbol constructors, + you may now use a variadic emplace for semantic values: + + %define api.value.type variant + %token <std::pair<int, int>> PAIR + + in your scanner: + + int yylex (parser::semantic_type *lvalp) + { + lvalp->emplace <std::pair<int, int>> (1, 2); + return parser::token::PAIR; + } + +*** C++: Syntax error exceptions in GLR + + The glr.cc skeleton now supports syntax_error exceptions thrown from user + actions, or from the scanner. + +*** More POSIX Yacc compatibility warnings + + More Bison specific directives are now reported with -y or -Wyacc. This + change was ready since the release of Bison 3.0 in September 2015. It was + delayed because Autoconf used to define YACC as `bison -y`, which resulted + in numerous warnings for Bison users that use the GNU Build System. + + If you still experience that problem, either redefine YACC as `bison -o + y.tab.c`, or pass -Wno-yacc to Bison. + +*** The tables yyrhs and yyphrs are back + + Because no Bison skeleton uses them, these tables were removed (no longer + passed to the skeletons, not even computed) in 2008. However, some users + have expressed interest in being able to use them in their own skeletons. + +** Bug fixes + +*** Incorrect number of reduce-reduce conflicts + + On a grammar such as + + exp: "num" | "num" | "num" + + bison used to report a single RR conflict, instead of two. This is now + fixed. This was the oldest (known) bug in Bison: it was there when Bison + was entered in the RCS version control system, in December 1987. + + Some grammar files might have to adjust their %expect-rr. + +*** Parser directives that were not careful enough + + Passing invalid arguments to %nterm, for instance character literals, used + to result in unclear error messages. + +** Documentation + + The examples/ directory (installed in .../share/doc/bison/examples) has + been restructured per language for clarity. The examples come with a + README and a Makefile. Not only can they be used to toy with Bison, they + can also be starting points for your own grammars. + + There is now a Java example, and a simple example in C based on Flex and + Bison (examples/c/lexcalc/). + +** Changes + +*** Parsers in C++ + + They now use noexcept and constexpr. Please, report missing annotations. + +*** Symbol Declarations + + The syntax of the variation directives to declare symbols was overhauled + for more consistency, and also better POSIX Yacc compliance (which, for + instance, allows "%type" without actually providing a type). The %nterm + directive, supported by Bison since its inception, is now documented and + officially supported. + + The syntax is now as follows: + + %token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )* + %left TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )* + %type TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )* + %nterm TAG? ID+ ( TAG ID+ )* + + where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier + such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or + ‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string + literal such as ‘"number"’. The post-fix quantifiers are ‘?’ (zero or + one), ‘*’ (zero or more) and ‘+’ (one or more). + * Noteworthy changes in release 3.2.4 (2018-12-24) [stable] ** Bug fixes @@ -32,7 +361,7 @@ GNU Bison NEWS ** Backward incompatible changes - Support for DJGPP, which have been unmaintained and untested for years, is + Support for DJGPP, which has been unmaintained and untested for years, is obsolete. Unless there is activity to revive it, it will be removed. ** Changes @@ -202,7 +531,7 @@ GNU Bison NEWS release of Bison 3.0, five years ago. Generated parsers do not require a C99 compiler. - Support for DJGPP, which have been unmaintained and untested for years, is + Support for DJGPP, which has been unmaintained and untested for years, is obsolete. Unless there is activity to revive it, the next release of Bison will have it removed. @@ -517,7 +846,7 @@ GNU Bison NEWS Traditional Yacc generates 'y.tab.c' whatever the name of the input file. Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly - 'y.tab.h' and 'y.outout') to be generated from 'foo.y'. + 'y.tab.h' and 'y.output') to be generated from 'foo.y'. To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an implementation of Yacc, was using Bison as 'bison -y'. While it does @@ -3112,7 +3441,7 @@ Output file does not redefine const for C++. ----- -Copyright (C) 1995-2015, 2018 Free Software Foundation, Inc. +Copyright (C) 1995-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Parser Generator. @@ -3154,10 +3483,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir - LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles outout PROG - LocalWords: Heimbigner AST src ast Makefile srcdir MinGW + LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num + LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE + LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits + LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README + LocalWords: noexcept constexpr ispell american deprecations Local Variables: +ispell-dictionary: "american" mode: outline fill-column: 76 End: diff --git a/contrib/tools/bison/README b/contrib/tools/bison/README index 9f266533b3..7fa1bfe949 100644 --- a/contrib/tools/bison/README +++ b/contrib/tools/bison/README @@ -2,31 +2,40 @@ This package contains the GNU Bison parser generator. * Installation ** Build -See the file INSTALL for generic compilation and installation -instructions. +See the file INSTALL for generic compilation and installation instructions. Bison requires GNU m4 1.4.6 or later. See: https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz +** Relocatability +If you pass '--enable-relocatable' to 'configure', Bison is relocatable. + +A relocatable program can be moved or copied to a different location on the +file system. It can also be used through mount points for network sharing. +It is possible to make symlinks to the installed and moved programs, and +invoke them through the symlink. + +See "Enabling Relocatability" in the documentation. + ** Internationalization Bison supports two catalogs: one for Bison itself (i.e., for the -maintainer-side parser generation), and one for the generated parsers -(i.e., for the user-side parser execution). The requirements between -both differ: bison needs ngettext, the generated parsers do not. To -simplify the build system, neither are installed if ngettext is not -supported, even if generated parsers could have been localized. See -http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for -more details. +maintainer-side parser generation), and one for the generated parsers (i.e., +for the user-side parser execution). The requirements between both differ: +bison needs ngettext, the generated parsers do not. To simplify the build +system, neither are installed if ngettext is not supported, even if +generated parsers could have been localized. See +http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for more +details. * Questions -See the section FAQ in the documentation (doc/bison.info) for -frequently asked questions. The documentation is also available in -PDF and HTML, provided you have a recent version of Texinfo installed: -run "make pdf" or "make html". +See the section FAQ in the documentation (doc/bison.info) for frequently +asked questions. The documentation is also available in PDF and HTML, +provided you have a recent version of Texinfo installed: run "make pdf" or +"make html". -If you have questions about using Bison and the documentation does -not answer them, please send mail to <help-bison@gnu.org>. +If you have questions about using Bison and the documentation does not +answer them, please send mail to <help-bison@gnu.org>. * Bug reports Please send bug reports to <bug-bison@gnu.org>. Be sure to include the @@ -34,8 +43,8 @@ version number from 'bison --version', and a complete, self-contained test case in each bug report. * Copyright statements -For any copyright year range specified as YYYY-ZZZZ in this package, -note that the range specifies every single year in that closed interval. +For any copyright year range specified as YYYY-ZZZZ in this package, note +that the range specifies every single year in that closed interval. ----- @@ -45,8 +54,8 @@ fill-column: 76 ispell-dictionary: "american" End: -Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software -Foundation, Inc. +Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2019 Free +Software Foundation, Inc. This file is part of GNU bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/README-alpha b/contrib/tools/bison/README-alpha index 8c1742ce89..c4effc4932 100644 --- a/contrib/tools/bison/README-alpha +++ b/contrib/tools/bison/README-alpha @@ -12,7 +12,8 @@ the problems you encounter. ----- -Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, Inc. +Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, +Inc. This file is part of GNU Bison. diff --git a/contrib/tools/bison/data/README b/contrib/tools/bison/data/README index 798750f7a9..ed217365b4 100644 --- a/contrib/tools/bison/data/README +++ b/contrib/tools/bison/data/README @@ -1,8 +1,9 @@ This directory contains data needed by Bison. -* Skeletons -Bison skeletons: the general shapes of the different parser kinds, -that are specialized for specific grammars by the bison program. +# Directory content +## Skeletons +Bison skeletons: the general shapes of the different parser kinds, that are +specialized for specific grammars by the bison program. Currently, the supported skeletons are: @@ -22,19 +23,18 @@ Currently, the supported skeletons are: - glr.cc A Generalized LR C++ parser. Actually a C++ wrapper around glr.c. -These skeletons are the only ones supported by the Bison team. -Because the interface between skeletons and the bison program is not -finished, *we are not bound to it*. In particular, Bison is not -mature enough for us to consider that "foreign skeletons" are -supported. +These skeletons are the only ones supported by the Bison team. Because the +interface between skeletons and the bison program is not finished, *we are +not bound to it*. In particular, Bison is not mature enough for us to +consider that "foreign skeletons" are supported. -* m4sugar -This directory contains M4sugar, sort of an extended library for M4, -which is used by Bison to instantiate the skeletons. +## m4sugar +This directory contains M4sugar, sort of an extended library for M4, which +is used by Bison to instantiate the skeletons. -* xslt -This directory contains XSLT programs that transform Bison's XML output -into various formats. +## xslt +This directory contains XSLT programs that transform Bison's XML output into +various formats. - bison.xsl A library of routines used by the other XSLT programs. @@ -48,13 +48,132 @@ into various formats. - xml2xhtml.xsl Conversion into XHTML. +# Implementation note about the skeletons + +"Skeleton" in Bison parlance means "backend": a skeleton is fed by the bison +executable with LR tables, facts about the symbols, etc. and they generate +the output (say parser.cc, parser.hh, location.hh, etc.). They are only in +charge of generating the parser and its auxiliary files, they do not +generate the XML output, the parser.output reports, nor the graphical +rendering. + +The bits of information passing from bison to the backend is named +"muscles". Muscles are passed to M4 via its standard input: it's a set of +m4 definitions. To see them, use `--trace=muscles`. + +Except for muscles, whose names are generated by bison, the skeletons have +no constraint at all on the macro names: there is no technical/theoretical +limitation, as long as you generate the output, you can do what you want. +However, of course, that would be a bad idea if, say, the C and C++ +skeletons used different approaches and had completely different +implementations. That would be a maintenance nightmare. + +Below, we document some of the macros that we use in several of the +skeletons. If you are to write a new skeleton, please, implement them for +your language. Overall, be sure to follow the same patterns as the existing +skeletons. + +## Symbols + +### `b4_symbol(NUM, FIELD)` +In order to unify the handling of the various aspects of symbols (tag, type +name, whether terminal, etc.), bison.exe defines one macro per (token, +field), where field can `has_id`, `id`, etc.: see +`prepare_symbols_definitions()` in `src/output.c`. + +The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS: + +- `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. + +- `tag`: string. + A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc. + +- `user_number`: integer + 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. + +- `is_token`: 0 or 1 + Whether this is a terminal symbol. + +- `number`: integer + 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). + + In bison, symbols are first assigned increasing numbers in order of + appearance (but tokens first, then nterms). After grammar reduction, + unused nterms are then renumbered to appear last (i.e., first tokens, then + used nterms and finally unused nterms). This final number NUM is the one + contained in this field, and it is the one used as key in `b4_symbol(NUM, + FIELD)`. + + The code of the rule actions, however, is emitted before we know what + symbols are unused, so they use the original numbers. To avoid confusion, + they actually use "orig NUM" instead of just "NUM". bison also emits + definitions for `b4_symbol(orig NUM, number)` that map from original + numbers to the new ones. `b4_symbol` actually resolves `orig NUM` in the + other case, i.e., `b4_symbol(orig 42, tag)` would return the tag of the + symbols whose original number was 42. + +- `has_type`: 0, 1 + Whether has a semantic value. + +- `type_tag`: string + When api.value.type=union, the generated name for the union member. + yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc. + +- `type` + If it has a semantic value, its type tag, or, if variant are used, + its type. + In the case of api.value.type=union, type is the real type (e.g. int). + +- `has_printer`: 0, 1 +- `printer`: string +- `printer_file`: string +- `printer_line`: integer + If the symbol has a printer, everything about it. + +- `has_destructor`, `destructor`, `destructor_file`, `destructor_line` + Likewise. + +### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])` +Expansion of $$, $1, $<TYPE-TAG>3, etc. + +The semantic value from a given VAL. +- `VAL`: some semantic value storage (typically a union). e.g., `yylval` +- `SYMBOL-NUM`: the symbol number from which we extract the type tag. +- `TYPE-TAG`, the user forced the `<TYPE-TAG>`. + +The result can be used safely, it is put in parens to avoid nasty precedence +issues. + +### `b4_lhs_value(SYMBOL-NUM, [TYPE])` +Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`. + +### `b4_rhs_data(RULE-LENGTH, POS)` +The data corresponding to the symbol `#POS`, where the current rule has +`RULE-LENGTH` symbols on RHS. + +### `b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])` +Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols +on RHS. + ----- Local Variables: -mode: outline +mode: markdown +fill-column: 76 +ispell-dictionary: "american" End: -Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc. +Copyright (C) 2002, 2008-2015, 2018-2019 Free Software Foundation, Inc. This file is part of GNU Bison. diff --git a/contrib/tools/bison/data/skeletons/README-D.txt b/contrib/tools/bison/data/skeletons/README-D.txt new file mode 100644 index 0000000000..214e309923 --- /dev/null +++ b/contrib/tools/bison/data/skeletons/README-D.txt @@ -0,0 +1,60 @@ +Some usage notes for the D Parser: + +- it is a port of the Java parser, so interface is very similar. + +- the lexer class needs to implement the interface 'Lexer' (similar to + java). It typically (depending on options) looks like this: + +public interface Lexer +{ + /** + * Method to retrieve the beginning position of the last scanned token. + * @return the position at which the last scanned token starts. */ + @property YYPosition startPos (); + + /** + * Method to retrieve the ending position of the last scanned token. + * @return the first position beyond the last scanned token. */ + @property YYPosition endPos (); + + /** + * Method to retrieve the semantic value of the last scanned token. + * @return the semantic value of the last scanned token. */ + @property YYSemanticType semanticVal (); + + /** + * Entry point for the scanner. Returns the token identifier corresponding + * 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 (); + + /** + * Entry point for error reporting. Emits an error + * referring to the given location in a user-defined way. + * + * @param loc The location of the element to which the + * error message is related + * @param s The string for the error message. */ + void yyerror (YYLocation loc, string s); +} + +- semantic types are handled by D usions (same as for C/C++ parsers) + +- the following (non-standard) %defines are supported: + + %define package "<package_name>" + %define api.parser.class "my_class_name>" + %define position_type "my_position_type" + %define location_type "my_location_type" + +- the following declarations basically work like in C/C++: + + %locations + %error-verbose + %parse-param + %initial-action + %code + %union + +- %destructor is not yet supported diff --git a/contrib/tools/bison/data/bison.m4 b/contrib/tools/bison/data/skeletons/bison.m4 index d2db2c86ee..e3591875c0 100644 --- a/contrib/tools/bison/data/bison.m4 +++ b/contrib/tools/bison/data/skeletons/bison.m4 @@ -2,7 +2,8 @@ # Language-independent M4 Macros for Bison. -# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018-2019 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 @@ -263,8 +264,8 @@ m4_define([b4_subtract], # ------------------- # Join with comma, skipping empty arguments. # b4_join calls itself recursively until it sees the first non-empty -# argument, then calls _b4_join which prepends each non-empty argument -# with a comma. +# argument, then calls _b4_join (i.e., `_$0`) which prepends each +# non-empty argument with a comma. m4_define([b4_join], [m4_if([$#$1], [1], [], @@ -374,60 +375,42 @@ b4_define_flag_if([token_table]) # Whether yytoken_table is demanded. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. +# b4_glr_cc_if([IF-TRUE], [IF-FALSE]) +# ----------------------------------- +m4_define([b4_glr_cc_if], + [m4_if(b4_skeleton, ["glr.cc"], $@)]) + + ## --------- ## ## Symbols. ## ## --------- ## -# In order to unify the handling of the various aspects of symbols -# (tag, type_name, whether terminal, etc.), bison.exe defines one -# macro per (token, field), where field can has_id, id, etc.: see -# src/output.c:prepare_symbols_definitions(). -# -# The various FIELDS are: +# For a description of the Symbol handling, see README. # -# - has_id: 0 or 1. -# Whether the symbol has an id. -# - id: string -# If has_id, the id. Guaranteed to be usable as a C identifier. -# Prefixed by api.token.prefix if defined. -# - tag: string. -# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc. -# - user_number: integer -# The assigned (external) number as used by yylex. -# - is_token: 0 or 1 -# Whether this is a terminal symbol. -# - number: integer -# The internalized number (used after yytranslate). -# - has_type: 0, 1 -# Whether has a semantic value. -# - type_tag: string -# When api.value.type=union, the generated name for the union member. -# yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc. -# - type -# If it has a semantic value, its type tag, or, if variant are used, -# its type. -# In the case of api.value.type=union, type is the real type (e.g. int). -# - has_printer: 0, 1 -# - printer: string -# - printer_file: string -# - printer_line: integer -# If the symbol has a printer, everything about it. -# - has_destructor, destructor, destructor_file, destructor_line -# Likewise. -# -# The following macros provide access to these values. +# 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. +m4_define([__b4_symbol], +[m4_indir([b4_symbol($1, $2)])]) + # _b4_symbol(NUM, FIELD) # ---------------------- -# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if +# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if # undefined. m4_define([_b4_symbol], -[m4_indir([b4_symbol($1, $2)])]) +[m4_ifdef([b4_symbol($1, number)], + [__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)], + [__b4_symbol([$1], [$2])])]) + # b4_symbol(NUM, FIELD) # --------------------- -# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if +# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if # undefined. If FIELD = id, prepend the token prefix. m4_define([b4_symbol], [m4_case([$2], @@ -468,8 +451,8 @@ m4_define([b4_symbol_action_location], m4_define([b4_symbol_action], [b4_symbol_if([$1], [has_$2], [b4_dollar_pushdef([(*yyvaluep)], - b4_symbol_if([$1], [has_type], - [m4_dquote(b4_symbol([$1], [type]))]), + [$1], + [], [(*yylocationp)])dnl _b4_symbol_case([$1])[]dnl b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) @@ -497,7 +480,7 @@ m4_define([b4_symbol_actions], m4_ifval(m4_defn([b4_actions_]), [switch (m4_default([$2], [yytype])) { - m4_defn([b4_actions_]) +m4_defn([b4_actions_])[]dnl default: break; }dnl @@ -508,7 +491,9 @@ m4_popdef([b4_actions_])dnl # _b4_symbol_case(SYMBOL-NUM) # --------------------------- -# Issue a "case NUM" for SYMBOL-NUM. +# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it +# easier to use with m4_map, but then, use []dnl to suppress the last +# one. m4_define([_b4_symbol_case], [case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])]) ]) @@ -569,7 +554,7 @@ m4_define([b4_token_format], # Run actions for the symbol NUMS that all have the same type-name. # Skip NUMS that have no type-name. # -# To specify the action to run, define b4_dollar_dollar(NUMBER, +# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM, # TAG, TYPE). m4_define([_b4_type_action], [b4_symbol_if([$1], [has_type], diff --git a/contrib/tools/bison/data/c++-skel.m4 b/contrib/tools/bison/data/skeletons/c++-skel.m4 index 3cd56789f3..1c3721cdbb 100644 --- a/contrib/tools/bison/data/c++-skel.m4 +++ b/contrib/tools/bison/data/skeletons/c++-skel.m4 @@ -2,8 +2,8 @@ # C++ skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, -# Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018-2019 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 @@ -18,10 +18,10 @@ # 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_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])]) -b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])]) +b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])]) +b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])]) -m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.cc]]) +m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]]) m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"]) m4_include(b4_used_skeleton) diff --git a/contrib/tools/bison/data/c++.m4 b/contrib/tools/bison/data/skeletons/c++.m4 index 9783293bfe..35008f3745 100644 --- a/contrib/tools/bison/data/c++.m4 +++ b/contrib/tools/bison/data/skeletons/c++.m4 @@ -2,7 +2,7 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2019 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 @@ -22,10 +22,10 @@ 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++])]) -m4_include(b4_pkgdatadir/[c.m4]) +m4_include(b4_skeletonsdir/[c.m4]) b4_percent_define_check_kind([api.namespace], [code], [deprecated]) -b4_percent_define_check_kind([parser_class_name], [code], [deprecated]) +b4_percent_define_check_kind([api.parser.class], [code], [deprecated]) ## ----- ## @@ -72,6 +72,22 @@ m4_define([b4_cxx_portability], # define YY_MOVE_REF(Type) Type& # define YY_RVREF(Type) const Type& # define YY_COPY(Type) const Type& +#endif + +// Support noexcept when possible. +#if 201103L <= YY_CPLUSPLUS +# define YY_NOEXCEPT noexcept +# define YY_NOTHROW +#else +# define YY_NOEXCEPT +# define YY_NOTHROW throw () +#endif + +// Support constexpr when possible. +#if 201703 <= YY_CPLUSPLUS +# define YY_CONSTEXPR constexpr +#else +# define YY_CONSTEXPR #endif[]dnl ]) @@ -80,7 +96,7 @@ m4_define([b4_cxx_portability], ## Default values. ## ## ---------------- ## -b4_percent_define_default([[parser_class_name]], [[parser]]) +b4_percent_define_default([[api.parser.class]], [[parser]]) # Don't do that so that we remember whether we're using a user # request, or the default value. @@ -200,7 +216,18 @@ m4_define([b4_public_types_declare], /// Syntax errors thrown from user actions. struct syntax_error : std::runtime_error { - syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m);]b4_locations_if([ + syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) + : std::runtime_error (m)]b4_locations_if([ + , location (l)])[ + {} + + syntax_error (const syntax_error& s) + : std::runtime_error (s.what ())]b4_locations_if([ + , location (s.location)])[ + {} + + ~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([ + location_type location;])[ }; @@ -224,11 +251,11 @@ m4_define([b4_public_types_declare], ]]) -# b4_symbol_type_declare -# ---------------------- +# b4_symbol_type_define +# --------------------- # Define symbol_type, the external type for symbols used for symbol # constructors. -m4_define([b4_symbol_type_declare], +m4_define([b4_symbol_type_define], [[ /// A complete symbol. /// /// Expects its Base type to provide access to the symbol type @@ -242,7 +269,10 @@ m4_define([b4_symbol_type_declare], typedef Base super_type; /// Default constructor. - basic_symbol (); + basic_symbol () + : value ()]b4_locations_if([ + , location ()])[ + {} #if 201103L <= YY_CPLUSPLUS /// Move constructor. @@ -250,11 +280,10 @@ m4_define([b4_symbol_type_declare], #endif /// Copy constructor. - basic_symbol (const basic_symbol& that); + basic_symbol (const basic_symbol& that);]b4_variant_if([[ -]b4_variant_if([[ /// Constructor for valueless symbols, and symbols from each type. -]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[ +]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ /// Constructor for valueless symbols. basic_symbol (typename Base::kind_type t]b4_locations_if([, YY_MOVE_REF (location_type) l])[); @@ -262,16 +291,35 @@ m4_define([b4_symbol_type_declare], /// Constructor for symbols with semantic value. basic_symbol (typename Base::kind_type t, YY_RVREF (semantic_type) v]b4_locations_if([, - YY_RVREF (location_type) l])[);]])[ - + YY_RVREF (location_type) l])[); +]])[ /// Destroy the symbol. - ~basic_symbol (); + ~basic_symbol () + { + clear (); + } /// Destroy contents, and record that is empty. - void clear (); + void clear () + {]b4_variant_if([[ + // User destructor. + symbol_number_type yytype = this->type_get (); + basic_symbol<Base>& yysym = *this; + (void) yysym; + switch (yytype) + { +]b4_symbol_foreach([b4_symbol_destructor])dnl +[ default: + break; + } + + // Type destructor. +]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[ + Base::clear (); + } /// Whether empty. - bool empty () const; + bool empty () const YY_NOEXCEPT; /// Destructive move, \a s is emptied into this. void move (basic_symbol& s); @@ -317,10 +365,10 @@ m4_define([b4_symbol_type_declare], /// The (internal) type number (corresponding to \a type). /// \a empty when empty. - symbol_number_type type_get () const; + symbol_number_type type_get () const YY_NOEXCEPT; /// The token. - token_type token () const; + token_type token () const YY_NOEXCEPT; /// The symbol type. /// \a empty_symbol when empty. @@ -329,7 +377,17 @@ m4_define([b4_symbol_type_declare], }; /// "External" symbols: returned by the scanner. - typedef basic_symbol<by_type> symbol_type; + struct symbol_type : basic_symbol<by_type> + {]b4_variant_if([[ + /// Superclass. + typedef basic_symbol<by_type> super_type; + + /// Empty symbol. + symbol_type () {} + + /// Constructor for valueless symbols, and symbols from each type. +]b4_type_foreach([_b4_token_constructor_define])dnl + ])[}; ]]) @@ -337,46 +395,33 @@ m4_define([b4_symbol_type_declare], # ----------------------------- # Provide the implementation needed by the public types. m4_define([b4_public_types_define], -[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) - : std::runtime_error (m)]b4_locations_if([ - , location (l)])[ - {} - - // basic_symbol. - template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol () - : value ()]b4_locations_if([ - , location ()])[ - {} - +[[ // basic_symbol. #if 201103L <= YY_CPLUSPLUS template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (basic_symbol&& that) + ]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)])])[ - } + [std::move (that.value)]) + ])[} #endif template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& that) + ]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], - [that.value])])[ - } + [YY_MOVE (that.value)]) + ])[} -]b4_variant_if([[ - // Implementation of basic_symbol constructor for each type. -]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ +]b4_variant_if([], [[ /// Constructor for valueless symbols. template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( + ]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], b4_locations_if([YY_MOVE_REF (location_type) l]))[) : Base (t) @@ -385,7 +430,7 @@ m4_define([b4_public_types_define], {} template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( + ]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join( [typename Base::kind_type t], [YY_RVREF (semantic_type) v], b4_locations_if([YY_RVREF (location_type) l]))[) @@ -397,41 +442,15 @@ m4_define([b4_public_types_define], ]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[ template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol () - { - clear (); - } - - template <typename Base> - void - ]b4_parser_class_name[::basic_symbol<Base>::clear () - {]b4_variant_if([[ - // User destructor. - symbol_number_type yytype = this->type_get (); - basic_symbol<Base>& yysym = *this; - (void) yysym; - switch (yytype) - { -]b4_symbol_foreach([b4_symbol_destructor])dnl -[ default: - break; - } - - // Type destructor. - ]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[ - Base::clear (); - } - - template <typename Base> bool - ]b4_parser_class_name[::basic_symbol<Base>::empty () const + ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT { return Base::type_get () == empty_symbol; } template <typename Base> void - ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s) + ]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], @@ -441,47 +460,47 @@ m4_define([b4_public_types_define], } // by_type. - ]b4_inline([$1])b4_parser_class_name[::by_type::by_type () + ]b4_inline([$1])b4_parser_class[::by_type::by_type () : type (empty_symbol) {} #if 201103L <= YY_CPLUSPLUS - ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (by_type&& that) + ]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that) : type (that.type) { that.clear (); } #endif - ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& that) + ]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that) : type (that.type) {} - ]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t) + ]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t) : type (yytranslate_ (t)) {} ]b4_inline([$1])[void - ]b4_parser_class_name[::by_type::clear () + ]b4_parser_class[::by_type::clear () { type = empty_symbol; } ]b4_inline([$1])[void - ]b4_parser_class_name[::by_type::move (by_type& that) + ]b4_parser_class[::by_type::move (by_type& that) { type = that.type; that.clear (); } ]b4_inline([$1])[int - ]b4_parser_class_name[::by_type::type_get () const + ]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT { return type; } ]b4_token_ctor_if([[ - ]b4_inline([$1])b4_parser_class_name[::token_type - ]b4_parser_class_name[::by_type::token () const + ]b4_inline([$1])b4_parser_class[::token_type + ]b4_parser_class[::by_type::token () const YY_NOEXCEPT { // YYTOKNUM[NUM] -- (External) token number corresponding to the // (internal) symbol number NUM (which must be that of a token). */ @@ -491,20 +510,17 @@ m4_define([b4_public_types_define], { ]b4_toknum[ }; - return static_cast<token_type> (yytoken_number_[type]); + return token_type (yytoken_number_[type]); } ]])[]dnl - -b4_symbol_constructor_define]) +]) -# b4_symbol_constructor_declare -# b4_symbol_constructor_define -# ----------------------------- -# Declare/define symbol constructors for all the value types. +# b4_token_constructor_define +# ---------------------------- +# Define symbol constructors for all the value types. # Use at class-level. Redefined in variant.hh. -m4_define([b4_symbol_constructor_declare], []) -m4_define([b4_symbol_constructor_define], []) +m4_define([b4_token_constructor_define], []) # b4_yytranslate_define(cc|hh) @@ -512,16 +528,17 @@ m4_define([b4_symbol_constructor_define], []) # Define yytranslate_. Sometimes used in the header file ($1=hh), # sometimes in the cc file. m4_define([b4_yytranslate_define], -[[ // Symbol number corresponding to token number t. - ]b4_inline([$1])b4_parser_class_name[::token_number_type - ]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type], +[ b4_inline([$1])b4_parser_class[::token_number_type + ]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t) { + // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to + // TOKEN-NUM as returned by yylex. static const token_number_type translate_table[] = { -]b4_translate[ + ]b4_translate[ }; const unsigned user_token_number_max_ = ]b4_user_token_number_max[; const token_number_type undef_token_ = ]b4_undef_token_number[; @@ -538,15 +555,13 @@ m4_define([b4_yytranslate_define], # b4_lhs_value([TYPE]) # -------------------- -# Expansion of $<TYPE>$. m4_define([b4_lhs_value], [b4_symbol_value([yyval], [$1])]) -# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) +# b4_rhs_value(RULE-LENGTH, POS, [TYPE]) # -------------------------------------- -# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH -# symbols on RHS. +# FIXME: Dead code. m4_define([b4_rhs_value], [b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])]) @@ -558,9 +573,9 @@ m4_define([b4_lhs_location], [(yyloc)]) -# b4_rhs_location(RULE-LENGTH, NUM) +# b4_rhs_location(RULE-LENGTH, POS) # --------------------------------- -# Expansion of @NUM, where the current rule has RULE-LENGTH symbols +# Expansion of @POS, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], [(yylocation_stack_@{($1) - ($2)@})]) @@ -633,7 +648,7 @@ m4_define([b4_yylloc_default_define], { \ (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ } \ - while (/*CONSTCOND*/ false) + while (false) # endif ]]) diff --git a/contrib/tools/bison/data/c-like.m4 b/contrib/tools/bison/data/skeletons/c-like.m4 index 4e476ac88e..8d891b67ef 100644 --- a/contrib/tools/bison/data/c-like.m4 +++ b/contrib/tools/bison/data/skeletons/c-like.m4 @@ -2,7 +2,7 @@ # Common code for C-like languages (C, C++, Java, etc.) -# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2012-2015, 2018-2019 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 @@ -39,25 +39,26 @@ m4_define([b4_comment], -# _b4_dollar_dollar(VALUE, FIELD, DEFAULT-FIELD) -# ---------------------------------------------- +# _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD) +# ---------------------------------------------------------- # If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD", -# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a +# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a # pointer. m4_define([_b4_dollar_dollar], [b4_symbol_value([$1], - m4_if([$2], [[]], - [[$3]], [[$2]]))]) + [$2], + m4_if([$3], [[]], + [[$4]], [[$3]]))]) -# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION) +# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION) # b4_dollar_popdef -# --------------------------------------------------------- -# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD, +# ------------------------------------------------------------------ +# Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD, # and b4_at_dollar for LOCATION. m4_define([b4_dollar_pushdef], [m4_pushdef([b4_dollar_dollar], - [_b4_dollar_dollar([$1], m4_dquote($][1), [$2])])dnl -m4_pushdef([b4_at_dollar], [$3])dnl + [_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl +m4_pushdef([b4_at_dollar], [$4])dnl ]) m4_define([b4_dollar_popdef], [m4_popdef([b4_at_dollar])dnl diff --git a/contrib/tools/bison/data/c-skel.m4 b/contrib/tools/bison/data/skeletons/c-skel.m4 index cb9a7a21a9..2a21cfc7d0 100644 --- a/contrib/tools/bison/data/c-skel.m4 +++ b/contrib/tools/bison/data/skeletons/c-skel.m4 @@ -2,8 +2,8 @@ # C skeleton dispatching for Bison. -# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, -# Inc. +# Copyright (C) 2006-2007, 2009-2015, 2018-2019 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 @@ -18,10 +18,10 @@ # 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_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])]) -b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])]) +b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])]) +b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])]) -m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[yacc.c]]) +m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[yacc.c]]) m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"]) m4_include(b4_used_skeleton) diff --git a/contrib/tools/bison/data/c.m4 b/contrib/tools/bison/data/skeletons/c.m4 index bb19b34826..3cde04a957 100644 --- a/contrib/tools/bison/data/c.m4 +++ b/contrib/tools/bison/data/skeletons/c.m4 @@ -2,7 +2,8 @@ # C M4 Macros for Bison. -# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004-2015, 2018-2019 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 @@ -17,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -m4_include(b4_pkgdatadir/[c-like.m4]) +m4_include(b4_skeletonsdir/[c-like.m4]) # b4_tocpp(STRING) # ---------------- @@ -373,15 +374,17 @@ m4_define([b4_token_enums_defines], ## ----------------- ## -# b4_symbol_value(VAL, [TYPE]) -# ---------------------------- -# Given a semantic value VAL ($$, $1 etc.), extract its value of type -# TYPE if TYPE is given, otherwise just return VAL. The result can be -# used safely, it is put in parens to avoid nasty precedence issues. -# TYPE is *not* put in braces, provide some if needed. +# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG]) +# ---------------------------------------------- +# See README. m4_define([b4_symbol_value], -[($1[]m4_ifval([$2], [.$2]))]) - +[m4_ifval([$3], + [($1.$3)], + [m4_ifval([$2], + [b4_symbol_if([$2], [has_type], + [($1.b4_symbol([$2], [type]))], + [$1])], + [$1])])]) ## ---------------------- ## @@ -604,14 +607,17 @@ m4_define([b4_type_define_tag], ]) -# b4_symbol_value_union(VAL, [TYPE]) -# ---------------------------------- +# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE]) +# ---------------------------------------------- # Same of b4_symbol_value, but when api.value.type=union. m4_define([b4_symbol_value_union], -[m4_ifval([$2], - [(*($2*)(&$1))], - [$1])]) -]) +[m4_ifval([$3], + [(*($3*)(&$1))], + [m4_ifval([$2], + [b4_symbol_if([$2], [has_type], + [($1.b4_symbol([$2], [type_tag]))], + [$1])], + [$1])])]) # b4_value_type_setup_union diff --git a/contrib/tools/bison/data/glr.cc b/contrib/tools/bison/data/skeletons/glr.cc index 0401b8492c..5621734163 100644 --- a/contrib/tools/bison/data/glr.cc +++ b/contrib/tools/bison/data/skeletons/glr.cc @@ -1,6 +1,6 @@ # C++ GLR skeleton for Bison -# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018-2019 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 @@ -46,11 +46,11 @@ # We require a pure interface. m4_define([b4_pure_flag], [1]) -m4_include(b4_pkgdatadir/[c++.m4]) -b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])]) +m4_include(b4_skeletonsdir/[c++.m4]) +b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])]) -m4_define([b4_parser_class_name], - [b4_percent_define_get([[parser_class_name]])]) +m4_define([b4_parser_class], + [b4_percent_define_get([[api.parser.class]])]) # Save the parse parameters. m4_define([b4_parse_param_orig], m4_defn([b4_parse_param])) @@ -60,10 +60,10 @@ m4_define([b4_parse_param_orig], m4_defn([b4_parse_param])) # New ones. m4_ifset([b4_parse_param], [m4_define([b4_parse_param_wrap], - [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],] + [[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]],] m4_defn([b4_parse_param]))], [m4_define([b4_parse_param_wrap], - [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]]) + [[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]]) ]) @@ -81,10 +81,10 @@ m4_define([b4_yy_symbol_print_define], [static void], [[FILE *], []], [[int yytype], [yytype]], - [[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep], + [[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep], [yyvaluep]][]dnl b4_locations_if([, - [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], [yylocationp]]]), b4_parse_param)[ { @@ -98,18 +98,15 @@ b4_locations_if([, [yylloc.initialize ();]m4_ifdef([b4_initial_action], [ m4_defn([b4_initial_action])]))])[ -# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT -# and declaration of yyerror. +# Hijack the post prologue to declare yyerror. ]m4_append([b4_post_prologue], [b4_syncline([@oline@], [@ofile@])[ -]b4_yylloc_default_define[ -#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) ]b4_function_declare([yyerror], [static void],b4_locations_if([ - [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], [yylocationp]],]) b4_parse_param, - [[const char* msg], [msg]])]) + [[const char* msg], [msg]])])[ #undef yynerrs @@ -122,8 +119,7 @@ m4_if(b4_prefix, [yy], [], #define yyparse ]b4_prefix[parse #define yylex ]b4_prefix[lex #define yyerror ]b4_prefix[error -#define yydebug ]b4_prefix[debug -]]b4_pure_if([], [[ +#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([[ @@ -140,7 +136,7 @@ m4_append([b4_epilogue], ]b4_function_define([yyerror], [static void],b4_locations_if([ - [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp], + [[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp], [yylocationp]],]) b4_parse_param, [[const char* msg], [msg]])[ @@ -154,26 +150,27 @@ m4_append([b4_epilogue], ]dnl In this section, the parse params are the original parse_params. m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl [ /// Build a parser object. - ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ + ]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ :])[ #if ]b4_api_PREFIX[DEBUG ]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ #endif]b4_parse_param_cons[ - { - } + {} - ]b4_parser_class_name::~b4_parser_class_name[ () - { - } + ]b4_parser_class::~b4_parser_class[ () + {} + + ]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW + {} int - ]b4_parser_class_name[::operator() () + ]b4_parser_class[::operator() () { return parse (); } int - ]b4_parser_class_name[::parse () + ]b4_parser_class[::parse () { return ::yyparse (*this]b4_user_args[); } @@ -184,7 +181,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl `--------------------*/ void - ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, + ]b4_parser_class[::yy_symbol_value_print_ (int yytype, const semantic_type* yyvaluep]b4_locations_if([[, const location_type* yylocationp]])[) {]b4_locations_if([[ @@ -198,7 +195,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl void - ]b4_parser_class_name[::yy_symbol_print_ (int yytype, + ]b4_parser_class[::yy_symbol_print_ (int yytype, const semantic_type* yyvaluep]b4_locations_if([[, const location_type* yylocationp]])[) { @@ -210,26 +207,26 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl } std::ostream& - ]b4_parser_class_name[::debug_stream () const + ]b4_parser_class[::debug_stream () const { return *yycdebug_; } void - ]b4_parser_class_name[::set_debug_stream (std::ostream& o) + ]b4_parser_class[::set_debug_stream (std::ostream& o) { yycdebug_ = &o; } - ]b4_parser_class_name[::debug_level_type - ]b4_parser_class_name[::debug_level () const + ]b4_parser_class[::debug_level_type + ]b4_parser_class[::debug_level () const { return yydebug; } void - ]b4_parser_class_name[::set_debug_level (debug_level_type l) + ]b4_parser_class[::set_debug_level (debug_level_type l) { // Actually, it is yydebug which is really used. yydebug = l; @@ -252,26 +249,39 @@ b4_percent_code_get([[requires]])[ #include <stdexcept> #include <string> -]m4_ifdef([b4_location_file], +]b4_cxx_portability[ +]m4_ifdef([b4_location_include], [[# include ]b4_location_include])[ +]b4_variant_if([b4_variant_includes])[ +]b4_attribute_define[ ]b4_null_define[ +// Whether we are compiled with exception support. +#ifndef YY_EXCEPTIONS +# if defined __GNUC__ && !defined __EXCEPTIONS +# define YY_EXCEPTIONS 0 +# else +# define YY_EXCEPTIONS 1 +# endif +#endif + ]b4_YYDEBUG_define[ ]b4_namespace_open[ + ]b4_bison_locations_if([m4_ifndef([b4_location_file], [b4_location_define])])[ /// A Bison parser. - class ]b4_parser_class_name[ + class ]b4_parser_class[ { public: ]b4_public_types_declare[ /// Build a parser object. - ]b4_parser_class_name[ (]b4_parse_param_decl[); - virtual ~]b4_parser_class_name[ (); + ]b4_parser_class[ (]b4_parse_param_decl[); + virtual ~]b4_parser_class[ (); /// Parse. An alias for parse (). /// \returns 0 iff parsing succeeded. @@ -281,6 +291,7 @@ b4_percent_code_get([[requires]])[ /// \returns 0 iff parsing succeeded. virtual int parse (); +#if ]b4_api_PREFIX[DEBUG /// The current debugging stream. std::ostream& debug_stream () const; /// Set the current debugging stream. @@ -292,8 +303,8 @@ b4_percent_code_get([[requires]])[ debug_level_type debug_level () const; /// Set the current debugging level. void set_debug_level (debug_level_type l); +#endif - public: /// Report a syntax error.]b4_locations_if([[ /// \param loc where the syntax error is found.]])[ /// \param msg a description of the syntax error. @@ -328,10 +339,10 @@ 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_name[::semantic_type +# 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_name[::location_type +# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type #endif ]b4_namespace_close[ @@ -342,7 +353,7 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]], b4_defines_if( [b4_output_begin([b4_spec_defines_file]) b4_copyright([Skeleton interface for Bison GLR parsers in C++], - [2002-2015, 2018])[ + [2002-2015, 2018-2019])[ // C++ GLR parser skeleton written by Akim Demaille. ]b4_disclaimer[ @@ -354,5 +365,5 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++], # Let glr.c (and b4_shared_declarations) believe that the user # arguments include the parser itself. m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap])) -m4_include(b4_pkgdatadir/[glr.c]) +m4_include(b4_skeletonsdir/[glr.c]) m4_popdef([b4_parse_param]) diff --git a/contrib/tools/bison/data/lalr1.cc b/contrib/tools/bison/data/skeletons/lalr1.cc index b40769d8d6..09f4259f28 100644 --- a/contrib/tools/bison/data/lalr1.cc +++ b/contrib/tools/bison/data/skeletons/lalr1.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018-2019 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 @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -m4_include(b4_pkgdatadir/[c++.m4]) +m4_include(b4_skeletonsdir/[c++.m4]) # api.value.type=variant is valid. m4_define([b4_value_type_setup_variant]) @@ -35,57 +35,55 @@ m4_define([b4_integral_parser_table_declare], # Define "parser::yy<TABLE-NAME>_" whose contents is CONTENT. m4_define([b4_integral_parser_table_define], [ const b4_int_type_for([$2]) - b4_parser_class_name::yy$1_[[]] = + b4_parser_class::yy$1_[[]] = { $2 };dnl ]) -# b4_symbol_value_template(VAL, [TYPE]) -# ------------------------------------- +# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE]) +# ------------------------------------------------- # Same as b4_symbol_value, but used in a template method. It makes # a difference when using variants. Note that b4_value_type_setup_union # overrides b4_symbol_value, so we must override it again. m4_copy([b4_symbol_value], [b4_symbol_value_template]) m4_append([b4_value_type_setup_union], - [m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])]) +[m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])]) -# b4_lhs_value([TYPE]) -# -------------------- -# Expansion of $<TYPE>$. +# b4_lhs_value(SYMBOL-NUM, [TYPE]) +# -------------------------------- +# See README. m4_define([b4_lhs_value], - [b4_symbol_value([yylhs.value], [$1])]) +[b4_symbol_value([yylhs.value], [$1], [$2])]) # b4_lhs_location() # ----------------- # Expansion of @$. m4_define([b4_lhs_location], - [yylhs.location]) +[yylhs.location]) -# b4_rhs_data(RULE-LENGTH, NUM) +# b4_rhs_data(RULE-LENGTH, POS) # ----------------------------- -# Return the data corresponding to the symbol #NUM, where the current -# rule has RULE-LENGTH symbols on RHS. +# See README. m4_define([b4_rhs_data], - [yystack_@{b4_subtract($@)@}]) +[yystack_@{b4_subtract($@)@}]) -# b4_rhs_state(RULE-LENGTH, NUM) +# b4_rhs_state(RULE-LENGTH, POS) # ------------------------------ -# The state corresponding to the symbol #NUM, where the current +# The state corresponding to the symbol #POS, where the current # rule has RULE-LENGTH symbols on RHS. m4_define([b4_rhs_state], - [b4_rhs_data([$1], [$2]).state]) +[b4_rhs_data([$1], [$2]).state]) -# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) -# -------------------------------------- -# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH -# symbols on RHS. +# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE]) +# -------------------------------------------------- +# See README. m4_define([_b4_rhs_value], - [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])]) +[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3], [$4])]) m4_define([b4_rhs_value], [b4_percent_define_ifdef([api.value.automove], @@ -93,12 +91,12 @@ m4_define([b4_rhs_value], [_b4_rhs_value($@)])]) -# b4_rhs_location(RULE-LENGTH, NUM) +# b4_rhs_location(RULE-LENGTH, POS) # --------------------------------- -# Expansion of @NUM, where the current rule has RULE-LENGTH symbols +# Expansion of @POS, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], - [b4_rhs_data([$1], [$2]).location]) +[b4_rhs_data([$1], [$2]).location]) # b4_symbol_action(SYMBOL-NUM, KIND) @@ -109,10 +107,10 @@ m4_define([b4_symbol_action], [b4_symbol_if([$1], [has_$2], [m4_pushdef([b4_symbol_value], m4_defn([b4_symbol_value_template]))[]dnl b4_dollar_pushdef([yysym.value], - b4_symbol_if([$1], [has_type], - [m4_dquote(b4_symbol([$1], [type]))]), - [yysym.location])dnl - _b4_symbol_case([$1]) + [$1], + [], + [yysym.location])dnl + _b4_symbol_case([$1])[]dnl b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])]) b4_symbol([$1], [$2]) b4_syncline([@oline@], [@ofile@]) @@ -137,16 +135,16 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])]) m4_pushdef([b4_copyright_years], - [2002-2015, 2018]) + [2002-2015, 2018-2019]) -m4_define([b4_parser_class_name], - [b4_percent_define_get([[parser_class_name]])]) +m4_define([b4_parser_class], + [b4_percent_define_get([[api.parser.class]])]) b4_bison_locations_if([# Backward compatibility. m4_define([b4_location_constructors]) - m4_include(b4_pkgdatadir/[location.cc])]) -m4_include(b4_pkgdatadir/[stack.hh]) -b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])]) + m4_include(b4_skeletonsdir/[location.cc])]) +m4_include(b4_skeletonsdir/[stack.hh]) +b4_variant_if([m4_include(b4_skeletonsdir/[variant.hh])]) # b4_shared_declarations(hh|cc) @@ -174,21 +172,18 @@ m4_define([b4_shared_declarations], ]b4_namespace_open[ -]b4_stack_define[ ]b4_bison_locations_if([m4_ifndef([b4_location_file], [b4_location_define])])[ -]b4_variant_if([b4_variant_define])[ - /// A Bison parser. - class ]b4_parser_class_name[ + class ]b4_parser_class[ { public: ]b4_public_types_declare[ -]b4_symbol_type_declare[ +]b4_symbol_type_define[ /// Build a parser object. - ]b4_parser_class_name[ (]b4_parse_param_decl[); - virtual ~]b4_parser_class_name[ (); + ]b4_parser_class[ (]b4_parse_param_decl[); + virtual ~]b4_parser_class[ (); /// Parse. An alias for parse (). /// \returns 0 iff parsing succeeded. @@ -220,12 +215,12 @@ m4_define([b4_shared_declarations], /// Report a syntax error. void error (const syntax_error& err); -]b4_symbol_constructor_declare[ +]b4_token_constructor_define[ private: /// This class is not copyable. - ]b4_parser_class_name[ (const ]b4_parser_class_name[&); - ]b4_parser_class_name[& operator= (const ]b4_parser_class_name[&); + ]b4_parser_class[ (const ]b4_parser_class[&); + ]b4_parser_class[& operator= (const ]b4_parser_class[&); /// State numbers. typedef int state_type; @@ -296,26 +291,26 @@ m4_define([b4_shared_declarations], struct by_state { /// Default constructor. - by_state (); + by_state () YY_NOEXCEPT; /// The symbol type as needed by the constructor. typedef state_type kind_type; /// Constructor. - by_state (kind_type s); + by_state (kind_type s) YY_NOEXCEPT; /// Copy constructor. - by_state (const by_state& other); + by_state (const by_state& that) YY_NOEXCEPT; /// Record that this symbol is empty. - void clear (); + void clear () YY_NOEXCEPT; /// Steal the symbol type 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; + symbol_number_type type_get () const YY_NOEXCEPT; /// The state number used to denote an empty symbol. enum { empty_state = -1 }; @@ -343,6 +338,8 @@ m4_define([b4_shared_declarations], #endif }; +]b4_stack_define[ + /// Stack type. typedef stack<stack_symbol_type> stack_type; @@ -391,7 +388,7 @@ m4_define([b4_shared_declarations], #ifndef ]b4_api_PREFIX[STYPE // Redirection for backward compatibility. -# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type +# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class::semantic_type #endif ])[ ]b4_percent_code_get([[provides]])[ @@ -518,11 +515,11 @@ m4_if(b4_prefix, [yy], [], apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. */ std::string - ]b4_parser_class_name[::yytnamerr_ (const char *yystr) + ]b4_parser_class[::yytnamerr_ (const char *yystr) { if (*yystr == '"') { - std::string yyr = ""; + std::string yyr; char const *yyp = yystr; for (;;) @@ -535,7 +532,10 @@ m4_if(b4_prefix, [yy], [], case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - // Fall through. + else + goto append; + + append: default: yyr += *yyp; break; @@ -551,7 +551,7 @@ m4_if(b4_prefix, [yy], [], ]])[ /// Build a parser object. - ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ + ]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ :])[ #if ]b4_api_PREFIX[DEBUG ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), @@ -559,9 +559,11 @@ m4_if(b4_prefix, [yy], [], #endif]b4_parse_param_cons[ {} - ]b4_parser_class_name::~b4_parser_class_name[ () + ]b4_parser_class::~b4_parser_class[ () {} + ]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW + {} /*---------------. | Symbol types. | @@ -570,33 +572,33 @@ m4_if(b4_prefix, [yy], [], ]b4_token_ctor_if([], [b4_public_types_define([cc])])[ // by_state. - ]b4_parser_class_name[::by_state::by_state () + ]b4_parser_class[::by_state::by_state () YY_NOEXCEPT : state (empty_state) {} - ]b4_parser_class_name[::by_state::by_state (const by_state& other) - : state (other.state) + ]b4_parser_class[::by_state::by_state (const by_state& that) YY_NOEXCEPT + : state (that.state) {} void - ]b4_parser_class_name[::by_state::clear () + ]b4_parser_class[::by_state::clear () YY_NOEXCEPT { state = empty_state; } void - ]b4_parser_class_name[::by_state::move (by_state& that) + ]b4_parser_class[::by_state::move (by_state& that) { state = that.state; that.clear (); } - ]b4_parser_class_name[::by_state::by_state (state_type s) + ]b4_parser_class[::by_state::by_state (state_type s) YY_NOEXCEPT : state (s) {} - ]b4_parser_class_name[::symbol_number_type - ]b4_parser_class_name[::by_state::type_get () const + ]b4_parser_class[::symbol_number_type + ]b4_parser_class[::by_state::type_get () const YY_NOEXCEPT { if (state == empty_state) return empty_symbol; @@ -604,10 +606,10 @@ m4_if(b4_prefix, [yy], [], return yystos_[state]; } - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () + ]b4_parser_class[::stack_symbol_type::stack_symbol_type () {} - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) + ]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 ()], @@ -618,7 +620,7 @@ m4_if(b4_prefix, [yy], [], #endif } - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) + ]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 ()], @@ -628,8 +630,8 @@ m4_if(b4_prefix, [yy], [], } #if YY_CPLUSPLUS < 201103L - ]b4_parser_class_name[::stack_symbol_type& - ]b4_parser_class_name[::stack_symbol_type::operator= (stack_symbol_type& that) + ]b4_parser_class[::stack_symbol_type& + ]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that) { state = that.state; ]b4_variant_if([b4_symbol_variant([that.type_get ()], @@ -644,7 +646,7 @@ m4_if(b4_prefix, [yy], [], template <typename Base> void - ]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const + ]b4_parser_class[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const { if (yymsg) YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [ @@ -656,16 +658,18 @@ m4_if(b4_prefix, [yy], [], #if ]b4_api_PREFIX[DEBUG template <typename Base> void - ]b4_parser_class_name[::yy_print_ (std::ostream& yyo, + ]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 << ": "])[; @@ -675,7 +679,7 @@ m4_if(b4_prefix, [yy], [], #endif void - ]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) + ]b4_parser_class[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) { if (m) YY_SYMBOL_PRINT (m, sym); @@ -683,7 +687,7 @@ m4_if(b4_prefix, [yy], [], } void - ]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) + ]b4_parser_class[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) { #if 201103L <= YY_CPLUSPLUS yypush_ (m, stack_symbol_type (s, std::move (sym))); @@ -694,40 +698,40 @@ m4_if(b4_prefix, [yy], [], } void - ]b4_parser_class_name[::yypop_ (int n) + ]b4_parser_class[::yypop_ (int n) { yystack_.pop (n); } #if ]b4_api_PREFIX[DEBUG std::ostream& - ]b4_parser_class_name[::debug_stream () const + ]b4_parser_class[::debug_stream () const { return *yycdebug_; } void - ]b4_parser_class_name[::set_debug_stream (std::ostream& o) + ]b4_parser_class[::set_debug_stream (std::ostream& o) { yycdebug_ = &o; } - ]b4_parser_class_name[::debug_level_type - ]b4_parser_class_name[::debug_level () const + ]b4_parser_class[::debug_level_type + ]b4_parser_class[::debug_level () const { return yydebug_; } void - ]b4_parser_class_name[::set_debug_level (debug_level_type l) + ]b4_parser_class[::set_debug_level (debug_level_type l) { yydebug_ = l; } #endif // ]b4_api_PREFIX[DEBUG - ]b4_parser_class_name[::state_type - ]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym) + ]b4_parser_class[::state_type + ]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym) { int yyr = yypgoto_[yysym - yyntokens_] + yystate; if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) @@ -737,25 +741,25 @@ m4_if(b4_prefix, [yy], [], } bool - ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) + ]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) { return yyvalue == yypact_ninf_; } bool - ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) + ]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) { return yyvalue == yytable_ninf_; } int - ]b4_parser_class_name[::operator() () + ]b4_parser_class[::operator() () { return parse (); } int - ]b4_parser_class_name[::parse () + ]b4_parser_class[::parse () { // State. int yyn; @@ -782,7 +786,7 @@ m4_if(b4_prefix, [yy], [], YYCDEBUG << "Starting parse\n"; ]m4_ifdef([b4_initial_action], [ -b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl +b4_dollar_pushdef([yyla.value], [], [], [yyla.location])dnl b4_user_initial_action b4_dollar_popdef])[]dnl @@ -793,17 +797,22 @@ b4_dollar_popdef])[]dnl yystack_.clear (); yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); - // A new symbol was pushed on the stack. + /*-----------------------------------------------. + | yynewstate -- push a new symbol on the stack. | + `-----------------------------------------------*/ yynewstate: YYCDEBUG << "Entering state " << yystack_[0].state << '\n'; // Accept? if (yystack_[0].state == yyfinal_) - goto yyacceptlab; + YYACCEPT; goto yybackup; - // Backup. + + /*-----------. + | yybackup. | + `-----------*/ yybackup: // Try to take a decision without lookahead. yyn = yypact_[yystack_[0].state]; @@ -825,6 +834,7 @@ b4_dollar_popdef])[]dnl #if YY_EXCEPTIONS catch (const syntax_error& yyexc) { + YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; error (yyexc); goto yyerrlab1; } @@ -856,6 +866,7 @@ b4_dollar_popdef])[]dnl yypush_ ("Shifting", yyn, YY_MOVE (yyla)); goto yynewstate; + /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ @@ -865,8 +876,9 @@ b4_dollar_popdef])[]dnl goto yyerrlab; goto yyreduce; + /*-----------------------------. - | yyreduce -- Do a reduction. | + | yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; @@ -891,8 +903,8 @@ b4_dollar_popdef])[]dnl [ // Default location. { - slice<stack_symbol_type, stack_type> slice (yystack_, yylen); - YYLLOC_DEFAULT (yylhs.location, slice, yylen); + stack_type::slice range (yystack_, yylen); + YYLLOC_DEFAULT (yylhs.location, range, yylen); yyerror_range[1].location = yylhs.location; }]])[ @@ -912,6 +924,7 @@ b4_dollar_popdef])[]dnl #if YY_EXCEPTIONS catch (const syntax_error& yyexc) { + YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; error (yyexc); YYERROR; } @@ -926,6 +939,7 @@ b4_dollar_popdef])[]dnl } goto yynewstate; + /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ @@ -963,18 +977,18 @@ b4_dollar_popdef])[]dnl | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ + /* Pacify compilers when the user code never invokes YYERROR and + the label yyerrorlab therefore never appears in user code. */ if (false) - goto yyerrorlab; + YYERROR; + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ yypop_ (yylen); yylen = 0; goto yyerrlab1; + /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ @@ -1015,16 +1029,26 @@ b4_dollar_popdef])[]dnl } goto yynewstate; - // Accept. + + /*-------------------------------------. + | yyacceptlab -- YYACCEPT comes here. | + `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; - // Abort. + + /*-----------------------------------. + | yyabortlab -- YYABORT comes here. | + `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; + + /*-----------------------------------------------------. + | yyreturn -- parsing is finished, return the result. | + `-----------------------------------------------------*/ yyreturn: if (!yyla.empty ()) yy_destroy_ ("Cleanup: discarding lookahead", yyla); @@ -1060,7 +1084,7 @@ b4_dollar_popdef])[]dnl } void - ]b4_parser_class_name[::error (const syntax_error& yyexc) + ]b4_parser_class[::error (const syntax_error& yyexc) { error (]b4_join(b4_locations_if([yyexc.location]), [[yyexc.what ()]])[); @@ -1068,7 +1092,7 @@ b4_dollar_popdef])[]dnl // Generate an error message. std::string - ]b4_parser_class_name[::yysyntax_error_ (]dnl + ]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([[ @@ -1167,9 +1191,9 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], } - const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; + const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[; - const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; + const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class::yytable_ninf_ = b4_table_ninf[; ]b4_parser_tables_define[ @@ -1177,7 +1201,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. // First, the terminals, then, starting at \a yyntokens_, nonterminals. const char* - const ]b4_parser_class_name[::yytname_[] = + const ]b4_parser_class[::yytname_[] = { ]b4_tname[ }; @@ -1187,7 +1211,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], // Print the state stack on the debug stream. void - ]b4_parser_class_name[::yystack_print_ () + ]b4_parser_class[::yystack_print_ () { *yycdebug_ << "Stack now"; for (stack_type::const_iterator @@ -1200,7 +1224,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], // Report on the debug stream that the rule \a yyrule is going to be reduced. void - ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) + ]b4_parser_class[::yy_reduce_print_ (int yyrule) { unsigned yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; diff --git a/contrib/tools/bison/data/location.cc b/contrib/tools/bison/data/skeletons/location.cc index 906939d42d..a57c0fb67a 100644 --- a/contrib/tools/bison/data/location.cc +++ b/contrib/tools/bison/data/skeletons/location.cc @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018-2019 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 @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. m4_pushdef([b4_copyright_years], - [2002-2015, 2018]) + [2002-2015, 2018-2019]) # b4_position_file diff --git a/contrib/tools/bison/data/skeletons/stack.hh b/contrib/tools/bison/data/skeletons/stack.hh new file mode 100644 index 0000000000..926a6f8cac --- /dev/null +++ b/contrib/tools/bison/data/skeletons/stack.hh @@ -0,0 +1,163 @@ +# C++ skeleton for Bison + +# Copyright (C) 2002-2015, 2018-2019 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 <http://www.gnu.org/licenses/>. + + +# b4_stack_file +# ------------- +# Name of the file containing the stack class, if we want this file. +b4_defines_if([b4_required_version_if([302], [], + [m4_define([b4_stack_file], [stack.hh])])]) + + +# b4_stack_define +# --------------- +m4_define([b4_stack_define], +[[ /// A stack with random access from its top. + template <typename T, typename S = std::vector<T> > + class stack + { + public: + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; + typedef typename S::size_type size_type; + + stack (size_type n = 200) + : seq_ (n) + {} + + /// Random access. + /// + /// Index 0 returns the topmost element. + T& + operator[] (size_type i) + { + return seq_[size () - 1 - i]; + } + + /// Random access. + /// + /// Index 0 returns the topmost element. + T& + operator[] (int i) + { + return operator[] (size_type (i)); + } + + /// Random access. + /// + /// Index 0 returns the topmost element. + const T& + operator[] (size_type i) const + { + return seq_[size () - 1 - i]; + } + + /// Random access. + /// + /// Index 0 returns the topmost element. + const T& + operator[] (int i) const + { + return operator[] (size_type (i)); + } + + /// Steal the contents of \a t. + /// + /// Close to move-semantics. + void + push (YY_MOVE_REF (T) t) + { + seq_.push_back (T ()); + operator[] (0).move (t); + } + + /// Pop elements from the stack. + void + pop (int n = 1) YY_NOEXCEPT + { + for (; 0 < n; --n) + seq_.pop_back (); + } + + /// Pop all elements from the stack. + void + clear () YY_NOEXCEPT + { + seq_.clear (); + } + + /// Number of elements on the stack. + size_type + size () const YY_NOEXCEPT + { + return seq_.size (); + } + + /// Iterator on top of the stack (going downwards). + const_iterator + begin () const YY_NOEXCEPT + { + return seq_.rbegin (); + } + + /// Bottom of the stack. + const_iterator + end () const YY_NOEXCEPT + { + return seq_.rend (); + } + + /// Present a slice of the top of a stack. + class slice + { + public: + slice (const stack& stack, int range) + : stack_ (stack) + , range_ (range) + {} + + const T& + operator[] (int i) const + { + return stack_[range_ - i]; + } + + private: + const stack& stack_; + int range_; + }; + + private: + stack (const stack&); + stack& operator= (const stack&); + /// The wrapped container. + S seq_; + }; +]]) + +m4_ifdef([b4_stack_file], +[b4_output_begin([b4_dir_prefix], [b4_stack_file])[ +]b4_generated_by[ +// Starting with Bison 3.2, this file is useless: the structure it +// used to define is now defined with the parser itself. +// +// To get rid of this file: +// 1. add 'require "3.2"' (or newer) to your grammar file +// 2. remove references to this file from your build system. +]b4_output_end[ +]]) diff --git a/contrib/tools/bison/data/variant.hh b/contrib/tools/bison/data/skeletons/variant.hh index 553bd0d611..8b9d4802df 100644 --- a/contrib/tools/bison/data/variant.hh +++ b/contrib/tools/bison/data/skeletons/variant.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2015, 2018-2019 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 @@ -78,72 +78,79 @@ m4_define([b4_variant_includes], #endif ]]) -# b4_variant_define -# ----------------- -# Define "variant". -m4_define([b4_variant_define], -[[ /// A char[S] buffer to store and retrieve objects. + + +## -------------------------- ## +## Adjustments for variants. ## +## -------------------------- ## + + +# b4_value_type_declare +# --------------------- +# Define semantic_type. +m4_define([b4_value_type_declare], +[[ /// A buffer to store and retrieve objects. /// /// Sort of a variant, but does not keep track of the nature /// of the stored data, since that knowledge is available - /// via the current state. - template <size_t S> - struct variant + /// via the current parser state. + class semantic_type { + public: /// Type of *this. - typedef variant<S> self_type; + typedef semantic_type self_type; /// Empty construction. - variant () + semantic_type () YY_NOEXCEPT : yybuffer_ ()]b4_parse_assert_if([ , yytypeid_ (YY_NULLPTR)])[ {} /// Construct and fill. template <typename T> - variant (YY_RVREF (T) t)]b4_parse_assert_if([ + semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([ : yytypeid_ (&typeid (T))])[ { - YYASSERT (sizeof (T) <= S); + YYASSERT (sizeof (T) <= size); new (yyas_<T> ()) T (YY_MOVE (t)); } /// Destruction, allowed only if empty. - ~variant () + ~semantic_type () YY_NOEXCEPT {]b4_parse_assert_if([ YYASSERT (!yytypeid_); ])[} - /// Instantiate an empty \a T in here. - template <typename T> +# if 201103L <= YY_CPLUSPLUS + /// Instantiate a \a T in here from \a t. + template <typename T, typename... U> T& - emplace () + emplace (U&&... u) {]b4_parse_assert_if([ YYASSERT (!yytypeid_); - YYASSERT (sizeof (T) <= S); + YYASSERT (sizeof (T) <= size); yytypeid_ = & typeid (T);])[ - return *new (yyas_<T> ()) T (); + return *new (yyas_<T> ()) T (std::forward <U>(u)...); } - -# if 201103L <= YY_CPLUSPLUS - /// Instantiate a \a T in here from \a t. - template <typename T, typename U> +# else + /// Instantiate an empty \a T in here. + template <typename T> T& - emplace (U&& u) + emplace () {]b4_parse_assert_if([ YYASSERT (!yytypeid_); - YYASSERT (sizeof (T) <= S); + YYASSERT (sizeof (T) <= size); yytypeid_ = & typeid (T);])[ - return *new (yyas_<T> ()) T (std::forward <U>(u)); + return *new (yyas_<T> ()) T (); } -# else + /// Instantiate a \a T in here from \a t. template <typename T> T& emplace (const T& t) {]b4_parse_assert_if([ YYASSERT (!yytypeid_); - YYASSERT (sizeof (T) <= S); + YYASSERT (sizeof (T) <= size); yytypeid_ = & typeid (T);])[ return *new (yyas_<T> ()) T (t); } @@ -170,75 +177,75 @@ m4_define([b4_variant_define], /// Accessor to a built \a T. template <typename T> T& - as () + as () YY_NOEXCEPT {]b4_parse_assert_if([ YYASSERT (yytypeid_); YYASSERT (*yytypeid_ == typeid (T)); - YYASSERT (sizeof (T) <= S);])[ + YYASSERT (sizeof (T) <= size);])[ return *yyas_<T> (); } /// Const accessor to a built \a T (for %printer). template <typename T> const T& - as () const + as () const YY_NOEXCEPT {]b4_parse_assert_if([ YYASSERT (yytypeid_); YYASSERT (*yytypeid_ == typeid (T)); - YYASSERT (sizeof (T) <= S);])[ + YYASSERT (sizeof (T) <= size);])[ return *yyas_<T> (); } - /// Swap the content with \a other, of same type. + /// Swap the content with \a that, of same type. /// /// Both variants must be built beforehand, because swapping the actual /// data requires reading it (with as()), and this is not possible on /// unconstructed variants: it would require some dynamic testing, which /// should not be the variant's responsibility. /// Swapping between built and (possibly) non-built is done with - /// variant::move (). + /// self_type::move (). template <typename T> void - swap (self_type& other) + swap (self_type& that) YY_NOEXCEPT {]b4_parse_assert_if([ YYASSERT (yytypeid_); - YYASSERT (*yytypeid_ == *other.yytypeid_);])[ - std::swap (as<T> (), other.as<T> ()); + YYASSERT (*yytypeid_ == *that.yytypeid_);])[ + std::swap (as<T> (), that.as<T> ()); } - /// Move the content of \a other to this. + /// Move the content of \a that to this. /// - /// Destroys \a other. + /// Destroys \a that. template <typename T> void - move (self_type& other) + move (self_type& that) { # if 201103L <= YY_CPLUSPLUS - emplace<T> (std::move (other.as<T> ())); + emplace<T> (std::move (that.as<T> ())); # else emplace<T> (); - swap<T> (other); + swap<T> (that); # endif - other.destroy<T> (); + that.destroy<T> (); } # if 201103L <= YY_CPLUSPLUS - /// Move the content of \a other to this. + /// Move the content of \a that to this. template <typename T> void - move (self_type&& other) + move (self_type&& that) { - emplace<T> (std::move (other.as<T> ())); - other.destroy<T> (); + emplace<T> (std::move (that.as<T> ())); + that.destroy<T> (); } #endif - /// Copy the content of \a other to this. + /// Copy the content of \a that to this. template <typename T> void - copy (const self_type& other) + copy (const self_type& that) { - emplace<T> (other.as<T> ()); + emplace<T> (that.as<T> ()); } /// Destroy the stored \a T. @@ -253,12 +260,12 @@ m4_define([b4_variant_define], private: /// Prohibit blind copies. self_type& operator= (const self_type&); - variant (const self_type&); + semantic_type (const self_type&); /// Accessor to raw memory as \a T. template <typename T> T* - yyas_ () + yyas_ () YY_NOEXCEPT { void *yyp = yybuffer_.yyraw; return static_cast<T*> (yyp); @@ -267,18 +274,26 @@ m4_define([b4_variant_define], /// Const accessor to raw memory as \a T. template <typename T> const T* - yyas_ () const + yyas_ () const YY_NOEXCEPT { const void *yyp = yybuffer_.yyraw; return static_cast<const T*> (yyp); } + /// An auxiliary type to compute the largest semantic type. + union union_type + {]b4_type_foreach([b4_char_sizeof])[ }; + + /// The size of the largest semantic type. + enum { size = sizeof (union_type) }; + + /// A buffer to store semantic values. union { /// Strongest alignment constraints. long double yyalign_me; /// A buffer large enough to store any of the semantic values. - char yyraw[S]; + char yyraw[size]; } yybuffer_;]b4_parse_assert_if([ /// Whether the content is built: if defined, the name of the stored type. @@ -287,40 +302,31 @@ m4_define([b4_variant_define], ]]) -## -------------------------- ## -## Adjustments for variants. ## -## -------------------------- ## - - -# b4_value_type_declare -# --------------------- -# Declare semantic_type. -m4_define([b4_value_type_declare], -[[ /// An auxiliary type to compute the largest semantic type. - union union_type - {]b4_type_foreach([b4_char_sizeof])[}; - - /// Symbol semantic values. - typedef variant<sizeof (union_type)> semantic_type;][]dnl -]) - - # How the semantic value is extracted when using variants. -# b4_symbol_value(VAL, [TYPE]) -# ---------------------------- +# b4_symbol_value(VAL, SYMBOL-NUM, [TYPE]) +# ---------------------------------------- +# See README. m4_define([b4_symbol_value], -[m4_ifval([$2], - [$1.as< $2 > ()], - [$1])]) - -# b4_symbol_value_template(VAL, [TYPE]) -# ------------------------------------- +[m4_ifval([$3], + [$1.as< $3 > ()], + [m4_ifval([$2], + [b4_symbol_if([$2], [has_type], + [$1.as < b4_symbol([$2], [type]) > ()], + [$1])], + [$1])])]) + +# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE]) +# ------------------------------------------------- # Same as b4_symbol_value, but used in a template method. m4_define([b4_symbol_value_template], -[m4_ifval([$2], - [$1.template as< $2 > ()], - [$1])]) +[m4_ifval([$3], + [$1.template as< $3 > ()], + [m4_ifval([$2], + [b4_symbol_if([$2], [has_type], + [$1.template as < b4_symbol([$2], [type]) > ()], + [$1])], + [$1])])]) @@ -329,120 +335,119 @@ m4_define([b4_symbol_value_template], ## ------------- ## -# _b4_symbol_constructor_declare(SYMBOL-NUMBER) -# --------------------------------------------- -# Declare the overloaded version of make_symbol for the (common) type of -# these SYMBOL-NUMBERS. Use at class-level. -m4_define([_b4_symbol_constructor_declare], -[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id], +# _b4_includes_tokens(SYMBOL-NUM...) +# ---------------------------------- +# Expands to non-empty iff one of the SYMBOL-NUM denotes +# a token. +m4_define([_b4_is_token], + [b4_symbol_if([$1], [is_token], [1])]) +m4_define([_b4_includes_tokens], + [m4_map([_b4_is_token], [$@])]) + + +# _b4_token_maker_define(SYMBOL-NUM) +# ---------------------------------- +# Declare make_SYMBOL for SYMBOL-NUM. Use at class-level. +m4_define([_b4_token_maker_define], +[b4_token_visible_if([$1], [#if 201103L <= YY_CPLUSPLUS - static - symbol_type - make_[]_b4_symbol([$1], [id]) (dnl -b4_join(b4_symbol_if([$1], [has_type], - [b4_symbol([$1], [type]) v]), - b4_locations_if([location_type l]))); + static + symbol_type + make_[]_b4_symbol([$1], [id]) (b4_join( + b4_symbol_if([$1], [has_type], + [b4_symbol([$1], [type]) v]), + b4_locations_if([location_type l]))) + { + return symbol_type (b4_join([token::b4_symbol([$1], [id])], + b4_symbol_if([$1], [has_type], [std::move (v)]), + b4_locations_if([std::move (l)]))); + } #else - static - symbol_type - make_[]_b4_symbol([$1], [id]) (dnl -b4_join(b4_symbol_if([$1], [has_type], - [const b4_symbol([$1], [type])& v]), - b4_locations_if([const location_type& l]))); + static + symbol_type + make_[]_b4_symbol([$1], [id]) (b4_join( + b4_symbol_if([$1], [has_type], + [const b4_symbol([$1], [type])& v]), + b4_locations_if([const location_type& l]))) + { + return symbol_type (b4_join([token::b4_symbol([$1], [id])], + b4_symbol_if([$1], [has_type], [v]), + b4_locations_if([l]))); + } #endif -])])]) - - -# b4_symbol_constructor_declare -# ----------------------------- -# Declare symbol constructors for all the value types. -# Use at class-level. -m4_define([b4_symbol_constructor_declare], -[ // Symbol constructors declarations. -b4_symbol_foreach([_b4_symbol_constructor_declare])]) - - - -# _b4_symbol_constructor_define(SYMBOL-NUMBER) -# -------------------------------------------- -# Define symbol constructor for this SYMBOL-NUMBER. -m4_define([_b4_symbol_constructor_define], -[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id], -[# if 201103L <= YY_CPLUSPLUS - inline - b4_parser_class_name::symbol_type - b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl -b4_join(b4_symbol_if([$1], [has_type], - [b4_symbol([$1], [type]) v]), - b4_locations_if([location_type l]))) - { - return symbol_type (b4_join([token::b4_symbol([$1], [id])], - b4_symbol_if([$1], [has_type], [std::move (v)]), - b4_locations_if([std::move (l)]))); - } -#else - inline - b4_parser_class_name::symbol_type - b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl -b4_join(b4_symbol_if([$1], [has_type], - [const b4_symbol([$1], [type])& v]), - b4_locations_if([const location_type& l]))) - { - return symbol_type (b4_join([token::b4_symbol([$1], [id])], - b4_symbol_if([$1], [has_type], [v]), - b4_locations_if([l]))); - } -#endif -])])]) +])]) -# b4_basic_symbol_constructor_declare -# ----------------------------------- -# Generate a constructor declaration for basic_symbol from given type. -m4_define([b4_basic_symbol_constructor_declare], -[[# if 201103L <= YY_CPLUSPLUS - basic_symbol (]b4_join( - [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]), - b4_locations_if([location_type&& l]))[); +m4_define([_b4_type_clause], +[b4_symbol_if([$1], [is_token], + [b4_symbol_if([$1], [has_id], + [tok == token::b4_symbol([$1], [id])], + [tok == b4_symbol([$1], [user_number])])])]) + + +# _b4_token_constructor_define(SYMBOL-NUM...) +# ------------------------------------------- +# Define a unique make_symbol for all the SYMBOL-NUM (they +# have the same type). Use at class-level. +m4_define([_b4_token_constructor_define], +[m4_ifval(_b4_includes_tokens($@), +[[#if 201103L <= YY_CPLUSPLUS + symbol_type (]b4_join( + [int tok], + b4_symbol_if([$1], [has_type], + [b4_symbol([$1], [type]) v]), + b4_locations_if([location_type l]))[) + : super_type(]b4_join([token_type (tok)], + b4_symbol_if([$1], [has_type], [std::move (v)]), + b4_locations_if([std::move (l)]))[) + { + YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[); + } #else - basic_symbol (]b4_join( - [typename Base::kind_type t], - b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]), - b4_locations_if([const location_type& l]))[); + symbol_type (]b4_join( + [int tok], + b4_symbol_if([$1], [has_type], + [const b4_symbol([$1], [type])& v]), + b4_locations_if([const location_type& l]))[) + : super_type(]b4_join([token_type (tok)], + b4_symbol_if([$1], [has_type], [v]), + b4_locations_if([l]))[) + { + YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[); + } #endif -]]) +]])]) -# b4_basic_symbol_constructor_define -# ---------------------------------- -# Generate a constructor implementation for basic_symbol from given type. + +# b4_basic_symbol_constructor_define(SYMBOL-NUM) +# ---------------------------------------------- +# Generate a constructor for basic_symbol from given type. m4_define([b4_basic_symbol_constructor_define], -[[# if 201103L <= YY_CPLUSPLUS - template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( +[[#if 201103L <= YY_CPLUSPLUS + basic_symbol (]b4_join( [typename Base::kind_type t], b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]), b4_locations_if([location_type&& l]))[) - : Base (t)]b4_symbol_if([$1], [has_type], [ - , value (std::move (v))])[]b4_locations_if([ - , location (std::move (l))])[ - {} + : Base (t)]b4_symbol_if([$1], [has_type], [ + , value (std::move (v))])[]b4_locations_if([ + , location (std::move (l))])[ + {} #else - template <typename Base> - ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( + basic_symbol (]b4_join( [typename Base::kind_type t], b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]), b4_locations_if([const location_type& l]))[) - : Base (t)]b4_symbol_if([$1], [has_type], [ - , value (v)])[]b4_locations_if([ - , location (l)])[ - {} + : Base (t)]b4_symbol_if([$1], [has_type], [ + , value (v)])[]b4_locations_if([ + , location (l)])[ + {} #endif ]]) -# b4_symbol_constructor_define -# ---------------------------- + +# b4_token_constructor_define +# --------------------------- # Define the overloaded versions of make_symbol for all the value types. -m4_define([b4_symbol_constructor_define], -[ // Implementation of make_symbol for each symbol type. -b4_symbol_foreach([_b4_symbol_constructor_define])]) +m4_define([b4_token_constructor_define], +[ // Implementation of make_symbol for each symbol type. +b4_symbol_foreach([_b4_token_maker_define])]) diff --git a/contrib/tools/bison/data/yacc.c b/contrib/tools/bison/data/skeletons/yacc.c index d8021ef67d..54e40e6741 100644 --- a/contrib/tools/bison/data/yacc.c +++ b/contrib/tools/bison/data/skeletons/yacc.c @@ -1,11 +1,11 @@ -*- C -*- # Yacc compatible skeleton for Bison -# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software +# Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software # Foundation, Inc. m4_pushdef([b4_copyright_years], - [1984, 1989-1990, 2000-2015, 2018]) + [1984, 1989-1990, 2000-2015, 2018-2019]) # 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 @@ -51,7 +51,7 @@ m4_define([b4_lac_flag], [m4_if(b4_percent_define_get([[parse.lac]]), [none], [[0]], [[1]])]) -m4_include(b4_pkgdatadir/[c.m4]) +m4_include(b4_skeletonsdir/[c.m4]) ## ---------------- ## ## Default values. ## @@ -128,19 +128,18 @@ m4_define([b4_int_type], ## ----------------- ## -# b4_lhs_value([TYPE]) -# -------------------- -# Expansion of $<TYPE>$. +# b4_lhs_value(SYMBOL-NUM, [TYPE]) +# -------------------------------- +# See README. m4_define([b4_lhs_value], -[b4_symbol_value(yyval, [$1])]) +[b4_symbol_value(yyval, [$1], [$2])]) -# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) -# -------------------------------------- -# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH -# symbols on RHS. +# b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE]) +# ---------------------------------------------------- +# See README. m4_define([b4_rhs_value], - [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])]) +[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3], [$4])]) ## ----------- ## @@ -154,12 +153,12 @@ m4_define([b4_lhs_location], [(yyloc)]) -# b4_rhs_location(RULE-LENGTH, NUM) +# b4_rhs_location(RULE-LENGTH, POS) # --------------------------------- -# Expansion of @NUM, where the current rule has RULE-LENGTH symbols +# Expansion of @POS, where the current rule has RULE-LENGTH symbols # on RHS. m4_define([b4_rhs_location], - [(yylsp@{b4_subtract([$2], [$1])@})]) +[(yylsp@{b4_subtract([$2], [$1])@})]) ## -------------- ## @@ -562,16 +561,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES ]b4_states_number[ -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #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. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = { ]b4_translate[ @@ -624,23 +623,23 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \]b4_lac_if([[ - YY_LAC_DISCARD ("YYBACKUP"); \]])[ - goto yybackup; \ - } \ - else \ - { \ - yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \]b4_lac_if([[ + YY_LAC_DISCARD ("YYBACKUP"); \]])[ + goto yybackup; \ + } \ + else \ + { \ + yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -1067,7 +1066,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1184,10 +1186,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } }]b4_lac_if([[ @@ -1215,9 +1217,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1275,13 +1278,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ ]b4_function_define([[yypull_parse]], [[int]], [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [, b4_parse_param]))[ -{ - int yystatus; - yypstate *yyps_local;]b4_pure_if([[ - int yychar; - YYSTYPE yylval;]b4_locations_if([[ +{]b4_pure_if([b4_locations_if([[ static YYLTYPE yyloc_default][]b4_yyloc_default[; YYLTYPE yylloc = yyloc_default;]])])[ + yypstate *yyps_local; if (yyps) yyps_local = yyps; else @@ -1295,8 +1295,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ return 2; } } - do { - yychar = ]b4_lex[; + int yystatus; + 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)])[); } while (yystatus == YYPUSH_MORE); @@ -1427,7 +1429,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ ]m4_ifdef([b4_initial_action], [ -b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], +b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [], [b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl b4_user_initial_action b4_dollar_popdef[]dnl @@ -1437,23 +1439,31 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo ]])dnl [ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1475,10 +1485,7 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo yyvs = yyvs1;]b4_locations_if([ yyls = yyls1;])[ } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1495,12 +1502,11 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo 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); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1;]b4_locations_if([ @@ -1512,6 +1518,7 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1520,11 +1527,11 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1622,7 +1629,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1773,12 +1780,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1849,6 +1854,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1856,6 +1862,7 @@ yyabortlab: yyresult = 1; goto yyreturn; + #if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[ /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1866,6 +1873,10 @@ yyexhaustedlab: /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1893,6 +1904,10 @@ yyreturn: YYSTACK_FREE (yyes);]])b4_push_if([[ yyps->yynew = 1; + +/*-----------------------------------------. +| yypushreturn -- ask for the next token. | +`-----------------------------------------*/ yypushreturn:]])[ #if YYERROR_VERBOSE if (yymsg != yymsgbuf) diff --git a/contrib/tools/bison/data/stack.hh b/contrib/tools/bison/data/stack.hh deleted file mode 100644 index 9ea5be158b..0000000000 --- a/contrib/tools/bison/data/stack.hh +++ /dev/null @@ -1,159 +0,0 @@ -# C++ skeleton for Bison - -# Copyright (C) 2002-2015, 2018 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 <http://www.gnu.org/licenses/>. - - -# b4_stack_file -# ------------- -# Name of the file containing the stack class, if we want this file. -b4_defines_if([b4_required_version_if([302], [], - [m4_define([b4_stack_file], [stack.hh])])]) - - -# b4_stack_define -# --------------- -m4_define([b4_stack_define], -[[ /// A stack with random access from its top. - template <typename T, typename S = std::vector<T> > - class stack - { - public: - // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; - typedef typename S::size_type size_type; - - stack (size_type n = 200) - : seq_ (n) - {} - - /// Random access. - /// - /// Index 0 returns the topmost element. - T& - operator[] (size_type i) - { - return seq_[size () - 1 - i]; - } - - /// Random access. - /// - /// Index 0 returns the topmost element. - T& - operator[] (int i) - { - return operator[] (size_type (i)); - } - - /// Random access. - /// - /// Index 0 returns the topmost element. - const T& - operator[] (size_type i) const - { - return seq_[size () - 1 - i]; - } - - /// Random access. - /// - /// Index 0 returns the topmost element. - const T& - operator[] (int i) const - { - return operator[] (size_type (i)); - } - - /// Steal the contents of \a t. - /// - /// Close to move-semantics. - void - push (YY_MOVE_REF (T) t) - { - seq_.push_back (T ()); - operator[](0).move (t); - } - - void - pop (int n = 1) - { - for (; 0 < n; --n) - seq_.pop_back (); - } - - void - clear () - { - seq_.clear (); - } - - size_type - size () const - { - return seq_.size (); - } - - const_iterator - begin () const - { - return seq_.rbegin (); - } - - const_iterator - end () const - { - return seq_.rend (); - } - - private: - stack (const stack&); - stack& operator= (const stack&); - /// The wrapped container. - S seq_; - }; - - /// Present a slice of the top of a stack. - template <typename T, typename S = stack<T> > - class slice - { - public: - slice (const S& stack, int range) - : stack_ (stack) - , range_ (range) - {} - - const T& - operator[] (int i) const - { - return stack_[range_ - i]; - } - - private: - const S& stack_; - int range_; - }; -]]) - -m4_ifdef([b4_stack_file], -[b4_output_begin([b4_dir_prefix], [b4_stack_file])[ -]b4_generated_by[ -// Starting with Bison 3.2, this file is useless: the structure it -// used to define is now defined with the parser itself. -// -// To get rid of this file: -// 1. add 'require "3.2"' (or newer) to your grammar file -// 2. remove references to this file from your build system. -]b4_output_end[ -]]) diff --git a/contrib/tools/bison/lib/allocator.c b/contrib/tools/bison/lib/allocator.c new file mode 100644 index 0000000000..2c1a3da03a --- /dev/null +++ b/contrib/tools/bison/lib/allocator.c @@ -0,0 +1,5 @@ +#define _GL_USE_STDLIB_ALLOC 1 +#include <config.h> +#include "allocator.h" +#include <stdlib.h> +struct allocator const stdlib_allocator = { malloc, realloc, free, NULL }; diff --git a/contrib/tools/bison/lib/allocator.h b/contrib/tools/bison/lib/allocator.h new file mode 100644 index 0000000000..5a632ba6ff --- /dev/null +++ b/contrib/tools/bison/lib/allocator.h @@ -0,0 +1,58 @@ +/* Memory allocators such as malloc+free. + + Copyright (C) 2011-2019 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. */ + +#ifndef _GL_ALLOCATOR_H +#define _GL_ALLOCATOR_H + +#include <stddef.h> + +/* An object describing a memory allocator family. */ + +struct allocator +{ + /* Do not use GCC attributes such as __attribute__ ((malloc)) with + the function types pointed at by these members, because these + attributes do not work with pointers to functions. See + <https://lists.gnu.org/r/bug-gnulib/2011-04/msg00007.html>. */ + + /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE + should return NULL, though not necessarily set errno. When given + a zero size it may return NULL even if successful. */ + void *(*allocate) (size_t); + + /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'. + On failure REALLOCATE should return NULL, though not necessarily set + errno. When given a zero size it may return NULL even if + successful. */ + void *(*reallocate) (void *, size_t); + + /* Call FREE to free memory, like 'free'. */ + void (*free) (void *); + + /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (..., + SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX + if size_t overflow was detected while calculating sizes to be + passed to MALLOC or REALLOC. */ + void (*die) (size_t); +}; + +/* An allocator using the stdlib functions and a null DIE function. */ +extern struct allocator const stdlib_allocator; + +#endif /* _GL_ALLOCATOR_H */ diff --git a/contrib/tools/bison/lib/areadlink.c b/contrib/tools/bison/lib/areadlink.c new file mode 100644 index 0000000000..059435624d --- /dev/null +++ b/contrib/tools/bison/lib/areadlink.c @@ -0,0 +1,56 @@ +/* areadlink.c -- readlink wrapper to return the link name in malloc'd storage + Unlike xreadlink and xreadlink_with_size, don't ever call exit. + + Copyright (C) 2001, 2003-2007, 2009-2019 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 Jim Meyering <jim@meyering.net> + and Bruno Haible <bruno@clisp.org>. */ + +#include <config.h> + +/* Specification. */ +#include "areadlink.h" + +#include "careadlinkat.h" + +#include <stdlib.h> +#include <unistd.h> + +/* Get the symbolic link value of FILENAME and put it into BUFFER, with + size BUFFER_SIZE. This function acts like readlink but has + readlinkat's signature. */ +static ssize_t +careadlinkatcwd (int fd, char const *filename, char *buffer, + size_t buffer_size) +{ + /* FD must be AT_FDCWD here, otherwise the caller is using this + function in contexts it was not meant for. */ + if (fd != AT_FDCWD) + abort (); + return readlink (filename, buffer, buffer_size); +} + +/* Call readlink to get the symbolic link value of FILENAME. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlink fails, return NULL and set errno. + If allocation fails, or if the link value is longer than SIZE_MAX :-), + return NULL and set errno to ENOMEM. */ + +char * +areadlink (char const *filename) +{ + return careadlinkat (AT_FDCWD, filename, NULL, 0, NULL, careadlinkatcwd); +} diff --git a/contrib/tools/bison/lib/areadlink.h b/contrib/tools/bison/lib/areadlink.h new file mode 100644 index 0000000000..ddcd06d7d7 --- /dev/null +++ b/contrib/tools/bison/lib/areadlink.h @@ -0,0 +1,33 @@ +/* Read symbolic links without size limitation. + + Copyright (C) 2001, 2003-2004, 2007, 2009-2019 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 Jim Meyering <jim@meyering.net> */ + +#include <stddef.h> + +extern char *areadlink (char const *filename); +extern char *areadlink_with_size (char const *filename, size_t size_hint); + +#if GNULIB_AREADLINKAT +extern char *areadlinkat (int fd, char const *filename); +#endif + +#if GNULIB_AREADLINKAT_WITH_SIZE +extern char *areadlinkat_with_size (int fd, char const *filename, + size_t size_hint); +#endif diff --git a/contrib/tools/bison/lib/arg-nonnull.h b/contrib/tools/bison/lib/arg-nonnull.h index 5f03408312..ad8c26c225 100644 --- a/contrib/tools/bison/lib/arg-nonnull.h +++ b/contrib/tools/bison/lib/arg-nonnull.h @@ -1,5 +1,5 @@ /* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 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 diff --git a/contrib/tools/bison/lib/argmatch.c b/contrib/tools/bison/lib/argmatch.c index 5c2202b4d2..b9a3e400c4 100644 --- a/contrib/tools/bison/lib/argmatch.c +++ b/contrib/tools/bison/lib/argmatch.c @@ -1,6 +1,6 @@ /* argmatch.c -- find a match for a string in an array - Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2018 Free Software + Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/argmatch.h b/contrib/tools/bison/lib/argmatch.h index e6b4c48f06..51d2885879 100644 --- a/contrib/tools/bison/lib/argmatch.h +++ b/contrib/tools/bison/lib/argmatch.h @@ -1,6 +1,6 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2018 Free Software + Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/asnprintf.c b/contrib/tools/bison/lib/asnprintf.c index 2298455b4a..d2a8c09720 100644 --- a/contrib/tools/bison/lib/asnprintf.c +++ b/contrib/tools/bison/lib/asnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/basename-lgpl.c b/contrib/tools/bison/lib/basename-lgpl.c index 33f9994f22..0ae04ee572 100644 --- a/contrib/tools/bison/lib/basename-lgpl.c +++ b/contrib/tools/bison/lib/basename-lgpl.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/basename.c b/contrib/tools/bison/lib/basename.c index 02adb8c3d1..1b6e0ea59b 100644 --- a/contrib/tools/bison/lib/basename.c +++ b/contrib/tools/bison/lib/basename.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/binary-io.c b/contrib/tools/bison/lib/binary-io.c index f9cc4dd2ec..01e0bf6476 100644 --- a/contrib/tools/bison/lib/binary-io.c +++ b/contrib/tools/bison/lib/binary-io.c @@ -1,5 +1,5 @@ /* Binary mode I/O. - Copyright 2017-2018 Free Software Foundation, Inc. + Copyright 2017-2019 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 diff --git a/contrib/tools/bison/lib/binary-io.h b/contrib/tools/bison/lib/binary-io.h index 7d3c4dfbaa..100ac3011c 100644 --- a/contrib/tools/bison/lib/binary-io.h +++ b/contrib/tools/bison/lib/binary-io.h @@ -1,5 +1,5 @@ /* Binary mode I/O. - Copyright (C) 2001, 2003, 2005, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2008-2019 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 diff --git a/contrib/tools/bison/lib/bitrotate.h b/contrib/tools/bison/lib/bitrotate.h index 9eb6a6f42d..862331e204 100644 --- a/contrib/tools/bison/lib/bitrotate.h +++ b/contrib/tools/bison/lib/bitrotate.h @@ -1,5 +1,5 @@ /* bitrotate.h - Rotate bits in integers - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 diff --git a/contrib/tools/bison/lib/bitset.c b/contrib/tools/bison/lib/bitset.c index 325213777b..cccb1e8347 100644 --- a/contrib/tools/bison/lib/bitset.c +++ b/contrib/tools/bison/lib/bitset.c @@ -1,7 +1,6 @@ /* General bitsets. - Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -27,11 +26,11 @@ #include "obstack.h" -#include "abitset.h" -#include "lbitset.h" -#include "ebitset.h" -#include "vbitset.h" -#include "bitset_stats.h" +#include "bitset/array.h" +#include "bitset/list.h" +#include "bitset/stats.h" +#include "bitset/table.h" +#include "bitset/vector.h" const char * const bitset_type_names[] = BITSET_TYPE_NAMES; @@ -56,9 +55,9 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits) return lbitset_bytes (n_bits); case BITSET_TABLE: - return ebitset_bytes (n_bits); + return tbitset_bytes (n_bits); - case BITSET_VARRAY: + case BITSET_VECTOR: return vbitset_bytes (n_bits); } } @@ -83,9 +82,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) return lbitset_init (bset, n_bits); case BITSET_TABLE: - return ebitset_init (bset, n_bits); + return tbitset_init (bset, n_bits); - case BITSET_VARRAY: + case BITSET_VECTOR: return vbitset_init (bset, n_bits); } } @@ -109,7 +108,7 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr) /* If no attributes selected, choose a good compromise. */ if (!attr) - return BITSET_VARRAY; + return BITSET_VECTOR; if (attr & BITSET_SPARSE) return BITSET_LIST; @@ -120,7 +119,7 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr) if (attr & BITSET_GREEDY) return BITSET_TABLE; - return BITSET_VARRAY; + return BITSET_VECTOR; } @@ -308,7 +307,7 @@ void bitset_release_memory (void) { lbitset_release_memory (); - ebitset_release_memory (); + tbitset_release_memory (); } @@ -374,9 +373,7 @@ bitset_copy_ (bitset dst, bitset src) is large enough to hold the SRC bitset. */ bitset_zero (dst); BITSET_FOR_EACH (iter, src, i, 0) - { - bitset_set (dst, i); - } + bitset_set (dst, i); return true; } diff --git a/contrib/tools/bison/lib/bitset.h b/contrib/tools/bison/lib/bitset.h index f7b2cd0bfa..32d08e7aa9 100644 --- a/contrib/tools/bison/lib/bitset.h +++ b/contrib/tools/bison/lib/bitset.h @@ -1,7 +1,6 @@ /* Generic bitsets. - Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,8 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _BITSET_H -#define _BITSET_H +#ifndef _GL_BITSET_H +#define _GL_BITSET_H /* This file is the public interface to the bitset abstract data type. Only use the functions and macros defined in this file. */ @@ -29,7 +28,7 @@ # include "unlocked-io.h" #endif -#include "bbitset.h" +#include "bitset/base.h" #include "obstack.h" /* Attributes used to select a bitset implementation. */ @@ -58,11 +57,11 @@ union bitset_union bitset_word words[1]; /* The array of bits. */ } a; - struct ebitset_struct + struct tbitset_struct { struct bbitset_struct b; bitset_windex size; /* Number of elements. */ - struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */ + struct tbitset_elt_struct **elts; /* Expanding array of ptrs to elts. */ } e; struct lbitset_struct @@ -386,4 +385,4 @@ void debug_bitset (bitset); /* Function to debug bitset stats from debugger. */ void debug_bitset_stats (void); -#endif /* _BITSET_H */ +#endif /* _GL_BITSET_H */ diff --git a/contrib/tools/bison/lib/abitset.c b/contrib/tools/bison/lib/bitset/array.c index 0d6b9a5d8a..fde9fa24f5 100644 --- a/contrib/tools/bison/lib/abitset.c +++ b/contrib/tools/bison/lib/bitset/array.c @@ -1,6 +1,6 @@ /* Array bitsets. - Copyright (C) 2002-2003, 2006, 2009-2015, 2018 Free Software + Copyright (C) 2002-2003, 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -20,7 +20,7 @@ #include <config.h> -#include "abitset.h" +#include "bitset/array.h" #include <stddef.h> #include <stdlib.h> #include <string.h> diff --git a/contrib/tools/bison/lib/abitset.h b/contrib/tools/bison/lib/bitset/array.h index 821eed9d96..6f49a2e047 100644 --- a/contrib/tools/bison/lib/abitset.h +++ b/contrib/tools/bison/lib/bitset/array.h @@ -1,6 +1,6 @@ /* Functions to support abitsets. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _ABITSET_H -#define _ABITSET_H +#ifndef _BITSET_ARRAY_H +#define _BITSET_ARRAY_H #include "bitset.h" diff --git a/contrib/tools/bison/lib/bbitset.h b/contrib/tools/bison/lib/bitset/base.h index 29502a5b1d..4fcafac8b6 100644 --- a/contrib/tools/bison/lib/bbitset.h +++ b/contrib/tools/bison/lib/bitset/base.h @@ -1,6 +1,6 @@ /* Base bitset stuff. - Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software + Copyright (C) 2002-2004, 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _BBITSET_H -#define _BBITSET_H +#ifndef _BITSET_BASE_H +#define _BITSET_BASE_H #include <limits.h> #include <stdbool.h> @@ -44,14 +44,14 @@ BITSET_TABLE: Expandable table of pointers to arrays of bits (variable size, less storage for large sparse sets). Faster than BITSET_LIST for random access. - BITSET_VARRAY: Variable array of bits (variable size, fast for + BITSET_VECTOR: Variable array of bits (variable size, fast for dense bitsets). BITSET_STATS: Wrapper bitset for internal use only. Used for gathering statistics and/or better run-time checking. */ -enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY, +enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VECTOR, BITSET_TYPE_NUM, BITSET_STATS}; -#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"} +#define BITSET_TYPE_NAMES {"abitset", "lbitset", "tbitset", "vbitset"} extern const char * const bitset_type_names[]; diff --git a/contrib/tools/bison/lib/lbitset.c b/contrib/tools/bison/lib/bitset/list.c index 705000929f..f42edb8ea3 100644 --- a/contrib/tools/bison/lib/lbitset.c +++ b/contrib/tools/bison/lib/bitset/list.c @@ -1,6 +1,6 @@ /* Functions to support link list bitsets. - Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software + Copyright (C) 2002-2004, 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -20,7 +20,7 @@ #include <config.h> -#include "lbitset.h" +#include "bitset/list.h" #include <stddef.h> #include <stdio.h> diff --git a/contrib/tools/bison/lib/lbitset.h b/contrib/tools/bison/lib/bitset/list.h index b9d266dafb..a0fc09f8c6 100644 --- a/contrib/tools/bison/lib/lbitset.h +++ b/contrib/tools/bison/lib/bitset/list.h @@ -1,6 +1,6 @@ /* Functions to support lbitsets. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _LBITSET_H -#define _LBITSET_H +#ifndef _BITSET_LIST_H +#define _BITSET_LIST_H #include "bitset.h" diff --git a/contrib/tools/bison/lib/bitset_stats.c b/contrib/tools/bison/lib/bitset/stats.c index d0967348e7..da73cdcac5 100644 --- a/contrib/tools/bison/lib/bitset_stats.c +++ b/contrib/tools/bison/lib/bitset/stats.c @@ -1,7 +1,6 @@ /* Bitset statistics. - Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -27,7 +26,7 @@ #include <config.h> -#include "bitset_stats.h" +#include "bitset/stats.h" #include <stdio.h> #include <stdlib.h> @@ -36,11 +35,11 @@ #include "gettext.h" #define _(Msgid) gettext (Msgid) -#include "abitset.h" -#include "bbitset.h" -#include "ebitset.h" -#include "lbitset.h" -#include "vbitset.h" +#include "bitset/array.h" +#include "bitset/base.h" +#include "bitset/list.h" +#include "bitset/table.h" +#include "bitset/vector.h" /* Configuration macros. */ #define BITSET_STATS_FILE "bitset.dat" @@ -710,13 +709,13 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type) case BITSET_TABLE: { - size_t bytes = ebitset_bytes (n_bits); + size_t bytes = tbitset_bytes (n_bits); bset->s.bset = xcalloc (1, bytes); - ebitset_init (bset->s.bset, n_bits); + tbitset_init (bset->s.bset, n_bits); } break; - case BITSET_VARRAY: + case BITSET_VECTOR: { size_t bytes = vbitset_bytes (n_bits); bset->s.bset = xcalloc (1, bytes); diff --git a/contrib/tools/bison/lib/bitset_stats.h b/contrib/tools/bison/lib/bitset/stats.h index 3a12ab3680..95e64dc4e5 100644 --- a/contrib/tools/bison/lib/bitset_stats.h +++ b/contrib/tools/bison/lib/bitset/stats.h @@ -1,7 +1,6 @@ /* Functions to support bitset statistics. - Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -21,7 +20,7 @@ #ifndef _BITSET_STATS_H #define _BITSET_STATS_H -#include "bbitset.h" +#include "bitset/base.h" extern bool bitset_stats_enabled; diff --git a/contrib/tools/bison/lib/ebitset.c b/contrib/tools/bison/lib/bitset/table.c index 561816b132..8351cf7848 100644 --- a/contrib/tools/bison/lib/ebitset.c +++ b/contrib/tools/bison/lib/bitset/table.c @@ -1,7 +1,6 @@ /* Functions to support expandable bitsets. - Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -20,7 +19,7 @@ #include <config.h> -#include "ebitset.h" +#include "bitset/table.h" #include <stdlib.h> #include <string.h> @@ -56,19 +55,19 @@ ((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS)) /* Ebitset element. We use an array of bits. */ -typedef struct ebitset_elt_struct +typedef struct tbitset_elt_struct { union { bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */ - struct ebitset_elt_struct *next; + struct tbitset_elt_struct *next; } u; } -ebitset_elt; +tbitset_elt; -typedef ebitset_elt *ebitset_elts; +typedef tbitset_elt *tbitset_elts; /* Number of elements to initially allocate. */ @@ -78,15 +77,15 @@ typedef ebitset_elt *ebitset_elts; #endif -enum ebitset_find_mode +enum tbitset_find_mode { EBITSET_FIND, EBITSET_CREATE, EBITSET_SUBST }; -static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */ +static tbitset_elt tbitset_zero_elts[1]; /* Elements of all zero bits. */ /* Obstack to allocate bitset elements from. */ -static struct obstack ebitset_obstack; -static bool ebitset_obstack_init = false; -static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */ +static struct obstack tbitset_obstack; +static bool tbitset_obstack_init = false; +static tbitset_elt *tbitset_free_list; /* Free list of bitset elements. */ #define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS) #define EBITSET_ELTS(BSET) ((BSET)->e.elts) @@ -122,7 +121,7 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */ #define max(a, b) ((a) > (b) ? (a) : (b)) static bitset_bindex -ebitset_resize (bitset src, bitset_bindex n_bits) +tbitset_resize (bitset src, bitset_bindex n_bits) { if (n_bits == BITSET_NBITS_ (src)) return n_bits; @@ -143,12 +142,12 @@ ebitset_resize (bitset src, bitset_bindex n_bits) bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4; EBITSET_ELTS (src) - = realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *)); + = realloc (EBITSET_ELTS (src), size * sizeof (tbitset_elt *)); EBITSET_ASIZE (src) = size; } memset (EBITSET_ELTS (src) + oldsize, 0, - (newsize - oldsize) * sizeof (ebitset_elt *)); + (newsize - oldsize) * sizeof (tbitset_elt *)); } else { @@ -157,7 +156,7 @@ ebitset_resize (bitset src, bitset_bindex n_bits) if ((oldsize - newsize) >= oldsize / 2) { EBITSET_ELTS (src) - = realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *)); + = realloc (EBITSET_ELTS (src), newsize * sizeof (tbitset_elt *)); EBITSET_ASIZE (src) = newsize; } @@ -169,22 +168,22 @@ ebitset_resize (bitset src, bitset_bindex n_bits) } -/* Allocate a ebitset element. The bits are not cleared. */ -static inline ebitset_elt * -ebitset_elt_alloc (void) +/* Allocate a tbitset element. The bits are not cleared. */ +static inline tbitset_elt * +tbitset_elt_alloc (void) { - ebitset_elt *elt; + tbitset_elt *elt; - if (ebitset_free_list != 0) + if (tbitset_free_list != 0) { - elt = ebitset_free_list; - ebitset_free_list = EBITSET_NEXT (elt); + elt = tbitset_free_list; + tbitset_free_list = EBITSET_NEXT (elt); } else { - if (!ebitset_obstack_init) + if (!tbitset_obstack_init) { - ebitset_obstack_init = true; + tbitset_obstack_init = true; /* Let particular systems override the size of a chunk. */ @@ -206,57 +205,57 @@ ebitset_elt_alloc (void) #define __alignof__(type) 0 #endif - obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE, - __alignof__ (ebitset_elt), + obstack_specify_allocation (&tbitset_obstack, OBSTACK_CHUNK_SIZE, + __alignof__ (tbitset_elt), OBSTACK_CHUNK_ALLOC, OBSTACK_CHUNK_FREE); } /* Perhaps we should add a number of new elements to the free list. */ - elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack, - sizeof (ebitset_elt)); + elt = (tbitset_elt *) obstack_alloc (&tbitset_obstack, + sizeof (tbitset_elt)); } return elt; } -/* Allocate a ebitset element. The bits are cleared. */ -static inline ebitset_elt * -ebitset_elt_calloc (void) +/* Allocate a tbitset element. The bits are cleared. */ +static inline tbitset_elt * +tbitset_elt_calloc (void) { - ebitset_elt *elt = ebitset_elt_alloc (); + tbitset_elt *elt = tbitset_elt_alloc (); memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt))); return elt; } static inline void -ebitset_elt_free (ebitset_elt *elt) +tbitset_elt_free (tbitset_elt *elt) { - EBITSET_NEXT (elt) = ebitset_free_list; - ebitset_free_list = elt; + EBITSET_NEXT (elt) = tbitset_free_list; + tbitset_free_list = elt; } /* Remove element with index EINDEX from bitset BSET. */ static inline void -ebitset_elt_remove (bitset bset, bitset_windex eindex) +tbitset_elt_remove (bitset bset, bitset_windex eindex) { - ebitset_elts *elts = EBITSET_ELTS (bset); - ebitset_elt *elt = elts[eindex]; + tbitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elt *elt = elts[eindex]; elts[eindex] = 0; - ebitset_elt_free (elt); + tbitset_elt_free (elt); } /* Add ELT into elts at index EINDEX of bitset BSET. */ static inline void -ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex) +tbitset_elt_add (bitset bset, tbitset_elt *elt, bitset_windex eindex) { - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); /* Assume that the elts entry not allocated. */ elts[eindex] = elt; } @@ -264,7 +263,7 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex) /* Are all bits in an element zero? */ static inline bool -ebitset_elt_zero_p (ebitset_elt *elt) +tbitset_elt_zero_p (tbitset_elt *elt) { for (int i = 0; i < EBITSET_ELT_WORDS; i++) if (EBITSET_WORDS (elt)[i]) @@ -273,18 +272,18 @@ ebitset_elt_zero_p (ebitset_elt *elt) } -static ebitset_elt * -ebitset_elt_find (bitset bset, bitset_bindex bindex, - enum ebitset_find_mode mode) +static tbitset_elt * +tbitset_elt_find (bitset bset, bitset_bindex bindex, + enum tbitset_find_mode mode) { bitset_windex eindex = bindex / EBITSET_ELT_BITS; - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); bitset_windex size = EBITSET_SIZE (bset); if (eindex < size) { - ebitset_elt *elt = elts[eindex]; + tbitset_elt *elt = elts[eindex]; if (elt) { if (EBITSET_WORDS (elt) != bset->b.cdata) @@ -305,41 +304,41 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex, case EBITSET_CREATE: if (eindex >= size) - ebitset_resize (bset, bindex); + tbitset_resize (bset, bindex); /* Create a new element. */ { - ebitset_elt *elt = ebitset_elt_calloc (); - ebitset_elt_add (bset, elt, eindex); + tbitset_elt *elt = tbitset_elt_calloc (); + tbitset_elt_add (bset, elt, eindex); EBITSET_CACHE_SET (bset, eindex); return elt; } case EBITSET_SUBST: - return &ebitset_zero_elts[0]; + return &tbitset_zero_elts[0]; } } /* Weed out the zero elements from the elts. */ static inline bitset_windex -ebitset_weed (bitset bset) +tbitset_weed (bitset bset) { if (EBITSET_ZERO_P (bset)) return 0; - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); bitset_windex count = 0; bitset_windex j; for (j = 0; j < EBITSET_SIZE (bset); j++) { - ebitset_elt *elt = elts[j]; + tbitset_elt *elt = elts[j]; if (elt) { - if (ebitset_elt_zero_p (elt)) + if (tbitset_elt_zero_p (elt)) { - ebitset_elt_remove (bset, j); + tbitset_elt_remove (bset, j); count++; } } @@ -363,17 +362,17 @@ ebitset_weed (bitset bset) /* Set all bits in the bitset to zero. */ static inline void -ebitset_zero (bitset bset) +tbitset_zero (bitset bset) { if (EBITSET_ZERO_P (bset)) return; - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++) { - ebitset_elt *elt = elts[j]; + tbitset_elt *elt = elts[j]; if (elt) - ebitset_elt_remove (bset, j); + tbitset_elt_remove (bset, j); } /* All the bits are zero. We could shrink the elts. @@ -383,24 +382,24 @@ ebitset_zero (bitset bset) static inline bool -ebitset_equal_p (bitset dst, bitset src) +tbitset_equal_p (bitset dst, bitset src) { if (src == dst) return true; - ebitset_weed (dst); - ebitset_weed (src); + tbitset_weed (dst); + tbitset_weed (src); if (EBITSET_SIZE (src) != EBITSET_SIZE (dst)) return false; - ebitset_elts *selts = EBITSET_ELTS (src); - ebitset_elts *delts = EBITSET_ELTS (dst); + tbitset_elts *selts = EBITSET_ELTS (src); + tbitset_elts *delts = EBITSET_ELTS (dst); for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++) { - ebitset_elt *selt = selts[j]; - ebitset_elt *delt = delts[j]; + tbitset_elt *selt = selts[j]; + tbitset_elt *delt = delts[j]; if (!selt && !delt) continue; @@ -417,24 +416,24 @@ ebitset_equal_p (bitset dst, bitset src) /* Copy bits from bitset SRC to bitset DST. */ static inline void -ebitset_copy_ (bitset dst, bitset src) +tbitset_copy_ (bitset dst, bitset src) { if (src == dst) return; - ebitset_zero (dst); + tbitset_zero (dst); if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src)) - ebitset_resize (dst, BITSET_NBITS_ (src)); + tbitset_resize (dst, BITSET_NBITS_ (src)); - ebitset_elts *selts = EBITSET_ELTS (src); - ebitset_elts *delts = EBITSET_ELTS (dst); + tbitset_elts *selts = EBITSET_ELTS (src); + tbitset_elts *delts = EBITSET_ELTS (dst); for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++) { - ebitset_elt *selt = selts[j]; + tbitset_elt *selt = selts[j]; if (selt) { - ebitset_elt *tmp = ebitset_elt_alloc (); + tbitset_elt *tmp = tbitset_elt_alloc (); delts[j] = tmp; memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt), sizeof (EBITSET_WORDS (selt))); @@ -447,32 +446,32 @@ ebitset_copy_ (bitset dst, bitset src) /* Copy bits from bitset SRC to bitset DST. Return true if bitsets different. */ static inline bool -ebitset_copy_cmp (bitset dst, bitset src) +tbitset_copy_cmp (bitset dst, bitset src) { if (src == dst) return false; if (EBITSET_ZERO_P (dst)) { - ebitset_copy_ (dst, src); + tbitset_copy_ (dst, src); return !EBITSET_ZERO_P (src); } - if (ebitset_equal_p (dst, src)) + if (tbitset_equal_p (dst, src)) return false; - ebitset_copy_ (dst, src); + tbitset_copy_ (dst, src); return true; } /* Set bit BITNO in bitset DST. */ static void -ebitset_set (bitset dst, bitset_bindex bitno) +tbitset_set (bitset dst, bitset_bindex bitno) { bitset_windex windex = bitno / BITSET_WORD_BITS; - ebitset_elt_find (dst, bitno, EBITSET_CREATE); + tbitset_elt_find (dst, bitno, EBITSET_CREATE); dst->b.cdata[windex - dst->b.cindex] |= (bitset_word) 1 << (bitno % BITSET_WORD_BITS); @@ -481,11 +480,11 @@ ebitset_set (bitset dst, bitset_bindex bitno) /* Reset bit BITNO in bitset DST. */ static void -ebitset_reset (bitset dst, bitset_bindex bitno) +tbitset_reset (bitset dst, bitset_bindex bitno) { bitset_windex windex = bitno / BITSET_WORD_BITS; - if (!ebitset_elt_find (dst, bitno, EBITSET_FIND)) + if (!tbitset_elt_find (dst, bitno, EBITSET_FIND)) return; dst->b.cdata[windex - dst->b.cindex] &= @@ -499,11 +498,11 @@ ebitset_reset (bitset dst, bitset_bindex bitno) /* Test bit BITNO in bitset SRC. */ static bool -ebitset_test (bitset src, bitset_bindex bitno) +tbitset_test (bitset src, bitset_bindex bitno) { bitset_windex windex = bitno / BITSET_WORD_BITS; - return (ebitset_elt_find (src, bitno, EBITSET_FIND) + return (tbitset_elt_find (src, bitno, EBITSET_FIND) && ((src->b.cdata[windex - src->b.cindex] >> (bitno % BITSET_WORD_BITS)) & 1)); @@ -511,9 +510,9 @@ ebitset_test (bitset src, bitset_bindex bitno) static void -ebitset_free (bitset bset) +tbitset_free (bitset bset) { - ebitset_zero (bset); + tbitset_zero (bset); free (EBITSET_ELTS (bset)); } @@ -522,7 +521,7 @@ ebitset_free (bitset bset) *NEXT and store in array LIST. Return with actual number of bits found and with *NEXT indicating where search stopped. */ static bitset_bindex -ebitset_list_reverse (bitset bset, bitset_bindex *list, +tbitset_list_reverse (bitset bset, bitset_bindex *list, bitset_bindex num, bitset_bindex *next) { if (EBITSET_ZERO_P (bset)) @@ -535,7 +534,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list, if (rbitno >= n_bits) return 0; - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); bitset_bindex bitno = n_bits - (rbitno + 1); @@ -551,7 +550,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list, do { - ebitset_elt *elt = elts[eindex]; + tbitset_elt *elt = elts[eindex]; if (elt) { bitset_word *srcp = EBITSET_WORDS (elt); @@ -592,7 +591,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list, *NEXT and store in array LIST. Return with actual number of bits found and with *NEXT indicating where search stopped. */ static bitset_bindex -ebitset_list (bitset bset, bitset_bindex *list, +tbitset_list (bitset bset, bitset_bindex *list, bitset_bindex num, bitset_bindex *next) { if (EBITSET_ZERO_P (bset)) @@ -601,7 +600,7 @@ ebitset_list (bitset bset, bitset_bindex *list, bitset_bindex bitno = *next; bitset_bindex count = 0; - ebitset_elts *elts = EBITSET_ELTS (bset); + tbitset_elts *elts = EBITSET_ELTS (bset); bitset_windex size = EBITSET_SIZE (bset); bitset_windex eindex = bitno / EBITSET_ELT_BITS; @@ -609,7 +608,7 @@ ebitset_list (bitset bset, bitset_bindex *list, { /* We need to start within an element. This is not very common. */ - ebitset_elt *elt = elts[eindex]; + tbitset_elt *elt = elts[eindex]; if (elt) { bitset_windex woffset; @@ -650,7 +649,7 @@ ebitset_list (bitset bset, bitset_bindex *list, { bitset_word *srcp; - ebitset_elt *elt = elts[eindex]; + tbitset_elt *elt = elts[eindex]; if (!elt) continue; @@ -763,18 +762,18 @@ ebitset_list (bitset bset, bitset_bindex *list, /* Ensure that any unused bits within the last element are clear. */ static inline void -ebitset_unused_clear (bitset dst) +tbitset_unused_clear (bitset dst) { bitset_bindex n_bits = BITSET_NBITS_ (dst); unsigned last_bit = n_bits % EBITSET_ELT_BITS; if (last_bit) { - ebitset_elts *elts = EBITSET_ELTS (dst); + tbitset_elts *elts = EBITSET_ELTS (dst); bitset_windex eindex = n_bits / EBITSET_ELT_BITS; - ebitset_elt *elt = elts[eindex]; + tbitset_elt *elt = elts[eindex]; if (elt) { bitset_word *srcp = EBITSET_WORDS (elt); @@ -792,92 +791,92 @@ ebitset_unused_clear (bitset dst) static void -ebitset_ones (bitset dst) +tbitset_ones (bitset dst) { for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++) { /* Create new elements if they cannot be found. Perhaps we should just add pointers to a ones element? */ - ebitset_elt *elt = - ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE); + tbitset_elt *elt = + tbitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE); memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt))); } EBITSET_NONZERO_SET (dst); - ebitset_unused_clear (dst); + tbitset_unused_clear (dst); } static bool -ebitset_empty_p (bitset dst) +tbitset_empty_p (bitset dst) { if (EBITSET_ZERO_P (dst)) - return 1; + return true; - ebitset_elts *elts = EBITSET_ELTS (dst); + tbitset_elts *elts = EBITSET_ELTS (dst); for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++) { - ebitset_elt *elt = elts[j]; + tbitset_elt *elt = elts[j]; if (elt) { - if (!ebitset_elt_zero_p (elt)) - return 0; + if (!tbitset_elt_zero_p (elt)) + return false; /* Do some weeding as we go. */ - ebitset_elt_remove (dst, j); + tbitset_elt_remove (dst, j); } } /* All the bits are zero. We could shrink the elts. For now just mark DST as known to be zero. */ EBITSET_ZERO_SET (dst); - return 1; + return true; } static void -ebitset_not (bitset dst, bitset src) +tbitset_not (bitset dst, bitset src) { - ebitset_resize (dst, BITSET_NBITS_ (src)); + tbitset_resize (dst, BITSET_NBITS_ (src)); for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++) { /* Create new elements for dst if they cannot be found or substitute zero elements if src elements not found. */ - ebitset_elt *selt = - ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST); - ebitset_elt *delt = - ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE); + tbitset_elt *selt = + tbitset_elt_find (src, j * EBITSET_ELT_BITS, EBITSET_SUBST); + tbitset_elt *delt = + tbitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE); for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++) EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i]; } EBITSET_NONZERO_SET (dst); - ebitset_unused_clear (dst); + tbitset_unused_clear (dst); } /* Is DST == DST | SRC? */ static bool -ebitset_subset_p (bitset dst, bitset src) +tbitset_subset_p (bitset dst, bitset src) { - ebitset_elts *selts = EBITSET_ELTS (src); - ebitset_elts *delts = EBITSET_ELTS (dst); + tbitset_elts *selts = EBITSET_ELTS (src); + tbitset_elts *delts = EBITSET_ELTS (dst); bitset_windex ssize = EBITSET_SIZE (src); bitset_windex dsize = EBITSET_SIZE (dst); for (bitset_windex j = 0; j < ssize; j++) { - ebitset_elt *selt = j < ssize ? selts[j] : 0; - ebitset_elt *delt = j < dsize ? delts[j] : 0; + tbitset_elt *selt = j < ssize ? selts[j] : 0; + tbitset_elt *delt = j < dsize ? delts[j] : 0; if (!selt && !delt) continue; if (!selt) - selt = &ebitset_zero_elts[0]; + selt = &tbitset_zero_elts[0]; if (!delt) - delt = &ebitset_zero_elts[0]; + delt = &tbitset_zero_elts[0]; for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++) if (EBITSET_WORDS (delt)[i] @@ -890,18 +889,18 @@ ebitset_subset_p (bitset dst, bitset src) /* Is DST & SRC == 0? */ static bool -ebitset_disjoint_p (bitset dst, bitset src) +tbitset_disjoint_p (bitset dst, bitset src) { - ebitset_elts *selts = EBITSET_ELTS (src); - ebitset_elts *delts = EBITSET_ELTS (dst); + tbitset_elts *selts = EBITSET_ELTS (src); + tbitset_elts *delts = EBITSET_ELTS (dst); bitset_windex ssize = EBITSET_SIZE (src); bitset_windex dsize = EBITSET_SIZE (dst); for (bitset_windex j = 0; j < ssize; j++) { - ebitset_elt *selt = j < ssize ? selts[j] : 0; - ebitset_elt *delt = j < dsize ? delts[j] : 0; + tbitset_elt *selt = j < ssize ? selts[j] : 0; + tbitset_elt *delt = j < dsize ? delts[j] : 0; if (!selt || !delt) continue; @@ -916,11 +915,11 @@ ebitset_disjoint_p (bitset dst, bitset src) static bool -ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) +tbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) { bool changed = false; - ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2))); + tbitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2))); bitset_windex ssize1 = EBITSET_SIZE (src1); bitset_windex ssize2 = EBITSET_SIZE (src2); @@ -929,33 +928,33 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) if (size < ssize2) size = ssize2; - ebitset_elts *selts1 = EBITSET_ELTS (src1); - ebitset_elts *selts2 = EBITSET_ELTS (src2); - ebitset_elts *delts = EBITSET_ELTS (dst); + tbitset_elts *selts1 = EBITSET_ELTS (src1); + tbitset_elts *selts2 = EBITSET_ELTS (src2); + tbitset_elts *delts = EBITSET_ELTS (dst); bitset_windex j = 0; for (j = 0; j < size; j++) { - ebitset_elt *selt1 = j < ssize1 ? selts1[j] : 0; - ebitset_elt *selt2 = j < ssize2 ? selts2[j] : 0; - ebitset_elt *delt = j < dsize ? delts[j] : 0; + tbitset_elt *selt1 = j < ssize1 ? selts1[j] : 0; + tbitset_elt *selt2 = j < ssize2 ? selts2[j] : 0; + tbitset_elt *delt = j < dsize ? delts[j] : 0; if (!selt1 && !selt2) { if (delt) { changed = true; - ebitset_elt_remove (dst, j); + tbitset_elt_remove (dst, j); } continue; } if (!selt1) - selt1 = &ebitset_zero_elts[0]; + selt1 = &tbitset_zero_elts[0]; if (!selt2) - selt2 = &ebitset_zero_elts[0]; + selt2 = &tbitset_zero_elts[0]; if (!delt) - delt = ebitset_elt_calloc (); + delt = tbitset_elt_calloc (); else delts[j] = 0; @@ -1020,13 +1019,13 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) break; } - if (!ebitset_elt_zero_p (delt)) + if (!tbitset_elt_zero_p (delt)) { - ebitset_elt_add (dst, delt, j); + tbitset_elt_add (dst, delt, j); } else { - ebitset_elt_free (delt); + tbitset_elt_free (delt); } } @@ -1035,9 +1034,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) { changed = true; - ebitset_elt *delt = delts[j]; + tbitset_elt *delt = delts[j]; if (delt) - ebitset_elt_remove (dst, j); + tbitset_elt_remove (dst, j); } EBITSET_NONZERO_SET (dst); @@ -1046,164 +1045,164 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op) static bool -ebitset_and_cmp (bitset dst, bitset src1, bitset src2) +tbitset_and_cmp (bitset dst, bitset src1, bitset src2) { if (EBITSET_ZERO_P (src2)) { - ebitset_weed (dst); + tbitset_weed (dst); bool changed = EBITSET_ZERO_P (dst); - ebitset_zero (dst); + tbitset_zero (dst); return changed; } else if (EBITSET_ZERO_P (src1)) { - ebitset_weed (dst); + tbitset_weed (dst); bool changed = EBITSET_ZERO_P (dst); - ebitset_zero (dst); + tbitset_zero (dst); return changed; } - return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_AND); + return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND); } static void -ebitset_and (bitset dst, bitset src1, bitset src2) +tbitset_and (bitset dst, bitset src1, bitset src2) { - ebitset_and_cmp (dst, src1, src2); + tbitset_and_cmp (dst, src1, src2); } static bool -ebitset_andn_cmp (bitset dst, bitset src1, bitset src2) +tbitset_andn_cmp (bitset dst, bitset src1, bitset src2) { if (EBITSET_ZERO_P (src2)) { - return ebitset_copy_cmp (dst, src1); + return tbitset_copy_cmp (dst, src1); } else if (EBITSET_ZERO_P (src1)) { - ebitset_weed (dst); + tbitset_weed (dst); bool changed = EBITSET_ZERO_P (dst); - ebitset_zero (dst); + tbitset_zero (dst); return changed; } - return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN); + return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN); } static void -ebitset_andn (bitset dst, bitset src1, bitset src2) +tbitset_andn (bitset dst, bitset src1, bitset src2) { - ebitset_andn_cmp (dst, src1, src2); + tbitset_andn_cmp (dst, src1, src2); } static bool -ebitset_or_cmp (bitset dst, bitset src1, bitset src2) +tbitset_or_cmp (bitset dst, bitset src1, bitset src2) { if (EBITSET_ZERO_P (src2)) { - return ebitset_copy_cmp (dst, src1); + return tbitset_copy_cmp (dst, src1); } else if (EBITSET_ZERO_P (src1)) { - return ebitset_copy_cmp (dst, src2); + return tbitset_copy_cmp (dst, src2); } - return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_OR); + return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR); } static void -ebitset_or (bitset dst, bitset src1, bitset src2) +tbitset_or (bitset dst, bitset src1, bitset src2) { - ebitset_or_cmp (dst, src1, src2); + tbitset_or_cmp (dst, src1, src2); } static bool -ebitset_xor_cmp (bitset dst, bitset src1, bitset src2) +tbitset_xor_cmp (bitset dst, bitset src1, bitset src2) { if (EBITSET_ZERO_P (src2)) { - return ebitset_copy_cmp (dst, src1); + return tbitset_copy_cmp (dst, src1); } else if (EBITSET_ZERO_P (src1)) { - return ebitset_copy_cmp (dst, src2); + return tbitset_copy_cmp (dst, src2); } - return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR); + return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR); } static void -ebitset_xor (bitset dst, bitset src1, bitset src2) +tbitset_xor (bitset dst, bitset src1, bitset src2) { - ebitset_xor_cmp (dst, src1, src2); + tbitset_xor_cmp (dst, src1, src2); } static void -ebitset_copy (bitset dst, bitset src) +tbitset_copy (bitset dst, bitset src) { if (BITSET_COMPATIBLE_ (dst, src)) - ebitset_copy_ (dst, src); + tbitset_copy_ (dst, src); else bitset_copy_ (dst, src); } /* Vector of operations for linked-list bitsets. */ -struct bitset_vtable ebitset_vtable = { - ebitset_set, - ebitset_reset, +struct bitset_vtable tbitset_vtable = { + tbitset_set, + tbitset_reset, bitset_toggle_, - ebitset_test, - ebitset_resize, + tbitset_test, + tbitset_resize, bitset_size_, bitset_count_, - ebitset_empty_p, - ebitset_ones, - ebitset_zero, - ebitset_copy, - ebitset_disjoint_p, - ebitset_equal_p, - ebitset_not, - ebitset_subset_p, - ebitset_and, - ebitset_and_cmp, - ebitset_andn, - ebitset_andn_cmp, - ebitset_or, - ebitset_or_cmp, - ebitset_xor, - ebitset_xor_cmp, + tbitset_empty_p, + tbitset_ones, + tbitset_zero, + tbitset_copy, + tbitset_disjoint_p, + tbitset_equal_p, + tbitset_not, + tbitset_subset_p, + tbitset_and, + tbitset_and_cmp, + tbitset_andn, + tbitset_andn_cmp, + tbitset_or, + tbitset_or_cmp, + tbitset_xor, + tbitset_xor_cmp, bitset_and_or_, bitset_and_or_cmp_, bitset_andn_or_, bitset_andn_or_cmp_, bitset_or_and_, bitset_or_and_cmp_, - ebitset_list, - ebitset_list_reverse, - ebitset_free, + tbitset_list, + tbitset_list_reverse, + tbitset_free, BITSET_TABLE }; /* Return size of initial structure. */ size_t -ebitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) +tbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED) { - return sizeof (struct ebitset_struct); + return sizeof (struct tbitset_struct); } /* Initialize a bitset. */ bitset -ebitset_init (bitset bset, bitset_bindex n_bits) +tbitset_init (bitset bset, bitset_bindex n_bits) { - bset->b.vtable = &ebitset_vtable; + bset->b.vtable = &tbitset_vtable; bset->b.csize = EBITSET_ELT_WORDS; @@ -1211,19 +1210,19 @@ ebitset_init (bitset bset, bitset_bindex n_bits) EBITSET_ASIZE (bset) = 0; EBITSET_ELTS (bset) = 0; - ebitset_resize (bset, n_bits); + tbitset_resize (bset, n_bits); return bset; } void -ebitset_release_memory (void) +tbitset_release_memory (void) { - ebitset_free_list = 0; - if (ebitset_obstack_init) + tbitset_free_list = 0; + if (tbitset_obstack_init) { - ebitset_obstack_init = false; - obstack_free (&ebitset_obstack, NULL); + tbitset_obstack_init = false; + obstack_free (&tbitset_obstack, NULL); } } diff --git a/contrib/tools/bison/lib/ebitset.h b/contrib/tools/bison/lib/bitset/table.h index 97b9ee1522..6c781adde3 100644 --- a/contrib/tools/bison/lib/ebitset.h +++ b/contrib/tools/bison/lib/bitset/table.h @@ -1,6 +1,6 @@ -/* Functions to support ebitsets. +/* Functions to support tbitsets. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,15 +18,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _EBITSET_H -#define _EBITSET_H +#ifndef _BITSET_TABLE_H +#define _BITSET_TABLE_H #include "bitset.h" -size_t ebitset_bytes (bitset_bindex); +size_t tbitset_bytes (bitset_bindex); -bitset ebitset_init (bitset, bitset_bindex); +bitset tbitset_init (bitset, bitset_bindex); -void ebitset_release_memory (void); +void tbitset_release_memory (void); #endif diff --git a/contrib/tools/bison/lib/vbitset.c b/contrib/tools/bison/lib/bitset/vector.c index f715f9b4f1..15d3e99567 100644 --- a/contrib/tools/bison/lib/vbitset.c +++ b/contrib/tools/bison/lib/bitset/vector.c @@ -1,7 +1,6 @@ /* Variable array bitsets. - Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -20,7 +19,7 @@ #include <config.h> -#include "vbitset.h" +#include "bitset/vector.h" #include <stdlib.h> #include <string.h> @@ -419,14 +418,12 @@ vbitset_subset_p (bitset dst, bitset src) unsigned i; for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++) if (*dstp != (*srcp | *dstp)) - return 0; + return false; if (ssize > dsize) - { - for (; i < ssize; i++) - if (*srcp++) - return false; - } + for (; i < ssize; i++) + if (*srcp++) + return false; return true; } @@ -966,7 +963,7 @@ struct bitset_vtable vbitset_vtable = { vbitset_list, vbitset_list_reverse, NULL, - BITSET_VARRAY + BITSET_VECTOR }; diff --git a/contrib/tools/bison/lib/vbitset.h b/contrib/tools/bison/lib/bitset/vector.h index 23b4652b87..1f5b94dea0 100644 --- a/contrib/tools/bison/lib/vbitset.h +++ b/contrib/tools/bison/lib/bitset/vector.h @@ -1,6 +1,6 @@ /* Functions to support vbitsets. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _VBITSET_H -#define _VBITSET_H +#ifndef _BITSET_VECTOR_H +#define _BITSET_VECTOR_H #include "bitset.h" diff --git a/contrib/tools/bison/lib/bitsetv-print.c b/contrib/tools/bison/lib/bitsetv-print.c deleted file mode 100644 index d229c7d613..0000000000 --- a/contrib/tools/bison/lib/bitsetv-print.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Bitset vectors. - - Copyright (C) 2001-2002, 2004, 2006, 2009-2015, 2018 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 <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -#include "bitsetv-print.h" - -#include <stdlib.h> - -/*--------------------------------------------------------. -| Display the MATRIX array of SIZE bitsets of size SIZE. | -`--------------------------------------------------------*/ - -void -bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset) -{ - bitset_bindex hsize = bitset_size (bset[0]); - - /* Title. */ - fprintf (out, "%s BEGIN\n", title); - - /* Column numbers. */ - fputs (" ", out); - for (bitset_bindex i = 0; i < hsize; ++i) - putc (i / 10 ? '0' + i / 10 : ' ', out); - putc ('\n', out); - fputs (" ", out); - for (bitset_bindex i = 0; i < hsize; ++i) - fprintf (out, "%d", (int) (i % 10)); - putc ('\n', out); - - /* Bar. */ - fputs (" .", out); - for (bitset_bindex i = 0; i < hsize; ++i) - putc ('-', out); - fputs (".\n", out); - - /* Contents. */ - for (bitset_bindex i = 0; bset[i]; ++i) - { - fprintf (out, "%2lu|", (unsigned long) i); - for (bitset_bindex j = 0; j < hsize; ++j) - fputs (bitset_test (bset[i], j) ? "1" : " ", out); - fputs ("|\n", out); - } - - /* Bar. */ - fputs (" `", out); - for (bitset_bindex i = 0; i < hsize; ++i) - putc ('-', out); - fputs ("'\n", out); - - /* End title. */ - fprintf (out, "%s END\n\n", title); -} diff --git a/contrib/tools/bison/lib/bitsetv-print.h b/contrib/tools/bison/lib/bitsetv-print.h deleted file mode 100644 index b706b04a8d..0000000000 --- a/contrib/tools/bison/lib/bitsetv-print.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Bitset vectors. - - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, - Inc. - - Contributed by Akim Demaille (akim@freefriends.org). - - 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 <http://www.gnu.org/licenses/>. */ - -#ifndef _BITSETV_PRINT_H -#define _BITSETV_PRINT_H - -#include "bitsetv.h" - -/* Dump vector of bitsets as a matrix. */ -void bitsetv_matrix_dump (FILE *, const char *, bitsetv); - -#endif /* _BITSETV_H */ diff --git a/contrib/tools/bison/lib/bitsetv.c b/contrib/tools/bison/lib/bitsetv.c index 7077795d6d..e3cc5845a7 100644 --- a/contrib/tools/bison/lib/bitsetv.c +++ b/contrib/tools/bison/lib/bitsetv.c @@ -1,6 +1,6 @@ /* Bitset vectors. - Copyright (C) 2001-2002, 2004-2006, 2009-2015, 2018 Free Software + Copyright (C) 2001-2002, 2004-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include <stdlib.h> +#include "xalloc.h" + /* Create a vector of N_VECS bitsets, each of N_BITS, and of type TYPE. */ @@ -146,3 +148,51 @@ debug_bitsetv (bitsetv bsetv) fprintf (stderr, "\n"); } + + +/*--------------------------------------------------------. +| Display the MATRIX array of SIZE bitsets of size SIZE. | +`--------------------------------------------------------*/ + +void +bitsetv_matrix_dump (FILE *out, const char *title, bitsetv bset) +{ + bitset_bindex hsize = bitset_size (bset[0]); + + /* Title. */ + fprintf (out, "%s BEGIN\n", title); + + /* Column numbers. */ + fputs (" ", out); + for (bitset_bindex i = 0; i < hsize; ++i) + putc (i / 10 ? '0' + i / 10 : ' ', out); + putc ('\n', out); + fputs (" ", out); + for (bitset_bindex i = 0; i < hsize; ++i) + fprintf (out, "%d", (int) (i % 10)); + putc ('\n', out); + + /* Bar. */ + fputs (" .", out); + for (bitset_bindex i = 0; i < hsize; ++i) + putc ('-', out); + fputs (".\n", out); + + /* Contents. */ + for (bitset_bindex i = 0; bset[i]; ++i) + { + fprintf (out, "%2lu|", (unsigned long) i); + for (bitset_bindex j = 0; j < hsize; ++j) + fputs (bitset_test (bset[i], j) ? "1" : " ", out); + fputs ("|\n", out); + } + + /* Bar. */ + fputs (" `", out); + for (bitset_bindex i = 0; i < hsize; ++i) + putc ('-', out); + fputs ("'\n", out); + + /* End title. */ + fprintf (out, "%s END\n\n", title); +} diff --git a/contrib/tools/bison/lib/bitsetv.h b/contrib/tools/bison/lib/bitsetv.h index 60777a21e0..798b70d9b4 100644 --- a/contrib/tools/bison/lib/bitsetv.h +++ b/contrib/tools/bison/lib/bitsetv.h @@ -1,6 +1,6 @@ /* Bitset vectors. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). @@ -58,4 +58,7 @@ void bitsetv_dump (FILE *, const char *, const char *, bitsetv); /* Function to debug vector of bitsets from debugger. */ void debug_bitsetv (bitsetv); +/* Dump vector of bitsets as a matrix. */ +void bitsetv_matrix_dump (FILE *, const char *, bitsetv); + #endif /* _BITSETV_H */ diff --git a/contrib/tools/bison/lib/c-ctype.h b/contrib/tools/bison/lib/c-ctype.h index d55d4f64e4..4d52176384 100644 --- a/contrib/tools/bison/lib/c-ctype.h +++ b/contrib/tools/bison/lib/c-ctype.h @@ -5,7 +5,7 @@ <ctype.h> functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2019 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 diff --git a/contrib/tools/bison/lib/c-strcase.h b/contrib/tools/bison/lib/c-strcase.h index 41f439e8de..b67c9b5da0 100644 --- a/contrib/tools/bison/lib/c-strcase.h +++ b/contrib/tools/bison/lib/c-strcase.h @@ -1,5 +1,5 @@ /* Case-insensitive string comparison functions in C locale. - Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2018 Free Software + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/c-strcasecmp.c b/contrib/tools/bison/lib/c-strcasecmp.c index 2b1ac99bb6..ec50f1abe7 100644 --- a/contrib/tools/bison/lib/c-strcasecmp.c +++ b/contrib/tools/bison/lib/c-strcasecmp.c @@ -1,5 +1,5 @@ /* c-strcasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/c-strcaseeq.h b/contrib/tools/bison/lib/c-strcaseeq.h index 9bde9de6af..bcc81fc388 100644 --- a/contrib/tools/bison/lib/c-strcaseeq.h +++ b/contrib/tools/bison/lib/c-strcaseeq.h @@ -1,5 +1,5 @@ /* Optimized case-insensitive string comparison in C locale. - Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/c-strncasecmp.c b/contrib/tools/bison/lib/c-strncasecmp.c index 8151c1a834..513c353f6c 100644 --- a/contrib/tools/bison/lib/c-strncasecmp.c +++ b/contrib/tools/bison/lib/c-strncasecmp.c @@ -1,5 +1,5 @@ /* c-strncasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/careadlinkat.c b/contrib/tools/bison/lib/careadlinkat.c new file mode 100644 index 0000000000..e56d503085 --- /dev/null +++ b/contrib/tools/bison/lib/careadlinkat.c @@ -0,0 +1,160 @@ +/* Read symbolic links into a buffer without size limitation, relative to fd. + + Copyright (C) 2001, 2003-2004, 2007, 2009-2019 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, Bruno Haible, and Jim Meyering. */ + +#include <config.h> + +#include "careadlinkat.h" + +#include <errno.h> +#include <limits.h> +#include <string.h> +#include <unistd.h> + +/* Define this independently so that stdint.h is not a prerequisite. */ +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif + +#include "allocator.h" + +/* Assuming the current directory is FD, get the symbolic link value + of FILENAME as a null-terminated string and put it into a buffer. + If FD is AT_FDCWD, FILENAME is interpreted relative to the current + working directory, as in openat. + + If the link is small enough to fit into BUFFER put it there. + BUFFER's size is BUFFER_SIZE, and BUFFER can be null + if BUFFER_SIZE is zero. + + If the link is not small, put it into a dynamically allocated + buffer managed by ALLOC. It is the caller's responsibility to free + the returned value if it is nonnull and is not BUFFER. A null + ALLOC stands for the standard allocator. + + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html> + but can assume that its first argument is the same as FD. + + If successful, return the buffer address; otherwise return NULL and + set errno. */ + +char * +careadlinkat (int fd, char const *filename, + char *buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, char *, size_t)) +{ + char *buf; + size_t buf_size; + size_t buf_size_max = + SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; + char stack_buf[1024]; + + if (! alloc) + alloc = &stdlib_allocator; + + if (! buffer_size) + { + /* 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; + buffer_size = sizeof stack_buf; + } + + buf = buffer; + buf_size = buffer_size; + + do + { + /* Attempt to read the link into the current buffer. */ + ssize_t link_length = preadlinkat (fd, filename, buf, buf_size); + size_t link_size; + if (link_length < 0) + { + /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 + with errno == ERANGE if the buffer is too small. */ + int readlinkat_errno = errno; + if (readlinkat_errno != ERANGE) + { + if (buf != buffer) + { + alloc->free (buf); + errno = readlinkat_errno; + } + return NULL; + } + } + + link_size = link_length; + + if (link_size < buf_size) + { + buf[link_size++] = '\0'; + + if (buf == stack_buf) + { + char *b = (char *) alloc->allocate (link_size); + buf_size = link_size; + if (! b) + break; + memcpy (b, buf, link_size); + buf = b; + } + else if (link_size < buf_size && buf != buffer && alloc->reallocate) + { + /* Shrink BUF before returning it. */ + char *b = (char *) alloc->reallocate (buf, link_size); + if (b) + buf = b; + } + + return buf; + } + + if (buf != buffer) + alloc->free (buf); + + if (buf_size <= buf_size_max / 2) + buf_size *= 2; + else if (buf_size < buf_size_max) + buf_size = buf_size_max; + else if (buf_size_max < SIZE_MAX) + { + errno = ENAMETOOLONG; + return NULL; + } + else + break; + buf = (char *) alloc->allocate (buf_size); + } + while (buf); + + if (alloc->die) + alloc->die (buf_size); + errno = ENOMEM; + return NULL; +} diff --git a/contrib/tools/bison/lib/careadlinkat.h b/contrib/tools/bison/lib/careadlinkat.h new file mode 100644 index 0000000000..68b69aa889 --- /dev/null +++ b/contrib/tools/bison/lib/careadlinkat.h @@ -0,0 +1,67 @@ +/* Read symbolic links into a buffer without size limitation, relative to fd. + + Copyright (C) 2011-2019 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, Bruno Haible, and Jim Meyering. */ + +#ifndef _GL_CAREADLINKAT_H +#define _GL_CAREADLINKAT_H + +#include <fcntl.h> +#include <unistd.h> + +struct allocator; + +/* Assuming the current directory is FD, get the symbolic link value + of FILENAME as a null-terminated string and put it into a buffer. + If FD is AT_FDCWD, FILENAME is interpreted relative to the current + working directory, as in openat. + + If the link is small enough to fit into BUFFER put it there. + BUFFER's size is BUFFER_SIZE, and BUFFER can be null + if BUFFER_SIZE is zero. + + If the link is not small, put it into a dynamically allocated + buffer managed by ALLOC. It is the caller's responsibility to free + the returned value if it is nonnull and is not BUFFER. + + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html> + but can assume that its first argument is the same as FD. + + If successful, return the buffer address; otherwise return NULL and + set errno. */ + +char *careadlinkat (int fd, char const *filename, + char *buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, + char *, size_t)); + +/* Suitable value for careadlinkat's FD argument. */ +#if HAVE_READLINKAT +/* AT_FDCWD is declared in <fcntl.h>. */ +#else +/* Define AT_FDCWD independently, so that the careadlinkat module does + not depend on the fcntl-h module. We might as well use the same value + as fcntl-h. */ +# ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +# endif +#endif + +#endif /* _GL_CAREADLINKAT_H */ diff --git a/contrib/tools/bison/lib/cloexec.c b/contrib/tools/bison/lib/cloexec.c index 238ab18886..db425766a0 100644 --- a/contrib/tools/bison/lib/cloexec.c +++ b/contrib/tools/bison/lib/cloexec.c @@ -1,6 +1,6 @@ /* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 1991, 2004-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1991, 2004-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/cloexec.h b/contrib/tools/bison/lib/cloexec.h index 59028058e6..06ad945d8e 100644 --- a/contrib/tools/bison/lib/cloexec.h +++ b/contrib/tools/bison/lib/cloexec.h @@ -1,6 +1,6 @@ /* cloexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2019 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 diff --git a/contrib/tools/bison/lib/close-stream.c b/contrib/tools/bison/lib/close-stream.c index 3d5a52ebd8..5458c4f29f 100644 --- a/contrib/tools/bison/lib/close-stream.c +++ b/contrib/tools/bison/lib/close-stream.c @@ -1,6 +1,6 @@ /* Close a stream, with nicer error checking than fclose's. - Copyright (C) 1998-2002, 2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2006-2019 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 diff --git a/contrib/tools/bison/lib/close.c b/contrib/tools/bison/lib/close.c index 01c326a28c..40ce845bc3 100644 --- a/contrib/tools/bison/lib/close.c +++ b/contrib/tools/bison/lib/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 diff --git a/contrib/tools/bison/lib/closeout.c b/contrib/tools/bison/lib/closeout.c index 0672732b63..4a604ec35d 100644 --- a/contrib/tools/bison/lib/closeout.c +++ b/contrib/tools/bison/lib/closeout.c @@ -1,6 +1,6 @@ /* Close standard output and standard error, exiting with a diagnostic on error. - Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation, + Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/closeout.h b/contrib/tools/bison/lib/closeout.h index 6629d49934..ac89f760a9 100644 --- a/contrib/tools/bison/lib/closeout.h +++ b/contrib/tools/bison/lib/closeout.h @@ -1,6 +1,6 @@ /* Close standard output and standard error. - Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2018 Free Software + Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/concat-filename.c b/contrib/tools/bison/lib/concat-filename.c index 578cb21fe3..df0e170a89 100644 --- a/contrib/tools/bison/lib/concat-filename.c +++ b/contrib/tools/bison/lib/concat-filename.c @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2019 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 diff --git a/contrib/tools/bison/lib/concat-filename.h b/contrib/tools/bison/lib/concat-filename.h index cca9597d07..4448b783fc 100644 --- a/contrib/tools/bison/lib/concat-filename.h +++ b/contrib/tools/bison/lib/concat-filename.h @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2007-2019 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 diff --git a/contrib/tools/bison/lib/config-linux.h b/contrib/tools/bison/lib/config-linux.h index 7c6759f463..9c4e201410 100644 --- a/contrib/tools/bison/lib/config-linux.h +++ b/contrib/tools/bison/lib/config-linux.h @@ -54,6 +54,9 @@ language is requested. */ /* #undef ENABLE_NLS */ +/* Define to 1 if the package shall run at any location in the file system. */ +/* #undef ENABLE_RELOCATABLE */ + /* Define this to 1 if F_DUPFD behavior does not match POSIX */ /* #undef FCNTL_DUPFD_BUGGY */ @@ -73,6 +76,10 @@ /* Define to 1 if fopen() fails to recognize a trailing slash. */ /* #undef FOPEN_TRAILING_SLASH_BUG */ +/* Define to 1 if realpath() can malloc memory, always gives an absolute path, + and handles trailing slash correctly. */ +#define FUNC_REALPATH_WORKS 1 + /* Define if gettimeofday clobbers the localtime buffer. */ /* #undef GETTIMEOFDAY_CLOBBERS_LOCALTIME */ @@ -81,6 +88,10 @@ #define GETTIMEOFDAY_TIMEZONE void /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module canonicalize-lgpl shall be considered present. */ +#define GNULIB_CANONICALIZE_LGPL 1 + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module close-stream shall be considered present. */ #define GNULIB_CLOSE_STREAM 1 @@ -102,7 +113,7 @@ /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module lock shall be considered present. */ -#define GNULIB_LOCK 1 +/* #undef GNULIB_LOCK */ /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module malloc-gnu shall be considered present. */ @@ -134,11 +145,18 @@ /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module strerror_r-posix shall be considered present. */ -#define GNULIB_STRERROR_R_POSIX 1 +/* #undef GNULIB_STRERROR_R_POSIX */ /* Define to 1 when the gnulib module calloc-posix should be tested. */ #define GNULIB_TEST_CALLOC_POSIX 1 +/* Define to 1 when the gnulib module canonicalize_file_name should be tested. + */ +#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1 + +/* Define to 1 when the gnulib module chdir should be tested. */ +/* #undef GNULIB_TEST_CHDIR */ + /* Define to 1 when the gnulib module cloexec should be tested. */ #define GNULIB_TEST_CLOEXEC 1 @@ -167,7 +185,7 @@ #define GNULIB_TEST_FREXPL 1 /* Define to 1 when the gnulib module fstat should be tested. */ -#define GNULIB_TEST_FSTAT 1 +/* #undef GNULIB_TEST_FSTAT */ /* Define to 1 when the gnulib module getdtablesize should be tested. */ #define GNULIB_TEST_GETDTABLESIZE 1 @@ -194,7 +212,7 @@ #define GNULIB_TEST_LDEXPL 1 /* Define to 1 when the gnulib module lstat should be tested. */ -#define GNULIB_TEST_LSTAT 1 +/* #undef GNULIB_TEST_LSTAT */ /* Define to 1 when the gnulib module malloc-posix should be tested. */ #define GNULIB_TEST_MALLOC_POSIX 1 @@ -266,11 +284,23 @@ #define GNULIB_TEST_RAISE 1 /* Define to 1 when the gnulib module rawmemchr should be tested. */ -#define GNULIB_TEST_RAWMEMCHR 1 +/* #undef GNULIB_TEST_RAWMEMCHR */ + +/* Define to 1 when the gnulib module readlink should be tested. */ +#define GNULIB_TEST_READLINK 1 /* Define to 1 when the gnulib module realloc-posix should be tested. */ #define GNULIB_TEST_REALLOC_POSIX 1 +/* Define to 1 when the gnulib module realpath should be tested. */ +#define GNULIB_TEST_REALPATH 1 + +/* Define to 1 when the gnulib module rename should be tested. */ +#define GNULIB_TEST_RENAME 1 + +/* Define to 1 when the gnulib module rmdir should be tested. */ +/* #undef GNULIB_TEST_RMDIR */ + /* Define to 1 when the gnulib module sigaction should be tested. */ #define GNULIB_TEST_SIGACTION 1 @@ -287,13 +317,13 @@ #define GNULIB_TEST_SPRINTF_POSIX 1 /* Define to 1 when the gnulib module stat should be tested. */ -#define GNULIB_TEST_STAT 1 +/* #undef GNULIB_TEST_STAT */ /* Define to 1 when the gnulib module stpcpy should be tested. */ #define GNULIB_TEST_STPCPY 1 /* Define to 1 when the gnulib module strchrnul should be tested. */ -#define GNULIB_TEST_STRCHRNUL 1 +/* #undef GNULIB_TEST_STRCHRNUL */ /* Define to 1 when the gnulib module strdup should be tested. */ #define GNULIB_TEST_STRDUP 1 @@ -302,13 +332,13 @@ #define GNULIB_TEST_STRERROR 1 /* Define to 1 when the gnulib module strerror_r should be tested. */ -#define GNULIB_TEST_STRERROR_R 1 +/* #undef GNULIB_TEST_STRERROR_R */ /* Define to 1 when the gnulib module strndup should be tested. */ #define GNULIB_TEST_STRNDUP 1 /* Define to 1 when the gnulib module strnlen should be tested. */ -#define GNULIB_TEST_STRNLEN 1 +/* #undef GNULIB_TEST_STRNLEN */ /* Define to 1 when the gnulib module strverscmp should be tested. */ #define GNULIB_TEST_STRVERSCMP 1 @@ -351,6 +381,9 @@ /* Define if the 'calloc' function is POSIX compliant. */ #define HAVE_CALLOC_POSIX 1 +/* Define to 1 if you have the `canonicalize_file_name' function. */ +#define HAVE_CANONICALIZE_FILE_NAME 1 + /* Define to 1 if you have the `catgets' function. */ #define HAVE_CATGETS 1 @@ -494,6 +527,10 @@ don't. */ #define HAVE_DECL_PUTC_UNLOCKED 1 +/* Define to 1 if you have the declaration of `setenv', and to 0 if you don't. + */ +#define HAVE_DECL_SETENV 1 + /* Define to 1 if you have the declaration of `snprintf', and to 0 if you don't. */ #define HAVE_DECL_SNPRINTF 1 @@ -560,6 +597,9 @@ /* Define if the frexp function is available in libc. */ #define HAVE_FREXP_IN_LIBC 1 +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + /* Define to 1 if you have the `getdtablesize' function. */ #define HAVE_GETDTABLESIZE 1 @@ -604,7 +644,7 @@ #define HAVE_ISNAND_IN_LIBC 1 /* Define if the isnan(float) function is available in libc. */ -#define HAVE_ISNANF_IN_LIBC 1 +/* #undef HAVE_ISNANF_IN_LIBC */ /* Define if the isnan(long double) function is available in libc. */ #define HAVE_ISNANL_IN_LIBC 1 @@ -627,6 +667,9 @@ /* Define to 1 if you have the <limits.h> header file. */ #define HAVE_LIMITS_H 1 +/* Define to 1 if you have the `link' function. */ +#define HAVE_LINK 1 + /* Define to 1 if you have the <locale.h> header file. */ #define HAVE_LOCALE_H 1 @@ -636,6 +679,9 @@ /* Define to 1 if you have the `lstat' function. */ #define HAVE_LSTAT 1 +/* Define to 1 if you have the <mach-o/dyld.h> header file. */ +/* #undef HAVE_MACH_O_DYLD_H */ + /* Define to 1 if your system has a GNU libc compatible 'malloc' function, and to 0 otherwise. */ #define HAVE_MALLOC_GNU 1 @@ -709,10 +755,10 @@ #define HAVE_POSIX_SPAWN_FILE_ACTIONS_T 1 /* Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE. */ -#define HAVE_PTHREAD_MUTEX_RECURSIVE 1 +/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE */ /* Define if the POSIX multithreading library has read/write locks. */ -#define HAVE_PTHREAD_RWLOCK 1 +/* #undef HAVE_PTHREAD_RWLOCK */ /* Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader. */ @@ -722,11 +768,20 @@ #define HAVE_RAISE 1 /* Define to 1 if you have the `rawmemchr' function. */ -#define HAVE_RAWMEMCHR 1 +/* #undef HAVE_RAWMEMCHR */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 /* Define if the 'realloc' function is POSIX compliant. */ #define HAVE_REALLOC_POSIX 1 +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + /* Define to 1 if 'long double' and 'double' have the same representation. */ /* #undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE */ @@ -739,12 +794,18 @@ /* Define to 1 if you have the `sched_setscheduler' function. */ /* #undef HAVE_SCHED_SETSCHEDULER */ +/* Define to 1 if you have the <search.h> header file. */ +#define HAVE_SEARCH_H 1 + /* Define to 1 if you have the `setdtablesize' function. */ /* #undef HAVE_SETDTABLESIZE */ /* Define to 1 if you have the `setegid' function. */ /* #undef HAVE_SETEGID */ +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + /* Define to 1 if you have the `seteuid' function. */ /* #undef HAVE_SETEUID */ @@ -806,7 +867,7 @@ #define HAVE_STPCPY 1 /* Define to 1 if you have the `strchrnul' function. */ -#define HAVE_STRCHRNUL 1 +/* #undef HAVE_STRCHRNUL */ /* Define to 1 if you have the `strdup' function. */ #define HAVE_STRDUP 1 @@ -839,7 +900,7 @@ /* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */ /* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1 +/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */ /* Define to 1 if `st_birthtimensec' is a member of `struct stat'. */ /* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC */ @@ -898,6 +959,9 @@ /* Define to 1 if you have the `towlower' function. */ #define HAVE_TOWLOWER 1 +/* Define to 1 if you have the `tsearch' function. */ +#define HAVE_TSEARCH 1 + /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 @@ -958,6 +1022,9 @@ /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 +/* Define to 1 if you have the `_NSGetExecutablePath' function. */ +/* #undef HAVE__NSGETEXECUTABLEPATH */ + /* Define to 1 if you have the `_set_invalid_parameter_handler' function. */ /* #undef HAVE__SET_INVALID_PARAMETER_HANDLER */ @@ -967,6 +1034,9 @@ /* Define to 1 if you have the `__xpg_strerror_r' function. */ #define HAVE___XPG_STRERROR_R 1 +/* Define to the value of ${prefix}, as a string. */ +#define INSTALLPREFIX "/var/empty/bison-3.3.2" + /* Define as the bit index in the word where to find bit 0 of the exponent of 'long double'. */ /* #undef LDBL_EXPBIT0_BIT */ @@ -1080,13 +1150,13 @@ #define PACKAGE_BUGREPORT "bug-bison@gnu.org" /* The copyright year for this package */ -#define PACKAGE_COPYRIGHT_YEAR 2018 +#define PACKAGE_COPYRIGHT_YEAR 2019 /* Define to the full name of this package. */ #define PACKAGE_NAME "GNU Bison" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Bison 3.2.4" +#define PACKAGE_STRING "GNU Bison 3.3.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "bison" @@ -1095,7 +1165,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/bison/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.2.4" +#define PACKAGE_VERSION "3.3.2" /* Define if <inttypes.h> exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -1111,6 +1181,25 @@ 'ptrdiff_t'. */ /* #undef PTRDIFF_T_SUFFIX */ +/* Define to 1 if readlink fails to recognize a trailing slash. */ +/* #undef READLINK_TRAILING_SLASH_BUG */ + +/* Define if rename does not work when the destination file exists, as on + Cygwin 1.5 or Windows. */ +/* #undef RENAME_DEST_EXISTS_BUG */ + +/* Define if rename fails to leave hard links alone, as on NetBSD 1.6 or + Cygwin 1.5. */ +/* #undef RENAME_HARD_LINK_BUG */ + +/* Define if rename does not correctly handle slashes on the destination + argument, such as on Solaris 11 or NetBSD 1.6. */ +/* #undef RENAME_TRAILING_SLASH_DEST_BUG */ + +/* Define if rename does not correctly handle slashes on the source argument, + such as on Solaris 9 or cygwin 1.5. */ +/* #undef RENAME_TRAILING_SLASH_SOURCE_BUG */ + /* Define if fprintf is overridden by a POSIX compliant gnulib implementation. */ #define REPLACE_FPRINTF_POSIX 1 @@ -1178,7 +1267,7 @@ /* Define to 1 if the type of the st_atim member of a struct stat is struct timespec. */ -#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1 +/* #undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC */ /* Define to 1 if unlink() on a parent directory may succeed */ /* #undef UNLINK_PARENT_BUG */ @@ -1290,7 +1379,7 @@ /* #undef USE_WINDOWS_THREADS */ /* Version number of package */ -#define VERSION "3.2.4" +#define VERSION "3.3.2" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ diff --git a/contrib/tools/bison/lib/config-win.h b/contrib/tools/bison/lib/config-win.h index 25076ea809..4e3fc4ebfa 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.2.4" +#define PACKAGE_STRING "GNU Bison 3.3.2" /* 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.2.4" +#define PACKAGE_VERSION "3.3.2" /* 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.2.4" +#define VERSION "3.3.2" /* Define to 1 if unsetenv returns void instead of int. */ /* #undef VOID_UNSETENV */ diff --git a/contrib/tools/bison/lib/configmake-linux.h b/contrib/tools/bison/lib/configmake-linux.h index bd096ef005..14fe253583 100644 --- a/contrib/tools/bison/lib/configmake-linux.h +++ b/contrib/tools/bison/lib/configmake-linux.h @@ -1,28 +1,28 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -#define PREFIX "/var/empty/bison-3.2.4" -#define EXEC_PREFIX "/var/empty/bison-3.2.4" -#define BINDIR "/var/empty/bison-3.2.4/bin" -#define SBINDIR "/var/empty/bison-3.2.4/sbin" -#define LIBEXECDIR "/var/empty/bison-3.2.4/libexec" -#define DATAROOTDIR "/var/empty/bison-3.2.4/share" -#define DATADIR "/var/empty/bison-3.2.4/share" -#define SYSCONFDIR "/var/empty/bison-3.2.4/etc" -#define SHAREDSTATEDIR "/var/empty/bison-3.2.4/com" -#define LOCALSTATEDIR "/var/empty/bison-3.2.4/var" -#define RUNSTATEDIR "/var/empty/bison-3.2.4/var/run" -#define INCLUDEDIR "/var/empty/bison-3.2.4/include" +#define PREFIX "/var/empty/bison-3.3.2" +#define EXEC_PREFIX "/var/empty/bison-3.3.2" +#define BINDIR "/var/empty/bison-3.3.2/bin" +#define SBINDIR "/var/empty/bison-3.3.2/sbin" +#define LIBEXECDIR "/var/empty/bison-3.3.2/libexec" +#define DATAROOTDIR "/var/empty/bison-3.3.2/share" +#define DATADIR "/var/empty/bison-3.3.2/share" +#define SYSCONFDIR "/var/empty/bison-3.3.2/etc" +#define SHAREDSTATEDIR "/var/empty/bison-3.3.2/com" +#define LOCALSTATEDIR "/var/empty/bison-3.3.2/var" +#define RUNSTATEDIR "/var/empty/bison-3.3.2/var/run" +#define INCLUDEDIR "/var/empty/bison-3.3.2/include" #define OLDINCLUDEDIR "/usr/include" -#define DOCDIR "/var/empty/bison-3.2.4/share/doc/bison" -#define INFODIR "/var/empty/bison-3.2.4/share/info" -#define HTMLDIR "/var/empty/bison-3.2.4/share/doc/bison" -#define DVIDIR "/var/empty/bison-3.2.4/share/doc/bison" -#define PDFDIR "/var/empty/bison-3.2.4/share/doc/bison" -#define PSDIR "/var/empty/bison-3.2.4/share/doc/bison" -#define LIBDIR "/var/empty/bison-3.2.4/lib" -#define LISPDIR "/var/empty/bison-3.2.4/share/emacs/site-lisp" -#define LOCALEDIR "/var/empty/bison-3.2.4/share/locale" -#define MANDIR "/var/empty/bison-3.2.4/share/man" -#define PKGDATADIR "/var/empty/bison-3.2.4/share/bison" -#define PKGINCLUDEDIR "/var/empty/bison-3.2.4/include/bison" -#define PKGLIBDIR "/var/empty/bison-3.2.4/lib/bison" -#define PKGLIBEXECDIR "/var/empty/bison-3.2.4/libexec/bison" +#define DOCDIR "/var/empty/bison-3.3.2/share/doc/bison" +#define INFODIR "/var/empty/bison-3.3.2/share/info" +#define HTMLDIR "/var/empty/bison-3.3.2/share/doc/bison" +#define DVIDIR "/var/empty/bison-3.3.2/share/doc/bison" +#define PDFDIR "/var/empty/bison-3.3.2/share/doc/bison" +#define PSDIR "/var/empty/bison-3.3.2/share/doc/bison" +#define LIBDIR "/var/empty/bison-3.3.2/lib" +#define LISPDIR "/var/empty/bison-3.3.2/share/emacs/site-lisp" +#define LOCALEDIR "/var/empty/bison-3.3.2/share/locale" +#define MANDIR "/var/empty/bison-3.3.2/share/man" +#define PKGDATADIR "/var/empty/bison-3.3.2/share/bison" +#define PKGINCLUDEDIR "/var/empty/bison-3.3.2/include/bison" +#define PKGLIBDIR "/var/empty/bison-3.3.2/lib/bison" +#define PKGLIBEXECDIR "/var/empty/bison-3.3.2/libexec/bison" diff --git a/contrib/tools/bison/lib/dirname-lgpl.c b/contrib/tools/bison/lib/dirname-lgpl.c index a40f6a901f..7cf89d8cf8 100644 --- a/contrib/tools/bison/lib/dirname-lgpl.c +++ b/contrib/tools/bison/lib/dirname-lgpl.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2018 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/dirname.c b/contrib/tools/bison/lib/dirname.c index 766f862569..1e042a5cdc 100644 --- a/contrib/tools/bison/lib/dirname.c +++ b/contrib/tools/bison/lib/dirname.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2018 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/dirname.h b/contrib/tools/bison/lib/dirname.h index 8b5111168d..579165947f 100644 --- a/contrib/tools/bison/lib/dirname.h +++ b/contrib/tools/bison/lib/dirname.h @@ -1,6 +1,6 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003-2006, 2009-2018 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/dosname.h b/contrib/tools/bison/lib/dosname.h index fef3b6daa1..c0ab6848a5 100644 --- a/contrib/tools/bison/lib/dosname.h +++ b/contrib/tools/bison/lib/dosname.h @@ -1,6 +1,6 @@ /* File names on MS-DOS/Windows systems. - Copyright (C) 2000-2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2004-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/dup-safer-flag.c b/contrib/tools/bison/lib/dup-safer-flag.c index aa28194d53..485f7411bd 100644 --- a/contrib/tools/bison/lib/dup-safer-flag.c +++ b/contrib/tools/bison/lib/dup-safer-flag.c @@ -1,7 +1,7 @@ /* Duplicate a file descriptor result, avoiding clobbering STD{IN,OUT,ERR}_FILENO, with specific flags. - Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/dup-safer.c b/contrib/tools/bison/lib/dup-safer.c index 1f1679ea18..c0c5f2a914 100644 --- a/contrib/tools/bison/lib/dup-safer.c +++ b/contrib/tools/bison/lib/dup-safer.c @@ -1,6 +1,6 @@ /* Invoke dup, but avoid some glitches. - Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/dup2.c b/contrib/tools/bison/lib/dup2.c index ba417823e9..56a2794478 100644 --- a/contrib/tools/bison/lib/dup2.c +++ b/contrib/tools/bison/lib/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/error.c b/contrib/tools/bison/lib/error.c index adc873391c..7e532f0e48 100644 --- a/contrib/tools/bison/lib/error.c +++ b/contrib/tools/bison/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/error.h b/contrib/tools/bison/lib/error.h index 36401e1aa3..3759f8ad44 100644 --- a/contrib/tools/bison/lib/error.h +++ b/contrib/tools/bison/lib/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995-1997, 2003, 2006, 2008-2018 Free Software Foundation, + Copyright (C) 1995-1997, 2003, 2006, 2008-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/contrib/tools/bison/lib/exitfail.c b/contrib/tools/bison/lib/exitfail.c index 19c5cba049..69b351372e 100644 --- a/contrib/tools/bison/lib/exitfail.c +++ b/contrib/tools/bison/lib/exitfail.c @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/exitfail.h b/contrib/tools/bison/lib/exitfail.h index a42057b11a..480ad1a166 100644 --- a/contrib/tools/bison/lib/exitfail.h +++ b/contrib/tools/bison/lib/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2019 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 diff --git a/contrib/tools/bison/lib/fatal-signal.c b/contrib/tools/bison/lib/fatal-signal.c index 9d795f746d..1fe31d10f5 100644 --- a/contrib/tools/bison/lib/fatal-signal.c +++ b/contrib/tools/bison/lib/fatal-signal.c @@ -1,5 +1,5 @@ /* Emergency actions in case of a fatal signal. - Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fatal-signal.h b/contrib/tools/bison/lib/fatal-signal.h index 41b4af7392..a2e60d3a62 100644 --- a/contrib/tools/bison/lib/fatal-signal.h +++ b/contrib/tools/bison/lib/fatal-signal.h @@ -1,5 +1,5 @@ /* Emergency actions in case of a fatal signal. - Copyright (C) 2003-2004, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2009-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fcntl.c b/contrib/tools/bison/lib/fcntl.c index bdf1e5bbda..e65f1b21c7 100644 --- a/contrib/tools/bison/lib/fcntl.c +++ b/contrib/tools/bison/lib/fcntl.c @@ -1,6 +1,6 @@ /* Provide file descriptor control. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 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 @@ -545,7 +545,7 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target) #ifdef __KLIBC__ static int -klibc_fcntl (int fd, int action, /* arg */...); +klibc_fcntl (int fd, int action, /* arg */...) { va_list arg_ptr; int arg; diff --git a/contrib/tools/bison/lib/fd-hook.c b/contrib/tools/bison/lib/fd-hook.c index 95a0662bc0..78791198fa 100644 --- a/contrib/tools/bison/lib/fd-hook.c +++ b/contrib/tools/bison/lib/fd-hook.c @@ -1,5 +1,5 @@ /* Hook for making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it diff --git a/contrib/tools/bison/lib/fd-hook.h b/contrib/tools/bison/lib/fd-hook.h index dbc5b67a81..bf07f0068b 100644 --- a/contrib/tools/bison/lib/fd-hook.h +++ b/contrib/tools/bison/lib/fd-hook.h @@ -1,5 +1,5 @@ /* Hook for making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 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 diff --git a/contrib/tools/bison/lib/fd-safer-flag.c b/contrib/tools/bison/lib/fd-safer-flag.c index b7574848d7..7c026ef541 100644 --- a/contrib/tools/bison/lib/fd-safer-flag.c +++ b/contrib/tools/bison/lib/fd-safer-flag.c @@ -1,7 +1,7 @@ /* Adjust a file descriptor result so that it avoids clobbering STD{IN,OUT,ERR}_FILENO, with specific flags. - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/fd-safer.c b/contrib/tools/bison/lib/fd-safer.c index 1ea9a4981d..b5113e1367 100644 --- a/contrib/tools/bison/lib/fd-safer.c +++ b/contrib/tools/bison/lib/fd-safer.c @@ -1,6 +1,6 @@ /* Return a safer copy of a file descriptor. - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/filename.h b/contrib/tools/bison/lib/filename.h index a7ad7e7e0c..3ba31059f6 100644 --- a/contrib/tools/bison/lib/filename.h +++ b/contrib/tools/bison/lib/filename.h @@ -1,5 +1,5 @@ /* Basic filename support macros. - Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2007-2019 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 diff --git a/contrib/tools/bison/lib/float+.h b/contrib/tools/bison/lib/float+.h index 2cb858f6a8..5af861f7ae 100644 --- a/contrib/tools/bison/lib/float+.h +++ b/contrib/tools/bison/lib/float+.h @@ -1,5 +1,5 @@ /* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fopen-safer.c b/contrib/tools/bison/lib/fopen-safer.c index faf7b66426..5d4a4a9e75 100644 --- a/contrib/tools/bison/lib/fopen-safer.c +++ b/contrib/tools/bison/lib/fopen-safer.c @@ -1,6 +1,6 @@ /* Invoke fopen, but avoid some glitches. - Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/fpending.c b/contrib/tools/bison/lib/fpending.c index de370d4b10..3c01285bb8 100644 --- a/contrib/tools/bison/lib/fpending.c +++ b/contrib/tools/bison/lib/fpending.c @@ -1,5 +1,5 @@ /* fpending.c -- return the number of pending output bytes on a stream - Copyright (C) 2000, 2004, 2006-2007, 2009-2018 Free Software Foundation, + Copyright (C) 2000, 2004, 2006-2007, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fpending.h b/contrib/tools/bison/lib/fpending.h index 2ff26bc6af..097a3ef071 100644 --- a/contrib/tools/bison/lib/fpending.h +++ b/contrib/tools/bison/lib/fpending.h @@ -1,6 +1,6 @@ /* Declare __fpending. - Copyright (C) 2000, 2003, 2005-2006, 2009-2018 Free Software Foundation, + Copyright (C) 2000, 2003, 2005-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fpucw.h b/contrib/tools/bison/lib/fpucw.h index 0c04800885..caa51fe3bb 100644 --- a/contrib/tools/bison/lib/fpucw.h +++ b/contrib/tools/bison/lib/fpucw.h @@ -1,5 +1,5 @@ /* Manipulating the FPU control word. -*- coding: utf-8 -*- - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2007. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/fseterr.c b/contrib/tools/bison/lib/fseterr.c index 81f51edade..8cd68e8ce7 100644 --- a/contrib/tools/bison/lib/fseterr.c +++ b/contrib/tools/bison/lib/fseterr.c @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 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 diff --git a/contrib/tools/bison/lib/fseterr.h b/contrib/tools/bison/lib/fseterr.h index d61643313a..7b57faa3d2 100644 --- a/contrib/tools/bison/lib/fseterr.h +++ b/contrib/tools/bison/lib/fseterr.h @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/get-errno.c b/contrib/tools/bison/lib/get-errno.c index fdce06586a..36e07adaff 100644 --- a/contrib/tools/bison/lib/get-errno.c +++ b/contrib/tools/bison/lib/get-errno.c @@ -1,7 +1,7 @@ /* get-errno.c - get and set errno. - Copyright (C) 2002, 2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002, 2006, 2009-2015, 2018-2019 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 diff --git a/contrib/tools/bison/lib/get-errno.h b/contrib/tools/bison/lib/get-errno.h index 39c9c8a1f7..c13ac6b319 100644 --- a/contrib/tools/bison/lib/get-errno.h +++ b/contrib/tools/bison/lib/get-errno.h @@ -1,6 +1,7 @@ /* get-errno.h - get and set errno. - Copyright (C) 2002, 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2015, 2018-2019 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 diff --git a/contrib/tools/bison/lib/getdtablesize.c b/contrib/tools/bison/lib/getdtablesize.c index ac05bc483c..03a92435f0 100644 --- a/contrib/tools/bison/lib/getdtablesize.c +++ b/contrib/tools/bison/lib/getdtablesize.c @@ -1,5 +1,5 @@ /* getdtablesize() function: Return maximum possible file descriptor value + 1. - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/gethrxtime.c b/contrib/tools/bison/lib/gethrxtime.c index 97e57ad577..877596257a 100644 --- a/contrib/tools/bison/lib/gethrxtime.c +++ b/contrib/tools/bison/lib/gethrxtime.c @@ -1,6 +1,6 @@ /* gethrxtime -- get high resolution real time - Copyright (C) 2005-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/gethrxtime.h b/contrib/tools/bison/lib/gethrxtime.h index bb781911e2..6491794554 100644 --- a/contrib/tools/bison/lib/gethrxtime.h +++ b/contrib/tools/bison/lib/gethrxtime.h @@ -1,6 +1,6 @@ /* gethrxtime -- get high resolution real time - Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2019 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 diff --git a/contrib/tools/bison/lib/getopt.c b/contrib/tools/bison/lib/getopt.c index 11e36eef81..8ee075a809 100644 --- a/contrib/tools/bison/lib/getopt.c +++ b/contrib/tools/bison/lib/getopt.c @@ -1,5 +1,5 @@ /* Getopt for GNU. - Copyright (C) 1987-2018 Free Software Foundation, Inc. + Copyright (C) 1987-2019 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/contrib/tools/bison/lib/getopt1.c b/contrib/tools/bison/lib/getopt1.c index 9c7fff4c73..883aa6bbc9 100644 --- a/contrib/tools/bison/lib/getopt1.c +++ b/contrib/tools/bison/lib/getopt1.c @@ -1,5 +1,5 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-2018 Free Software Foundation, Inc. + Copyright (C) 1987-2019 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/contrib/tools/bison/lib/getopt_int.h b/contrib/tools/bison/lib/getopt_int.h index b0e9a6d012..e63706f60e 100644 --- a/contrib/tools/bison/lib/getopt_int.h +++ b/contrib/tools/bison/lib/getopt_int.h @@ -1,5 +1,5 @@ /* Internal declarations for getopt. - Copyright (C) 1989-2018 Free Software Foundation, Inc. + Copyright (C) 1989-2019 Free Software Foundation, Inc. This file is part of the GNU C Library and is also part of gnulib. Patches to this file should be submitted to both projects. diff --git a/contrib/tools/bison/lib/getprogname.c b/contrib/tools/bison/lib/getprogname.c index 284581da24..50fe23cb89 100644 --- a/contrib/tools/bison/lib/getprogname.c +++ b/contrib/tools/bison/lib/getprogname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 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 diff --git a/contrib/tools/bison/lib/getprogname.h b/contrib/tools/bison/lib/getprogname.h index ee6688fc2a..1590b38d3f 100644 --- a/contrib/tools/bison/lib/getprogname.h +++ b/contrib/tools/bison/lib/getprogname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2019 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 diff --git a/contrib/tools/bison/lib/gettext.h b/contrib/tools/bison/lib/gettext.h index f2d7458f4a..c7c0fdb531 100644 --- a/contrib/tools/bison/lib/gettext.h +++ b/contrib/tools/bison/lib/gettext.h @@ -1,5 +1,5 @@ /* Convenience header for conditional use of GNU <libintl.h>. - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -184,9 +184,16 @@ npgettext_aux (const char *domain, #include <string.h> -#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ == 199901L - || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ) +/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. + This relates to the -Wvla and -Wvla-larger-than warnings, enabled in + the default GCC many warnings set. This allows programs to disable use + of VLAs, which may be unintended, or may be awkward to support portably, + or may have security implications due to non-deterministic stack usage. */ + +#if (!defined GNULIB_NO_VLA \ + && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ + /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) + || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )) # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 #else # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 diff --git a/contrib/tools/bison/lib/gl_array_list.c b/contrib/tools/bison/lib/gl_array_list.c new file mode 100644 index 0000000000..4ac743fde4 --- /dev/null +++ b/contrib/tools/bison/lib/gl_array_list.c @@ -0,0 +1,680 @@ +/* Sequential list data type implemented by an array. + Copyright (C) 2006-2019 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2006. + + 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> + +/* Specification. */ +#include "gl_array_list.h" + +#include <stdlib.h> +/* Get memcpy. */ +#include <string.h> + +/* Checked size_t computations. */ +#include "xsize.h" + +#ifndef uintptr_t +# define uintptr_t unsigned long +#endif + +/* -------------------------- gl_list_t Data Type -------------------------- */ + +/* Concrete gl_list_impl type, valid for this file only. */ +struct gl_list_impl +{ + struct gl_list_impl_base base; + /* An array of ALLOCATED elements, of which the first COUNT are used. + 0 <= COUNT <= ALLOCATED. */ + const void **elements; + size_t count; + size_t allocated; +}; + +/* struct gl_list_node_impl doesn't exist here. The pointers are actually + indices + 1. */ +#define INDEX_TO_NODE(index) (gl_list_node_t)(uintptr_t)(size_t)((index) + 1) +#define NODE_TO_INDEX(node) ((uintptr_t)(node) - 1) + +static gl_list_t +gl_array_nx_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates) +{ + struct gl_list_impl *list = + (struct gl_list_impl *) malloc (sizeof (struct gl_list_impl)); + + if (list == NULL) + return NULL; + + list->base.vtable = implementation; + list->base.equals_fn = equals_fn; + list->base.hashcode_fn = hashcode_fn; + list->base.dispose_fn = dispose_fn; + list->base.allow_duplicates = allow_duplicates; + list->elements = NULL; + list->count = 0; + list->allocated = 0; + + return list; +} + +static gl_list_t +gl_array_nx_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents) +{ + struct gl_list_impl *list = + (struct gl_list_impl *) malloc (sizeof (struct gl_list_impl)); + + if (list == NULL) + return NULL; + + list->base.vtable = implementation; + list->base.equals_fn = equals_fn; + list->base.hashcode_fn = hashcode_fn; + list->base.dispose_fn = dispose_fn; + list->base.allow_duplicates = allow_duplicates; + if (count > 0) + { + if (size_overflow_p (xtimes (count, sizeof (const void *)))) + goto fail; + list->elements = (const void **) malloc (count * sizeof (const void *)); + if (list->elements == NULL) + goto fail; + memcpy (list->elements, contents, count * sizeof (const void *)); + } + else + list->elements = NULL; + list->count = count; + list->allocated = count; + + return list; + + fail: + free (list); + return NULL; +} + +static size_t +gl_array_size (gl_list_t list) +{ + return list->count; +} + +static const void * _GL_ATTRIBUTE_PURE +gl_array_node_value (gl_list_t list, gl_list_node_t node) +{ + uintptr_t index = NODE_TO_INDEX (node); + if (!(index < list->count)) + /* Invalid argument. */ + abort (); + return list->elements[index]; +} + +static int +gl_array_node_nx_set_value (gl_list_t list, gl_list_node_t node, + const void *elt) +{ + uintptr_t index = NODE_TO_INDEX (node); + if (!(index < list->count)) + /* Invalid argument. */ + abort (); + list->elements[index] = elt; + return 0; +} + +static gl_list_node_t _GL_ATTRIBUTE_PURE +gl_array_next_node (gl_list_t list, gl_list_node_t node) +{ + uintptr_t index = NODE_TO_INDEX (node); + if (!(index < list->count)) + /* Invalid argument. */ + abort (); + index++; + if (index < list->count) + return INDEX_TO_NODE (index); + else + return NULL; +} + +static gl_list_node_t _GL_ATTRIBUTE_PURE +gl_array_previous_node (gl_list_t list, gl_list_node_t node) +{ + uintptr_t index = NODE_TO_INDEX (node); + if (!(index < list->count)) + /* Invalid argument. */ + abort (); + if (index > 0) + return INDEX_TO_NODE (index - 1); + else + return NULL; +} + +static const void * _GL_ATTRIBUTE_PURE +gl_array_get_at (gl_list_t list, size_t position) +{ + size_t count = list->count; + + if (!(position < count)) + /* Invalid argument. */ + abort (); + return list->elements[position]; +} + +static gl_list_node_t +gl_array_nx_set_at (gl_list_t list, size_t position, const void *elt) +{ + size_t count = list->count; + + if (!(position < count)) + /* Invalid argument. */ + abort (); + list->elements[position] = elt; + return INDEX_TO_NODE (position); +} + +static size_t +gl_array_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, + const void *elt) +{ + size_t count = list->count; + + if (!(start_index <= end_index && end_index <= count)) + /* Invalid arguments. */ + abort (); + + if (start_index < end_index) + { + gl_listelement_equals_fn equals = list->base.equals_fn; + if (equals != NULL) + { + size_t i; + + for (i = start_index;;) + { + if (equals (elt, list->elements[i])) + return i; + i++; + if (i == end_index) + break; + } + } + else + { + size_t i; + + for (i = start_index;;) + { + if (elt == list->elements[i]) + return i; + i++; + if (i == end_index) + break; + } + } + } + return (size_t)(-1); +} + +static gl_list_node_t +gl_array_search_from_to (gl_list_t list, size_t start_index, size_t end_index, + const void *elt) +{ + size_t index = gl_array_indexof_from_to (list, start_index, end_index, elt); + return INDEX_TO_NODE (index); +} + +/* Ensure that list->allocated > list->count. + Return 0 upon success, -1 upon out-of-memory. */ +static int +grow (gl_list_t list) +{ + size_t new_allocated; + size_t memory_size; + const void **memory; + + new_allocated = xtimes (list->allocated, 2); + new_allocated = xsum (new_allocated, 1); + memory_size = xtimes (new_allocated, sizeof (const void *)); + if (size_overflow_p (memory_size)) + /* Overflow, would lead to out of memory. */ + return -1; + memory = (const void **) realloc (list->elements, memory_size); + if (memory == NULL) + /* Out of memory. */ + return -1; + list->elements = memory; + list->allocated = new_allocated; + return 0; +} + +static gl_list_node_t +gl_array_nx_add_first (gl_list_t list, const void *elt) +{ + size_t count = list->count; + const void **elements; + size_t i; + + if (count == list->allocated) + if (grow (list) < 0) + return NULL; + elements = list->elements; + for (i = count; i > 0; i--) + elements[i] = elements[i - 1]; + elements[0] = elt; + list->count = count + 1; + return INDEX_TO_NODE (0); +} + +static gl_list_node_t +gl_array_nx_add_last (gl_list_t list, const void *elt) +{ + size_t count = list->count; + + if (count == list->allocated) + if (grow (list) < 0) + return NULL; + list->elements[count] = elt; + list->count = count + 1; + return INDEX_TO_NODE (count); +} + +static gl_list_node_t +gl_array_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) +{ + size_t count = list->count; + uintptr_t index = NODE_TO_INDEX (node); + size_t position; + const void **elements; + size_t i; + + if (!(index < count)) + /* Invalid argument. */ + abort (); + position = index; + if (count == list->allocated) + if (grow (list) < 0) + return NULL; + elements = list->elements; + for (i = count; i > position; i--) + elements[i] = elements[i - 1]; + elements[position] = elt; + list->count = count + 1; + return INDEX_TO_NODE (position); +} + +static gl_list_node_t +gl_array_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) +{ + size_t count = list->count; + uintptr_t index = NODE_TO_INDEX (node); + size_t position; + const void **elements; + size_t i; + + if (!(index < count)) + /* Invalid argument. */ + abort (); + position = index + 1; + if (count == list->allocated) + if (grow (list) < 0) + return NULL; + elements = list->elements; + for (i = count; i > position; i--) + elements[i] = elements[i - 1]; + elements[position] = elt; + list->count = count + 1; + return INDEX_TO_NODE (position); +} + +static gl_list_node_t +gl_array_nx_add_at (gl_list_t list, size_t position, const void *elt) +{ + size_t count = list->count; + const void **elements; + size_t i; + + if (!(position <= count)) + /* Invalid argument. */ + abort (); + if (count == list->allocated) + if (grow (list) < 0) + return NULL; + elements = list->elements; + for (i = count; i > position; i--) + elements[i] = elements[i - 1]; + elements[position] = elt; + list->count = count + 1; + return INDEX_TO_NODE (position); +} + +static bool +gl_array_remove_node (gl_list_t list, gl_list_node_t node) +{ + size_t count = list->count; + uintptr_t index = NODE_TO_INDEX (node); + size_t position; + const void **elements; + size_t i; + + if (!(index < count)) + /* Invalid argument. */ + abort (); + position = index; + elements = list->elements; + if (list->base.dispose_fn != NULL) + list->base.dispose_fn (elements[position]); + for (i = position + 1; i < count; i++) + elements[i - 1] = elements[i]; + list->count = count - 1; + return true; +} + +static bool +gl_array_remove_at (gl_list_t list, size_t position) +{ + size_t count = list->count; + const void **elements; + size_t i; + + if (!(position < count)) + /* Invalid argument. */ + abort (); + elements = list->elements; + if (list->base.dispose_fn != NULL) + list->base.dispose_fn (elements[position]); + for (i = position + 1; i < count; i++) + elements[i - 1] = elements[i]; + list->count = count - 1; + return true; +} + +static bool +gl_array_remove (gl_list_t list, const void *elt) +{ + size_t position = gl_array_indexof_from_to (list, 0, list->count, elt); + if (position == (size_t)(-1)) + return false; + else + return gl_array_remove_at (list, position); +} + +static void +gl_array_list_free (gl_list_t list) +{ + if (list->elements != NULL) + { + if (list->base.dispose_fn != NULL) + { + size_t count = list->count; + + if (count > 0) + { + gl_listelement_dispose_fn dispose = list->base.dispose_fn; + const void **elements = list->elements; + + do + dispose (*elements++); + while (--count > 0); + } + } + free (list->elements); + } + free (list); +} + +/* --------------------- gl_list_iterator_t Data Type --------------------- */ + +static gl_list_iterator_t +gl_array_iterator (gl_list_t list) +{ + gl_list_iterator_t result; + + result.vtable = list->base.vtable; + result.list = list; + result.count = list->count; + result.p = list->elements + 0; + result.q = list->elements + list->count; +#if defined GCC_LINT || defined lint + result.i = 0; + result.j = 0; +#endif + + return result; +} + +static gl_list_iterator_t +gl_array_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index) +{ + gl_list_iterator_t result; + + if (!(start_index <= end_index && end_index <= list->count)) + /* Invalid arguments. */ + abort (); + result.vtable = list->base.vtable; + result.list = list; + result.count = list->count; + result.p = list->elements + start_index; + result.q = list->elements + end_index; +#if defined GCC_LINT || defined lint + result.i = 0; + result.j = 0; +#endif + + return result; +} + +static bool +gl_array_iterator_next (gl_list_iterator_t *iterator, + const void **eltp, gl_list_node_t *nodep) +{ + gl_list_t list = iterator->list; + if (iterator->count != list->count) + { + if (iterator->count != list->count + 1) + /* Concurrent modifications were done on the list. */ + abort (); + /* The last returned element was removed. */ + iterator->count--; + iterator->p = (const void **) iterator->p - 1; + iterator->q = (const void **) iterator->q - 1; + } + if (iterator->p < iterator->q) + { + const void **p = (const void **) iterator->p; + *eltp = *p; + if (nodep != NULL) + *nodep = INDEX_TO_NODE (p - list->elements); + iterator->p = p + 1; + return true; + } + else + return false; +} + +static void +gl_array_iterator_free (gl_list_iterator_t *iterator _GL_UNUSED) +{ +} + +/* ---------------------- Sorted gl_list_t Data Type ---------------------- */ + +static size_t +gl_array_sortedlist_indexof_from_to (gl_list_t list, + gl_listelement_compar_fn compar, + size_t low, size_t high, + const void *elt) +{ + if (!(low <= high && high <= list->count)) + /* Invalid arguments. */ + abort (); + if (low < high) + { + /* At each loop iteration, low < high; for indices < low the values + are smaller than ELT; for indices >= high the values are greater + than ELT. So, if the element occurs in the list, it is at + low <= position < high. */ + do + { + size_t mid = low + (high - low) / 2; /* low <= mid < high */ + int cmp = compar (list->elements[mid], elt); + + if (cmp < 0) + low = mid + 1; + else if (cmp > 0) + high = mid; + else /* cmp == 0 */ + { + /* We have an element equal to ELT at index MID. But we need + the minimal such index. */ + high = mid; + /* At each loop iteration, low <= high and + compar (list->elements[high], elt) == 0, + and we know that the first occurrence of the element is at + low <= position <= high. */ + while (low < high) + { + size_t mid2 = low + (high - low) / 2; /* low <= mid2 < high */ + int cmp2 = compar (list->elements[mid2], elt); + + if (cmp2 < 0) + low = mid2 + 1; + else if (cmp2 > 0) + /* The list was not sorted. */ + abort (); + else /* cmp2 == 0 */ + { + if (mid2 == low) + break; + high = mid2 - 1; + } + } + return low; + } + } + while (low < high); + /* Here low == high. */ + } + return (size_t)(-1); +} + +static size_t +gl_array_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, + const void *elt) +{ + return gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count, + elt); +} + +static gl_list_node_t +gl_array_sortedlist_search_from_to (gl_list_t list, + gl_listelement_compar_fn compar, + size_t low, size_t high, + const void *elt) +{ + size_t index = + gl_array_sortedlist_indexof_from_to (list, compar, low, high, elt); + return INDEX_TO_NODE (index); +} + +static gl_list_node_t +gl_array_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, + const void *elt) +{ + size_t index = + gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count, elt); + return INDEX_TO_NODE (index); +} + +static gl_list_node_t +gl_array_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, + const void *elt) +{ + size_t count = list->count; + size_t low = 0; + size_t high = count; + + /* At each loop iteration, low <= high; for indices < low the values are + smaller than ELT; for indices >= high the values are greater than ELT. */ + while (low < high) + { + size_t mid = low + (high - low) / 2; /* low <= mid < high */ + int cmp = compar (list->elements[mid], elt); + + if (cmp < 0) + low = mid + 1; + else if (cmp > 0) + high = mid; + else /* cmp == 0 */ + { + low = mid; + break; + } + } + return gl_array_nx_add_at (list, low, elt); +} + +static bool +gl_array_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, + const void *elt) +{ + size_t index = gl_array_sortedlist_indexof (list, compar, elt); + if (index == (size_t)(-1)) + return false; + else + return gl_array_remove_at (list, index); +} + + +const struct gl_list_implementation gl_array_list_implementation = + { + gl_array_nx_create_empty, + gl_array_nx_create, + gl_array_size, + gl_array_node_value, + gl_array_node_nx_set_value, + gl_array_next_node, + gl_array_previous_node, + gl_array_get_at, + gl_array_nx_set_at, + gl_array_search_from_to, + gl_array_indexof_from_to, + gl_array_nx_add_first, + gl_array_nx_add_last, + gl_array_nx_add_before, + gl_array_nx_add_after, + gl_array_nx_add_at, + gl_array_remove_node, + gl_array_remove_at, + gl_array_remove, + gl_array_list_free, + gl_array_iterator, + gl_array_iterator_from_to, + gl_array_iterator_next, + gl_array_iterator_free, + gl_array_sortedlist_search, + gl_array_sortedlist_search_from_to, + gl_array_sortedlist_indexof, + gl_array_sortedlist_indexof_from_to, + gl_array_sortedlist_nx_add, + gl_array_sortedlist_remove + }; diff --git a/contrib/tools/bison/lib/gl_array_list.h b/contrib/tools/bison/lib/gl_array_list.h new file mode 100644 index 0000000000..98158feb1b --- /dev/null +++ b/contrib/tools/bison/lib/gl_array_list.h @@ -0,0 +1,34 @@ +/* Sequential list data type implemented by an array. + Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2006. + + 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_ARRAY_LIST_H +#define _GL_ARRAY_LIST_H + +#include "gl_list.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern const struct gl_list_implementation gl_array_list_implementation; +#define GL_ARRAY_LIST &gl_array_list_implementation + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_ARRAY_LIST_H */ diff --git a/contrib/tools/bison/lib/gl_list.c b/contrib/tools/bison/lib/gl_list.c new file mode 100644 index 0000000000..8793298070 --- /dev/null +++ b/contrib/tools/bison/lib/gl_list.c @@ -0,0 +1,3 @@ +#include <config.h> +#define GL_LIST_INLINE _GL_EXTERN_INLINE +#include "gl_list.h" diff --git a/contrib/tools/bison/lib/gl_list.h b/contrib/tools/bison/lib/gl_list.h new file mode 100644 index 0000000000..5f2cade22c --- /dev/null +++ b/contrib/tools/bison/lib/gl_list.h @@ -0,0 +1,843 @@ +/* Abstract sequential list data type. -*- coding: utf-8 -*- + Copyright (C) 2006-2019 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2006. + + 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_LIST_H +#define _GL_LIST_H + +#include <stdbool.h> +#include <stddef.h> + +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef GL_LIST_INLINE +# define GL_LIST_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* gl_list is an abstract list data type. It can contain any number of + objects ('void *' or 'const void *' pointers) in any given order. + Duplicates are allowed, but can optionally be forbidden. + + There are several implementations of this list datatype, optimized for + different operations or for memory. You can start using the simplest list + implementation, GL_ARRAY_LIST, and switch to a different implementation + later, when you realize which operations are performed the most frequently. + The API of the different implementations is exactly the same; when + switching to a different implementation, you only have to change the + gl_list_create call. + + The implementations are: + GL_ARRAY_LIST a growable array + GL_CARRAY_LIST a growable circular array + GL_LINKED_LIST a linked list + GL_AVLTREE_LIST a binary tree (AVL tree) + GL_RBTREE_LIST a binary tree (red-black tree) + GL_LINKEDHASH_LIST a hash table with a linked list + GL_AVLTREEHASH_LIST a hash table with a binary tree (AVL tree) + GL_RBTREEHASH_LIST a hash table with a binary tree (red-black tree) + + The memory consumption is asymptotically the same: O(1) for every object + in the list. When looking more closely at the average memory consumed + for an object, GL_ARRAY_LIST is the most compact representation, and + GL_LINKEDHASH_LIST and GL_TREEHASH_LIST need more memory. + + The guaranteed average performance of the operations is, for a list of + n elements: + + Operation ARRAY LINKED TREE LINKEDHASH TREEHASH + CARRAY with|without with|without + duplicates duplicates + + gl_list_size O(1) O(1) O(1) O(1) O(1) + gl_list_node_value O(1) O(1) O(1) O(1) O(1) + gl_list_node_set_value O(1) O(1) O(1) O(1) O((log n)²)/O(1) + 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_set_at O(1) O(n) O(log n) O(n) 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) + gl_list_indexof O(n) O(n) O(n) O(n) O(log n) + gl_list_indexof_from O(n) O(n) O(n) O(n) O((log n)²)/O(log n) + gl_list_indexof_from_to O(n) O(n) O(n) O(n) O((log n)²)/O(log n) + gl_list_add_first O(n)/O(1) O(1) O(log n) O(1) O((log n)²)/O(log n) + gl_list_add_last O(1) O(1) O(log n) O(1) O((log n)²)/O(log n) + gl_list_add_before O(n) O(1) O(log n) O(1) O((log n)²)/O(log n) + gl_list_add_after O(n) O(1) O(log n) O(1) O((log n)²)/O(log n) + 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 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) + gl_list_iterator_next O(1) O(1) O(log n) O(1) O(log n) + gl_sortedlist_search O(log n) O(n) O(log n) O(n) O(log n) + gl_sortedlist_search_from O(log n) O(n) O(log n) O(n) O(log n) + gl_sortedlist_indexof O(log n) O(n) O(log n) O(n) O(log n) + gl_sortedlist_indexof_fro O(log n) O(n) O(log n) O(n) O(log n) + gl_sortedlist_add O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) + gl_sortedlist_remove O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) + */ + +/* -------------------------- gl_list_t Data Type -------------------------- */ + +/* Type of function used to compare two elements. + NULL denotes pointer comparison. */ +typedef bool (*gl_listelement_equals_fn) (const void *elt1, const void *elt2); + +/* Type of function used to compute a hash code. + NULL denotes a function that depends only on the pointer itself. */ +typedef size_t (*gl_listelement_hashcode_fn) (const void *elt); + +/* Type of function used to dispose an element once it's removed from a list. + NULL denotes a no-op. */ +typedef void (*gl_listelement_dispose_fn) (const void *elt); + +struct gl_list_impl; +/* Type representing an entire list. */ +typedef struct gl_list_impl * gl_list_t; + +struct gl_list_node_impl; +/* Type representing the position of an element in the list, in a way that + is more adapted to the list implementation than a plain index. + Note: It is invalidated by insertions and removals! */ +typedef struct gl_list_node_impl * gl_list_node_t; + +struct gl_list_implementation; +/* Type representing a list datatype implementation. */ +typedef const struct gl_list_implementation * gl_list_implementation_t; + +#if 0 /* Unless otherwise specified, these are defined inline below. */ + +/* Create an empty list. + IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST, + GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST, + GL_RBTREEHASH_LIST. + EQUALS_FN is an element comparison function or NULL. + HASHCODE_FN is an element hash code function or NULL. + DISPOSE_FN is an element disposal function or NULL. + ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in + the list. The implementation may verify this at runtime. */ +/* declared in gl_xlist.h */ +extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates); +/* Likewise. Return NULL upon out-of-memory. */ +extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates); + +/* Create a list with given contents. + IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST, + GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST, + GL_RBTREEHASH_LIST. + EQUALS_FN is an element comparison function or NULL. + HASHCODE_FN is an element hash code function or NULL. + DISPOSE_FN is an element disposal function or NULL. + ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in + the list. The implementation may verify this at runtime. + COUNT is the number of initial elements. + CONTENTS[0..COUNT-1] is the initial contents. */ +/* declared in gl_xlist.h */ +extern gl_list_t gl_list_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents); +/* Likewise. Return NULL upon out-of-memory. */ +extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents); + +/* Return the current number of elements in a list. */ +extern size_t gl_list_size (gl_list_t list); + +/* Return the element value represented by a list node. */ +extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node); + +/* Replace the element value represented by a list node. */ +/* declared in gl_xlist.h */ +extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, + const void *elt); +/* Likewise. Return 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 + ; + +/* Return the node immediately after the given node in the list, or NULL + if the given node is the last (rightmost) one in the list. */ +extern gl_list_node_t gl_list_next_node (gl_list_t list, gl_list_node_t node); + +/* Return the node immediately before the given node in the list, or NULL + if the given node is the first (leftmost) one in the list. */ +extern gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node); + +/* Return the element at a given position in the list. + POSITION must be >= 0 and < gl_list_size (list). */ +extern const void * gl_list_get_at (gl_list_t list, size_t position); + +/* Replace the element at a given position in the list. + POSITION must be >= 0 and < gl_list_size (list). + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, + const void *elt); +/* Likewise. Return 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 + ; + +/* Search whether an element is already in the list. + Return its node if found, or NULL if not present in the list. */ +extern gl_list_node_t gl_list_search (gl_list_t list, const void *elt); + +/* Search whether an element is already in the list, + at a position >= START_INDEX. + Return its node if found, or NULL if not present in the list. */ +extern gl_list_node_t gl_list_search_from (gl_list_t list, size_t start_index, + const void *elt); + +/* Search whether an element is already in the list, + at a position >= START_INDEX and < END_INDEX. + Return its node if found, or NULL if not present in the list. */ +extern gl_list_node_t gl_list_search_from_to (gl_list_t list, + size_t start_index, + size_t end_index, + const void *elt); + +/* Search whether an element is already in the list. + Return its position if found, or (size_t)(-1) if not present in the list. */ +extern size_t gl_list_indexof (gl_list_t list, const void *elt); + +/* Search whether an element is already in the list, + at a position >= START_INDEX. + Return its position if found, or (size_t)(-1) if not present in the list. */ +extern size_t gl_list_indexof_from (gl_list_t list, size_t start_index, + const void *elt); + +/* Search whether an element is already in the list, + at a position >= START_INDEX and < END_INDEX. + Return its position if found, or (size_t)(-1) if not present in the list. */ +extern size_t gl_list_indexof_from_to (gl_list_t list, + size_t start_index, size_t end_index, + const void *elt); + +/* Add an element as the first element of the list. + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt); +/* Likewise. Return 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 + ; + +/* Add an element as the last element of the list. + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt); +/* Likewise. Return 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 + ; + +/* Add an element before a given element node of the list. + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, + const void *elt); +/* Likewise. Return NULL upon out-of-memory. */ +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 + ; + +/* Add an element after a given element node of the list. + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, + const void *elt); +/* Likewise. Return 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 + ; + +/* Add an element at a given position in the list. + POSITION must be >= 0 and <= gl_list_size (list). */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, + const void *elt); +/* Likewise. Return 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 + ; + +/* Remove an element from the list. + Return true. */ +extern bool gl_list_remove_node (gl_list_t list, gl_list_node_t node); + +/* Remove an element at a given position from the list. + POSITION must be >= 0 and < gl_list_size (list). + Return true. */ +extern bool gl_list_remove_at (gl_list_t list, size_t position); + +/* Search and remove an element from the list. + Return true if it was found and removed. */ +extern bool gl_list_remove (gl_list_t list, const void *elt); + +/* Free an entire list. + (But this call does not free the elements of the list. It only invokes + the DISPOSE_FN on each of the elements of the list, and only if the list + is not a sublist.) */ +extern void gl_list_free (gl_list_t list); + +#endif /* End of inline and gl_xlist.h-defined functions. */ + +/* --------------------- gl_list_iterator_t Data Type --------------------- */ + +/* Functions for iterating through a list. */ + +/* Type of an iterator that traverses a list. + This is a fixed-size struct, so that creation of an iterator doesn't need + memory allocation on the heap. */ +typedef struct +{ + /* For fast dispatch of gl_list_iterator_next. */ + const struct gl_list_implementation *vtable; + /* For detecting whether the last returned element was removed. */ + gl_list_t list; + size_t count; + /* Other, implementation-private fields. */ + void *p; void *q; + size_t i; size_t j; +} gl_list_iterator_t; + +#if 0 /* These are defined inline below. */ + +/* Create an iterator traversing a list. + The list contents must not be modified while the iterator is in use, + except for replacing or removing the last returned element. */ +extern gl_list_iterator_t gl_list_iterator (gl_list_t list); + +/* Create an iterator traversing the element with indices i, + start_index <= i < end_index, of a list. + The list contents must not be modified while the iterator is in use, + except for replacing or removing the last returned element. */ +extern gl_list_iterator_t gl_list_iterator_from_to (gl_list_t list, + size_t start_index, + size_t end_index); + +/* If there is a next element, store the next element in *ELTP, store its + node in *NODEP if NODEP is non-NULL, advance the iterator and return true. + Otherwise, return false. */ +extern bool gl_list_iterator_next (gl_list_iterator_t *iterator, + const void **eltp, gl_list_node_t *nodep); + +/* Free an iterator. */ +extern void gl_list_iterator_free (gl_list_iterator_t *iterator); + +#endif /* End of inline functions. */ + +/* ---------------------- Sorted gl_list_t Data Type ---------------------- */ + +/* The following functions are for lists without duplicates where the + order is given by a sort criterion. */ + +/* Type of function used to compare two elements. Same as for qsort(). + NULL denotes pointer comparison. */ +typedef int (*gl_listelement_compar_fn) (const void *elt1, const void *elt2); + +#if 0 /* Unless otherwise specified, these are defined inline below. */ + +/* Search whether an element is already in the list. + The list is assumed to be sorted with COMPAR. + Return its node if found, or NULL if not present in the list. + If the list contains several copies of ELT, the node of the leftmost one is + returned. */ +extern gl_list_node_t gl_sortedlist_search (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + +/* Search whether an element is already in the list. + The list is assumed to be sorted with COMPAR. + Only list elements with indices >= START_INDEX and < END_INDEX are + considered; the implementation uses these bounds to minimize the number + of COMPAR invocations. + Return its node if found, or NULL if not present in the list. + If the list contains several copies of ELT, the node of the leftmost one is + returned. */ +extern gl_list_node_t gl_sortedlist_search_from_to (gl_list_t list, + gl_listelement_compar_fn compar, + size_t start_index, + size_t end_index, + const void *elt); + +/* Search whether an element is already in the list. + The list is assumed to be sorted with COMPAR. + Return its position if found, or (size_t)(-1) if not present in the list. + If the list contains several copies of ELT, the position of the leftmost one + is returned. */ +extern size_t gl_sortedlist_indexof (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + +/* Search whether an element is already in the list. + The list is assumed to be sorted with COMPAR. + Only list elements with indices >= START_INDEX and < END_INDEX are + considered; the implementation uses these bounds to minimize the number + of COMPAR invocations. + Return its position if found, or (size_t)(-1) if not present in the list. + If the list contains several copies of ELT, the position of the leftmost one + is returned. */ +extern size_t gl_sortedlist_indexof_from_to (gl_list_t list, + gl_listelement_compar_fn compar, + size_t start_index, + size_t end_index, + const void *elt); + +/* Add an element at the appropriate position in the list. + The list is assumed to be sorted with COMPAR. + Return its node. */ +/* declared in gl_xlist.h */ +extern gl_list_node_t gl_sortedlist_add (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); +/* Likewise. Return NULL upon out-of-memory. */ +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 + ; + +/* Search and remove an element from the list. + The list is assumed to be sorted with COMPAR. + Return true if it was found and removed. + If the list contains several copies of ELT, only the leftmost one is + removed. */ +extern bool gl_sortedlist_remove (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + +#endif /* End of inline and gl_xlist.h-defined functions. */ + +/* ------------------------ Implementation Details ------------------------ */ + +struct gl_list_implementation +{ + /* gl_list_t functions. */ + gl_list_t (*nx_create_empty) (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates); + gl_list_t (*nx_create) (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents); + size_t (*size) (gl_list_t list); + const void * (*node_value) (gl_list_t list, gl_list_node_t node); + int (*node_nx_set_value) (gl_list_t list, gl_list_node_t node, + const void *elt); + gl_list_node_t (*next_node) (gl_list_t list, gl_list_node_t node); + gl_list_node_t (*previous_node) (gl_list_t list, gl_list_node_t node); + const void * (*get_at) (gl_list_t list, size_t position); + gl_list_node_t (*nx_set_at) (gl_list_t list, size_t position, + const void *elt); + gl_list_node_t (*search_from_to) (gl_list_t list, size_t start_index, + size_t end_index, const void *elt); + size_t (*indexof_from_to) (gl_list_t list, size_t start_index, + size_t end_index, const void *elt); + gl_list_node_t (*nx_add_first) (gl_list_t list, const void *elt); + gl_list_node_t (*nx_add_last) (gl_list_t list, const void *elt); + gl_list_node_t (*nx_add_before) (gl_list_t list, gl_list_node_t node, + const void *elt); + gl_list_node_t (*nx_add_after) (gl_list_t list, gl_list_node_t node, + const void *elt); + gl_list_node_t (*nx_add_at) (gl_list_t list, size_t position, + const void *elt); + bool (*remove_node) (gl_list_t list, gl_list_node_t node); + bool (*remove_at) (gl_list_t list, size_t position); + bool (*remove_elt) (gl_list_t list, const void *elt); + void (*list_free) (gl_list_t list); + /* gl_list_iterator_t functions. */ + gl_list_iterator_t (*iterator) (gl_list_t list); + gl_list_iterator_t (*iterator_from_to) (gl_list_t list, + size_t start_index, + size_t end_index); + bool (*iterator_next) (gl_list_iterator_t *iterator, + const void **eltp, gl_list_node_t *nodep); + void (*iterator_free) (gl_list_iterator_t *iterator); + /* Sorted gl_list_t functions. */ + gl_list_node_t (*sortedlist_search) (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + gl_list_node_t (*sortedlist_search_from_to) (gl_list_t list, + gl_listelement_compar_fn compar, + size_t start_index, + size_t end_index, + const void *elt); + size_t (*sortedlist_indexof) (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + size_t (*sortedlist_indexof_from_to) (gl_list_t list, + gl_listelement_compar_fn compar, + size_t start_index, size_t end_index, + const void *elt); + gl_list_node_t (*sortedlist_nx_add) (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); + bool (*sortedlist_remove) (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); +}; + +struct gl_list_impl_base +{ + const struct gl_list_implementation *vtable; + gl_listelement_equals_fn equals_fn; + gl_listelement_hashcode_fn hashcode_fn; + gl_listelement_dispose_fn dispose_fn; + bool allow_duplicates; +}; + +/* Define all functions of this file as accesses to the + struct gl_list_implementation. */ + +GL_LIST_INLINE gl_list_t +gl_list_nx_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates) +{ + return implementation->nx_create_empty (implementation, equals_fn, + hashcode_fn, dispose_fn, + allow_duplicates); +} + +GL_LIST_INLINE gl_list_t +gl_list_nx_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents) +{ + return implementation->nx_create (implementation, equals_fn, hashcode_fn, + dispose_fn, allow_duplicates, count, + contents); +} + +GL_LIST_INLINE size_t +gl_list_size (gl_list_t list) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->size (list); +} + +GL_LIST_INLINE const void * +gl_list_node_value (gl_list_t list, gl_list_node_t node) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->node_value (list, node); +} + +GL_LIST_INLINE int +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif +gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, + const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->node_nx_set_value (list, node, elt); +} + +GL_LIST_INLINE gl_list_node_t +gl_list_next_node (gl_list_t list, gl_list_node_t node) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->next_node (list, node); +} + +GL_LIST_INLINE gl_list_node_t +gl_list_previous_node (gl_list_t list, gl_list_node_t node) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->previous_node (list, node); +} + +GL_LIST_INLINE const void * +gl_list_get_at (gl_list_t list, size_t position) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->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_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_list_node_t +gl_list_search (gl_list_t list, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->search_from_to (list, 0, size, elt); +} + +GL_LIST_INLINE gl_list_node_t +gl_list_search_from (gl_list_t list, size_t start_index, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->search_from_to (list, start_index, size, elt); +} + +GL_LIST_INLINE gl_list_node_t +gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, + const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->search_from_to (list, start_index, end_index, elt); +} + +GL_LIST_INLINE size_t +gl_list_indexof (gl_list_t list, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->indexof_from_to (list, 0, size, elt); +} + +GL_LIST_INLINE size_t +gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->indexof_from_to (list, start_index, size, elt); +} + +GL_LIST_INLINE size_t +gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, + const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->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_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_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_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_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_nx_add_at (gl_list_t list, size_t position, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->nx_add_at (list, position, elt); +} + +GL_LIST_INLINE bool +gl_list_remove_node (gl_list_t list, gl_list_node_t node) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->remove_node (list, node); +} + +GL_LIST_INLINE bool +gl_list_remove_at (gl_list_t list, size_t position) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->remove_at (list, position); +} + +GL_LIST_INLINE bool +gl_list_remove (gl_list_t list, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->remove_elt (list, elt); +} + +GL_LIST_INLINE void +gl_list_free (gl_list_t list) +{ + ((const struct gl_list_impl_base *) list)->vtable->list_free (list); +} + +GL_LIST_INLINE gl_list_iterator_t +gl_list_iterator (gl_list_t list) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->iterator (list); +} + +GL_LIST_INLINE gl_list_iterator_t +gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->iterator_from_to (list, start_index, end_index); +} + +GL_LIST_INLINE bool +gl_list_iterator_next (gl_list_iterator_t *iterator, + const void **eltp, gl_list_node_t *nodep) +{ + return iterator->vtable->iterator_next (iterator, eltp, nodep); +} + +GL_LIST_INLINE void +gl_list_iterator_free (gl_list_iterator_t *iterator) +{ + iterator->vtable->iterator_free (iterator); +} + +GL_LIST_INLINE gl_list_node_t +gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_search (list, compar, elt); +} + +GL_LIST_INLINE gl_list_node_t +gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_search_from_to (list, compar, start_index, end_index, + elt); +} + +GL_LIST_INLINE size_t +gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_indexof (list, compar, elt); +} + +GL_LIST_INLINE size_t +gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_indexof_from_to (list, compar, 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_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_nx_add (list, compar, elt); +} + +GL_LIST_INLINE bool +gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_remove (list, compar, elt); +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif /* _GL_LIST_H */ diff --git a/contrib/tools/bison/lib/gl_xlist.c b/contrib/tools/bison/lib/gl_xlist.c new file mode 100644 index 0000000000..fe3c893396 --- /dev/null +++ b/contrib/tools/bison/lib/gl_xlist.c @@ -0,0 +1,3 @@ +#include <config.h> +#define GL_XLIST_INLINE _GL_EXTERN_INLINE +#include "gl_xlist.h" diff --git a/contrib/tools/bison/lib/gl_xlist.h b/contrib/tools/bison/lib/gl_xlist.h new file mode 100644 index 0000000000..87885c33c8 --- /dev/null +++ b/contrib/tools/bison/lib/gl_xlist.h @@ -0,0 +1,177 @@ +/* Abstract sequential list data type, with out-of-memory checking. + Copyright (C) 2009-2019 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2009. + + 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_XLIST_H +#define _GL_XLIST_H + +#include "gl_list.h" +#include "xalloc.h" + +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef GL_XLIST_INLINE +# define GL_XLIST_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* These functions are thin wrappers around the corresponding functions with + _nx_ infix from gl_list.h. Upon out-of-memory, they invoke xalloc_die (), + instead of returning an error indicator. */ +#if 0 /* These are defined inline below. */ +extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates); +extern gl_list_t gl_list_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents); +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_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, + const void *elt); +extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, + const void *elt); +extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, + const void *elt); +extern gl_list_node_t gl_sortedlist_add (gl_list_t list, + gl_listelement_compar_fn compar, + const void *elt); +#endif + +GL_XLIST_INLINE gl_list_t +gl_list_create_empty (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates) +{ + gl_list_t result = + gl_list_nx_create_empty (implementation, equals_fn, hashcode_fn, dispose_fn, + allow_duplicates); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_t +gl_list_create (gl_list_implementation_t implementation, + gl_listelement_equals_fn equals_fn, + gl_listelement_hashcode_fn hashcode_fn, + gl_listelement_dispose_fn dispose_fn, + bool allow_duplicates, + size_t count, const void **contents) +{ + gl_list_t result = + gl_list_nx_create (implementation, equals_fn, hashcode_fn, dispose_fn, + allow_duplicates, count, contents); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE void +gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt) +{ + int result = gl_list_node_nx_set_value (list, node, elt); + if (result < 0) + xalloc_die (); +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_set_at (gl_list_t list, size_t position, const void *elt) +{ + gl_list_node_t result = gl_list_nx_set_at (list, position, 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); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_add_last (gl_list_t list, const void *elt) +{ + gl_list_node_t result = gl_list_nx_add_last (list, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt) +{ + gl_list_node_t result = gl_list_nx_add_before (list, node, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt) +{ + gl_list_node_t result = gl_list_nx_add_after (list, node, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_list_add_at (gl_list_t list, size_t position, const void *elt) +{ + gl_list_node_t result = gl_list_nx_add_at (list, position, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +GL_XLIST_INLINE gl_list_node_t +gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, + const void *elt) +{ + gl_list_node_t result = gl_sortedlist_nx_add (list, compar, elt); + if (result == NULL) + xalloc_die (); + return result; +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif /* _GL_XLIST_H */ diff --git a/contrib/tools/bison/lib/glthread/lock.c b/contrib/tools/bison/lib/glthread/lock.c deleted file mode 100644 index f166d7ca8c..0000000000 --- a/contrib/tools/bison/lib/glthread/lock.c +++ /dev/null @@ -1,1221 +0,0 @@ -/* Locking in multithreaded situations. - Copyright (C) 2005-2018 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, 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 Bruno Haible <bruno@clisp.org>, 2005. - Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, - gthr-win32.h. */ - -#include <config.h> - -#include "glthread/lock.h" - -/* ========================================================================= */ - -#if USE_POSIX_THREADS - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) - -# ifdef PTHREAD_RWLOCK_INITIALIZER - -# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER - /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ - -int -glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock) -{ - pthread_rwlockattr_t attributes; - int err; - - err = pthread_rwlockattr_init (&attributes); - if (err != 0) - return err; - /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that - causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not - do this; see - http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ - err = pthread_rwlockattr_setkind_np (&attributes, - PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); - if (err == 0) - err = pthread_rwlock_init(lock, &attributes); - /* pthread_rwlockattr_destroy always returns 0. It cannot influence the - return value. */ - pthread_rwlockattr_destroy (&attributes); - return err; -} - -# endif -# else - -int -glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_rwlock_init (&lock->rwlock, NULL); - if (err != 0) - return err; - lock->initialized = 1; - return 0; -} - -int -glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - { - int err; - - err = pthread_mutex_lock (&lock->guard); - if (err != 0) - return err; - if (!lock->initialized) - { - err = glthread_rwlock_init_multithreaded (lock); - if (err != 0) - { - pthread_mutex_unlock (&lock->guard); - return err; - } - } - err = pthread_mutex_unlock (&lock->guard); - if (err != 0) - return err; - } - return pthread_rwlock_rdlock (&lock->rwlock); -} - -int -glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - { - int err; - - err = pthread_mutex_lock (&lock->guard); - if (err != 0) - return err; - if (!lock->initialized) - { - err = glthread_rwlock_init_multithreaded (lock); - if (err != 0) - { - pthread_mutex_unlock (&lock->guard); - return err; - } - } - err = pthread_mutex_unlock (&lock->guard); - if (err != 0) - return err; - } - return pthread_rwlock_wrlock (&lock->rwlock); -} - -int -glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - return EINVAL; - return pthread_rwlock_unlock (&lock->rwlock); -} - -int -glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) -{ - int err; - - if (!lock->initialized) - return EINVAL; - err = pthread_rwlock_destroy (&lock->rwlock); - if (err != 0) - return err; - lock->initialized = 0; - return 0; -} - -# endif - -# else - -int -glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_mutex_init (&lock->lock, NULL); - if (err != 0) - return err; - err = pthread_cond_init (&lock->waiting_readers, NULL); - if (err != 0) - return err; - err = pthread_cond_init (&lock->waiting_writers, NULL); - if (err != 0) - return err; - lock->waiting_writers_count = 0; - lock->runcount = 0; - return 0; -} - -int -glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_mutex_lock (&lock->lock); - if (err != 0) - return err; - /* Test whether only readers are currently running, and whether the runcount - field will not overflow, and whether no writer is waiting. The latter - condition is because POSIX recommends that "write locks shall take - precedence over read locks", to avoid "writer starvation". */ - while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_readers. */ - err = pthread_cond_wait (&lock->waiting_readers, &lock->lock); - if (err != 0) - { - pthread_mutex_unlock (&lock->lock); - return err; - } - } - lock->runcount++; - return pthread_mutex_unlock (&lock->lock); -} - -int -glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_mutex_lock (&lock->lock); - if (err != 0) - return err; - /* Test whether no readers or writers are currently running. */ - while (!(lock->runcount == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_writers. */ - lock->waiting_writers_count++; - err = pthread_cond_wait (&lock->waiting_writers, &lock->lock); - if (err != 0) - { - lock->waiting_writers_count--; - pthread_mutex_unlock (&lock->lock); - return err; - } - lock->waiting_writers_count--; - } - lock->runcount--; /* runcount becomes -1 */ - return pthread_mutex_unlock (&lock->lock); -} - -int -glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_mutex_lock (&lock->lock); - if (err != 0) - return err; - if (lock->runcount < 0) - { - /* Drop a writer lock. */ - if (!(lock->runcount == -1)) - { - pthread_mutex_unlock (&lock->lock); - return EINVAL; - } - lock->runcount = 0; - } - else - { - /* Drop a reader lock. */ - if (!(lock->runcount > 0)) - { - pthread_mutex_unlock (&lock->lock); - return EINVAL; - } - lock->runcount--; - } - if (lock->runcount == 0) - { - /* POSIX recommends that "write locks shall take precedence over read - locks", to avoid "writer starvation". */ - if (lock->waiting_writers_count > 0) - { - /* Wake up one of the waiting writers. */ - err = pthread_cond_signal (&lock->waiting_writers); - if (err != 0) - { - pthread_mutex_unlock (&lock->lock); - return err; - } - } - else - { - /* Wake up all waiting readers. */ - err = pthread_cond_broadcast (&lock->waiting_readers); - if (err != 0) - { - pthread_mutex_unlock (&lock->lock); - return err; - } - } - } - return pthread_mutex_unlock (&lock->lock); -} - -int -glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) -{ - int err; - - err = pthread_mutex_destroy (&lock->lock); - if (err != 0) - return err; - err = pthread_cond_destroy (&lock->waiting_readers); - if (err != 0) - return err; - err = pthread_cond_destroy (&lock->waiting_writers); - if (err != 0) - return err; - return 0; -} - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -# if HAVE_PTHREAD_MUTEX_RECURSIVE - -# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - -int -glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) -{ - pthread_mutexattr_t attributes; - int err; - - err = pthread_mutexattr_init (&attributes); - if (err != 0) - return err; - err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); - if (err != 0) - { - pthread_mutexattr_destroy (&attributes); - return err; - } - err = pthread_mutex_init (lock, &attributes); - if (err != 0) - { - pthread_mutexattr_destroy (&attributes); - return err; - } - err = pthread_mutexattr_destroy (&attributes); - if (err != 0) - return err; - return 0; -} - -# else - -int -glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) -{ - pthread_mutexattr_t attributes; - int err; - - err = pthread_mutexattr_init (&attributes); - if (err != 0) - return err; - err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); - if (err != 0) - { - pthread_mutexattr_destroy (&attributes); - return err; - } - err = pthread_mutex_init (&lock->recmutex, &attributes); - if (err != 0) - { - pthread_mutexattr_destroy (&attributes); - return err; - } - err = pthread_mutexattr_destroy (&attributes); - if (err != 0) - return err; - lock->initialized = 1; - return 0; -} - -int -glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) -{ - if (!lock->initialized) - { - int err; - - err = pthread_mutex_lock (&lock->guard); - if (err != 0) - return err; - if (!lock->initialized) - { - err = glthread_recursive_lock_init_multithreaded (lock); - if (err != 0) - { - pthread_mutex_unlock (&lock->guard); - return err; - } - } - err = pthread_mutex_unlock (&lock->guard); - if (err != 0) - return err; - } - return pthread_mutex_lock (&lock->recmutex); -} - -int -glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) -{ - if (!lock->initialized) - return EINVAL; - return pthread_mutex_unlock (&lock->recmutex); -} - -int -glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) -{ - int err; - - if (!lock->initialized) - return EINVAL; - err = pthread_mutex_destroy (&lock->recmutex); - if (err != 0) - return err; - lock->initialized = 0; - return 0; -} - -# endif - -# else - -int -glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) -{ - int err; - - err = pthread_mutex_init (&lock->mutex, NULL); - if (err != 0) - return err; - lock->owner = (pthread_t) 0; - lock->depth = 0; - return 0; -} - -int -glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) -{ - pthread_t self = pthread_self (); - if (lock->owner != self) - { - int err; - - err = pthread_mutex_lock (&lock->mutex); - if (err != 0) - return err; - lock->owner = self; - } - if (++(lock->depth) == 0) /* wraparound? */ - { - lock->depth--; - return EAGAIN; - } - return 0; -} - -int -glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) -{ - if (lock->owner != pthread_self ()) - return EPERM; - if (lock->depth == 0) - return EINVAL; - if (--(lock->depth) == 0) - { - lock->owner = (pthread_t) 0; - return pthread_mutex_unlock (&lock->mutex); - } - else - return 0; -} - -int -glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) -{ - if (lock->owner != (pthread_t) 0) - return EBUSY; - return pthread_mutex_destroy (&lock->mutex); -} - -# endif - -/* -------------------------- gl_once_t datatype -------------------------- */ - -static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; - -int -glthread_once_singlethreaded (pthread_once_t *once_control) -{ - /* We don't know whether pthread_once_t is an integer type, a floating-point - type, a pointer type, or a structure type. */ - char *firstbyte = (char *)once_control; - if (*firstbyte == *(const char *)&fresh_once) - { - /* First time use of once_control. Invert the first byte. */ - *firstbyte = ~ *(const char *)&fresh_once; - return 1; - } - else - return 0; -} - -#endif - -/* ========================================================================= */ - -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -# if !HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER - -int -glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) -{ - if (!pth_mutex_init (&lock->lock)) - return errno; - if (!pth_cond_init (&lock->waiting_readers)) - return errno; - if (!pth_cond_init (&lock->waiting_writers)) - return errno; - lock->waiting_writers_count = 0; - lock->runcount = 0; - lock->initialized = 1; - return 0; -} - -int -glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - glthread_rwlock_init_multithreaded (lock); - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - /* Test whether only readers are currently running, and whether the runcount - field will not overflow, and whether no writer is waiting. The latter - condition is because POSIX recommends that "write locks shall take - precedence over read locks", to avoid "writer starvation". */ - while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_readers. */ - if (!pth_cond_await (&lock->waiting_readers, &lock->lock, NULL)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - lock->runcount++; - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - glthread_rwlock_init_multithreaded (lock); - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - /* Test whether no readers or writers are currently running. */ - while (!(lock->runcount == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_writers. */ - lock->waiting_writers_count++; - if (!pth_cond_await (&lock->waiting_writers, &lock->lock, NULL)) - { - int err = errno; - lock->waiting_writers_count--; - pth_mutex_release (&lock->lock); - return err; - } - lock->waiting_writers_count--; - } - lock->runcount--; /* runcount becomes -1 */ - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) -{ - int err; - - if (!lock->initialized) - return EINVAL; - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - if (lock->runcount < 0) - { - /* Drop a writer lock. */ - if (!(lock->runcount == -1)) - { - pth_mutex_release (&lock->lock); - return EINVAL; - } - lock->runcount = 0; - } - else - { - /* Drop a reader lock. */ - if (!(lock->runcount > 0)) - { - pth_mutex_release (&lock->lock); - return EINVAL; - } - lock->runcount--; - } - if (lock->runcount == 0) - { - /* POSIX recommends that "write locks shall take precedence over read - locks", to avoid "writer starvation". */ - if (lock->waiting_writers_count > 0) - { - /* Wake up one of the waiting writers. */ - if (!pth_cond_notify (&lock->waiting_writers, FALSE)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - else - { - /* Wake up all waiting readers. */ - if (!pth_cond_notify (&lock->waiting_readers, TRUE)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - } - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) -{ - lock->initialized = 0; - return 0; -} - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* -------------------------- gl_once_t datatype -------------------------- */ - -static void -glthread_once_call (void *arg) -{ - void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; - void (*initfunction) (void) = *gl_once_temp_addr; - initfunction (); -} - -int -glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)) -{ - void (*temp) (void) = initfunction; - return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0); -} - -int -glthread_once_singlethreaded (pth_once_t *once_control) -{ - /* We know that pth_once_t is an integer type. */ - if (*once_control == PTH_ONCE_INIT) - { - /* First time use of once_control. Invert the marker. */ - *once_control = ~ PTH_ONCE_INIT; - return 1; - } - else - return 0; -} - -#endif - -/* ========================================================================= */ - -#if USE_SOLARIS_THREADS - -/* Use the old Solaris threads library. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -int -glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) -{ - int err; - - err = mutex_init (&lock->mutex, USYNC_THREAD, NULL); - if (err != 0) - return err; - lock->owner = (thread_t) 0; - lock->depth = 0; - return 0; -} - -int -glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) -{ - thread_t self = thr_self (); - if (lock->owner != self) - { - int err; - - err = mutex_lock (&lock->mutex); - if (err != 0) - return err; - lock->owner = self; - } - if (++(lock->depth) == 0) /* wraparound? */ - { - lock->depth--; - return EAGAIN; - } - return 0; -} - -int -glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) -{ - if (lock->owner != thr_self ()) - return EPERM; - if (lock->depth == 0) - return EINVAL; - if (--(lock->depth) == 0) - { - lock->owner = (thread_t) 0; - return mutex_unlock (&lock->mutex); - } - else - return 0; -} - -int -glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) -{ - if (lock->owner != (thread_t) 0) - return EBUSY; - return mutex_destroy (&lock->mutex); -} - -/* -------------------------- gl_once_t datatype -------------------------- */ - -int -glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)) -{ - if (!once_control->inited) - { - int err; - - /* Use the mutex to guarantee that if another thread is already calling - the initfunction, this thread waits until it's finished. */ - err = mutex_lock (&once_control->mutex); - if (err != 0) - return err; - if (!once_control->inited) - { - once_control->inited = 1; - initfunction (); - } - return mutex_unlock (&once_control->mutex); - } - else - return 0; -} - -int -glthread_once_singlethreaded (gl_once_t *once_control) -{ - /* We know that gl_once_t contains an integer type. */ - if (!once_control->inited) - { - /* First time use of once_control. Invert the marker. */ - once_control->inited = ~ 0; - return 1; - } - else - return 0; -} - -#endif - -/* ========================================================================= */ - -#if USE_WINDOWS_THREADS - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -void -glthread_lock_init_func (gl_lock_t *lock) -{ - InitializeCriticalSection (&lock->lock); - lock->guard.done = 1; -} - -int -glthread_lock_lock_func (gl_lock_t *lock) -{ - if (!lock->guard.done) - { - if (InterlockedIncrement (&lock->guard.started) == 0) - /* This thread is the first one to need this lock. Initialize it. */ - glthread_lock_init (lock); - else - /* Yield the CPU while waiting for another thread to finish - initializing this lock. */ - while (!lock->guard.done) - Sleep (0); - } - EnterCriticalSection (&lock->lock); - return 0; -} - -int -glthread_lock_unlock_func (gl_lock_t *lock) -{ - if (!lock->guard.done) - return EINVAL; - LeaveCriticalSection (&lock->lock); - return 0; -} - -int -glthread_lock_destroy_func (gl_lock_t *lock) -{ - if (!lock->guard.done) - return EINVAL; - DeleteCriticalSection (&lock->lock); - lock->guard.done = 0; - return 0; -} - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* In this file, the waitqueues are implemented as circular arrays. */ -#define gl_waitqueue_t gl_carray_waitqueue_t - -static void -gl_waitqueue_init (gl_waitqueue_t *wq) -{ - wq->array = NULL; - wq->count = 0; - wq->alloc = 0; - wq->offset = 0; -} - -/* Enqueues the current thread, represented by an event, in a wait queue. - Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ -static HANDLE -gl_waitqueue_add (gl_waitqueue_t *wq) -{ - HANDLE event; - unsigned int index; - - if (wq->count == wq->alloc) - { - unsigned int new_alloc = 2 * wq->alloc + 1; - HANDLE *new_array = - (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); - if (new_array == NULL) - /* No more memory. */ - return INVALID_HANDLE_VALUE; - /* Now is a good opportunity to rotate the array so that its contents - starts at offset 0. */ - if (wq->offset > 0) - { - unsigned int old_count = wq->count; - unsigned int old_alloc = wq->alloc; - unsigned int old_offset = wq->offset; - unsigned int i; - if (old_offset + old_count > old_alloc) - { - unsigned int limit = old_offset + old_count - old_alloc; - for (i = 0; i < limit; i++) - new_array[old_alloc + i] = new_array[i]; - } - for (i = 0; i < old_count; i++) - new_array[i] = new_array[old_offset + i]; - wq->offset = 0; - } - wq->array = new_array; - wq->alloc = new_alloc; - } - /* Whether the created event is a manual-reset one or an auto-reset one, - does not matter, since we will wait on it only once. */ - event = CreateEvent (NULL, TRUE, FALSE, NULL); - if (event == INVALID_HANDLE_VALUE) - /* No way to allocate an event. */ - return INVALID_HANDLE_VALUE; - index = wq->offset + wq->count; - if (index >= wq->alloc) - index -= wq->alloc; - wq->array[index] = event; - wq->count++; - return event; -} - -/* Notifies the first thread from a wait queue and dequeues it. */ -static void -gl_waitqueue_notify_first (gl_waitqueue_t *wq) -{ - SetEvent (wq->array[wq->offset + 0]); - wq->offset++; - wq->count--; - if (wq->count == 0 || wq->offset == wq->alloc) - wq->offset = 0; -} - -/* Notifies all threads from a wait queue and dequeues them all. */ -static void -gl_waitqueue_notify_all (gl_waitqueue_t *wq) -{ - unsigned int i; - - for (i = 0; i < wq->count; i++) - { - unsigned int index = wq->offset + i; - if (index >= wq->alloc) - index -= wq->alloc; - SetEvent (wq->array[index]); - } - wq->count = 0; - wq->offset = 0; -} - -void -glthread_rwlock_init_func (gl_rwlock_t *lock) -{ - InitializeCriticalSection (&lock->lock); - gl_waitqueue_init (&lock->waiting_readers); - gl_waitqueue_init (&lock->waiting_writers); - lock->runcount = 0; - lock->guard.done = 1; -} - -int -glthread_rwlock_rdlock_func (gl_rwlock_t *lock) -{ - if (!lock->guard.done) - { - if (InterlockedIncrement (&lock->guard.started) == 0) - /* This thread is the first one to need this lock. Initialize it. */ - glthread_rwlock_init (lock); - else - /* Yield the CPU while waiting for another thread to finish - initializing this lock. */ - while (!lock->guard.done) - Sleep (0); - } - EnterCriticalSection (&lock->lock); - /* Test whether only readers are currently running, and whether the runcount - field will not overflow, and whether no writer is waiting. The latter - condition is because POSIX recommends that "write locks shall take - precedence over read locks", to avoid "writer starvation". */ - if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_readers. */ - HANDLE event = gl_waitqueue_add (&lock->waiting_readers); - if (event != INVALID_HANDLE_VALUE) - { - DWORD result; - LeaveCriticalSection (&lock->lock); - /* Wait until another thread signals this event. */ - result = WaitForSingleObject (event, INFINITE); - if (result == WAIT_FAILED || result == WAIT_TIMEOUT) - abort (); - CloseHandle (event); - /* The thread which signalled the event already did the bookkeeping: - removed us from the waiting_readers, incremented lock->runcount. */ - if (!(lock->runcount > 0)) - abort (); - return 0; - } - else - { - /* Allocation failure. Weird. */ - do - { - LeaveCriticalSection (&lock->lock); - Sleep (1); - EnterCriticalSection (&lock->lock); - } - while (!(lock->runcount + 1 > 0)); - } - } - lock->runcount++; - LeaveCriticalSection (&lock->lock); - return 0; -} - -int -glthread_rwlock_wrlock_func (gl_rwlock_t *lock) -{ - if (!lock->guard.done) - { - if (InterlockedIncrement (&lock->guard.started) == 0) - /* This thread is the first one to need this lock. Initialize it. */ - glthread_rwlock_init (lock); - else - /* Yield the CPU while waiting for another thread to finish - initializing this lock. */ - while (!lock->guard.done) - Sleep (0); - } - EnterCriticalSection (&lock->lock); - /* Test whether no readers or writers are currently running. */ - if (!(lock->runcount == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_writers. */ - HANDLE event = gl_waitqueue_add (&lock->waiting_writers); - if (event != INVALID_HANDLE_VALUE) - { - DWORD result; - LeaveCriticalSection (&lock->lock); - /* Wait until another thread signals this event. */ - result = WaitForSingleObject (event, INFINITE); - if (result == WAIT_FAILED || result == WAIT_TIMEOUT) - abort (); - CloseHandle (event); - /* The thread which signalled the event already did the bookkeeping: - removed us from the waiting_writers, set lock->runcount = -1. */ - if (!(lock->runcount == -1)) - abort (); - return 0; - } - else - { - /* Allocation failure. Weird. */ - do - { - LeaveCriticalSection (&lock->lock); - Sleep (1); - EnterCriticalSection (&lock->lock); - } - while (!(lock->runcount == 0)); - } - } - lock->runcount--; /* runcount becomes -1 */ - LeaveCriticalSection (&lock->lock); - return 0; -} - -int -glthread_rwlock_unlock_func (gl_rwlock_t *lock) -{ - if (!lock->guard.done) - return EINVAL; - EnterCriticalSection (&lock->lock); - if (lock->runcount < 0) - { - /* Drop a writer lock. */ - if (!(lock->runcount == -1)) - abort (); - lock->runcount = 0; - } - else - { - /* Drop a reader lock. */ - if (!(lock->runcount > 0)) - { - LeaveCriticalSection (&lock->lock); - return EPERM; - } - lock->runcount--; - } - if (lock->runcount == 0) - { - /* POSIX recommends that "write locks shall take precedence over read - locks", to avoid "writer starvation". */ - if (lock->waiting_writers.count > 0) - { - /* Wake up one of the waiting writers. */ - lock->runcount--; - gl_waitqueue_notify_first (&lock->waiting_writers); - } - else - { - /* Wake up all waiting readers. */ - lock->runcount += lock->waiting_readers.count; - gl_waitqueue_notify_all (&lock->waiting_readers); - } - } - LeaveCriticalSection (&lock->lock); - return 0; -} - -int -glthread_rwlock_destroy_func (gl_rwlock_t *lock) -{ - if (!lock->guard.done) - return EINVAL; - if (lock->runcount != 0) - return EBUSY; - DeleteCriticalSection (&lock->lock); - if (lock->waiting_readers.array != NULL) - free (lock->waiting_readers.array); - if (lock->waiting_writers.array != NULL) - free (lock->waiting_writers.array); - lock->guard.done = 0; - return 0; -} - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -void -glthread_recursive_lock_init_func (gl_recursive_lock_t *lock) -{ - lock->owner = 0; - lock->depth = 0; - InitializeCriticalSection (&lock->lock); - lock->guard.done = 1; -} - -int -glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock) -{ - if (!lock->guard.done) - { - if (InterlockedIncrement (&lock->guard.started) == 0) - /* This thread is the first one to need this lock. Initialize it. */ - glthread_recursive_lock_init (lock); - else - /* Yield the CPU while waiting for another thread to finish - initializing this lock. */ - while (!lock->guard.done) - Sleep (0); - } - { - DWORD self = GetCurrentThreadId (); - if (lock->owner != self) - { - EnterCriticalSection (&lock->lock); - lock->owner = self; - } - if (++(lock->depth) == 0) /* wraparound? */ - { - lock->depth--; - return EAGAIN; - } - } - return 0; -} - -int -glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock) -{ - if (lock->owner != GetCurrentThreadId ()) - return EPERM; - if (lock->depth == 0) - return EINVAL; - if (--(lock->depth) == 0) - { - lock->owner = 0; - LeaveCriticalSection (&lock->lock); - } - return 0; -} - -int -glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock) -{ - if (lock->owner != 0) - return EBUSY; - DeleteCriticalSection (&lock->lock); - lock->guard.done = 0; - return 0; -} - -/* -------------------------- gl_once_t datatype -------------------------- */ - -void -glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)) -{ - if (once_control->inited <= 0) - { - if (InterlockedIncrement (&once_control->started) == 0) - { - /* This thread is the first one to come to this once_control. */ - InitializeCriticalSection (&once_control->lock); - EnterCriticalSection (&once_control->lock); - once_control->inited = 0; - initfunction (); - once_control->inited = 1; - LeaveCriticalSection (&once_control->lock); - } - else - { - /* Undo last operation. */ - InterlockedDecrement (&once_control->started); - /* Some other thread has already started the initialization. - Yield the CPU while waiting for the other thread to finish - initializing and taking the lock. */ - while (once_control->inited < 0) - Sleep (0); - if (once_control->inited <= 0) - { - /* Take the lock. This blocks until the other thread has - finished calling the initfunction. */ - EnterCriticalSection (&once_control->lock); - LeaveCriticalSection (&once_control->lock); - if (!(once_control->inited > 0)) - abort (); - } - } - } -} - -#endif - -/* ========================================================================= */ diff --git a/contrib/tools/bison/lib/glthread/lock.h b/contrib/tools/bison/lib/glthread/lock.h deleted file mode 100644 index 9c9e2f6840..0000000000 --- a/contrib/tools/bison/lib/glthread/lock.h +++ /dev/null @@ -1,985 +0,0 @@ -/* Locking in multithreaded situations. - Copyright (C) 2005-2018 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, 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 Bruno Haible <bruno@clisp.org>, 2005. - Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, - gthr-win32.h. */ - -/* This file contains locking primitives for use with a given thread library. - It does not contain primitives for creating threads or for other - synchronization primitives. - - Normal (non-recursive) locks: - Type: gl_lock_t - Declaration: gl_lock_define(extern, name) - Initializer: gl_lock_define_initialized(, name) - Initialization: gl_lock_init (name); - Taking the lock: gl_lock_lock (name); - Releasing the lock: gl_lock_unlock (name); - De-initialization: gl_lock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_lock_init (&name); - Taking the lock: err = glthread_lock_lock (&name); - Releasing the lock: err = glthread_lock_unlock (&name); - De-initialization: err = glthread_lock_destroy (&name); - - Read-Write (non-recursive) locks: - Type: gl_rwlock_t - Declaration: gl_rwlock_define(extern, name) - Initializer: gl_rwlock_define_initialized(, name) - Initialization: gl_rwlock_init (name); - Taking the lock: gl_rwlock_rdlock (name); - gl_rwlock_wrlock (name); - Releasing the lock: gl_rwlock_unlock (name); - De-initialization: gl_rwlock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_rwlock_init (&name); - Taking the lock: err = glthread_rwlock_rdlock (&name); - err = glthread_rwlock_wrlock (&name); - Releasing the lock: err = glthread_rwlock_unlock (&name); - De-initialization: err = glthread_rwlock_destroy (&name); - - Recursive locks: - Type: gl_recursive_lock_t - Declaration: gl_recursive_lock_define(extern, name) - Initializer: gl_recursive_lock_define_initialized(, name) - Initialization: gl_recursive_lock_init (name); - Taking the lock: gl_recursive_lock_lock (name); - Releasing the lock: gl_recursive_lock_unlock (name); - De-initialization: gl_recursive_lock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_recursive_lock_init (&name); - Taking the lock: err = glthread_recursive_lock_lock (&name); - Releasing the lock: err = glthread_recursive_lock_unlock (&name); - De-initialization: err = glthread_recursive_lock_destroy (&name); - - Once-only execution: - Type: gl_once_t - Initializer: gl_once_define(extern, name) - Execution: gl_once (name, initfunction); - Equivalent functions with control of error handling: - Execution: err = glthread_once (&name, initfunction); -*/ - - -#ifndef _LOCK_H -#define _LOCK_H - -#include <errno.h> -#include <stdlib.h> - -/* ========================================================================= */ - -#if USE_POSIX_THREADS - -/* Use the POSIX threads library. */ - -# include <pthread.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if PTHREAD_IN_USE_DETECTION_HARD - -/* The pthread_in_use() detection needs to be done at runtime. */ -# define pthread_in_use() \ - glthread_in_use () -extern int glthread_in_use (void); - -# endif - -# if USE_POSIX_THREADS_WEAK - -/* Use weak references to the POSIX threads library. */ - -/* Weak references avoid dragging in external libraries if the other parts - of the program don't use them. Here we use them, because we don't want - every program that uses libintl to depend on libpthread. This assumes - that libpthread would not be loaded after libintl; i.e. if libintl is - loaded first, by an executable that does not depend on libpthread, and - then a module is dynamically loaded that depends on libpthread, libintl - will not be multithread-safe. */ - -/* The way to test at runtime whether libpthread is present is to test - whether a function pointer's value, such as &pthread_mutex_init, is - non-NULL. However, some versions of GCC have a bug through which, in - PIC mode, &foo != NULL always evaluates to true if there is a direct - call to foo(...) in the same function. To avoid this, we test the - address of a function in libpthread that we don't use. */ - -# pragma weak pthread_mutex_init -# pragma weak pthread_mutex_lock -# pragma weak pthread_mutex_unlock -# pragma weak pthread_mutex_destroy -# pragma weak pthread_rwlock_init -# pragma weak pthread_rwlock_rdlock -# pragma weak pthread_rwlock_wrlock -# pragma weak pthread_rwlock_unlock -# pragma weak pthread_rwlock_destroy -# pragma weak pthread_once -# pragma weak pthread_cond_init -# pragma weak pthread_cond_wait -# pragma weak pthread_cond_signal -# pragma weak pthread_cond_broadcast -# pragma weak pthread_cond_destroy -# pragma weak pthread_mutexattr_init -# pragma weak pthread_mutexattr_settype -# pragma weak pthread_mutexattr_destroy -# pragma weak pthread_rwlockattr_init -# if __GNU_LIBRARY__ > 1 -# pragma weak pthread_rwlockattr_setkind_np -# endif -# pragma weak pthread_rwlockattr_destroy -# ifndef pthread_self -# pragma weak pthread_self -# endif - -# if !PTHREAD_IN_USE_DETECTION_HARD - /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols - can be used to determine whether libpthread is in use. These are: - pthread_mutexattr_gettype - pthread_rwlockattr_destroy - pthread_rwlockattr_init - */ -# pragma weak pthread_mutexattr_gettype -# define pthread_in_use() (pthread_mutexattr_gettype != NULL) -# endif - -# else - -# if !PTHREAD_IN_USE_DETECTION_HARD -# define pthread_in_use() 1 -# endif - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef pthread_mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - PTHREAD_MUTEX_INITIALIZER -# define glthread_lock_init(LOCK) \ - (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0) -# define glthread_lock_lock(LOCK) \ - (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) -# define glthread_lock_unlock(LOCK) \ - (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) -# define glthread_lock_destroy(LOCK) \ - (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1))) - -# ifdef PTHREAD_RWLOCK_INITIALIZER - -typedef pthread_rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; -# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER -# define gl_rwlock_initializer \ - PTHREAD_RWLOCK_INITIALIZER -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) -# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ -# define gl_rwlock_initializer \ - PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0) -extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock); -# endif -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0) - -# else - -typedef struct - { - int initialized; - pthread_mutex_t guard; /* protects the initialization */ - pthread_rwlock_t rwlock; /* read-write lock */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { 0, PTHREAD_MUTEX_INITIALIZER } -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -# else - -typedef struct - { - pthread_mutex_t lock; /* protects the remaining fields */ - pthread_cond_t waiting_readers; /* waiting readers */ - pthread_cond_t waiting_writers; /* waiting writers */ - unsigned int waiting_writers_count; /* number of waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -# if HAVE_PTHREAD_MUTEX_RECURSIVE - -# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - -typedef pthread_mutex_t gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; -# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER -# define gl_recursive_lock_initializer \ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER -# else -# define gl_recursive_lock_initializer \ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -# endif -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); - -# else - -typedef struct - { - pthread_mutex_t recmutex; /* recursive mutex */ - pthread_mutex_t guard; /* protects the initialization */ - int initialized; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -# endif - -# else - -/* Old versions of POSIX threads on Solaris did not have recursive locks. - We have to implement them ourselves. */ - -typedef struct - { - pthread_mutex_t mutex; - pthread_t owner; - unsigned long depth; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -# endif - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef pthread_once_t gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pthread_in_use () \ - ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_singlethreaded (pthread_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_mutex_init -# pragma weak pth_mutex_acquire -# pragma weak pth_mutex_release -# pragma weak pth_rwlock_init -# pragma weak pth_rwlock_acquire -# pragma weak pth_rwlock_release -# pragma weak pth_once - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL) - -# else - -# define pth_in_use() 1 - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef pth_mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* Pth pth_rwlock_acquire always prefers readers. No autoconf test so far. */ -# if HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER - -typedef pth_rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - PTH_RWLOCK_INIT -# define glthread_rwlock_init(LOCK) \ - (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0) -# define glthread_rwlock_destroy(LOCK) \ - ((void)(LOCK), 0) - -# else - -typedef struct - { - int initialized; - pth_mutex_t lock; /* protects the remaining fields */ - pth_cond_t waiting_readers; /* waiting readers */ - pth_cond_t waiting_writers; /* waiting writers */ - unsigned int waiting_writers_count; /* number of waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { 0 } -# define glthread_rwlock_init(LOCK) \ - (pth_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pth_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* In Pth, mutexes are recursive by default. */ -typedef pth_mutex_t gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_recursive_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef pth_once_t gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pth_in_use () \ - ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)); -extern int glthread_once_singlethreaded (pth_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_SOLARIS_THREADS - -/* Use the old Solaris threads library. */ - -# include <thread.h> -# error #include <synch.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_SOLARIS_THREADS_WEAK - -/* Use weak references to the old Solaris threads library. */ - -# pragma weak mutex_init -# pragma weak mutex_lock -# pragma weak mutex_unlock -# pragma weak mutex_destroy -# pragma weak rwlock_init -# pragma weak rw_rdlock -# pragma weak rw_wrlock -# pragma weak rw_unlock -# pragma weak rwlock_destroy -# pragma weak thr_self - -# pragma weak thr_suspend -# define thread_in_use() (thr_suspend != NULL) - -# else - -# define thread_in_use() 1 - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - DEFAULTMUTEX -# define glthread_lock_init(LOCK) \ - (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0) -# define glthread_lock_lock(LOCK) \ - (thread_in_use () ? mutex_lock (LOCK) : 0) -# define glthread_lock_unlock(LOCK) \ - (thread_in_use () ? mutex_unlock (LOCK) : 0) -# define glthread_lock_destroy(LOCK) \ - (thread_in_use () ? mutex_destroy (LOCK) : 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -typedef rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - DEFAULTRWLOCK -# define glthread_rwlock_init(LOCK) \ - (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (thread_in_use () ? rw_rdlock (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (thread_in_use () ? rw_wrlock (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (thread_in_use () ? rw_unlock (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (thread_in_use () ? rwlock_destroy (LOCK) : 0) - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* Old Solaris threads did not have recursive locks. - We have to implement them ourselves. */ - -typedef struct - { - mutex_t mutex; - thread_t owner; - unsigned long depth; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { DEFAULTMUTEX, (thread_t) 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef struct - { - volatile int inited; - mutex_t mutex; - } - gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (thread_in_use () \ - ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)); -extern int glthread_once_singlethreaded (gl_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_WINDOWS_THREADS - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> - -# ifdef __cplusplus -extern "C" { -# endif - -/* We can use CRITICAL_SECTION directly, rather than the native Windows Event, - Mutex, Semaphore types, because - - we need only to synchronize inside a single process (address space), - not inter-process locking, - - we don't need to support trylock operations. (TryEnterCriticalSection - does not work on Windows 95/98/ME. Packages that need trylock usually - define their own mutex type.) */ - -/* There is no way to statically initialize a CRITICAL_SECTION. It needs - to be done lazily, once only. For this we need spinlocks. */ - -typedef struct { volatile int done; volatile long started; } gl_spinlock_t; - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - CRITICAL_SECTION lock; - } - gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_lock_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_lock_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - { { 0, -1 } } -# define glthread_lock_init(LOCK) \ - (glthread_lock_init_func (LOCK), 0) -# define glthread_lock_lock(LOCK) \ - glthread_lock_lock_func (LOCK) -# define glthread_lock_unlock(LOCK) \ - glthread_lock_unlock_func (LOCK) -# define glthread_lock_destroy(LOCK) \ - glthread_lock_destroy_func (LOCK) -extern void glthread_lock_init_func (gl_lock_t *lock); -extern int glthread_lock_lock_func (gl_lock_t *lock); -extern int glthread_lock_unlock_func (gl_lock_t *lock); -extern int glthread_lock_destroy_func (gl_lock_t *lock); - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* It is impossible to implement read-write locks using plain locks, without - introducing an extra thread dedicated to managing read-write locks. - Therefore here we need to use the low-level Event type. */ - -typedef struct - { - HANDLE *array; /* array of waiting threads, each represented by an event */ - unsigned int count; /* number of waiting threads */ - unsigned int alloc; /* length of allocated array */ - unsigned int offset; /* index of first waiting thread in array */ - } - gl_carray_waitqueue_t; -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - CRITICAL_SECTION lock; /* protects the remaining fields */ - gl_carray_waitqueue_t waiting_readers; /* waiting readers */ - gl_carray_waitqueue_t waiting_writers; /* waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { { 0, -1 } } -# define glthread_rwlock_init(LOCK) \ - (glthread_rwlock_init_func (LOCK), 0) -# define glthread_rwlock_rdlock(LOCK) \ - glthread_rwlock_rdlock_func (LOCK) -# define glthread_rwlock_wrlock(LOCK) \ - glthread_rwlock_wrlock_func (LOCK) -# define glthread_rwlock_unlock(LOCK) \ - glthread_rwlock_unlock_func (LOCK) -# define glthread_rwlock_destroy(LOCK) \ - glthread_rwlock_destroy_func (LOCK) -extern void glthread_rwlock_init_func (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* The native Windows documentation says that CRITICAL_SECTION already - implements a recursive lock. But we need not rely on it: It's easy to - implement a recursive lock without this assumption. */ - -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - DWORD owner; - unsigned long depth; - CRITICAL_SECTION lock; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { { 0, -1 }, 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (glthread_recursive_lock_init_func (LOCK), 0) -# define glthread_recursive_lock_lock(LOCK) \ - glthread_recursive_lock_lock_func (LOCK) -# define glthread_recursive_lock_unlock(LOCK) \ - glthread_recursive_lock_unlock_func (LOCK) -# define glthread_recursive_lock_destroy(LOCK) \ - glthread_recursive_lock_destroy_func (LOCK) -extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock); - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef struct - { - volatile int inited; - volatile long started; - CRITICAL_SECTION lock; - } - gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = { -1, -1 }; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) -extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) - -/* Provide dummy implementation if threads are not supported. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef int gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) -# define gl_lock_define_initialized(STORAGECLASS, NAME) -# define glthread_lock_init(NAME) 0 -# define glthread_lock_lock(NAME) 0 -# define glthread_lock_unlock(NAME) 0 -# define glthread_lock_destroy(NAME) 0 - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -typedef int gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) -# define glthread_rwlock_init(NAME) 0 -# define glthread_rwlock_rdlock(NAME) 0 -# define glthread_rwlock_wrlock(NAME) 0 -# define glthread_rwlock_unlock(NAME) 0 -# define glthread_rwlock_destroy(NAME) 0 - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -typedef int gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) -# define glthread_recursive_lock_init(NAME) 0 -# define glthread_recursive_lock_lock(NAME) 0 -# define glthread_recursive_lock_unlock(NAME) 0 -# define glthread_recursive_lock_destroy(NAME) 0 - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef int gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = 0; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0) - -#endif - -/* ========================================================================= */ - -/* Macros with built-in error handling. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -#define gl_lock_init(NAME) \ - do \ - { \ - if (glthread_lock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_lock(NAME) \ - do \ - { \ - if (glthread_lock_lock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_unlock(NAME) \ - do \ - { \ - if (glthread_lock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_destroy(NAME) \ - do \ - { \ - if (glthread_lock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -#define gl_rwlock_init(NAME) \ - do \ - { \ - if (glthread_rwlock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_rdlock(NAME) \ - do \ - { \ - if (glthread_rwlock_rdlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_wrlock(NAME) \ - do \ - { \ - if (glthread_rwlock_wrlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_unlock(NAME) \ - do \ - { \ - if (glthread_rwlock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_destroy(NAME) \ - do \ - { \ - if (glthread_rwlock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -#define gl_recursive_lock_init(NAME) \ - do \ - { \ - if (glthread_recursive_lock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_lock(NAME) \ - do \ - { \ - if (glthread_recursive_lock_lock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_unlock(NAME) \ - do \ - { \ - if (glthread_recursive_lock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_destroy(NAME) \ - do \ - { \ - if (glthread_recursive_lock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* -------------------------- gl_once_t datatype -------------------------- */ - -#define gl_once(NAME, INITFUNCTION) \ - do \ - { \ - if (glthread_once (&NAME, INITFUNCTION)) \ - abort (); \ - } \ - while (0) - -/* ========================================================================= */ - -#endif /* _LOCK_H */ diff --git a/contrib/tools/bison/lib/glthread/threadlib.c b/contrib/tools/bison/lib/glthread/threadlib.c deleted file mode 100644 index e8b484a05c..0000000000 --- a/contrib/tools/bison/lib/glthread/threadlib.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Multithreading primitives. - Copyright (C) 2005-2018 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, 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 Bruno Haible <bruno@clisp.org>, 2005. */ - -#include <config.h> - -/* ========================================================================= */ - -#if USE_POSIX_THREADS - -/* Use the POSIX threads library. */ - -# include <pthread.h> -# include <stdlib.h> - -# if PTHREAD_IN_USE_DETECTION_HARD - -/* The function to be executed by a dummy thread. */ -static void * -dummy_thread_func (void *arg) -{ - return arg; -} - -int -glthread_in_use (void) -{ - static int tested; - static int result; /* 1: linked with -lpthread, 0: only with libc */ - - if (!tested) - { - pthread_t thread; - - if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) - /* Thread creation failed. */ - result = 0; - else - { - /* Thread creation works. */ - void *retval; - if (pthread_join (thread, &retval) != 0) - abort (); - result = 1; - } - tested = 1; - } - return result; -} - -# endif - -#endif - -/* ========================================================================= */ - -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -typedef int dummy; diff --git a/contrib/tools/bison/lib/hard-locale.c b/contrib/tools/bison/lib/hard-locale.c index 49bc6caff4..dcfcad62ee 100644 --- a/contrib/tools/bison/lib/hard-locale.c +++ b/contrib/tools/bison/lib/hard-locale.c @@ -1,6 +1,6 @@ /* hard-locale.c -- Determine whether a locale is hard. - Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2018 Free Software + Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/hard-locale.h b/contrib/tools/bison/lib/hard-locale.h index 22eecc5ed8..8f1da96e2f 100644 --- a/contrib/tools/bison/lib/hard-locale.h +++ b/contrib/tools/bison/lib/hard-locale.h @@ -1,6 +1,6 @@ /* Determine whether a locale is hard. - Copyright (C) 1999, 2003-2004, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1999, 2003-2004, 2009-2019 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 diff --git a/contrib/tools/bison/lib/hash.c b/contrib/tools/bison/lib/hash.c index 98a8ea3d3c..9e1f8e8417 100644 --- a/contrib/tools/bison/lib/hash.c +++ b/contrib/tools/bison/lib/hash.c @@ -1,6 +1,6 @@ /* hash - hashing table processing. - Copyright (C) 1998-2004, 2006-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1998-2004, 2006-2007, 2009-2019 Free Software Foundation, Inc. Written by Jim Meyering, 1992. diff --git a/contrib/tools/bison/lib/hash.h b/contrib/tools/bison/lib/hash.h index 562f5e6796..a1a483a359 100644 --- a/contrib/tools/bison/lib/hash.h +++ b/contrib/tools/bison/lib/hash.h @@ -1,5 +1,5 @@ /* hash - hashing table processing. - Copyright (C) 1998-1999, 2001, 2003, 2009-2018 Free Software Foundation, + Copyright (C) 1998-1999, 2001, 2003, 2009-2019 Free Software Foundation, Inc. Written by Jim Meyering <meyering@ascend.com>, 1998. diff --git a/contrib/tools/bison/lib/intprops.h b/contrib/tools/bison/lib/intprops.h deleted file mode 100644 index cdaf6586cb..0000000000 --- a/contrib/tools/bison/lib/intprops.h +++ /dev/null @@ -1,455 +0,0 @@ -/* intprops.h -- properties of integer types - - Copyright (C) 2001-2018 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. */ - -#ifndef _GL_INTPROPS_H -#define _GL_INTPROPS_H - -#include <limits.h> - -/* Return a value with the common real type of E and V and the value of V. - Do not evaluate E. */ -#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) - -/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see - <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */ -#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v)) - -/* The extra casts in the following macros work around compiler bugs, - e.g., in Cray C 5.0.3.0. */ - -/* True if the arithmetic type T is an integer type. bool counts as - an integer. */ -#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) - -/* True if the real type T is signed. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) - -/* Return 1 if the real expression E, after promotion, has a - signed or floating type. Do not evaluate E. */ -#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) - - -/* Minimum and maximum values for integer types and expressions. */ - -/* The width in bits of the integer type or expression T. - Do not evaluate T. - Padding bits are not supported; this is checked at compile-time below. */ -#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) - -/* The maximum and minimum values for the integer type T. */ -#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) -#define TYPE_MAXIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) - -/* The maximum and minimum values for the type of the expression E, - after integer promotion. E is not evaluated. */ -#define _GL_INT_MINIMUM(e) \ - (EXPR_SIGNED (e) \ - ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_CONVERT (e, 0)) -#define _GL_INT_MAXIMUM(e) \ - (EXPR_SIGNED (e) \ - ? _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_NEGATE_CONVERT (e, 1)) -#define _GL_SIGNED_INT_MAXIMUM(e) \ - (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1) - -/* Work around OpenVMS incompatibility with C99. */ -#if !defined LLONG_MAX && defined __INT64_MAX -# define LLONG_MAX __INT64_MAX -# define LLONG_MIN __INT64_MIN -#endif - -/* This include file assumes that signed types are two's complement without - padding bits; the above macros have undefined behavior otherwise. - If this is a problem for you, please let us know how to fix it for your host. - This assumption is tested by the intprops-tests module. */ - -/* Does the __typeof__ keyword work? This could be done by - 'configure', but for now it's easier to do it by hand. */ -#if (2 <= __GNUC__ \ - || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ - || (0x5110 <= __SUNPRO_C && !__STDC__)) -# define _GL_HAVE___TYPEOF__ 1 -#else -# define _GL_HAVE___TYPEOF__ 0 -#endif - -/* Return 1 if the integer type or expression T might be signed. Return 0 - if it is definitely unsigned. This macro does not evaluate its argument, - and expands to an integer constant expression. */ -#if _GL_HAVE___TYPEOF__ -# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) -#else -# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 -#endif - -/* Bound on length of the string representing an unsigned integer - value representable in B bits. log10 (2.0) < 146/485. The - smallest value of B where this bound is not tight is 2621. */ -#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) - -/* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if T is signed, and then add 1 more for - a minus sign if needed. - - Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is - signed, this macro may overestimate the true bound by one byte when - applied to unsigned types of size 2, 4, 16, ... bytes. */ -#define INT_STRLEN_BOUND(t) \ - (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \ - + _GL_SIGNED_TYPE_OR_EXPR (t)) - -/* Bound on buffer size needed to represent an integer type or expression T, - including the terminating null. */ -#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) - - -/* Range overflow checks. - - The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C - operators might not yield numerically correct answers due to - arithmetic overflow. They do not rely on undefined or - implementation-defined behavior. Their implementations are simple - and straightforward, but they are a bit harder to use than the - INT_<op>_OVERFLOW macros described below. - - Example usage: - - long int i = ...; - long int j = ...; - if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) - printf ("multiply would overflow"); - else - printf ("product is %ld", i * j); - - Restrictions on *_RANGE_OVERFLOW macros: - - These macros do not check for all possible numerical problems or - undefined or unspecified behavior: they do not check for division - by zero, for bad shift counts, or for shifting negative numbers. - - These macros may evaluate their arguments zero or multiple times, - so the arguments should not have side effects. The arithmetic - arguments (including the MIN and MAX arguments) must be of the same - integer type after the usual arithmetic conversions, and the type - must have minimum value MIN and maximum MAX. Unsigned types should - use a zero MIN of the proper type. - - These macros are tuned for constant MIN and MAX. For commutative - operations such as A + B, they are also tuned for constant B. */ - -/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? (a) < (min) - (b) \ - : (max) - (b) < (a)) - -/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? (max) + (b) < (a) \ - : (a) < (min) + (b)) - -/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ -#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ - ((min) < 0 \ - ? (a) < - (max) \ - : 0 < (a)) - -/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Avoid && and || as they tickle - bugs in Sun C 5.11 2010/08/13 and other compilers; see - <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */ -#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ - ((b) < 0 \ - ? ((a) < 0 \ - ? (a) < (max) / (b) \ - : (b) == -1 \ - ? 0 \ - : (min) / (b) < (a)) \ - : (b) == 0 \ - ? 0 \ - : ((a) < 0 \ - ? (a) < (min) / (b) \ - : (max) / (b) < (a))) - -/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Do not check for division by zero. */ -#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ - ((min) < 0 && (b) == -1 && (a) < - (max)) - -/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Do not check for division by zero. - Mathematically, % should never overflow, but on x86-like hosts - INT_MIN % -1 traps, and the C standard permits this, so treat this - as an overflow too. */ -#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ - INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) - -/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. Here, MIN and MAX are for A only, and B need - not be of the same type as the other arguments. The C standard says that - behavior is undefined for shifts unless 0 <= B < wordwidth, and that when - A is negative then A << B has undefined behavior and A >> B has - implementation-defined behavior, but do not check these other - restrictions. */ -#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ - ((a) < 0 \ - ? (a) < (min) >> (b) \ - : (max) >> (b) < (a)) - -/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ -#if 5 <= __GNUC__ && !defined __ICC -# define _GL_HAS_BUILTIN_OVERFLOW 1 -#else -# define _GL_HAS_BUILTIN_OVERFLOW 0 -#endif - -/* True if __builtin_add_overflow_p (A, B, C) works. */ -#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) - -/* The _GL*_OVERFLOW macros have the same restrictions as the - *_RANGE_OVERFLOW macros, except that they do not assume that operands - (e.g., A and B) have the same type as MIN and MAX. Instead, they assume - that the result (e.g., A + B) has that type. */ -#if _GL_HAS_BUILTIN_OVERFLOW_P -# define _GL_ADD_OVERFLOW(a, b, min, max) \ - __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) -# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ - __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) -# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ - __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) -#else -# define _GL_ADD_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ - : (a) < 0 ? (b) <= (a) + (b) \ - : (b) < 0 ? (a) <= (a) + (b) \ - : (a) + (b) < (b)) -# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ - : (a) < 0 ? 1 \ - : (b) < 0 ? (a) - (b) <= (a) \ - : (a) < (b)) -# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ - (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ - || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) -#endif -#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ - : (a) < 0 ? (b) <= (a) + (b) - 1 \ - : (b) < 0 && (a) + (b) <= (a)) -#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ - : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ - : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) - -/* Return a nonzero value if A is a mathematical multiple of B, where - A is unsigned, B is negative, and MAX is the maximum value of A's - type. A's type must be the same as (A % B)'s type. Normally (A % - -B == 0) suffices, but things get tricky if -B would overflow. */ -#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ - (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ - ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ - ? (a) \ - : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ - : (a) % - (b)) \ - == 0) - -/* Check for integer overflow, and report low order bits of answer. - - The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators - might not yield numerically correct answers due to arithmetic overflow. - The INT_<op>_WRAPV macros also store the low-order bits of the answer. - These macros work correctly on all known practical hosts, and do not rely - on undefined behavior due to signed arithmetic overflow. - - Example usage, assuming A and B are long int: - - if (INT_MULTIPLY_OVERFLOW (a, b)) - printf ("result would overflow\n"); - else - printf ("result is %ld (no overflow)\n", a * b); - - Example usage with WRAPV flavor: - - long int result; - bool overflow = INT_MULTIPLY_WRAPV (a, b, &result); - printf ("result is %ld (%s)\n", result, - overflow ? "after overflow" : "no overflow"); - - Restrictions on these macros: - - These macros do not check for all possible numerical problems or - undefined or unspecified behavior: they do not check for division - by zero, for bad shift counts, or for shifting negative numbers. - - These macros may evaluate their arguments zero or multiple times, so the - arguments should not have side effects. - - The WRAPV macros are not constant expressions. They support only - +, binary -, and *. The result type must be signed. - - These macros are tuned for their last argument being a constant. - - Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, - A % B, and A << B would overflow, respectively. */ - -#define INT_ADD_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) -#define INT_SUBTRACT_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) -#if _GL_HAS_BUILTIN_OVERFLOW_P -# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) -#else -# define INT_NEGATE_OVERFLOW(a) \ - INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) -#endif -#define INT_MULTIPLY_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) -#define INT_DIVIDE_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) -#define INT_REMAINDER_OVERFLOW(a, b) \ - _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) -#define INT_LEFT_SHIFT_OVERFLOW(a, b) \ - INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ - _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) - -/* Return 1 if the expression A <op> B would overflow, - where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, - assuming MIN and MAX are the minimum and maximum for the result type. - Arguments should be free of side effects. */ -#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ - op_result_overflow (a, b, \ - _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \ - _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b))) - -/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. - Return 1 if the result overflows. See above for restrictions. */ -#define INT_ADD_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW) -#define INT_SUBTRACT_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW) -#define INT_MULTIPLY_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) - -/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 - https://llvm.org/bugs/show_bug.cgi?id=25390 - For now, assume all versions of GCC-like compilers generate bogus - warnings for _Generic. This matters only for older compilers that - lack __builtin_add_overflow. */ -#if __GNUC__ -# define _GL__GENERIC_BOGUS 1 -#else -# define _GL__GENERIC_BOGUS 0 -#endif - -/* Store the low-order bits of A <op> B into *R, where OP specifies - the operation. BUILTIN is the builtin operation, and OVERFLOW the - overflow predicate. Return 1 if the result overflows. See above - for restrictions. */ -#if _GL_HAS_BUILTIN_OVERFLOW -# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) -#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS -# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ - (_Generic \ - (*(r), \ - signed char: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - signed char, SCHAR_MIN, SCHAR_MAX), \ - short int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - short int, SHRT_MIN, SHRT_MAX), \ - int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - int, INT_MIN, INT_MAX), \ - long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX), \ - long long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - long long int, LLONG_MIN, LLONG_MAX))) -#else -# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ - (sizeof *(r) == sizeof (signed char) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - signed char, SCHAR_MIN, SCHAR_MAX) \ - : sizeof *(r) == sizeof (short int) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - short int, SHRT_MIN, SHRT_MAX) \ - : sizeof *(r) == sizeof (int) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - int, INT_MIN, INT_MAX) \ - : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) -# ifdef LLONG_MAX -# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ - (sizeof *(r) == sizeof (long int) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - long long int, LLONG_MIN, LLONG_MAX)) -# else -# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX) -# endif -#endif - -/* Store the low-order bits of A <op> B into *R, where the operation - is given by OP. Use the unsigned type UT for calculation to avoid - overflow problems. *R's type is T, with extrema TMIN and TMAX. - T must be a signed integer type. Return 1 if the result overflows. */ -#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \ - (sizeof ((a) op (b)) < sizeof (t) \ - ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \ - : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax)) -#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \ - ((overflow (a, b) \ - || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \ - || (tmax) < ((a) op (b))) \ - ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \ - : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0)) - -/* Return the low-order bits of A <op> B, where the operation is given - by OP. Use the unsigned type UT for calculation to avoid undefined - behavior on signed integer overflow, and convert the result to type T. - UT is at least as wide as T and is no narrower than unsigned int, - T is two's complement, and there is no padding or trap representations. - Assume that converting UT to T yields the low-order bits, as is - done in all known two's-complement C compilers. E.g., see: - https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html - - According to the C standard, converting UT to T yields an - implementation-defined result or signal for values outside T's - range. However, code that works around this theoretical problem - runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: - https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html - As the compiler bug is real, don't try to work around the - theoretical problem. */ - -#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \ - ((t) ((ut) (a) op (ut) (b))) - -#endif /* _GL_INTPROPS_H */ diff --git a/contrib/tools/bison/lib/isnand-nolibm.h b/contrib/tools/bison/lib/isnand-nolibm.h index 7be4573955..174c61ebd2 100644 --- a/contrib/tools/bison/lib/isnand-nolibm.h +++ b/contrib/tools/bison/lib/isnand-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 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 diff --git a/contrib/tools/bison/lib/isnanl-nolibm.h b/contrib/tools/bison/lib/isnanl-nolibm.h index ddd12f0d24..fdedf56b62 100644 --- a/contrib/tools/bison/lib/isnanl-nolibm.h +++ b/contrib/tools/bison/lib/isnanl-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 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 diff --git a/contrib/tools/bison/lib/localcharset.c b/contrib/tools/bison/lib/localcharset.c index bfa5531778..579972bc2f 100644 --- a/contrib/tools/bison/lib/localcharset.c +++ b/contrib/tools/bison/lib/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2019 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 diff --git a/contrib/tools/bison/lib/localcharset.h b/contrib/tools/bison/lib/localcharset.h index e4ba2960ba..7d0d7711db 100644 --- a/contrib/tools/bison/lib/localcharset.h +++ b/contrib/tools/bison/lib/localcharset.h @@ -1,5 +1,5 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc. This file is part of the GNU CHARSET Library. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/localtime-buffer.c b/contrib/tools/bison/lib/localtime-buffer.c deleted file mode 100644 index df11f4321d..0000000000 --- a/contrib/tools/bison/lib/localtime-buffer.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Provide access to the last buffer returned by localtime() or gmtime(). - - Copyright (C) 2001-2003, 2005-2007, 2009-2018 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, 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 Jim Meyering */ - -#include <config.h> - -/* Specification. */ -#include "localtime-buffer.h" - -#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME - -static struct tm tm_zero_buffer; -struct tm *localtime_buffer_addr = &tm_zero_buffer; - -/* This is a wrapper for localtime. - - On the first call, record the address of the static buffer that - localtime uses for its result. */ - -struct tm * -rpl_localtime (time_t const *timep) -{ - struct tm *tm = localtime (timep); - - if (localtime_buffer_addr == &tm_zero_buffer) - localtime_buffer_addr = tm; - - return tm; -} - -/* Same as above, since gmtime and localtime use the same buffer. */ -struct tm * -rpl_gmtime (time_t const *timep) -{ - struct tm *tm = gmtime (timep); - - if (localtime_buffer_addr == &tm_zero_buffer) - localtime_buffer_addr = tm; - - return tm; -} - -#endif diff --git a/contrib/tools/bison/lib/localtime-buffer.h b/contrib/tools/bison/lib/localtime-buffer.h deleted file mode 100644 index f381ff0e6d..0000000000 --- a/contrib/tools/bison/lib/localtime-buffer.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Provide access to the last buffer returned by localtime() or gmtime(). - - Copyright (C) 2001-2003, 2005-2007, 2009-2018 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, 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 Jim Meyering */ - -#include <time.h> - -#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME - -/* The address of the last buffer returned by localtime() or gmtime(). */ -extern struct tm *localtime_buffer_addr; - -#endif diff --git a/contrib/tools/bison/lib/malloca.c b/contrib/tools/bison/lib/malloca.c deleted file mode 100644 index c54e1e0f9b..0000000000 --- a/contrib/tools/bison/lib/malloca.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003, 2018. - - 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, 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/>. */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include <config.h> - -/* Specification. */ -#include "malloca.h" - -#include "verify.h" - -/* The speed critical point in this file is freea() applied to an alloca() - result: it must be fast, to match the speed of alloca(). The speed of - mmalloca() and freea() in the other case are not critical, because they - are only invoked for big memory sizes. - Here we use a bit in the address as an indicator, an idea by OndÅ™ej BÃlka. - malloca() can return three types of pointers: - - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation. - - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap - allocation. - - NULL comes from a failed heap allocation. */ - -/* Type for holding very small pointer differences. */ -typedef unsigned char small_t; -/* Verify that it is wide enough. */ -verify (2 * sa_alignment_max - 1 <= (small_t) -1); - -void * -mmalloca (size_t n) -{ -#if HAVE_ALLOCA - /* Allocate one more word, used to determine the address to pass to freea(), - and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */ - size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1; - - if (nplus >= n) - { - char *mem = (char *) malloc (nplus); - - if (mem != NULL) - { - char *p = - (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1) - & ~(uintptr_t)(2 * sa_alignment_max - 1)) - + sa_alignment_max); - /* Here p >= mem + sizeof (small_t), - and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 - hence p + n <= mem + nplus. - So, the memory range [p, p+n) lies in the allocated memory range - [mem, mem + nplus). */ - ((small_t *) p)[-1] = p - mem; - /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ - return p; - } - } - /* Out of memory. */ - return NULL; -#else -# if !MALLOC_0_IS_NONNULL - if (n == 0) - n = 1; -# endif - return malloc (n); -#endif -} - -#if HAVE_ALLOCA -void -freea (void *p) -{ - /* Check argument. */ - if ((uintptr_t) p & (sa_alignment_max - 1)) - { - /* p was not the result of a malloca() call. Invalid argument. */ - abort (); - } - /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ - if ((uintptr_t) p & sa_alignment_max) - { - void *mem = (char *) p - ((small_t *) p)[-1]; - free (mem); - } -} -#endif - -/* - * Hey Emacs! - * Local Variables: - * coding: utf-8 - * End: - */ diff --git a/contrib/tools/bison/lib/malloca.h b/contrib/tools/bison/lib/malloca.h deleted file mode 100644 index 1e47813ff4..0000000000 --- a/contrib/tools/bison/lib/malloca.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003. - - 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, 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 _MALLOCA_H -#define _MALLOCA_H - -#include <alloca.h> -#include <stddef.h> -#include <stdlib.h> -#include <stdint.h> - -#include "xalloc-oversized.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call - alloca(N); otherwise it returns NULL. It either returns N bytes of - memory allocated on the stack, that lasts until the function returns, - or NULL. - Use of safe_alloca should be avoided: - - inside arguments of function calls - undefined behaviour, - - in inline functions - the allocation may actually last until the - calling function returns. -*/ -#if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. - This must be a macro, not a function. */ -# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) -#else -# define safe_alloca(N) ((void) (N), NULL) -#endif - -/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of - memory allocated on the stack, that must be freed using freea() before - the function returns. Upon failure, it returns NULL. */ -#if HAVE_ALLOCA -# define malloca(N) \ - ((N) < 4032 - (2 * sa_alignment_max - 1) \ - ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ - + (2 * sa_alignment_max - 1)) \ - & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ - : mmalloca (N)) -#else -# define malloca(N) \ - mmalloca (N) -#endif -extern void * mmalloca (size_t n); - -/* Free a block of memory allocated through malloca(). */ -#if HAVE_ALLOCA -extern void freea (void *p); -#else -# define freea free -#endif - -/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). - It allocates an array of N objects, each with S bytes of memory, - on the stack. S must be positive and N must be nonnegative. - The array must be freed using freea() before the function returns. */ -#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s))) - - -#ifdef __cplusplus -} -#endif - - -/* ------------------- Auxiliary, non-public definitions ------------------- */ - -/* Determine the alignment of a type at compile time. */ -#if defined __GNUC__ || defined __IBM__ALIGNOF__ -# define sa_alignof __alignof__ -#elif defined __cplusplus - template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; -# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2) -#elif defined __hpux - /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#elif defined _AIX - /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#else -# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) -#endif - -enum -{ -/* The desired alignment of memory allocations is the maximum alignment - among all elementary types. */ - sa_alignment_long = sa_alignof (long), - sa_alignment_double = sa_alignof (double), -#if HAVE_LONG_LONG_INT - sa_alignment_longlong = sa_alignof (long long), -#endif - sa_alignment_longdouble = sa_alignof (long double), - sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) -#if HAVE_LONG_LONG_INT - | (sa_alignment_longlong - 1) -#endif - | (sa_alignment_longdouble - 1) - ) + 1 -}; - -#endif /* _MALLOCA_H */ diff --git a/contrib/tools/bison/lib/mbrtowc.c b/contrib/tools/bison/lib/mbrtowc.c index 2f6df287a5..bbe3f7a3b9 100644 --- a/contrib/tools/bison/lib/mbrtowc.c +++ b/contrib/tools/bison/lib/mbrtowc.c @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2018 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/mbswidth.c b/contrib/tools/bison/lib/mbswidth.c index 7ef404794c..408a15e344 100644 --- a/contrib/tools/bison/lib/mbswidth.c +++ b/contrib/tools/bison/lib/mbswidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2019 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 diff --git a/contrib/tools/bison/lib/mbswidth.h b/contrib/tools/bison/lib/mbswidth.h index 0f22ca572d..2b5c53c372 100644 --- a/contrib/tools/bison/lib/mbswidth.h +++ b/contrib/tools/bison/lib/mbswidth.h @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2000-2004, 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/minmax.h b/contrib/tools/bison/lib/minmax.h index 33a5305f42..d7f6bea061 100644 --- a/contrib/tools/bison/lib/minmax.h +++ b/contrib/tools/bison/lib/minmax.h @@ -1,5 +1,5 @@ /* MIN, MAX macros. - Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2018 Free Software + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/msvc-inval.c b/contrib/tools/bison/lib/msvc-inval.c index 0f19a09aee..75b5a070ab 100644 --- a/contrib/tools/bison/lib/msvc-inval.c +++ b/contrib/tools/bison/lib/msvc-inval.c @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2018 Free Software Foundation, Inc. + Copyright (C) 2011-2019 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 diff --git a/contrib/tools/bison/lib/msvc-inval.h b/contrib/tools/bison/lib/msvc-inval.h index 8e7ff303a7..e31cf65091 100644 --- a/contrib/tools/bison/lib/msvc-inval.h +++ b/contrib/tools/bison/lib/msvc-inval.h @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2018 Free Software Foundation, Inc. + Copyright (C) 2011-2019 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 diff --git a/contrib/tools/bison/lib/msvc-nothrow.c b/contrib/tools/bison/lib/msvc-nothrow.c index 785733e439..49b709ca4a 100644 --- a/contrib/tools/bison/lib/msvc-nothrow.c +++ b/contrib/tools/bison/lib/msvc-nothrow.c @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2018 Free Software Foundation, Inc. + Copyright (C) 2011-2019 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 diff --git a/contrib/tools/bison/lib/msvc-nothrow.h b/contrib/tools/bison/lib/msvc-nothrow.h index a9671c3b64..8d3ca7892e 100644 --- a/contrib/tools/bison/lib/msvc-nothrow.h +++ b/contrib/tools/bison/lib/msvc-nothrow.h @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2018 Free Software Foundation, Inc. + Copyright (C) 2011-2019 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 diff --git a/contrib/tools/bison/lib/obstack.c b/contrib/tools/bison/lib/obstack.c index 16d1770882..411de47429 100644 --- a/contrib/tools/bison/lib/obstack.c +++ b/contrib/tools/bison/lib/obstack.c @@ -1,5 +1,5 @@ /* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988-2018 Free Software Foundation, Inc. + Copyright (C) 1988-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/contrib/tools/bison/lib/obstack.h b/contrib/tools/bison/lib/obstack.h index 4355fc55c8..90ba66004b 100644 --- a/contrib/tools/bison/lib/obstack.h +++ b/contrib/tools/bison/lib/obstack.h @@ -1,5 +1,5 @@ /* obstack.h - object stack macros - Copyright (C) 1988-2018 Free Software Foundation, Inc. + Copyright (C) 1988-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -111,7 +111,7 @@ #include <stddef.h> /* For size_t and ptrdiff_t. */ #include <string.h> /* For __GNU_LIBRARY__, and memcpy. */ -#if __STDC_VERSION__ < 199901L +#if __STDC_VERSION__ < 199901L || defined __HP_cc # define __FLEXIBLE_ARRAY_MEMBER 1 #else # define __FLEXIBLE_ARRAY_MEMBER diff --git a/contrib/tools/bison/lib/obstack_printf.c b/contrib/tools/bison/lib/obstack_printf.c index 705b4c0e7d..0d59a8bcff 100644 --- a/contrib/tools/bison/lib/obstack_printf.c +++ b/contrib/tools/bison/lib/obstack_printf.c @@ -1,5 +1,5 @@ /* Formatted output to obstacks. - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 diff --git a/contrib/tools/bison/lib/open.c b/contrib/tools/bison/lib/open.c index 792e258ba0..655260572d 100644 --- a/contrib/tools/bison/lib/open.c +++ b/contrib/tools/bison/lib/open.c @@ -1,5 +1,5 @@ /* Open a descriptor to a file. - Copyright (C) 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2019 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 diff --git a/contrib/tools/bison/lib/path-join.c b/contrib/tools/bison/lib/path-join.c index 73560b445d..727874222a 100644 --- a/contrib/tools/bison/lib/path-join.c +++ b/contrib/tools/bison/lib/path-join.c @@ -1,5 +1,5 @@ /* Concatenate path components. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2019 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 diff --git a/contrib/tools/bison/lib/path-join.h b/contrib/tools/bison/lib/path-join.h index baa472a97c..0ac7055ff0 100644 --- a/contrib/tools/bison/lib/path-join.h +++ b/contrib/tools/bison/lib/path-join.h @@ -1,5 +1,5 @@ /* Concatenate path components. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2019 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 diff --git a/contrib/tools/bison/lib/pipe-safer.c b/contrib/tools/bison/lib/pipe-safer.c index 1669d90934..62017397c6 100644 --- a/contrib/tools/bison/lib/pipe-safer.c +++ b/contrib/tools/bison/lib/pipe-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe, but avoid some glitches. - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/pipe2-safer.c b/contrib/tools/bison/lib/pipe2-safer.c index 71fef9ec8e..390d96b51c 100644 --- a/contrib/tools/bison/lib/pipe2-safer.c +++ b/contrib/tools/bison/lib/pipe2-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe2, but avoid some glitches. - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/pipe2.c b/contrib/tools/bison/lib/pipe2.c index c16d9351ec..15a5dec985 100644 --- a/contrib/tools/bison/lib/pipe2.c +++ b/contrib/tools/bison/lib/pipe2.c @@ -1,5 +1,5 @@ /* Create a pipe, with specific opening flags. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2019 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 diff --git a/contrib/tools/bison/lib/printf-args.c b/contrib/tools/bison/lib/printf-args.c index 1079e0a9a6..e45cfbede1 100644 --- a/contrib/tools/bison/lib/printf-args.c +++ b/contrib/tools/bison/lib/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2018 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/printf-args.h b/contrib/tools/bison/lib/printf-args.h index 111e8a5605..866cba04d8 100644 --- a/contrib/tools/bison/lib/printf-args.h +++ b/contrib/tools/bison/lib/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2018 Free Software + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/printf-frexp.c b/contrib/tools/bison/lib/printf-frexp.c index c704090b9e..77eafab544 100644 --- a/contrib/tools/bison/lib/printf-frexp.c +++ b/contrib/tools/bison/lib/printf-frexp.c @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/printf-frexp.h b/contrib/tools/bison/lib/printf-frexp.h index 814229f9c0..93107343ad 100644 --- a/contrib/tools/bison/lib/printf-frexp.h +++ b/contrib/tools/bison/lib/printf-frexp.h @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/printf-frexpl.c b/contrib/tools/bison/lib/printf-frexpl.c index cc8db67e33..693b88976d 100644 --- a/contrib/tools/bison/lib/printf-frexpl.c +++ b/contrib/tools/bison/lib/printf-frexpl.c @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/printf-frexpl.h b/contrib/tools/bison/lib/printf-frexpl.h index c48c70cd3a..2760769442 100644 --- a/contrib/tools/bison/lib/printf-frexpl.h +++ b/contrib/tools/bison/lib/printf-frexpl.h @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/printf-parse.c b/contrib/tools/bison/lib/printf-parse.c index e6251458fd..8596fd5f30 100644 --- a/contrib/tools/bison/lib/printf-parse.c +++ b/contrib/tools/bison/lib/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2019 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 diff --git a/contrib/tools/bison/lib/printf-parse.h b/contrib/tools/bison/lib/printf-parse.h index 16d817ec02..746bb3fe0f 100644 --- a/contrib/tools/bison/lib/printf-parse.h +++ b/contrib/tools/bison/lib/printf-parse.h @@ -1,5 +1,5 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2018 Free Software + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/progname.c b/contrib/tools/bison/lib/progname.c index 382f5031d5..a42b7fa2f7 100644 --- a/contrib/tools/bison/lib/progname.c +++ b/contrib/tools/bison/lib/progname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/progname.h b/contrib/tools/bison/lib/progname.h index adc6b01d23..c726e97e90 100644 --- a/contrib/tools/bison/lib/progname.h +++ b/contrib/tools/bison/lib/progname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2004, 2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/quote.h b/contrib/tools/bison/lib/quote.h index eedc283e08..5cef8ff1e0 100644 --- a/contrib/tools/bison/lib/quote.h +++ b/contrib/tools/bison/lib/quote.h @@ -1,6 +1,6 @@ /* quote.h - prototypes for quote.c - Copyright (C) 1998-2001, 2003, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 1998-2001, 2003, 2009-2019 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 diff --git a/contrib/tools/bison/lib/quotearg.c b/contrib/tools/bison/lib/quotearg.c index fe68dca313..773d53f115 100644 --- a/contrib/tools/bison/lib/quotearg.c +++ b/contrib/tools/bison/lib/quotearg.c @@ -1,6 +1,6 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998-2002, 2004-2018 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004-2019 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 diff --git a/contrib/tools/bison/lib/quotearg.h b/contrib/tools/bison/lib/quotearg.h index 0584c56a2b..0f07e0211e 100644 --- a/contrib/tools/bison/lib/quotearg.h +++ b/contrib/tools/bison/lib/quotearg.h @@ -1,6 +1,6 @@ /* quotearg.h - quote arguments for output - Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation, + Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/raise.c b/contrib/tools/bison/lib/raise.c index 8a93bea7f7..e750b7a4c6 100644 --- a/contrib/tools/bison/lib/raise.c +++ b/contrib/tools/bison/lib/raise.c @@ -1,6 +1,6 @@ /* Provide a non-threads replacement for the POSIX raise function. - Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/relocatable.h b/contrib/tools/bison/lib/relocatable.h new file mode 100644 index 0000000000..896a7e59c0 --- /dev/null +++ b/contrib/tools/bison/lib/relocatable.h @@ -0,0 +1,101 @@ +/* Provide relocatable packages. + Copyright (C) 2003, 2005, 2008-2019 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2003. + + 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 _RELOCATABLE_H +#define _RELOCATABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* This can be enabled through the configure --enable-relocatable option. */ +#if ENABLE_RELOCATABLE + +/* When building a DLL, we must export some functions. Note that because + this is a private .h file, we don't need to use __declspec(dllimport) + in any case. */ +#if HAVE_VISIBILITY && BUILDING_DLL +# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default"))) +#elif defined _MSC_VER && BUILDING_DLL +# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport) +#else +# define RELOCATABLE_DLL_EXPORTED +#endif + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +extern RELOCATABLE_DLL_EXPORTED void + set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + +/* Returns the pathname, relocated according to the current installation + directory. + The returned string is either PATHNAME unmodified or a freshly allocated + string that you can free with free() after casting it to 'char *'. */ +extern const char * relocate (const char *pathname); + +/* Returns the pathname, relocated according to the current installation + directory. + This function sets *ALLOCATEDP to the allocated memory, or to NULL if + no memory allocation occurs. So that, after you're done with the return + value, to reclaim allocated memory, you can do: free (*ALLOCATEDP). */ +extern const char * relocate2 (const char *pathname, char **allocatedp); + +/* Memory management: relocate() potentially allocates memory, because it has + to construct a fresh pathname. If this is a problem because your program + calls relocate() frequently or because you want to fix all potential memory + leaks anyway, you have three options: + 1) Use this idiom: + const char *pathname = ...; + const char *rel_pathname = relocate (pathname); + ... + if (rel_pathname != pathname) + free ((char *) rel_pathname); + 2) Use this idiom: + char *allocated; + const char *rel_pathname = relocate2 (..., &allocated); + ... + free (allocated); + 3) Think about caching the result. */ + +/* Convenience function: + Computes the current installation prefix, based on the original + installation prefix, the original installation directory of a particular + file, and the current pathname of this file. + Returns it, freshly allocated. Returns NULL upon failure. */ +extern char * compute_curr_prefix (const char *orig_installprefix, + const char *orig_installdir, + const char *curr_pathname); + +#else + +/* By default, we use the hardwired pathnames. */ +#define relocate(pathname) (pathname) +#define relocate2(pathname,allocatedp) (*(allocatedp) = NULL, (pathname)) + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _RELOCATABLE_H */ diff --git a/contrib/tools/bison/lib/sig-handler.h b/contrib/tools/bison/lib/sig-handler.h index 9ea339453f..b289473dbd 100644 --- a/contrib/tools/bison/lib/sig-handler.h +++ b/contrib/tools/bison/lib/sig-handler.h @@ -1,6 +1,6 @@ /* Convenience declarations when working with <signal.h>. - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 diff --git a/contrib/tools/bison/lib/sigaction.c b/contrib/tools/bison/lib/sigaction.c index 7e4af5fe55..abedfdcdc4 100644 --- a/contrib/tools/bison/lib/sigaction.c +++ b/contrib/tools/bison/lib/sigaction.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 Free Software Foundation, Inc. Written by Eric Blake <ebb9@byu.net>, 2008. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/sigprocmask.c b/contrib/tools/bison/lib/sigprocmask.c index 7a49bcd115..d6cd3f82e5 100644 --- a/contrib/tools/bison/lib/sigprocmask.c +++ b/contrib/tools/bison/lib/sigprocmask.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2006-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2006. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/spawn-pipe.c b/contrib/tools/bison/lib/spawn-pipe.c index 1324f9008c..5fe50fc640 100644 --- a/contrib/tools/bison/lib/spawn-pipe.c +++ b/contrib/tools/bison/lib/spawn-pipe.c @@ -1,5 +1,5 @@ /* Creation of subprocesses, communicating via pipes. - Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/spawn-pipe.h b/contrib/tools/bison/lib/spawn-pipe.h index 52576d00b8..0d70968666 100644 --- a/contrib/tools/bison/lib/spawn-pipe.h +++ b/contrib/tools/bison/lib/spawn-pipe.h @@ -1,5 +1,5 @@ /* Creation of subprocesses, communicating via pipes. - Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006, 2008-2019 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/stat-time.c b/contrib/tools/bison/lib/stat-time.c deleted file mode 100644 index 81b83ddb4f..0000000000 --- a/contrib/tools/bison/lib/stat-time.c +++ /dev/null @@ -1,3 +0,0 @@ -#include <config.h> -#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE -#include "stat-time.h" diff --git a/contrib/tools/bison/lib/stat-time.h b/contrib/tools/bison/lib/stat-time.h deleted file mode 100644 index 69ebe85df1..0000000000 --- a/contrib/tools/bison/lib/stat-time.h +++ /dev/null @@ -1,252 +0,0 @@ -/* stat-related time functions. - - Copyright (C) 2005, 2007, 2009-2018 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. */ - -#ifndef STAT_TIME_H -#define STAT_TIME_H 1 - -#include "intprops.h" - -#include <errno.h> -#include <stddef.h> -#include <sys/stat.h> -#include <time.h> - -#ifndef _GL_INLINE_HEADER_BEGIN - #error "Please include config.h first." -#endif -_GL_INLINE_HEADER_BEGIN -#ifndef _GL_STAT_TIME_INLINE -# define _GL_STAT_TIME_INLINE _GL_INLINE -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type - struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, - ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, - if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim - for access, status change, data modification, or birth (creation) - time respectively. - - These macros are private to stat-time.h. */ -#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC -# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC -# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) -# else -# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) -# endif -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC -# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) -#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC -# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) -#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC -# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec) -#endif - -/* Return the nanosecond component of *ST's access time. */ -_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE -get_stat_atime_ns (struct stat const *st) -{ -# if defined STAT_TIMESPEC - return STAT_TIMESPEC (st, st_atim).tv_nsec; -# elif defined STAT_TIMESPEC_NS - return STAT_TIMESPEC_NS (st, st_atim); -# else - return 0; -# endif -} - -/* Return the nanosecond component of *ST's status change time. */ -_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE -get_stat_ctime_ns (struct stat const *st) -{ -# if defined STAT_TIMESPEC - return STAT_TIMESPEC (st, st_ctim).tv_nsec; -# elif defined STAT_TIMESPEC_NS - return STAT_TIMESPEC_NS (st, st_ctim); -# else - return 0; -# endif -} - -/* Return the nanosecond component of *ST's data modification time. */ -_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE -get_stat_mtime_ns (struct stat const *st) -{ -# if defined STAT_TIMESPEC - return STAT_TIMESPEC (st, st_mtim).tv_nsec; -# elif defined STAT_TIMESPEC_NS - return STAT_TIMESPEC_NS (st, st_mtim); -# else - return 0; -# endif -} - -/* Return the nanosecond component of *ST's birth time. */ -_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE -get_stat_birthtime_ns (struct stat const *st _GL_UNUSED) -{ -# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC - return STAT_TIMESPEC (st, st_birthtim).tv_nsec; -# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC - return STAT_TIMESPEC_NS (st, st_birthtim); -# else - return 0; -# endif -} - -/* Return *ST's access time. */ -_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE -get_stat_atime (struct stat const *st) -{ -#ifdef STAT_TIMESPEC - return STAT_TIMESPEC (st, st_atim); -#else - struct timespec t; - t.tv_sec = st->st_atime; - t.tv_nsec = get_stat_atime_ns (st); - return t; -#endif -} - -/* Return *ST's status change time. */ -_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE -get_stat_ctime (struct stat const *st) -{ -#ifdef STAT_TIMESPEC - return STAT_TIMESPEC (st, st_ctim); -#else - struct timespec t; - t.tv_sec = st->st_ctime; - t.tv_nsec = get_stat_ctime_ns (st); - return t; -#endif -} - -/* Return *ST's data modification time. */ -_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE -get_stat_mtime (struct stat const *st) -{ -#ifdef STAT_TIMESPEC - return STAT_TIMESPEC (st, st_mtim); -#else - struct timespec t; - t.tv_sec = st->st_mtime; - t.tv_nsec = get_stat_mtime_ns (st); - return t; -#endif -} - -/* Return *ST's birth time, if available; otherwise return a value - with tv_sec and tv_nsec both equal to -1. */ -_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE -get_stat_birthtime (struct stat const *st _GL_UNUSED) -{ - struct timespec t; - -#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) - t = STAT_TIMESPEC (st, st_birthtim); -#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC - t.tv_sec = st->st_birthtime; - t.tv_nsec = st->st_birthtimensec; -#elif defined _WIN32 && ! defined __CYGWIN__ - /* Native Windows platforms (but not Cygwin) put the "file creation - time" in st_ctime (!). See - <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>. */ -# if _GL_WINDOWS_STAT_TIMESPEC - t = st->st_ctim; -# else - t.tv_sec = st->st_ctime; - t.tv_nsec = 0; -# endif -#else - /* Birth time is not supported. */ - t.tv_sec = -1; - t.tv_nsec = -1; -#endif - -#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC) - /* FreeBSD and NetBSD sometimes signal the absence of knowledge by - using zero. Attempt to work around this problem. Alas, this can - report failure even for valid timestamps. Also, NetBSD - sometimes returns junk in the birth time fields; work around this - bug if it is detected. */ - if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) - { - t.tv_sec = -1; - t.tv_nsec = -1; - } -#endif - - return t; -} - -/* If a stat-like function returned RESULT, normalize the timestamps - in *ST, in case this platform suffers from the Solaris 11 bug where - tv_nsec might be negative. Return the adjusted RESULT, setting - errno to EOVERFLOW if normalization overflowed. This function - is intended to be private to this .h file. */ -_GL_STAT_TIME_INLINE int -stat_time_normalize (int result, struct stat *st _GL_UNUSED) -{ -#if defined __sun && defined STAT_TIMESPEC - if (result == 0) - { - long int timespec_hz = 1000000000; - short int const ts_off[] = { offsetof (struct stat, st_atim), - offsetof (struct stat, st_mtim), - offsetof (struct stat, st_ctim) }; - int i; - for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) - { - struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); - long int q = ts->tv_nsec / timespec_hz; - long int r = ts->tv_nsec % timespec_hz; - if (r < 0) - { - r += timespec_hz; - q--; - } - ts->tv_nsec = r; - /* Overflow is possible, as Solaris 11 stat can yield - tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. - INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */ - if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec)) - { - errno = EOVERFLOW; - return -1; - } - } - } -#endif - return result; -} - -#ifdef __cplusplus -} -#endif - -_GL_INLINE_HEADER_END - -#endif diff --git a/contrib/tools/bison/lib/stdio-impl.h b/contrib/tools/bison/lib/stdio-impl.h index 393ef0cf58..4260468b61 100644 --- a/contrib/tools/bison/lib/stdio-impl.h +++ b/contrib/tools/bison/lib/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010-2019 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 @@ -61,6 +61,11 @@ # define _r pub._r # define _w pub._w # elif defined __ANDROID__ /* Android */ +# ifdef __LP64__ +# define _gl_flags_file_t int +# else +# define _gl_flags_file_t short +# endif /* Up to this commit from 2015-10-12 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a> the innards of FILE were public, and fp_ub could be defined like for OpenBSD, @@ -70,8 +75,8 @@ # define fp_ ((struct { unsigned char *_p; \ int _r; \ int _w; \ - int _flags; \ - int _file; \ + _gl_flags_file_t _flags; \ + _gl_flags_file_t _file; \ struct { unsigned char *_base; size_t _size; } _bf; \ int _lbfsize; \ void *_cookie; \ diff --git a/contrib/tools/bison/lib/stdio-safer.h b/contrib/tools/bison/lib/stdio-safer.h index 17d4dd282a..790846c2e7 100644 --- a/contrib/tools/bison/lib/stdio-safer.h +++ b/contrib/tools/bison/lib/stdio-safer.h @@ -1,6 +1,6 @@ /* Invoke stdio functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/stpcpy.c b/contrib/tools/bison/lib/stpcpy.c index 61239e9f1d..a1d32fdaf8 100644 --- a/contrib/tools/bison/lib/stpcpy.c +++ b/contrib/tools/bison/lib/stpcpy.c @@ -1,5 +1,5 @@ /* stpcpy.c -- copy a string and return pointer to end of new string - Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2018 Free Software + Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2019 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. diff --git a/contrib/tools/bison/lib/streq.h b/contrib/tools/bison/lib/streq.h index bde1b9562f..326537b6d0 100644 --- a/contrib/tools/bison/lib/streq.h +++ b/contrib/tools/bison/lib/streq.h @@ -1,5 +1,5 @@ /* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/stripslash.c b/contrib/tools/bison/lib/stripslash.c index 60c6781ca1..dfc15b43cc 100644 --- a/contrib/tools/bison/lib/stripslash.c +++ b/contrib/tools/bison/lib/stripslash.c @@ -1,6 +1,6 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003-2006, 2009-2018 Free Software Foundation, + Copyright (C) 1990, 2001, 2003-2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/strndup.c b/contrib/tools/bison/lib/strndup.c index b5c18dda66..5b74828469 100644 --- a/contrib/tools/bison/lib/strndup.c +++ b/contrib/tools/bison/lib/strndup.c @@ -1,6 +1,6 @@ /* A replacement function, for systems that lack strndup. - Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2018 Free Software + Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it diff --git a/contrib/tools/bison/lib/strverscmp.c b/contrib/tools/bison/lib/strverscmp.c index 4eac791584..bf5ce5086f 100644 --- a/contrib/tools/bison/lib/strverscmp.c +++ b/contrib/tools/bison/lib/strverscmp.c @@ -1,5 +1,5 @@ /* Compare strings while treating digits characters numerically. - Copyright (C) 1997-2018 Free Software Foundation, Inc. + Copyright (C) 1997-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997. diff --git a/contrib/tools/bison/lib/timespec.h b/contrib/tools/bison/lib/timespec.h index cc49668f42..26f1bc1a4c 100644 --- a/contrib/tools/bison/lib/timespec.h +++ b/contrib/tools/bison/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2018 Free Software + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/timevar.c b/contrib/tools/bison/lib/timevar.c index 46b8a689b4..0f6fb402e4 100644 --- a/contrib/tools/bison/lib/timevar.c +++ b/contrib/tools/bison/lib/timevar.c @@ -1,6 +1,6 @@ /* Timing variables for measuring compiler performance. - Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018 Free Software + Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Alex Samuel <samuel@codesourcery.com> diff --git a/contrib/tools/bison/lib/timevar.def b/contrib/tools/bison/lib/timevar.def index 00d0cd3391..9de9b815a7 100644 --- a/contrib/tools/bison/lib/timevar.def +++ b/contrib/tools/bison/lib/timevar.def @@ -1,8 +1,8 @@ /* This file contains the definitions for timing variables used to -*- C -*- measure run-time performance of the compiler. - Copyright (C) 2002, 2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002, 2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. Contributed by Akim Demaille <akim@freefriends.org>. diff --git a/contrib/tools/bison/lib/timevar.h b/contrib/tools/bison/lib/timevar.h index cf9e0830d1..5d5a279cc5 100644 --- a/contrib/tools/bison/lib/timevar.h +++ b/contrib/tools/bison/lib/timevar.h @@ -1,6 +1,6 @@ /* Timing variables for measuring application performance. - Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software + Copyright (C) 2000, 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation, Inc. Contributed by Alex Samuel <samuel@codesourcery.com> diff --git a/contrib/tools/bison/lib/unistd-safer.h b/contrib/tools/bison/lib/unistd-safer.h index 5baf339a08..8eebffcae2 100644 --- a/contrib/tools/bison/lib/unistd-safer.h +++ b/contrib/tools/bison/lib/unistd-safer.h @@ -1,6 +1,6 @@ /* Invoke unistd-like functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2005, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2009-2019 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 diff --git a/contrib/tools/bison/lib/unitypes.h b/contrib/tools/bison/lib/unitypes.h index e45ff8052a..8ce466142b 100644 --- a/contrib/tools/bison/lib/unitypes.h +++ b/contrib/tools/bison/lib/unitypes.h @@ -1,6 +1,6 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Elementary types and macros for the GNU UniString library. - Copyright (C) 2002, 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/uniwidth.h b/contrib/tools/bison/lib/uniwidth.h index 65445fa519..cb79a70481 100644 --- a/contrib/tools/bison/lib/uniwidth.h +++ b/contrib/tools/bison/lib/uniwidth.h @@ -1,6 +1,6 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Display width functions. - Copyright (C) 2001-2002, 2005, 2007, 2009-2018 Free Software Foundation, + Copyright (C) 2001-2002, 2005, 2007, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it diff --git a/contrib/tools/bison/lib/uniwidth/cjk.h b/contrib/tools/bison/lib/uniwidth/cjk.h index f7f822ca68..9870422ca6 100644 --- a/contrib/tools/bison/lib/uniwidth/cjk.h +++ b/contrib/tools/bison/lib/uniwidth/cjk.h @@ -1,5 +1,5 @@ /* Test for CJK encoding. - Copyright (C) 2001-2002, 2005-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2007, 2009-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it diff --git a/contrib/tools/bison/lib/uniwidth/width.c b/contrib/tools/bison/lib/uniwidth/width.c index cd27d61b8d..a7f59b18eb 100644 --- a/contrib/tools/bison/lib/uniwidth/width.c +++ b/contrib/tools/bison/lib/uniwidth/width.c @@ -1,5 +1,5 @@ /* Determine display width of Unicode character. - Copyright (C) 2001-2002, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it diff --git a/contrib/tools/bison/lib/unlocked-io.h b/contrib/tools/bison/lib/unlocked-io.h index e3f0fcfed4..ee1c06268f 100644 --- a/contrib/tools/bison/lib/unlocked-io.h +++ b/contrib/tools/bison/lib/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001-2004, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2009-2019 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 diff --git a/contrib/tools/bison/lib/vasnprintf.c b/contrib/tools/bison/lib/vasnprintf.c index 57571750a0..f1f47f0d21 100644 --- a/contrib/tools/bison/lib/vasnprintf.c +++ b/contrib/tools/bison/lib/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2019 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 @@ -4874,6 +4874,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ && !defined __UCLIBC__) \ || (defined __APPLE__ && defined __MACH__) \ + || defined __ANDROID__ \ || (defined _WIN32 && ! defined __CYGWIN__)) fbp[1] = '%'; fbp[2] = 'n'; @@ -4895,6 +4896,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, On Mac OS X 10.13 or newer, the use of %n in format strings in writable memory by default crashes the program, so we should avoid it in this situation. */ + /* On Android, we know that snprintf's return value conforms to + ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and + gl_SNPRINTF_TRUNCATION_C99 pass. + Therefore we can avoid using %n in this situation. + Starting on 2018-03-07, the use of %n in format strings + produces a fatal error (see + <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>), + so we should avoid it. */ /* On native Windows systems (such as mingw), we can avoid using %n because: - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, diff --git a/contrib/tools/bison/lib/vasnprintf.h b/contrib/tools/bison/lib/vasnprintf.h index 3eaaa7e537..5b192b21e9 100644 --- a/contrib/tools/bison/lib/vasnprintf.h +++ b/contrib/tools/bison/lib/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2018 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2019 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 diff --git a/contrib/tools/bison/lib/verify.h b/contrib/tools/bison/lib/verify.h index 3b57ddee0a..6930645a35 100644 --- a/contrib/tools/bison/lib/verify.h +++ b/contrib/tools/bison/lib/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 @@ -26,7 +26,7 @@ here generates easier-to-read diagnostics when verify (R) fails. Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. - This will likely be supported by future GCC versions, in C++ mode. + This is supported by GCC 6.1.0 and later, in C++ mode. Use this only with GCC. If we were willing to slow 'configure' down we could also use it with other compilers, but since this @@ -36,9 +36,7 @@ && !defined __cplusplus) # define _GL_HAVE__STATIC_ASSERT 1 #endif -/* The condition (99 < __GNUC__) is temporary, until we know about the - first G++ release that supports static_assert. */ -#if (99 < __GNUC__) && defined __cplusplus +#if (6 <= __GNUC__) && defined __cplusplus # define _GL_HAVE_STATIC_ASSERT 1 #endif diff --git a/contrib/tools/bison/lib/w32spawn.h b/contrib/tools/bison/lib/w32spawn.h index 3f675ebc44..941ff1ab2d 100644 --- a/contrib/tools/bison/lib/w32spawn.h +++ b/contrib/tools/bison/lib/w32spawn.h @@ -1,5 +1,5 @@ /* Auxiliary functions for the creation of subprocesses. Native Windows API. - Copyright (C) 2001, 2003-2018 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2019 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/wait-process.c b/contrib/tools/bison/lib/wait-process.c index 9e59c08dd8..84c0e86b1f 100644 --- a/contrib/tools/bison/lib/wait-process.c +++ b/contrib/tools/bison/lib/wait-process.c @@ -1,5 +1,5 @@ /* Waiting for a subprocess to finish. - Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/wait-process.h b/contrib/tools/bison/lib/wait-process.h index 0e73e710de..08470fb850 100644 --- a/contrib/tools/bison/lib/wait-process.h +++ b/contrib/tools/bison/lib/wait-process.h @@ -1,5 +1,5 @@ /* Waiting for a subprocess to finish. - Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006, 2008-2019 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/waitpid.c b/contrib/tools/bison/lib/waitpid.c index b2e346a475..a9dace628c 100644 --- a/contrib/tools/bison/lib/waitpid.c +++ b/contrib/tools/bison/lib/waitpid.c @@ -1,5 +1,5 @@ /* Wait for process state change. - Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2019 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 diff --git a/contrib/tools/bison/lib/wcwidth.c b/contrib/tools/bison/lib/wcwidth.c index d33b6a9a55..1f081ccaa1 100644 --- a/contrib/tools/bison/lib/wcwidth.c +++ b/contrib/tools/bison/lib/wcwidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a character. - Copyright (C) 2006-2007, 2010-2018 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2010-2019 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 diff --git a/contrib/tools/bison/lib/xalloc-die.c b/contrib/tools/bison/lib/xalloc-die.c index bfe610990e..295f8d8e75 100644 --- a/contrib/tools/bison/lib/xalloc-die.c +++ b/contrib/tools/bison/lib/xalloc-die.c @@ -1,6 +1,6 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2018 Free Software + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/contrib/tools/bison/lib/xalloc-oversized.h b/contrib/tools/bison/lib/xalloc-oversized.h index 3426e10f4d..e3068c83c4 100644 --- a/contrib/tools/bison/lib/xalloc-oversized.h +++ b/contrib/tools/bison/lib/xalloc-oversized.h @@ -1,6 +1,6 @@ /* xalloc-oversized.h -- memory allocation size checking - Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2019 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 diff --git a/contrib/tools/bison/lib/xalloc.h b/contrib/tools/bison/lib/xalloc.h index c419a2de6c..fc7e86bd89 100644 --- a/contrib/tools/bison/lib/xalloc.h +++ b/contrib/tools/bison/lib/xalloc.h @@ -1,6 +1,6 @@ /* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2019 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 diff --git a/contrib/tools/bison/lib/xconcat-filename.c b/contrib/tools/bison/lib/xconcat-filename.c index d44ca7d5ea..ad2d5f66b4 100644 --- a/contrib/tools/bison/lib/xconcat-filename.c +++ b/contrib/tools/bison/lib/xconcat-filename.c @@ -1,5 +1,5 @@ /* Construct a full filename from a directory and a relative filename. - Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2019 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 diff --git a/contrib/tools/bison/lib/xmalloc.c b/contrib/tools/bison/lib/xmalloc.c index 9a30d67b9f..cbe9a4f567 100644 --- a/contrib/tools/bison/lib/xmalloc.c +++ b/contrib/tools/bison/lib/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2000, 2002-2006, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2019 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 diff --git a/contrib/tools/bison/lib/xmemdup0.c b/contrib/tools/bison/lib/xmemdup0.c index 1b53d11757..4f491be1b8 100644 --- a/contrib/tools/bison/lib/xmemdup0.c +++ b/contrib/tools/bison/lib/xmemdup0.c @@ -1,6 +1,6 @@ /* xmemdup0.c -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 diff --git a/contrib/tools/bison/lib/xmemdup0.h b/contrib/tools/bison/lib/xmemdup0.h index d1820288d6..768f0b274b 100644 --- a/contrib/tools/bison/lib/xmemdup0.h +++ b/contrib/tools/bison/lib/xmemdup0.h @@ -1,6 +1,6 @@ /* xmemdup0.h -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2019 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 @@ -25,13 +25,6 @@ extern "C" { # 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 - function to call when one wants the program to die because of a - memory allocation failure. */ -extern _Noreturn void xalloc_die (void); - char *xmemdup0 (void const *p, size_t s); # ifdef __cplusplus diff --git a/contrib/tools/bison/lib/xreadlink.c b/contrib/tools/bison/lib/xreadlink.c new file mode 100644 index 0000000000..59cfde91b9 --- /dev/null +++ b/contrib/tools/bison/lib/xreadlink.c @@ -0,0 +1,44 @@ +/* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage + + Copyright (C) 2001, 2003-2007, 2009-2019 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 Jim Meyering <jim@meyering.net> + and Bruno Haible <bruno@clisp.org>. */ + +#include <config.h> + +/* Specification. */ +#include "xreadlink.h" + +#include <errno.h> + +#include "areadlink.h" +#include "xalloc.h" + +/* Call readlink to get the symbolic link value of FILENAME. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlink fails, return NULL and set errno. + If realloc fails, or if the link value is longer than SIZE_MAX :-), + give a diagnostic and exit. */ + +char * +xreadlink (char const *filename) +{ + char *result = areadlink (filename); + if (result == NULL && errno == ENOMEM) + xalloc_die (); + return result; +} diff --git a/contrib/tools/bison/lib/xreadlink.h b/contrib/tools/bison/lib/xreadlink.h new file mode 100644 index 0000000000..583205be54 --- /dev/null +++ b/contrib/tools/bison/lib/xreadlink.h @@ -0,0 +1,25 @@ +/* Reading symbolic links without size limitation. + + Copyright (C) 2001, 2003-2004, 2007, 2009-2019 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 Jim Meyering <jim@meyering.net> */ + +extern char *xreadlink (char const *filename); + +#if GNULIB_XREADLINKAT +extern char *xreadlinkat (int fd, char const *filename); +#endif diff --git a/contrib/tools/bison/lib/xsize.h b/contrib/tools/bison/lib/xsize.h index 8aeb3b7a68..ecfd478dcd 100644 --- a/contrib/tools/bison/lib/xsize.h +++ b/contrib/tools/bison/lib/xsize.h @@ -1,6 +1,6 @@ /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2003, 2008-2019 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 diff --git a/contrib/tools/bison/lib/xstrndup.c b/contrib/tools/bison/lib/xstrndup.c index 3b1700a627..a973829113 100644 --- a/contrib/tools/bison/lib/xstrndup.c +++ b/contrib/tools/bison/lib/xstrndup.c @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2019 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 diff --git a/contrib/tools/bison/lib/xstrndup.h b/contrib/tools/bison/lib/xstrndup.h index 54b0967f15..360ccfdbb1 100644 --- a/contrib/tools/bison/lib/xstrndup.h +++ b/contrib/tools/bison/lib/xstrndup.h @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2003, 2009-2019 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 diff --git a/contrib/tools/bison/lib/xtime.h b/contrib/tools/bison/lib/xtime.h index aabcee9e68..9edd12392d 100644 --- a/contrib/tools/bison/lib/xtime.h +++ b/contrib/tools/bison/lib/xtime.h @@ -1,6 +1,6 @@ /* xtime -- extended-resolution integer timestamps - Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2019 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 diff --git a/contrib/tools/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make index adda78c9fd..4d6afb692a 100644 --- a/contrib/tools/bison/lib/ya.make +++ b/contrib/tools/bison/lib/ya.make @@ -15,8 +15,13 @@ NO_COMPILER_WARNINGS() NO_RUNTIME() +CFLAGS( + -DEXEEXT=\"\" +) + SRCS( - abitset.c + allocator.c + areadlink.c argmatch.c asnprintf.c basename-lgpl.c @@ -24,12 +29,16 @@ SRCS( binary-io.c bitrotate.c bitset.c - bitset_stats.c - bitsetv-print.c + bitset/array.c + bitset/list.c + bitset/stats.c + bitset/table.c + bitset/vector.c bitsetv.c c-ctype.c c-strcasecmp.c c-strncasecmp.c + careadlinkat.c cloexec.c close-stream.c closeout.c @@ -38,10 +47,8 @@ SRCS( dirname.c dup-safer-flag.c dup-safer.c - ebitset.c exitfail.c fatal-signal.c - fd-hook.c fd-safer-flag.c fd-safer.c fopen-safer.c @@ -49,14 +56,12 @@ SRCS( get-errno.c gethrxtime.c getprogname.c - glthread/lock.c - glthread/threadlib.c + gl_array_list.c + gl_list.c + gl_xlist.c hard-locale.c hash.c - lbitset.c localcharset.c - localtime-buffer.c - malloca.c math.c mbrtowc.c mbswidth.c @@ -72,20 +77,19 @@ SRCS( quotearg.c sig-handler.c spawn-pipe.c - stat-time.c stripslash.c timespec.c timevar.c unistd.c uniwidth/width.c vasnprintf.c - vbitset.c wait-process.c wctype-h.c xalloc-die.c xconcat-filename.c xmalloc.c xmemdup0.c + xreadlink.c xsize.c xstrndup.c xtime.c @@ -108,6 +112,7 @@ ELSEIF (OS_WINDOWS) dup2.c error.c fcntl.c + fd-hook.c fpending.c getdtablesize.c getopt.c diff --git a/contrib/tools/bison/src/AnnotationList.c b/contrib/tools/bison/src/AnnotationList.c index 34b9231068..4e29127c57 100644 --- a/contrib/tools/bison/src/AnnotationList.c +++ b/contrib/tools/bison/src/AnnotationList.c @@ -1,6 +1,6 @@ /* IELR's inadequacy annotation list. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/AnnotationList.h b/contrib/tools/bison/src/AnnotationList.h index f770f6f0aa..ef3eeb6b0f 100644 --- a/contrib/tools/bison/src/AnnotationList.h +++ b/contrib/tools/bison/src/AnnotationList.h @@ -1,6 +1,6 @@ /* IELR's inadequacy annotation list. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/InadequacyList.c b/contrib/tools/bison/src/InadequacyList.c index 4d36533f93..6caa14ea2f 100644 --- a/contrib/tools/bison/src/InadequacyList.c +++ b/contrib/tools/bison/src/InadequacyList.c @@ -1,6 +1,6 @@ /* IELR's inadequacy list. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/InadequacyList.h b/contrib/tools/bison/src/InadequacyList.h index a05b99da84..bb52f7ae84 100644 --- a/contrib/tools/bison/src/InadequacyList.h +++ b/contrib/tools/bison/src/InadequacyList.h @@ -1,6 +1,6 @@ /* IELR's inadequacy list. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/LR0.c b/contrib/tools/bison/src/LR0.c index 023f395552..d977d36455 100644 --- a/contrib/tools/bison/src/LR0.c +++ b/contrib/tools/bison/src/LR0.c @@ -1,6 +1,6 @@ /* Generate the LR(0) parser states for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2015, 2018 Free + Copyright (C) 1984, 1986, 1989, 2000-2002, 2004-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/LR0.h b/contrib/tools/bison/src/LR0.h index f7f6b63af9..3197ee9055 100644 --- a/contrib/tools/bison/src/LR0.h +++ b/contrib/tools/bison/src/LR0.h @@ -1,6 +1,6 @@ /* Generate the LR(0) parser states for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2002, 2009-2015, 2018 Free + Copyright (C) 1984, 1986, 1989, 2000-2002, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/Sbitset.c b/contrib/tools/bison/src/Sbitset.c index b6ba379de6..aaa6819be0 100644 --- a/contrib/tools/bison/src/Sbitset.c +++ b/contrib/tools/bison/src/Sbitset.c @@ -1,6 +1,6 @@ /* A simple, memory-efficient bitset implementation. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/Sbitset.h b/contrib/tools/bison/src/Sbitset.h index 82acdc5204..fc6347aa24 100644 --- a/contrib/tools/bison/src/Sbitset.h +++ b/contrib/tools/bison/src/Sbitset.h @@ -1,6 +1,6 @@ /* A simple, memory-efficient bitset implementation. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/assoc.c b/contrib/tools/bison/src/assoc.c index 38d24e3498..fc1f937fb7 100644 --- a/contrib/tools/bison/src/assoc.c +++ b/contrib/tools/bison/src/assoc.c @@ -1,6 +1,6 @@ /* Associativity information. - Copyright (C) 2002, 2005-2006, 2008-2015, 2018 Free Software + Copyright (C) 2002, 2005-2006, 2008-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/assoc.h b/contrib/tools/bison/src/assoc.h index 661e1e541c..680e2fbcc6 100644 --- a/contrib/tools/bison/src/assoc.h +++ b/contrib/tools/bison/src/assoc.h @@ -1,7 +1,7 @@ /* Associativity information. - Copyright (C) 2002, 2006, 2008-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002, 2006, 2008-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/closure.c b/contrib/tools/bison/src/closure.c index 6729d702ec..16be645229 100644 --- a/contrib/tools/bison/src/closure.c +++ b/contrib/tools/bison/src/closure.c @@ -1,7 +1,7 @@ /* Closures for Bison - Copyright (C) 1984, 1989, 2000-2002, 2004-2005, 2007, 2009-2015, 2018 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2004-2005, 2007, 2009-2015, + 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -22,7 +22,6 @@ #include "system.h" #include <bitset.h> -#include <bitsetv-print.h> #include <bitsetv.h> #include "closure.h" diff --git a/contrib/tools/bison/src/closure.h b/contrib/tools/bison/src/closure.h index 1d728984fd..c75b8497e5 100644 --- a/contrib/tools/bison/src/closure.h +++ b/contrib/tools/bison/src/closure.h @@ -1,6 +1,6 @@ /* Subroutines for bison - Copyright (C) 1984, 1989, 2000-2002, 2007, 2009-2015, 2018 Free + Copyright (C) 1984, 1989, 2000-2002, 2007, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/complain.c b/contrib/tools/bison/src/complain.c index 6c1acf392e..50f65af54c 100644 --- a/contrib/tools/bison/src/complain.c +++ b/contrib/tools/bison/src/complain.c @@ -1,7 +1,7 @@ /* Declaration for error-reporting function for Bison. - Copyright (C) 2000-2002, 2004-2006, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 2000-2002, 2004-2006, 2009-2015, 2018-2019 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 @@ -28,6 +28,7 @@ #include "complain.h" #include "files.h" +#include "fixits.h" #include "getargs.h" #include "quote.h" @@ -278,15 +279,18 @@ error_message (const location *loc, warnings flags, const char *prefix, *indent_ptr = pos; else if (*indent_ptr > pos) fprintf (stderr, "%*s", *indent_ptr - pos, ""); - indent_ptr = 0; + indent_ptr = NULL; } if (prefix) fprintf (stderr, "%s: ", prefix); vfprintf (stderr, message, args); - if (! (flags & silent)) + /* Print the type of warning, only if this is not a sub message + (in which case the prefix is null). */ + if (! (flags & silent) && prefix) warnings_print_categories (flags, stderr); + { size_t l = strlen (message); if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ') @@ -374,6 +378,14 @@ complain_args (location const *loc, warnings w, unsigned *indent, } } + +void +bison_directive (location const *loc, char const *directive) +{ + complain (loc, Wyacc, + _("POSIX Yacc does not support %s"), directive); +} + void deprecated_directive (location const *loc, char const *old, char const *upd) { @@ -385,6 +397,9 @@ 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)); + /* Register updates only if -Wdeprecated is enabled. */ + if (warnings_flag[warning_deprecated] != severity_disabled) + fixits_register (loc, upd); } void @@ -392,7 +407,24 @@ duplicate_directive (char const *directive, location first, location second) { unsigned i = 0; - complain (&second, complaint, _("only one %s allowed per rule"), directive); + if (feature_flag & feature_caret) + complain_indent (&second, Wother, &i, _("duplicate directive")); + else + complain_indent (&second, Wother, &i, _("duplicate directive: %s"), quote (directive)); + i += SUB_INDENT; + complain_indent (&first, Wother, &i, _("previous declaration")); + fixits_register (&second, ""); +} + +void +duplicate_rule_directive (char const *directive, + location first, location second) +{ + unsigned 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_indent (&first, complaint, &i, + _("previous declaration")); + fixits_register (&second, ""); } diff --git a/contrib/tools/bison/src/complain.h b/contrib/tools/bison/src/complain.h index 599afb97c7..266992f6f4 100644 --- a/contrib/tools/bison/src/complain.h +++ b/contrib/tools/bison/src/complain.h @@ -1,6 +1,6 @@ /* Declaration for error-reporting function for Bison. - Copyright (C) 2000-2002, 2006, 2009-2015, 2018 Free Software + Copyright (C) 2000-2002, 2006, 2009-2015, 2018-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -78,8 +78,7 @@ void complain_init (void); typedef enum { - /**< Issue no warnings. */ - Wnone = 0, + Wnone = 0, /**< Issue no warnings. */ Wmidrule_values = 1 << warning_midrule_values, Wyacc = 1 << warning_yacc, @@ -120,14 +119,21 @@ void complain_indent (location const *loc, warnings flags, unsigned *indent, __attribute__ ((__format__ (__printf__, 4, 5))); +/** GNU Bison extension not valid with POSIX Yacc. */ +void bison_directive (location const *loc, char const *directive); + /** Report an obsolete syntax, suggest the updated one. */ void deprecated_directive (location const *loc, char const *obsolete, char const *updated); -/** Report a repeated directive for a rule. */ +/** Report a repeated directive. */ void duplicate_directive (char const *directive, location first, location second); +/** Report a repeated directive for a rule. */ +void duplicate_rule_directive (char const *directive, + location first, location second); + /** 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/conflicts.c b/contrib/tools/bison/src/conflicts.c index 6a6f88d90f..f81d831864 100644 --- a/contrib/tools/bison/src/conflicts.c +++ b/contrib/tools/bison/src/conflicts.c @@ -1,6 +1,6 @@ /* Find and resolve or report lookahead conflicts for bison, - Copyright (C) 1984, 1989, 1992, 2000-2015, 2018 Free Software + Copyright (C) 1984, 1989, 1992, 2000-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -467,15 +467,13 @@ count_sr_conflicts (void) -/*----------------------------------------------------------------. -| Count the number of reduce/reduce conflicts. If ONE_PER_TOKEN, | -| count one conflict for each token that has any reduce/reduce | -| conflicts. Otherwise, count one conflict for each pair of | -| conflicting reductions. | -`----------------------------------------------------------------*/ +/*-----------------------------------------------------------------. +| Count the number of reduce/reduce conflicts. Count one conflict | +| for each reduction after the first for a given token. | +`-----------------------------------------------------------------*/ static size_t -count_state_rr_conflicts (state *s, bool one_per_token) +count_state_rr_conflicts (state *s) { reductions *reds = s->reductions; size_t res = 0; @@ -485,25 +483,99 @@ count_state_rr_conflicts (state *s, bool one_per_token) int count = 0; for (int j = 0; j < reds->num; ++j) count += bitset_test (reds->lookahead_tokens[j], i); - if (count >= 2) - res += one_per_token ? 1 : count-1; + if (2 <= count) + res += count-1; } return res; } static size_t -count_rr_conflicts (bool one_per_token) +count_rr_conflicts (void) { size_t res = 0; /* Conflicts by state. */ for (state_number i = 0; i < nstates; ++i) if (conflicts[i]) - res += count_state_rr_conflicts (states[i], one_per_token); + res += count_state_rr_conflicts (states[i]); return res; } +/*------------------------------------------------------------------. +| For a given rule, the number of shift/reduce conflicts in a given | +| state. | +`------------------------------------------------------------------*/ + +static size_t +count_rule_state_sr_conflicts (rule *r, state *s) +{ + size_t res = 0; + transitions *trans = s->transitions; + reductions *reds = s->reductions; + + for (int i = 0; i < reds->num; ++i) + if (reds->rules[i] == r) + { + bitset lookaheads = reds->lookahead_tokens[i]; + int j; + FOR_EACH_SHIFT (trans, j) + res += bitset_test (lookaheads, TRANSITION_SYMBOL (trans, j)); + } + + return res; +} + +/*----------------------------------------------------------------------. +| For a given rule, count the number of states for which it is involved | +| in shift/reduce conflicts. | +`----------------------------------------------------------------------*/ + +static size_t +count_rule_sr_conflicts (rule *r) +{ + size_t res = 0; + for (state_number i = 0; i < nstates; ++i) + if (conflicts[i]) + res += count_rule_state_sr_conflicts (r, states[i]); + return res; +} + +/*-----------------------------------------------------------------. +| For a given rule, count the number of states in which it is | +| involved in reduce/reduce conflicts. | +`-----------------------------------------------------------------*/ + +static size_t +count_rule_state_rr_conflicts (rule *r, state *s) +{ + size_t res = 0; + const reductions *reds = s->reductions; + bitset lookaheads = bitset_create (ntokens, BITSET_FIXED); + + for (int i = 0; i < reds->num; ++i) + if (reds->rules[i] == r) + for (int j = 0; j < reds->num; ++j) + if (reds->rules[j] != r) + { + bitset_and (lookaheads, + reds->lookahead_tokens[i], + reds->lookahead_tokens[j]); + res += bitset_count (lookaheads); + } + bitset_free (lookaheads); + return res; +} + +static size_t +count_rule_rr_conflicts (rule *r) +{ + size_t res = 0; + for (state_number i = 0; i < nstates; ++i) + res += count_rule_state_rr_conflicts (r, states[i]); + return res; +} + /*-----------------------------------------------------------. | Output the detailed description of states with conflicts. | `-----------------------------------------------------------*/ @@ -518,7 +590,7 @@ conflicts_output (FILE *out) if (conflicts[i]) { int src = count_state_sr_conflicts (s); - int rrc = count_state_rr_conflicts (s, true); + int rrc = count_state_rr_conflicts (s); fprintf (out, _("State %d "), i); if (src && rrc) fprintf (out, @@ -535,27 +607,56 @@ conflicts_output (FILE *out) fputs ("\n\n", out); } -/*--------------------------------------------------------. -| Total the number of S/R and R/R conflicts. Unlike the | -| code in conflicts_output, however, count EACH pair of | -| reductions for the same state and lookahead as one | -| conflict. | -`--------------------------------------------------------*/ +/*--------------------------------------------. +| Total the number of S/R and R/R conflicts. | +`--------------------------------------------*/ int conflicts_total_count (void) { - return count_sr_conflicts () + count_rr_conflicts (false); + return count_sr_conflicts () + count_rr_conflicts (); } +/*------------------------------. +| Reporting per-rule conflicts. | +`------------------------------*/ + +static void +rule_conflicts_print (void) +{ + for (rule_number i = 0; i < nrules; i += 1) + { + rule *r = &rules[i]; + int expected_sr = r->expected_sr_conflicts; + int expected_rr = r->expected_rr_conflicts; + + if (expected_sr != -1 || expected_rr != -1) + { + int sr = count_rule_sr_conflicts (r); + if (sr != expected_sr && (sr != 0 || expected_sr != -1)) + complain (&r->location, complaint, + _("shift/reduce conflicts for rule %d:" + " %d found, %d expected"), + r->user_number, sr, expected_sr); + int rr = count_rule_rr_conflicts (r); + if (rr != expected_rr && (rr != 0 || expected_rr != -1)) + complain (&r->location, complaint, + _("reduce/reduce conflicts for rule %d:" + " %d found, %d expected"), + r->user_number, rr, expected_rr); + } + } +} -/*------------------------------------------. -| Reporting the total number of conflicts. | -`------------------------------------------*/ +/*---------------------------------. +| Reporting numbers of conflicts. | +`---------------------------------*/ void conflicts_print (void) { + rule_conflicts_print (); + if (! glr_parser && expected_rr_conflicts != -1) { complain (NULL, Wother, _("%%expect-rr applies only to GLR parsers")); @@ -587,7 +688,7 @@ conflicts_print (void) } { - int total = count_rr_conflicts (true); + int total = count_rr_conflicts (); /* If %expect-rr is not used, but %expect is, then expect 0 rr. */ int expected = (expected_rr_conflicts == -1 && expected_sr_conflicts != -1) @@ -609,7 +710,6 @@ conflicts_print (void) } } - void conflicts_free (void) { diff --git a/contrib/tools/bison/src/conflicts.h b/contrib/tools/bison/src/conflicts.h index 22a177cbe4..c068e36da9 100644 --- a/contrib/tools/bison/src/conflicts.h +++ b/contrib/tools/bison/src/conflicts.h @@ -1,7 +1,7 @@ /* Find and resolve or report lookahead conflicts for bison, - Copyright (C) 2000-2002, 2004, 2007, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 2000-2002, 2004, 2007, 2009-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -44,4 +44,5 @@ void conflicts_free (void); /* Were there conflicts? */ extern int expected_sr_conflicts; extern int expected_rr_conflicts; + #endif /* !CONFLICTS_H_ */ diff --git a/contrib/tools/bison/src/derives.c b/contrib/tools/bison/src/derives.c index 7564b41153..7b7d5c94af 100644 --- a/contrib/tools/bison/src/derives.c +++ b/contrib/tools/bison/src/derives.c @@ -1,6 +1,6 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000-2003, 2005, 2009-2015, 2018 Free + Copyright (C) 1984, 1989, 2000-2003, 2005, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/derives.h b/contrib/tools/bison/src/derives.h index c4a701c034..521a10c60b 100644 --- a/contrib/tools/bison/src/derives.h +++ b/contrib/tools/bison/src/derives.h @@ -1,7 +1,7 @@ /* Match rules with nonterminals for bison, - Copyright (C) 1984, 1989, 2000-2002, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2009-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/files.c b/contrib/tools/bison/src/files.c index 87136908ca..727a41af80 100644 --- a/contrib/tools/bison/src/files.c +++ b/contrib/tools/bison/src/files.c @@ -1,7 +1,7 @@ /* Open and close files for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -43,7 +43,9 @@ char const *spec_outfile = NULL; /* for -o. */ char const *spec_file_prefix = NULL; /* for -b. */ +location spec_file_prefix_loc = EMPTY_LOCATION_INIT; char const *spec_name_prefix = NULL; /* for -p. */ +location spec_name_prefix_loc = EMPTY_LOCATION_INIT; char *spec_verbose_file = NULL; /* for --verbose. */ char *spec_graph_file = NULL; /* for -g. */ char *spec_xml_file = NULL; /* for -x. */ @@ -119,14 +121,12 @@ concat2 (char const *str1, char const *str2) FILE * xfopen (const char *name, const char *mode) { - FILE *ptr; - - ptr = fopen_safer (name, mode); - if (!ptr) + FILE *res = fopen_safer (name, mode); + if (!res) error (EXIT_FAILURE, get_errno (), _("%s: cannot open"), quotearg_colon (name)); - return ptr; + return res; } /*-------------------------------------------------------------. @@ -253,19 +253,18 @@ file_name_split (const char *file_name, } } +/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE or + GRAMMAR_FILE. + + The precise -o name will be used for FTABLE. For other output + files, remove the ".c" or ".tab.c" suffix. */ static void compute_file_name_parts (void) { - const char *base, *tab, *ext; - - /* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE - or GRAMMAR_FILE. - - The precise -o name will be used for FTABLE. For other output - files, remove the ".c" or ".tab.c" suffix. */ if (spec_outfile) { + const char *base, *tab, *ext; file_name_split (spec_outfile, &base, &tab, &ext); dir_prefix = xstrndup (spec_outfile, base - spec_outfile); @@ -285,6 +284,7 @@ compute_file_name_parts (void) } else { + const char *base, *tab, *ext; file_name_split (grammar_file, &base, &tab, &ext); if (spec_file_prefix) @@ -295,7 +295,7 @@ compute_file_name_parts (void) last_component (spec_file_prefix) - spec_file_prefix); all_but_tab_ext = xstrdup (spec_file_prefix); } - else if (yacc_flag) + else if (! location_empty (yacc_loc)) { /* If --yacc, then the output is 'y.tab.c'. */ dir_prefix = xstrdup (""); @@ -316,7 +316,7 @@ compute_file_name_parts (void) all_but_ext = xstrdup (all_but_tab_ext); /* Compute the extensions from the grammar file name. */ - if (ext && !yacc_flag) + if (ext && location_empty (yacc_loc)) compute_exts_from_gf (ext); } } @@ -384,16 +384,13 @@ output_file_name_check (char **file_name, bool source) conflict = true; } else - { - int i; - for (i = 0; i < generated_files_size; i++) - if (STREQ (generated_files[i].name, *file_name)) - { - complain (NULL, Wother, _("conflicting outputs to file %s"), - quote (generated_files[i].name)); - conflict = true; - } - } + for (int i = 0; i < generated_files_size; i++) + if (STREQ (generated_files[i].name, *file_name)) + { + complain (NULL, Wother, _("conflicting outputs to file %s"), + quote (generated_files[i].name)); + conflict = true; + } if (conflict) { free (*file_name); @@ -411,8 +408,7 @@ output_file_name_check (char **file_name, bool source) void unlink_generated_sources (void) { - int i; - for (i = 0; i < generated_files_size; i++) + for (int i = 0; i < generated_files_size; i++) if (generated_files[i].is_source) /* Ignore errors. The file might not even exist. */ unlink (generated_files[i].name); @@ -428,10 +424,7 @@ output_file_names_free (void) free (spec_defines_file); free (parser_file_name); free (dir_prefix); - { - int i; - for (i = 0; i < generated_files_size; i++) - free (generated_files[i].name); - } + for (int i = 0; i < generated_files_size; i++) + free (generated_files[i].name); free (generated_files); } diff --git a/contrib/tools/bison/src/files.h b/contrib/tools/bison/src/files.h index 9970e88b66..d5ee44c274 100644 --- a/contrib/tools/bison/src/files.h +++ b/contrib/tools/bison/src/files.h @@ -1,7 +1,7 @@ /* File names and variables for bison, - Copyright (C) 1984, 1989, 2000-2002, 2006-2007, 2009-2015, 2018 Free - Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2006-2007, 2009-2015, 2018-2019 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -21,6 +21,7 @@ #ifndef FILES_H_ # define FILES_H_ +# include "location.h" # include "uniqstr.h" /* File name specified with -o for the output file, or 0 if no -o. */ @@ -31,9 +32,11 @@ extern char *parser_file_name; /* Symbol prefix specified with -p, or 0 if no -p. */ extern const char *spec_name_prefix; +extern location spec_name_prefix_loc; /* File name prefix specified with -b, or 0 if no -b. */ extern char const *spec_file_prefix; +extern location spec_file_prefix_loc; /* --verbose. */ extern char *spec_verbose_file; @@ -55,7 +58,7 @@ extern char *dir_prefix; and therefore GCC warns about a name clash. */ extern uniqstr grammar_file; -/* The current file name. Might change with %include, or with #line. */ +/* The current file name. Might change with #line. */ extern uniqstr current_file; /* The computed base for output file names. */ diff --git a/contrib/tools/bison/src/fixits.c b/contrib/tools/bison/src/fixits.c new file mode 100644 index 0000000000..5ffd793524 --- /dev/null +++ b/contrib/tools/bison/src/fixits.c @@ -0,0 +1,212 @@ +/* Support for fixing grammar files. + + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of Bison, the GNU Compiler Compiler. + + 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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "fixits.h" + +#include "system.h" + +#include "error.h" +#include "get-errno.h" +#include "getargs.h" +#include "gl_array_list.h" +#include "gl_xlist.h" +#include "progname.h" +#include "quote.h" +#include "quotearg.h" +#include "vasnprintf.h" + +#include "files.h" + +typedef struct +{ + location location; + char *fix; +} fixit; + +gl_list_t fixits = NULL; + +static fixit * +fixit_new (location const *loc, char const* fix) +{ + fixit *res = xmalloc (sizeof *res); + res->location = *loc; + res->fix = xstrdup (fix); + return res; +} + + +static void +fixit_free (fixit *f) +{ + free (f->fix); + free (f); +} + + +/* GCC and Clang follow the same pattern. + https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html + http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-parseable-fixits */ +static void +fixit_print (fixit const *f, FILE *out) +{ + fprintf (out, "fix-it:%s:{%d:%d-%d:%d}:%s\n", + quotearg_n_style (1, c_quoting_style, f->location.start.file), + f->location.start.line, f->location.start.column, + f->location.end.line, f->location.end.column, + quotearg_n_style (2, c_quoting_style, f->fix)); +} + + +void +fixits_register (location const *loc, char const* fix) +{ + if (!fixits) + fixits = gl_list_create_empty (GL_ARRAY_LIST, + /* equals */ NULL, + /* hashcode */ NULL, + (gl_listelement_dispose_fn) fixit_free, + true); + fixit *f = fixit_new (loc, fix); + gl_list_add_last (fixits, f); + if (feature_flag & feature_fixit_parsable) + fixit_print (f, stderr); +} + + +bool +fixits_empty (void) +{ + return !fixits; +} + + +void +fixits_run (void) +{ + if (!fixits) + return; + + /* This is not unlike what is done in location_caret. */ + uniqstr input = ((fixit *) gl_list_get_at (fixits, 0))->location.start.file; + /* Backup the file. */ + char buf[256]; + size_t len = sizeof (buf); + char *backup = asnprintf (buf, &len, "%s~", input); + if (!backup) + xalloc_die (); + if (rename (input, backup)) + error (EXIT_FAILURE, get_errno (), + _("%s: cannot backup"), quotearg_colon (input)); + FILE *in = xfopen (backup, "r"); + FILE *out = xfopen (input, "w"); + size_t line = 1; + size_t offset = 1; + fixit const *f = NULL; + gl_list_iterator_t iter = gl_list_iterator (fixits); + while (gl_list_iterator_next (&iter, (const void**) &f, NULL)) + { + /* Look for the correct line. */ + while (line < f->location.start.line) + { + int c = getc (in); + if (c == EOF) + break; + if (c == '\n') + { + ++line; + offset = 1; + } + putc (c, out); + } + /* Look for the right offset. */ + while (offset < f->location.start.column) + { + int c = getc (in); + if (c == EOF) + break; + ++offset; + putc (c, out); + } + + /* Paste the fix instead. */ + fputs (f->fix, out); + + /* Skip the bad input. */ + while (line < f->location.end.line) + { + int c = getc (in); + if (c == EOF) + break; + if (c == '\n') + { + ++line; + offset = 1; + } + } + while (offset < f->location.end.column) + { + int c = getc (in); + if (c == EOF) + break; + ++offset; + } + /* If erasing the content of a full line, also remove the + end-of-line. */ + if (f->fix[0] == 0 && f->location.start.column == 1) + { + int c = getc (in); + if (c == EOF) + break; + else if (c == '\n') + { + ++line; + offset = 1; + } + else + ungetc (c, in); + } + } + /* Paste the rest of the file. */ + { + int c; + while ((c = getc (in)) != EOF) + putc (c, out); + } + + gl_list_iterator_free (&iter); + xfclose (out); + xfclose (in); + fprintf (stderr, "%s: file %s was updated (backup: %s)\n", + program_name, quote_n (0, input), quote_n (1, backup)); + if (backup != buf) + free (backup); +} + + +/* Free the registered fixits. */ +void fixits_free (void) +{ + if (fixits) + { + gl_list_free (fixits); + fixits = NULL; + } +} diff --git a/contrib/tools/bison/src/fixits.h b/contrib/tools/bison/src/fixits.h new file mode 100644 index 0000000000..45c2780af8 --- /dev/null +++ b/contrib/tools/bison/src/fixits.h @@ -0,0 +1,35 @@ +/* Support for fixing grammar files. + + Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. */ + +#ifndef FIXITS_H_ +# define FIXITS_H_ 1 + +# include "location.h" + +/* Declare a fix to apply. */ +void fixits_register (location const *loc, char const* update); + +/* Apply the fixits: update the source file. */ +void fixits_run (void); + +/* Whether there are no fixits. */ +bool fixits_empty (void); + +/* Free the registered fixits. */ +void fixits_free (void); + +#endif /* !FIXITS_H_ */ diff --git a/contrib/tools/bison/src/flex-scanner.h b/contrib/tools/bison/src/flex-scanner.h index 66b6098e13..9e4408f49d 100644 --- a/contrib/tools/bison/src/flex-scanner.h +++ b/contrib/tools/bison/src/flex-scanner.h @@ -1,6 +1,7 @@ /* Common parts between scan-code.l, scan-gram.l, and scan-skel.l. - Copyright (C) 2006, 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/getargs.c b/contrib/tools/bison/src/getargs.c index 69486abff9..51d66be3f5 100644 --- a/contrib/tools/bison/src/getargs.c +++ b/contrib/tools/bison/src/getargs.c @@ -1,7 +1,7 @@ /* Parse command line arguments for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -36,12 +36,13 @@ #include "quote.h" #include "uniqstr.h" -bool defines_flag; -bool graph_flag; -bool xml_flag; -bool no_lines_flag; -bool token_table_flag; -bool yacc_flag; /* for -y */ +bool defines_flag = false; +bool graph_flag = false; +bool xml_flag = false; +bool no_lines_flag = false; +bool token_table_flag = false; +location yacc_loc = EMPTY_LOCATION_INIT; +bool update_flag = false; /* for -u */ bool nondeterministic_parser = false; bool glr_parser = false; @@ -54,6 +55,7 @@ static struct bison_language const valid_languages[] = { /* lang, skeleton, ext, hdr, add_tab */ { "c", "c-skel.m4", ".c", ".h", true }, { "c++", "c++-skel.m4", ".cc", ".hh", true }, + { "d", "d-skel.m4", ".d", ".d", false }, { "java", "java-skel.m4", ".java", ".java", false }, { "", "", "", "", false } }; @@ -229,6 +231,7 @@ static const char * const feature_args[] = { "none", "caret", "diagnostics-show-caret", + "fixit", "diagnostics-parseable-fixits", "all", 0 }; @@ -237,6 +240,7 @@ static const int feature_types[] = { feature_none, feature_caret, feature_caret, + feature_fixit_parsable, feature_fixit_parsable, feature_all }; @@ -282,7 +286,10 @@ Operation modes:\n\ -h, --help display this help and exit\n\ -V, --version output version information and exit\n\ --print-localedir output directory containing locale-dependent data\n\ + and exit\n\ --print-datadir output directory containing skeletons and XSLT\n\ + and exit\n\ + -u, --update apply fixes to the source grammar file and exit\n\ -y, --yacc emulate POSIX Yacc\n\ -W, --warnings[=CATEGORY] report the warnings falling in CATEGORY\n\ -f, --feature[=FEATURE] activate miscellaneous features\n\ @@ -477,6 +484,7 @@ static char const short_options[] = "p:" "r:" "t" + "u" /* --update */ "v" "x::" "y" @@ -499,6 +507,7 @@ static struct option const long_options[] = { "version", no_argument, 0, 'V' }, { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION }, { "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION }, + { "update", no_argument, 0, 'u' }, { "warnings", optional_argument, 0, 'W' }, /* Parser. */ @@ -685,6 +694,10 @@ getargs (int argc, char *argv[]) MUSCLE_PERCENT_DEFINE_D); break; + case 'u': + update_flag = true; + break; + case 'v': report_flag |= report_states; break; @@ -699,8 +712,8 @@ getargs (int argc, char *argv[]) break; case 'y': - warning_argmatch ("error=yacc", 0, 6); - yacc_flag = true; + warning_argmatch ("yacc", 0, 0); + yacc_loc = command_line_location (); break; case LOCATIONS_OPTION: diff --git a/contrib/tools/bison/src/getargs.h b/contrib/tools/bison/src/getargs.h index 4e127d4a59..b488091393 100644 --- a/contrib/tools/bison/src/getargs.h +++ b/contrib/tools/bison/src/getargs.h @@ -1,7 +1,7 @@ /* Parse command line arguments for bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -39,9 +39,10 @@ extern bool graph_flag; /* for -g */ extern bool xml_flag; /* for -x */ extern bool no_lines_flag; /* for -l */ extern bool token_table_flag; /* for -k */ -extern bool yacc_flag; /* for -y */ +extern location yacc_loc; /* for -y */ +extern bool update_flag; /* for -u */ -extern const char *m4_path; +extern const char* m4_path; /* GLR_PARSER is true if the input file says to use the GLR (Generalized LR) parser, and to output some additional information @@ -115,9 +116,10 @@ extern int trace_flag; enum feature { - feature_none = 0, /**< No additional feature. */ - feature_caret = 1 << 0, /**< Enhance the output of errors with carets. */ - feature_all = ~0 /**< All above features. */ + feature_none = 0, /**< No additional feature. */ + feature_caret = 1 << 0, /**< Output errors with carets. */ + feature_fixit_parsable = 1 << 1, /**< Issue instructions to fix the sources. */ + feature_all = ~0 /**< All above features. */ }; /** What additional features to use. */ extern int feature_flag; diff --git a/contrib/tools/bison/src/gram.c b/contrib/tools/bison/src/gram.c index fd07719e86..7f2c943961 100644 --- a/contrib/tools/bison/src/gram.c +++ b/contrib/tools/bison/src/gram.c @@ -1,6 +1,6 @@ /* Allocate input grammar variables for Bison. - Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2015, 2018 Free + Copyright (C) 1984, 1986, 1989, 2001-2003, 2005-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/gram.h b/contrib/tools/bison/src/gram.h index 4ecf4bf2b5..83dd8aacf7 100644 --- a/contrib/tools/bison/src/gram.h +++ b/contrib/tools/bison/src/gram.h @@ -1,7 +1,7 @@ /* Data definitions for internal representation of Bison's input. - Copyright (C) 1984, 1986, 1989, 1992, 2001-2007, 2009-2015, 2018 Free - Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2001-2007, 2009-2015, 2018-2019 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -196,6 +196,11 @@ typedef struct bool useful; bool is_predicate; + /* Counts of the numbers of expected conflicts for this rule, or -1 if none + given. */ + int expected_sr_conflicts; + int expected_rr_conflicts; + const char *action; location action_location; } rule; diff --git a/contrib/tools/bison/src/graphviz.c b/contrib/tools/bison/src/graphviz.c index a5e3a5e9ab..75e4a6e6a8 100644 --- a/contrib/tools/bison/src/graphviz.c +++ b/contrib/tools/bison/src/graphviz.c @@ -1,7 +1,7 @@ /* Output Graphviz specification of a state machine generated by Bison. - Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/graphviz.h b/contrib/tools/bison/src/graphviz.h index f2aaa91feb..cceb1fbd3d 100644 --- a/contrib/tools/bison/src/graphviz.h +++ b/contrib/tools/bison/src/graphviz.h @@ -1,6 +1,7 @@ /* Output Graphviz specification of a state machine generated by Bison. - Copyright (C) 2006, 2010-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2006, 2010-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/ielr.c b/contrib/tools/bison/src/ielr.c index 5eb7d312dc..867b8a0a2a 100644 --- a/contrib/tools/bison/src/ielr.c +++ b/contrib/tools/bison/src/ielr.c @@ -1,6 +1,6 @@ /* IELR main implementation. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -50,7 +50,7 @@ ielr_compute_ritem_sees_lookahead_set (void) { bitset result = bitset_create (nritems, BITSET_FIXED); unsigned i = nritems-1; - while (i>0) + while (0 < i) { --i; while (!item_number_is_rule_number (ritem[i]) @@ -59,7 +59,7 @@ ielr_compute_ritem_sees_lookahead_set (void) bitset_set (result, i--); if (!item_number_is_rule_number (ritem[i]) && ISVAR (ritem[i])) bitset_set (result, i--); - while (!item_number_is_rule_number (ritem[i]) && i>0) + while (!item_number_is_rule_number (ritem[i]) && 0 < i) --i; } if (trace_flag & trace_ielr) @@ -205,8 +205,7 @@ ielr_compute_follow_kernel_items (bitset ritem_sees_lookahead_set, { size_t nitems = states[from_state[i]]->nitems; item_number *items = states[from_state[i]]->items; - size_t j; - for (j = 0; j < nitems; ++j) + for (size_t j = 0; j < nitems; ++j) /* If this item has this goto and if all subsequent symbols in this RHS (if any) are nullable nonterminals, then record this item as one whose lookahead set is included in this goto's follows. */ @@ -298,11 +297,8 @@ ielr_compute_predecessors (void) for (state_number i = 0; i < nstates; ++i) predecessor_counts[i] = 0; for (state_number i = 0; i < nstates; ++i) - { - int j; - for (j = 0; j < states[i]->transitions->num; ++j) - ++predecessor_counts[states[i]->transitions->states[j]->number]; - } + for (int j = 0; j < states[i]->transitions->num; ++j) + ++predecessor_counts[states[i]->transitions->states[j]->number]; for (state_number i = 0; i < nstates; ++i) { result[i] = xnmalloc (predecessor_counts[i]+1, sizeof *result[i]); @@ -530,7 +526,8 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, free (annotation_counts); } -typedef struct state_list { +typedef struct state_list +{ struct state_list *next; state *state; /** Has this state been recomputed as a successor of another state? */ @@ -683,7 +680,6 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows, { state_list *lr0_isocore = t->state_list->lr0Isocore; state_list **this_isocorep; - bool has_lookaheads; /* Determine whether there's an isocore of t with which these lookaheads can be merged. */ @@ -750,7 +746,7 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows, } } - has_lookaheads = false; + bool has_lookaheads = false; for (size_t i = 0; i < lr0_isocore->state->nitems; ++i) if (!bitset_empty_p (lookaheads[i])) { @@ -894,10 +890,9 @@ ielr_compute_state (bitsetv follow_kernel_items, bitsetv always_follows, (*last_statep)->lookaheads = NULL; if (has_lookaheads) { - size_t i; (*last_statep)->lookaheads = xnmalloc (t->nitems, sizeof (*last_statep)->lookaheads); - for (i = 0; i < t->nitems; ++i) + for (size_t i = 0; i < t->nitems; ++i) { if (bitset_empty_p (lookaheads[i])) (*last_statep)->lookaheads[i] = NULL; @@ -1046,8 +1041,7 @@ ielr_split_states (bitsetv follow_kernel_items, bitsetv always_follows, state_list *node = first_state; if (node->lookaheads) { - size_t i; - for (i = 0; i < node->state->nitems; ++i) + for (size_t i = 0; i < node->state->nitems; ++i) if (node->lookaheads[i]) bitset_free (node->lookaheads[i]); free (node->lookaheads); diff --git a/contrib/tools/bison/src/ielr.h b/contrib/tools/bison/src/ielr.h index c080fdf0d3..17dcb2c8c8 100644 --- a/contrib/tools/bison/src/ielr.h +++ b/contrib/tools/bison/src/ielr.h @@ -1,6 +1,6 @@ /* IELR main implementation. - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/lalr.c b/contrib/tools/bison/src/lalr.c index 109aa0f4d9..0f1149d7fb 100644 --- a/contrib/tools/bison/src/lalr.c +++ b/contrib/tools/bison/src/lalr.c @@ -1,6 +1,6 @@ /* Compute lookahead criteria for Bison. - Copyright (C) 1984, 1986, 1989, 2000-2015, 2018 Free Software + Copyright (C) 1984, 1986, 1989, 2000-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -40,10 +40,10 @@ #include "relation.h" #include "symtab.h" -goto_number *goto_map; -goto_number ngotos; -state_number *from_state; -state_number *to_state; +goto_number *goto_map = NULL; +goto_number ngotos = 0; +state_number *from_state = NULL; +state_number *to_state = NULL; bitsetv goto_follows = NULL; /* Linked list of goto numbers. */ @@ -70,16 +70,14 @@ static goto_list **lookback; void set_goto_map (void) { - state_number s; goto_number *temp_map = xnmalloc (nvars + 1, sizeof *temp_map); goto_map = xcalloc (nvars + 1, sizeof *goto_map); ngotos = 0; - for (s = 0; s < nstates; ++s) + for (state_number s = 0; s < nstates; ++s) { transitions *sp = states[s]->transitions; - int i; - for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i) + for (int i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i) { ngotos++; @@ -92,14 +90,13 @@ set_goto_map (void) { goto_number k = 0; - int i; - for (i = ntokens; i < nsyms; i++) + for (symbol_number i = ntokens; i < nsyms; ++i) { temp_map[i - ntokens] = k; k += goto_map[i - ntokens]; } - for (i = ntokens; i < nsyms; i++) + for (symbol_number i = ntokens; i < nsyms; ++i) goto_map[i - ntokens] = temp_map[i - ntokens]; goto_map[nsyms - ntokens] = ngotos; @@ -109,11 +106,10 @@ set_goto_map (void) from_state = xcalloc (ngotos, sizeof *from_state); to_state = xcalloc (ngotos, sizeof *to_state); - for (s = 0; s < nstates; ++s) + for (state_number s = 0; s < nstates; ++s) { - transitions *sp = states[s]->transitions; - int i; - for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i) + const transitions *sp = states[s]->transitions; + for (int i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i) { goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++; from_state[k] = s; @@ -133,11 +129,9 @@ map_goto (state_number s0, symbol_number sym) for (;;) { - goto_number middle; - state_number s; aver (low <= high); - middle = (low + high) / 2; - s = from_state[middle]; + goto_number middle = (low + high) / 2; + state_number s = from_state[middle]; if (s == s0) return middle; else if (s < s0) @@ -155,20 +149,18 @@ initialize_F (void) goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge); goto_number nedges = 0; - goto_number i; - goto_follows = bitsetv_create (ngotos, ntokens, BITSET_FIXED); - for (i = 0; i < ngotos; i++) + for (goto_number i = 0; i < ngotos; ++i) { state_number stateno = to_state[i]; - transitions *sp = states[stateno]->transitions; + const transitions *sp = states[stateno]->transitions; int j; FOR_EACH_SHIFT (sp, j) bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j)); - for (; j < sp->num; j++) + for (; j < sp->num; ++j) { symbol_number sym = TRANSITION_SYMBOL (sp, j); if (nullable[sym - ntokens]) @@ -188,7 +180,7 @@ initialize_F (void) relation_digraph (reads, ngotos, &goto_follows); - for (i = 0; i < ngotos; i++) + for (goto_number i = 0; i < ngotos; ++i) free (reads[i]); free (reads); @@ -213,19 +205,16 @@ build_relations (void) { goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge); state_number *states1 = xnmalloc (ritem_longest_rhs () + 1, sizeof *states1); - goto_number i; includes = xnmalloc (ngotos, sizeof *includes); - for (i = 0; i < ngotos; i++) + for (goto_number i = 0; i < ngotos; ++i) { int nedges = 0; symbol_number symbol1 = states[to_state[i]]->accessing_symbol; - rule **rulep; - for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++) + for (rule **rulep = derives[symbol1 - ntokens]; *rulep; rulep++) { - bool done; int length = 1; item_number const *rp; state *s = states[from_state[i]]; @@ -242,7 +231,7 @@ build_relations (void) add_lookback_edge (s, *rulep, i); length--; - done = false; + bool done = false; while (!done) { done = true; @@ -265,9 +254,8 @@ build_relations (void) includes[i] = NULL; else { - int j; includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]); - for (j = 0; j < nedges; j++) + for (int j = 0; j < nedges; ++j) includes[i][j] = edge[j]; includes[i][nedges] = END_NODE; } @@ -284,11 +272,9 @@ build_relations (void) static void compute_FOLLOWS (void) { - goto_number i; - relation_digraph (includes, ngotos, &goto_follows); - for (i = 0; i < ngotos; i++) + for (goto_number i = 0; i < ngotos; ++i) free (includes[i]); free (includes); @@ -298,15 +284,12 @@ compute_FOLLOWS (void) static void compute_lookahead_tokens (void) { - size_t i; - goto_list *sp; - - for (i = 0; i < nLA; i++) - for (sp = lookback[i]; sp; sp = sp->next) + for (size_t i = 0; i < nLA; ++i) + for (goto_list *sp = lookback[i]; sp; sp = sp->next) bitset_or (LA[i], LA[i], goto_follows[sp->value]); /* Free LOOKBACK. */ - for (i = 0; i < nLA; i++) + for (size_t i = 0; i < nLA; ++i) LIST_FREE (goto_list, lookback[i]); free (lookback); @@ -346,7 +329,7 @@ state_lookahead_tokens_count (state *s, bool default_reduction_only_for_accept) && default_reduction_only_for_accept)) n_lookahead_tokens += rp->num; else - s->consistent = 1; + s->consistent = true; return n_lookahead_tokens; } @@ -359,8 +342,6 @@ state_lookahead_tokens_count (state *s, bool default_reduction_only_for_accept) void initialize_LA (void) { - state_number i; - bitsetv pLA; bool default_reduction_only_for_accept; { char *default_reductions = @@ -371,7 +352,7 @@ initialize_LA (void) /* Compute the total number of reductions requiring a lookahead. */ nLA = 0; - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) nLA += state_lookahead_tokens_count (states[i], default_reduction_only_for_accept); @@ -379,11 +360,11 @@ initialize_LA (void) if (!nLA) nLA = 1; - pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED); + bitsetv pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED); /* Initialize the members LOOKAHEAD_TOKENS for each state whose reductions require lookahead tokens. */ - for (i = 0; i < nstates; i++) + for (state_number i = 0; i < nstates; ++i) { int count = state_lookahead_tokens_count (states[i], @@ -404,34 +385,30 @@ initialize_LA (void) static void lookahead_tokens_print (FILE *out) { - state_number i; fprintf (out, "Lookahead tokens: BEGIN\n"); - for (i = 0; i < nstates; ++i) + for (state_number i = 0; i < nstates; ++i) { - reductions *reds = states[i]->reductions; - bitset_iterator iter; + const reductions *reds = states[i]->reductions; int n_lookahead_tokens = 0; if (reds->lookahead_tokens) - { - int j; - for (j = 0; j < reds->num; ++j) - if (reds->lookahead_tokens[j]) - ++n_lookahead_tokens; - } + for (int j = 0; j < reds->num; ++j) + if (reds->lookahead_tokens[j]) + ++n_lookahead_tokens; fprintf (out, "State %d: %d lookahead tokens\n", i, n_lookahead_tokens); if (reds->lookahead_tokens) - { - int j, k; - for (j = 0; j < reds->num; ++j) + for (int j = 0; j < reds->num; ++j) + { + bitset_iterator iter; + int k; BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0) fprintf (out, " on %d (%s) -> rule %d\n", k, symbols[k]->tag, reds->rules[j]->number); - } + } } fprintf (out, "Lookahead tokens: END\n"); } @@ -458,25 +435,23 @@ lalr_update_state_numbers (state_number old_to_new[], state_number nstates_old) goto_number ngotos_reachable = 0; symbol_number nonterminal = 0; aver (nsyms == nvars + ntokens); - { - goto_number i; - for (i = 0; i < ngotos; ++i) - { - while (i == goto_map[nonterminal]) - goto_map[nonterminal++] = ngotos_reachable; - /* If old_to_new[from_state[i]] = nstates_old, remove this goto - entry. */ - if (old_to_new[from_state[i]] != nstates_old) - { - /* from_state[i] is not removed, so it and thus to_state[i] are - reachable, so to_state[i] != nstates_old. */ - aver (old_to_new[to_state[i]] != nstates_old); - from_state[ngotos_reachable] = old_to_new[from_state[i]]; - to_state[ngotos_reachable] = old_to_new[to_state[i]]; - ++ngotos_reachable; - } - } - } + + for (goto_number i = 0; i < ngotos; ++i) + { + while (i == goto_map[nonterminal]) + goto_map[nonterminal++] = ngotos_reachable; + /* If old_to_new[from_state[i]] = nstates_old, remove this goto + entry. */ + if (old_to_new[from_state[i]] != nstates_old) + { + /* from_state[i] is not removed, so it and thus to_state[i] are + reachable, so to_state[i] != nstates_old. */ + aver (old_to_new[to_state[i]] != nstates_old); + from_state[ngotos_reachable] = old_to_new[from_state[i]]; + to_state[ngotos_reachable] = old_to_new[to_state[i]]; + ++ngotos_reachable; + } + } while (nonterminal <= nvars) { aver (ngotos == goto_map[nonterminal]); @@ -489,8 +464,7 @@ lalr_update_state_numbers (state_number old_to_new[], state_number nstates_old) void lalr_free (void) { - state_number s; - for (s = 0; s < nstates; ++s) + for (state_number s = 0; s < nstates; ++s) states[s]->reductions->lookahead_tokens = NULL; bitsetv_free (LA); } diff --git a/contrib/tools/bison/src/lalr.h b/contrib/tools/bison/src/lalr.h index 898053f5c9..b06b3051ec 100644 --- a/contrib/tools/bison/src/lalr.h +++ b/contrib/tools/bison/src/lalr.h @@ -1,7 +1,7 @@ /* Compute lookahead criteria for bison, Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006-2007, - 2009-2015, 2018 Free Software Foundation, Inc. + 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/location.c b/contrib/tools/bison/src/location.c index e75e67e331..6876890c02 100644 --- a/contrib/tools/bison/src/location.c +++ b/contrib/tools/bison/src/location.c @@ -1,6 +1,7 @@ /* Locations for Bison - Copyright (C) 2002, 2005-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -208,13 +209,20 @@ location_caret (location loc, FILE *out) /* Print the carets (at least one), with the same indent as above.*/ fprintf (out, " %*s", loc.start.column - 1, ""); for (i = loc.start.column; i == loc.start.column || i < len; ++i) - putc ('^', out); + putc (i == loc.start.column ? '^' : '~', out); } putc ('\n', out); } } } +bool +location_empty (location loc) +{ + return !loc.start.file && !loc.start.line && !loc.start.column + && !loc.end.file && !loc.end.line && !loc.end.column; +} + void boundary_set_from_string (boundary *bound, char *loc_str) { diff --git a/contrib/tools/bison/src/location.h b/contrib/tools/bison/src/location.h index 106048dd07..39e0507d96 100644 --- a/contrib/tools/bison/src/location.h +++ b/contrib/tools/bison/src/location.h @@ -1,6 +1,7 @@ /* Locations for Bison - Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -125,6 +126,9 @@ location_cmp (location a, location b) return res; } +/* Whether this is the empty location. */ +bool location_empty (location loc); + /* LOC_STR must be formatted as 'file:line.column', it will be modified. */ void boundary_set_from_string (boundary *bound, char *loc_str); diff --git a/contrib/tools/bison/src/main.c b/contrib/tools/bison/src/main.c index 957005ceaa..164712f484 100644 --- a/contrib/tools/bison/src/main.c +++ b/contrib/tools/bison/src/main.c @@ -1,7 +1,7 @@ /* Top level entry point of Bison. Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2002, 2004-2015, - 2018 Free Software Foundation, Inc. + 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -21,11 +21,12 @@ #include <config.h> #include "system.h" -#include <bitset_stats.h> #include <bitset.h> +#include <bitset/stats.h> #include <configmake.h> #include <progname.h> #include <quotearg.h> +#include <relocatable.h> /* relocate2 */ #include <timevar.h> #include "LR0.h" @@ -34,6 +35,7 @@ #include "conflicts.h" #include "derives.h" #include "files.h" +#include "fixits.h" #include "getargs.h" #include "gram.h" #include "lalr.h" @@ -58,6 +60,7 @@ int main (int argc, char *argv[]) { +#define DEPENDS_ON_LIBINTL 1 set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -144,31 +147,34 @@ main (int argc, char *argv[]) print_precedence_warnings (); - /* Output file names. */ - compute_output_file_names (); - - /* Output the detailed report on the grammar. */ - if (report_flag) - { - timevar_push (tv_report); - print_results (); - timevar_pop (tv_report); - } - - /* Output the graph. */ - if (graph_flag) - { - timevar_push (tv_graph); - print_graph (); - timevar_pop (tv_graph); - } - - /* Output xml. */ - if (xml_flag) + if (!update_flag) { - timevar_push (tv_xml); - print_xml (); - timevar_pop (tv_xml); + /* Output file names. */ + compute_output_file_names (); + + /* Output the detailed report on the grammar. */ + if (report_flag) + { + timevar_push (tv_report); + print_results (); + timevar_pop (tv_report); + } + + /* Output the graph. */ + if (graph_flag) + { + timevar_push (tv_graph); + print_graph (); + timevar_pop (tv_graph); + } + + /* Output xml. */ + if (xml_flag) + { + timevar_push (tv_xml); + print_xml (); + timevar_pop (tv_xml); + } } /* Stop if there were errors, to avoid trashing previous output @@ -182,9 +188,12 @@ main (int argc, char *argv[]) timevar_pop (tv_free); /* Output the tables and the parser to ftable. In file output. */ - timevar_push (tv_parser); - output (); - timevar_pop (tv_parser); + if (!update_flag) + { + timevar_push (tv_parser); + output (); + timevar_pop (tv_parser); + } timevar_push (tv_free); nullable_free (); @@ -200,7 +209,6 @@ main (int argc, char *argv[]) contains things such as user actions, prologue, epilogue etc. */ gram_scanner_free (); muscle_free (); - uniqstrs_free (); code_scanner_free (); skel_scanner_free (); quotearg_free (); @@ -217,5 +225,18 @@ main (int argc, char *argv[]) cleanup_caret (); + /* Fix input file now, even if there are errors: that's less + warnings in the following runs. */ + if (!fixits_empty ()) + { + if (update_flag) + fixits_run (); + else + complain (NULL, Wother, + _("fix-its can be applied. Rerun with option '--update'.")); + fixits_free (); + } + uniqstrs_free (); + return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/contrib/tools/bison/src/muscle-tab.c b/contrib/tools/bison/src/muscle-tab.c index d4c195cb9d..8a1b00fc63 100644 --- a/contrib/tools/bison/src/muscle-tab.c +++ b/contrib/tools/bison/src/muscle-tab.c @@ -1,6 +1,6 @@ /* Muscle table manager for Bison. - Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -24,6 +24,7 @@ #include "complain.h" #include "files.h" +#include "fixits.h" #include "getargs.h" #include "muscle-tab.h" #include "quote.h" @@ -407,10 +408,16 @@ muscle_user_name_list_grow (char const *key, char const *user_name, static char * -define_directive (char const *assignment, char const *value) +define_directive (char const *assignment, + muscle_kind kind, + char const *value) { char *eq = strchr (assignment, '='); - char const *fmt = !eq && value && *value ? "%%define %s %s" : "%%define %s"; + char const *fmt + = eq || !value || !*value ? "%%define %s" + : kind == muscle_code ? "%%define %s {%s}" + : kind == muscle_string ? "%%define %s \"%s\"" + : "%%define %s %s"; char *res = xmalloc (strlen (fmt) + strlen (assignment) + (value ? strlen (value) : 0)); sprintf (res, fmt, assignment, value); @@ -423,32 +430,46 @@ define_directive (char const *assignment, char const *value) /** If the \a variable name is obsolete, return the name to use, * otherwise \a variable. If the \a value is obsolete, update it too. * - * Allocates the returned value. */ + * Allocates the returned value if needed, otherwise the returned + * value is exactly \a variable. */ static -char * -muscle_percent_variable_update (char const *variable, location variable_loc, - char const **value) +char const * +muscle_percent_variable_update (char const *variable, + muscle_kind kind, + char const **value, + char **old, char **upd) { typedef struct { const char *obsolete; const char *updated; + muscle_kind kind; } conversion_type; const conversion_type conversion[] = - { - { "api.push_pull", "api.push-pull", }, - { "api.tokens.prefix", "api.token.prefix", }, - { "lex_symbol", "api.token.constructor", }, - { "location_type", "api.location.type", }, - { "lr.default-reductions", "lr.default-reduction", }, - { "lr.keep-unreachable-states", "lr.keep-unreachable-state", }, - { "lr.keep_unreachable_states", "lr.keep-unreachable-state", }, - { "namespace", "api.namespace", }, - { "stype", "api.value.type", }, - { "variant=", "api.value.type=variant", }, - { "variant=true", "api.value.type=variant", }, - { NULL, NULL, } - }; + { + { "%error-verbose", "parse.error=verbose", muscle_keyword }, + { "%error_verbose", "parse.error=verbose", muscle_keyword }, + { "abstract", "api.parser.abstract", muscle_keyword }, + { "annotations", "api.parser.annotations", muscle_code }, + { "api.push_pull", "api.push-pull", muscle_keyword }, + { "api.tokens.prefix", "api.token.prefix", muscle_code }, + { "extends", "api.parser.extends", muscle_keyword }, + { "final", "api.parser.final", muscle_keyword }, + { "implements", "api.parser.implements", muscle_keyword }, + { "lex_symbol", "api.token.constructor", -1 }, + { "location_type", "api.location.type", muscle_code }, + { "lr.default-reductions", "lr.default-reduction", muscle_keyword }, + { "lr.keep-unreachable-states", "lr.keep-unreachable-state", muscle_keyword }, + { "lr.keep_unreachable_states", "lr.keep-unreachable-state", muscle_keyword }, + { "namespace", "api.namespace", muscle_code }, + { "parser_class_name", "api.parser.class", muscle_code }, + { "public", "api.parser.public", muscle_keyword }, + { "strictfp", "api.parser.strictfp", muscle_keyword }, + { "stype", "api.value.type", -1 }, + { "variant=", "api.value.type=variant", -1 }, + { "variant=true", "api.value.type=variant", -1 }, + { NULL, NULL, -1, } + }; for (conversion_type const *c = conversion; c->obsolete; ++c) { @@ -458,22 +479,25 @@ muscle_percent_variable_update (char const *variable, location variable_loc, && STREQ (eq + 1, *value)) : STREQ (c->obsolete, variable)) { - char *old = define_directive (c->obsolete, *value); - char *upd = define_directive (c->updated, *value); - deprecated_directive (&variable_loc, old, upd); - free (old); - free (upd); - char *res = xstrdup (c->updated); - char *eq2 = strchr (res, '='); - if (eq2) - { - *eq2 = '\0'; - *value = eq2 + 1; - } - return res; + /* Generate the deprecation warning. */ + *old = c->obsolete[0] == '%' + ? xstrdup (c->obsolete) + : define_directive (c->obsolete, kind, *value); + *upd = define_directive (c->updated, c->kind, *value); + /* Update the variable and its value. */ + { + char *res = xstrdup (c->updated); + char *eq2 = strchr (res, '='); + if (eq2) + { + *eq2 = '\0'; + *value = eq2 + 1; + } + return res; + } } } - return xstrdup (variable); + return variable; } void @@ -483,7 +507,11 @@ muscle_percent_define_insert (char const *var, location variable_loc, muscle_percent_define_how how) { /* Backward compatibility. */ - char *variable = muscle_percent_variable_update (var, variable_loc, &value); + char *old = NULL; + char *upd = NULL; + char const *variable + = muscle_percent_variable_update (var, kind, + &value, &old, &upd); uniqstr name = muscle_name (variable, NULL); uniqstr loc_name = muscle_name (variable, "loc"); uniqstr syncline_name = muscle_name (variable, "syncline"); @@ -491,21 +519,33 @@ muscle_percent_define_insert (char const *var, location variable_loc, uniqstr kind_name = muscle_name (variable, "kind"); /* Command-line options are processed before the grammar file. */ - if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE - && muscle_find_const (name)) + bool warned = false; + if (how == MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE) { - muscle_percent_define_how how_old = atoi (muscle_find_const (how_name)); - if (how_old == MUSCLE_PERCENT_DEFINE_F) - goto end; - unsigned i = 0; - complain_indent (&variable_loc, complaint, &i, - _("%%define variable %s redefined"), - quote (variable)); - i += SUB_INDENT; - location loc = muscle_percent_define_get_loc (variable); - complain_indent (&loc, complaint, &i, _("previous definition")); + char const *current_value = muscle_find_const (name); + if (current_value) + { + muscle_percent_define_how how_old + = atoi (muscle_find_const (how_name)); + if (how_old == MUSCLE_PERCENT_DEFINE_F) + goto end; + unsigned 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; + location loc = muscle_percent_define_get_loc (variable); + complain_indent (&loc, warn, &i, _("previous definition")); + fixits_register (&variable_loc, ""); + warned = true; + } } + if (!warned && old && upd) + deprecated_directive (&variable_loc, old, upd); + MUSCLE_INSERT_STRING (name, value); muscle_insert (loc_name, ""); muscle_location_grow (loc_name, variable_loc); @@ -516,7 +556,10 @@ muscle_percent_define_insert (char const *var, location variable_loc, MUSCLE_INSERT_INT (how_name, how); MUSCLE_INSERT_STRING (kind_name, muscle_kind_string (kind)); end: - free (variable); + free (old); + free (upd); + if (variable != var) + free ((char *) variable); } /* This is used for backward compatibility, e.g., "%define api.pure" diff --git a/contrib/tools/bison/src/muscle-tab.h b/contrib/tools/bison/src/muscle-tab.h index b1c59506a1..70c45db57c 100644 --- a/contrib/tools/bison/src/muscle-tab.h +++ b/contrib/tools/bison/src/muscle-tab.h @@ -1,7 +1,7 @@ /* Muscle table manager for Bison, - Copyright (C) 2001-2003, 2006-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2001-2003, 2006-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/named-ref.c b/contrib/tools/bison/src/named-ref.c index ac5af1c8e9..b9f49c4f63 100644 --- a/contrib/tools/bison/src/named-ref.c +++ b/contrib/tools/bison/src/named-ref.c @@ -1,6 +1,6 @@ /* Named symbol references for Bison - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/named-ref.h b/contrib/tools/bison/src/named-ref.h index f42036facb..bc9f99fac3 100644 --- a/contrib/tools/bison/src/named-ref.h +++ b/contrib/tools/bison/src/named-ref.h @@ -1,6 +1,6 @@ /* Named symbol references for Bison - Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/nullable.c b/contrib/tools/bison/src/nullable.c index 0dffd575b0..7d6cf9c885 100644 --- a/contrib/tools/bison/src/nullable.c +++ b/contrib/tools/bison/src/nullable.c @@ -1,7 +1,7 @@ /* Calculate which nonterminals can expand into the null string for Bison. - Copyright (C) 1984, 1989, 2000-2006, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2006, 2009-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/nullable.h b/contrib/tools/bison/src/nullable.h index 8b6cfddd23..60caf3db22 100644 --- a/contrib/tools/bison/src/nullable.h +++ b/contrib/tools/bison/src/nullable.h @@ -1,7 +1,7 @@ /* Part of the bison parser generator, - Copyright (C) 2000, 2002, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2000, 2002, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/output.c b/contrib/tools/bison/src/output.c index 5009fe7f7b..ae0dc5834f 100644 --- a/contrib/tools/bison/src/output.c +++ b/contrib/tools/bison/src/output.c @@ -1,7 +1,7 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -26,6 +26,7 @@ #include <get-errno.h> #include <path-join.h> #include <quotearg.h> +#include <relocatable.h> /* relocate2 */ #include <spawn-pipe.h> #include <timevar.h> #include <wait-process.h> @@ -37,6 +38,7 @@ #include "muscle-tab.h" #include "output.h" #include "reader.h" +#include "reduce.h" #include "scan-code.h" /* max_left_semantic_context */ #include "scan-skel.h" #include "symtab.h" @@ -65,6 +67,9 @@ default_pkgdatadir() static struct obstack format_obstack; +/* Memory allocated by relocate2, to free. */ +static char *relocate_buffer = NULL; + /*-------------------------------------------------------------------. | Create a function NAME which associates to the muscle NAME the | @@ -77,11 +82,8 @@ static struct obstack format_obstack; #define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \ \ static void \ -Name (char const *name, \ - Type *table_data, \ - Type first, \ - int begin, \ - int end) \ +Name (char const *name, Type *table_data, Type first, \ + int begin, int end) \ { \ Type min = first; \ Type max = first; \ @@ -115,11 +117,12 @@ Name (char const *name, \ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \ } -GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_int_table, unsigned) +GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_table, unsigned) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_int_table, int) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_base_table, base_number) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_rule_number_table, rule_number) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_symbol_number_table, symbol_number) +GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_item_number_table, item_number) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_state_number_table, state_number) /*----------------------------------------------------------------. @@ -156,6 +159,46 @@ string_output (FILE *out, char const *string) } +/*----------------------------. +| Prepare the symbols names. | +`----------------------------*/ + +static void +prepare_symbol_names (char const *muscle_name) +{ + /* We assume that the table will be output starting at column 2. */ + int j = 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); + /* Width of the next token, including the two quotes, the + comma and the space. */ + int width = strlen (cp) + 2; + + if (j + width > 75) + { + obstack_sgrow (&format_obstack, "\n "); + j = 1; + } + + if (i) + obstack_1grow (&format_obstack, ' '); + obstack_escape (&format_obstack, cp); + free (cp); + obstack_1grow (&format_obstack, ','); + j += width; + } + free (qo); + obstack_sgrow (&format_obstack, " ]b4_null["); + + /* Finish table and store. */ + muscle_insert (muscle_name, obstack_finish0 (&format_obstack)); +} + + /*------------------------------------------------------------------. | Prepare the muscles related to the symbols: translate, tname, and | | toknum. | @@ -176,38 +219,7 @@ prepare_symbols (void) 1, max_user_token_number + 1); /* tname -- token names. */ - { - /* We assume that the table will be output starting at column 2. */ - int j = 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); - /* Width of the next token, including the two quotes, the - comma and the space. */ - int width = strlen (cp) + 2; - - if (j + width > 75) - { - obstack_sgrow (&format_obstack, "\n "); - j = 1; - } - - if (i) - obstack_1grow (&format_obstack, ' '); - obstack_escape (&format_obstack, cp); - free (cp); - obstack_1grow (&format_obstack, ','); - j += width; - } - free (qo); - obstack_sgrow (&format_obstack, " ]b4_null["); - - /* Finish table and store. */ - muscle_insert ("tname", obstack_finish0 (&format_obstack)); - } + prepare_symbol_names ("tname"); /* Output YYTOKNUM. */ { @@ -221,14 +233,16 @@ prepare_symbols (void) } -/*----------------------------------------------------------------. -| Prepare the muscles related to the rules: r1, r2, rline, dprec, | -| merger, immediate. | -`----------------------------------------------------------------*/ +/*-------------------------------------------------------------. +| Prepare the muscles related to the rules: rhs, prhs, r1, r2, | +| rline, dprec, merger, immediate. | +`-------------------------------------------------------------*/ static void prepare_rules (void) { + unsigned *prhs = xnmalloc (nrules, sizeof *prhs); + item_number *rhs = xnmalloc (nritems, sizeof *rhs); unsigned *rline = xnmalloc (nrules, sizeof *rline); symbol_number *r1 = xnmalloc (nrules, sizeof *r1); unsigned *r2 = xnmalloc (nrules, sizeof *r2); @@ -236,14 +250,24 @@ prepare_rules (void) int *merger = xnmalloc (nrules, sizeof *merger); int *immediate = xnmalloc (nrules, sizeof *immediate); + /* Index in RHS. */ + unsigned i = 0; for (rule_number r = 0; r < nrules; ++r) { + /* Index of rule R in RHS. */ + prhs[r] = i; + /* RHS of the rule R. */ + for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) + rhs[i++] = *rhsp; + /* Separator in RHS. */ + rhs[i++] = -1; + + /* Line where rule was defined. */ + rline[r] = rules[r].location.start.line; /* LHS of the rule R. */ r1[r] = rules[r].lhs->number; /* Length of rule R's RHS. */ r2[r] = rule_rhs_length (&rules[r]); - /* Line where rule was defined. */ - rline[r] = rules[r].location.start.line; /* Dynamic precedence (GLR). */ dprec[r] = rules[r].dprec; /* Merger-function index (GLR). */ @@ -251,10 +275,13 @@ prepare_rules (void) /* Immediate reduction flags (GLR). */ immediate[r] = rules[r].is_predicate; } + aver (i == nritems); - muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules); + muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems); + muscle_insert_unsigned_table ("prhs", prhs, 0, 0, nrules); + muscle_insert_unsigned_table ("rline", rline, 0, 0, nrules); muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules); - muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules); + muscle_insert_unsigned_table ("r2", r2, 0, 0, nrules); muscle_insert_int_table ("dprec", dprec, 0, 0, nrules); muscle_insert_int_table ("merger", merger, 0, 0, nrules); muscle_insert_int_table ("immediate", immediate, 0, 0, nrules); @@ -262,6 +289,8 @@ prepare_rules (void) MUSCLE_INSERT_INT ("rules_number", nrules); MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context); + free (prhs); + free (rhs); free (rline); free (r1); free (r2); @@ -407,6 +436,14 @@ merger_output (FILE *out) static void prepare_symbol_definitions (void) { + /* Map "orig NUM" to new numbers. See data/README. */ + for (symbol_number i = ntokens; i < nsyms + nuseless_nonterminals; ++i) + { + obstack_printf (&format_obstack, "symbol(orig %d, number)", i); + const char *key = obstack_finish0 (&format_obstack); + MUSCLE_INSERT_INT (key, nterm_map ? nterm_map[i - ntokens] : i); + } + for (int i = 0; i < nsyms; ++i) { symbol *sym = symbols[i]; @@ -519,10 +556,10 @@ prepare_actions (void) parser, so we could avoid accidents by not writing them out in that case. Nevertheless, it seems even better to be able to use the GLR skeletons even without the non-deterministic tables. */ - muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table, - conflict_table[0], 1, high + 1); - muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list, - 0, 1, conflict_list_cnt); + muscle_insert_unsigned_table ("conflict_list_heads", conflict_table, + conflict_table[0], 1, high + 1); + muscle_insert_unsigned_table ("conflicting_rules", conflict_list, + 0, 1, conflict_list_cnt); } @@ -552,11 +589,12 @@ output_skeleton (void) /* Compute the names of the package data dir and skeleton files. */ char const *m4 = (m4 = getenv ("M4")) ? m4 : M4; char const *datadir = pkgdatadir (); + char *skeldir = xpath_join (datadir, "skeletons"); char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4"); - char *m4bison = xpath_join (datadir, "bison.m4"); + char *m4bison = xpath_join (skeldir, "bison.m4"); char *skel = (IS_PATH_WITH_DIR (skeleton) ? xstrdup (skeleton) - : xpath_join (datadir, skeleton)); + : xpath_join (skeldir, skeleton)); /* Test whether m4sugar.m4 is readable, to check for proper installation. A faulty installation can cause deadlock, so a @@ -611,6 +649,7 @@ output_skeleton (void) true, filter_fd); } + free (skeldir); free (m4sugar); free (m4bison); free (skel); @@ -656,7 +695,7 @@ prepare (void) MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen); MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag); MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag); - MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag); + MUSCLE_INSERT_BOOL ("yacc_flag", !location_empty (yacc_loc)); /* File names. */ if (spec_name_prefix) @@ -683,10 +722,12 @@ prepare (void) /* About the skeletons. */ { - /* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs + /* b4_skeletonsdir is used inside m4_include in the skeletons, so digraphs would never be expanded. Hopefully no one has M4-special characters in his Bison installation path. */ - MUSCLE_INSERT_STRING_RAW ("pkgdatadir", pkgdatadir ()); + char *skeldir = xpath_join (pkgdatadir (), "skeletons"); + MUSCLE_INSERT_STRING_RAW ("skeletonsdir", skeldir); + free (skeldir); } } @@ -717,11 +758,17 @@ output (void) unlink_generated_sources (); obstack_free (&format_obstack, NULL); + free (relocate_buffer); } char const * pkgdatadir (void) { - char const *cp = getenv ("BISON_PKGDATADIR"); - return cp ? cp : PKGDATADIR; + if (relocate_buffer) + return relocate_buffer; + else + { + char const *cp = getenv ("BISON_PKGDATADIR"); + return cp ? cp : relocate2 (PKGDATADIR, &relocate_buffer); + } } diff --git a/contrib/tools/bison/src/output.h b/contrib/tools/bison/src/output.h index ba47a89c4d..c308bf5630 100644 --- a/contrib/tools/bison/src/output.h +++ b/contrib/tools/bison/src/output.h @@ -1,7 +1,7 @@ /* Output the generated parsing program for bison, - Copyright (C) 2000-2003, 2006-2007, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 2000-2003, 2006-2007, 2009-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/parse-gram.c b/contrib/tools/bison/src/parse-gram.c index 82ac533466..fb5add9c28 100644 --- a/contrib/tools/bison/src/parse-gram.c +++ b/contrib/tools/bison/src/parse-gram.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.1.91.31-00793. */ +/* A Bison parser, made by GNU Bison 3.2.90.23-0bbcb-dirty. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -47,7 +48,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.1.91.31-00793" +#define YYBISON_VERSION "3.2.90.23-0bbcb-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,12 +63,12 @@ #define YYPULL 1 /* "%code top" blocks. */ -#line 27 "src/parse-gram.y" /* yacc.c:316 */ +#line 27 "src/parse-gram.y" /* yacc.c:315 */ /* On column 0 to please syntax-check. */ #include <config.h> -#line 71 "src/parse-gram.c" /* yacc.c:316 */ +#line 72 "src/parse-gram.c" /* yacc.c:315 */ /* Substitute the type names. */ #define YYSTYPE GRAM_STYPE #define YYLTYPE GRAM_LTYPE @@ -120,11 +121,11 @@ extern int gram_debug; #endif /* "%code requires" blocks. */ -#line 21 "src/parse-gram.y" /* yacc.c:353 */ +#line 21 "src/parse-gram.y" /* yacc.c:352 */ #include "symlist.h" #include "symtab.h" -#line 222 "src/parse-gram.y" /* yacc.c:353 */ +#line 239 "src/parse-gram.y" /* yacc.c:352 */ typedef enum { @@ -133,10 +134,16 @@ extern int gram_debug; param_parse = 1 << 1, param_both = param_lex | param_parse } param_type; -#line 645 "src/parse-gram.y" /* yacc.c:353 */ -#include "muscle-tab.h" +#line 682 "src/parse-gram.y" /* yacc.c:352 */ -#line 140 "src/parse-gram.c" /* yacc.c:353 */ + #include "muscle-tab.h" + typedef struct + { + char const *chars; + muscle_kind kind; + } value_type; + +#line 147 "src/parse-gram.c" /* yacc.c:352 */ /* Token type. */ #ifndef GRAM_TOKENTYPE @@ -207,35 +214,90 @@ extern int gram_debug; union GRAM_STYPE { -#line 183 "src/parse-gram.y" /* yacc.c:353 */ -unsigned char character; -#line 187 "src/parse-gram.y" /* yacc.c:353 */ -char *code; -#line 192 "src/parse-gram.y" /* yacc.c:353 */ -uniqstr uniqstr; -#line 200 "src/parse-gram.y" /* yacc.c:353 */ -int integer; -#line 204 "src/parse-gram.y" /* yacc.c:353 */ -symbol *symbol; -#line 209 "src/parse-gram.y" /* yacc.c:353 */ -assoc assoc; -#line 212 "src/parse-gram.y" /* yacc.c:353 */ -symbol_list *list; -#line 215 "src/parse-gram.y" /* yacc.c:353 */ -named_ref *named_ref; -#line 242 "src/parse-gram.y" /* yacc.c:353 */ -param_type param; -#line 409 "src/parse-gram.y" /* yacc.c:353 */ -code_props_type code_type; -#line 647 "src/parse-gram.y" /* yacc.c:353 */ - - struct - { - char const *chars; - muscle_kind kind; - } value; -#line 239 "src/parse-gram.c" /* yacc.c:353 */ + /* 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_79; + /* named_ref.opt */ + named_ref* yytype_91; + /* "%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_98; + /* 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_77; + /* token_decls_for_prec */ + symbol_list* token_decls_for_prec; + /* token_decl_for_prec.1 */ + symbol_list* yytype_81; + /* symbol_decls */ + symbol_list* symbol_decls; + /* symbol_decl.1 */ + symbol_list* yytype_84; + /* "%error-verbose" */ + uniqstr PERCENT_ERROR_VERBOSE; + /* "%<flag>" */ + uniqstr PERCENT_FLAG; + /* "%file-prefix" */ + uniqstr PERCENT_FILE_PREFIX; + /* "%name-prefix" */ + uniqstr PERCENT_NAME_PREFIX; + /* "%yacc" */ + uniqstr PERCENT_YACC; + /* "[identifier]" */ + uniqstr BRACKETED_ID; + /* "identifier" */ + uniqstr ID; + /* "identifier:" */ + uniqstr ID_COLON; + /* "<tag>" */ + uniqstr TAG; + /* tag.opt */ + uniqstr yytype_71; + /* tag */ + uniqstr tag; + /* variable */ + uniqstr variable; + /* "char" */ + unsigned char CHAR; + /* value */ + value_type value; +#line 301 "src/parse-gram.c" /* yacc.c:352 */ }; typedef union GRAM_STYPE GRAM_STYPE; @@ -265,7 +327,7 @@ int gram_parse (void); /* Unqualified %code blocks. */ -#line 33 "src/parse-gram.y" /* yacc.c:356 */ +#line 33 "src/parse-gram.y" /* yacc.c:355 */ #include "system.h" #include <errno.h> @@ -279,8 +341,9 @@ int gram_parse (void); #include "named-ref.h" #include "quotearg.h" #include "reader.h" - #include "scan-gram.h" #include "scan-code.h" + #include "scan-gram.h" + #include "vasnprintf.h" #include "xmemdup0.h" static int current_prec = 0; @@ -288,7 +351,6 @@ int gram_parse (void); static named_ref *current_lhs_named_ref; static symbol *current_lhs_symbol; static symbol_class current_class = unknown_sym; - static uniqstr current_type = NULL; /** Set the new current left-hand side symbol, possibly common * to several right-hand side parts of rule. @@ -318,7 +380,26 @@ int gram_parse (void); string from the scanner (should be CODE). */ static char const *translate_code_braceless (char *code, location loc); - static void version_check (location const *loc, char const *version); + /* Handle a %error-verbose directive. */ + static void handle_error_verbose (location const *loc, char const *directive); + + /* Handle a %file-prefix directive. */ + static void handle_file_prefix (location const *loc, + location const *dir_loc, + char const *directive, char const *value); + + /* Handle a %name-prefix directive. */ + static void handle_name_prefix (location const *loc, + char const *directive, char const *value); + + /* Handle a %require directive. */ + static void handle_require (location const *loc, char const *version); + + /* Handle a %skeleton directive. */ + static void handle_skeleton (location const *loc, char const *skel); + + /* Handle a %yacc directive. */ + static void handle_yacc (location const *loc, char const *directive); static void gram_error (location const *, char const *); @@ -329,7 +410,7 @@ int gram_parse (void); #define YYTYPE_INT8 int_fast8_t #define YYTYPE_UINT16 uint_fast16_t #define YYTYPE_UINT8 uint_fast8_t -#line 232 "src/parse-gram.y" /* yacc.c:356 */ +#line 249 "src/parse-gram.y" /* yacc.c:355 */ /** Add a lex-param and/or a parse-param. * @@ -340,7 +421,7 @@ int gram_parse (void); static void add_param (param_type type, char *decl, location loc); static param_type current_param = param_none; -#line 344 "src/parse-gram.c" /* yacc.c:356 */ +#line 425 "src/parse-gram.c" /* yacc.c:355 */ #ifdef short # undef short @@ -552,27 +633,27 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 164 +#define YYLAST 229 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 58 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 37 +#define YYNNTS 42 /* YYNRULES -- Number of rules. */ -#define YYNRULES 110 +#define YYNRULES 121 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 145 +#define YYNSTATES 164 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 312 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -613,18 +694,19 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 265, 265, 274, 275, 279, 280, 286, 290, 295, - 296, 301, 307, 308, 309, 310, 315, 320, 321, 322, - 323, 324, 325, 325, 326, 327, 351, 352, 353, 354, - 358, 359, 368, 369, 370, 374, 385, 389, 393, 401, - 412, 413, 423, 424, 430, 442, 442, 447, 447, 452, - 462, 476, 477, 478, 479, 483, 484, 489, 491, 496, - 501, 511, 513, 518, 519, 523, 524, 528, 529, 530, - 535, 540, 545, 551, 557, 568, 569, 578, 579, 585, - 586, 587, 594, 594, 602, 603, 604, 609, 612, 614, - 616, 618, 620, 622, 624, 629, 630, 640, 641, 666, - 667, 668, 669, 681, 683, 692, 697, 698, 703, 711, - 712 + 0, 281, 281, 290, 291, 295, 296, 302, 306, 311, + 312, 317, 318, 319, 320, 321, 326, 331, 332, 333, + 334, 335, 336, 336, 337, 338, 339, 340, 341, 342, + 343, 347, 348, 357, 358, 362, 373, 377, 381, 389, + 399, 400, 410, 411, 417, 430, 430, 435, 435, 440, + 444, 454, 455, 456, 457, 461, 462, 467, 468, 472, + 473, 477, 478, 479, 492, 501, 505, 509, 517, 518, + 522, 535, 536, 548, 552, 556, 564, 566, 571, 578, + 588, 592, 596, 604, 605, 613, 614, 620, 621, 622, + 629, 629, 637, 638, 639, 644, 647, 649, 651, 653, + 655, 657, 659, 661, 663, 668, 669, 678, 702, 703, + 704, 705, 717, 719, 734, 739, 740, 745, 754, 755, + 759, 760 }; #endif @@ -649,12 +731,14 @@ static const char *const yytname[] = "\"integer\"", "\"%param\"", "\"%union\"", "\"%empty\"", "$accept", "input", "prologue_declarations", "prologue_declaration", "$@1", "params", "grammar_declaration", "code_props_type", "union_name", - "symbol_declaration", "$@2", "$@3", "precedence_declaration", - "precedence_declarator", "tag.opt", "symbols.prec", "symbol.prec", - "symbols.1", "generic_symlist", "generic_symlist_item", "tag", - "symbol_def", "symbol_defs.1", "grammar", "rules_or_grammar_declaration", - "rules", "$@4", "rhses.1", "rhs", "named_ref.opt", "variable", "value", - "id", "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULLPTR + "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_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 }; #endif @@ -672,35 +756,37 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -116 +#define YYPACT_NINF -123 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-116))) + (!!((Yystate) == (-123))) -#define YYTABLE_NINF -110 +#define YYTABLE_NINF -121 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -static const yytype_int8 yypact[] = +static const yytype_int16 yypact[] = { - -116, 16, 108, -116, -116, -116, -27, -116, -116, -116, - -116, -116, -116, -24, -116, 23, 29, -116, -29, -21, - -116, 36, -116, 3, 38, 42, -116, -116, -116, 44, - 47, 71, 31, -116, -116, -116, 55, -116, -116, -116, - 30, -116, -116, 39, -116, -116, 26, -22, -22, 31, - -116, 48, -116, -116, 1, -116, -116, -116, -116, -116, - -116, -116, -116, -116, -116, -116, -116, -116, -116, -116, - -116, 45, -116, 50, 2, -116, -116, 57, 49, -116, - 63, 41, -116, 31, -116, -116, -22, -2, -22, 31, - -116, -116, -116, -116, -116, -116, -116, -116, 46, -116, - -116, -116, -116, -116, 64, -116, -116, -116, -116, 41, - -116, -116, -116, 31, -116, 51, -116, 101, -116, -116, - -116, -116, -116, -116, -116, -116, -116, -20, 40, -116, - -116, 31, 53, 58, -116, -116, 82, 57, 40, -116, - -116, -116, 57, -116, -116 + -123, 6, 109, -123, -21, -123, -123, 2, -123, -123, + -123, -123, -123, -123, -11, -123, -7, 46, -123, 3, + 13, -123, 77, -123, 43, 87, 88, -123, -123, -123, + 91, 92, 94, 32, -123, -123, -123, 162, -123, -123, + -123, 53, -123, -123, 61, -123, 30, -123, -15, -15, + -123, -123, -123, 32, 50, 32, -123, -123, -123, -123, + 64, -123, 23, -123, -123, -123, -123, -123, -123, -123, + -123, -123, -123, -123, 54, -123, 55, 8, -123, -123, + 65, 68, -123, 69, 18, 32, 60, 32, -123, 70, + -123, 16, 72, 16, -123, 70, -123, 72, 32, 32, + -123, -123, -123, -123, -123, -123, -123, -123, 105, -123, + -123, -123, -123, -123, 110, -123, -123, -123, -123, 18, + -123, -123, -123, 32, 32, -123, -123, -123, 16, 16, + -123, 147, 32, -123, -123, -123, -123, 32, 16, -123, + -123, 37, 172, -123, -123, 32, 97, 101, 99, 100, + -123, -123, -123, 116, 65, 172, -123, -123, -123, -123, + -123, 65, -123, -123 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -708,39 +794,43 @@ static const yytype_int8 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 3, 0, 0, 1, 47, 45, 0, 40, 41, 51, - 52, 53, 54, 0, 36, 0, 9, 11, 0, 0, - 7, 0, 15, 0, 0, 0, 37, 19, 20, 0, - 0, 0, 0, 26, 27, 28, 0, 6, 29, 22, - 42, 4, 5, 0, 33, 32, 55, 0, 0, 0, - 38, 0, 98, 97, 99, 10, 12, 13, 14, 16, - 17, 18, 21, 24, 25, 108, 104, 103, 106, 34, - 107, 0, 105, 0, 0, 77, 79, 95, 0, 43, - 0, 0, 56, 0, 70, 75, 48, 71, 46, 49, - 61, 39, 101, 102, 100, 8, 81, 80, 0, 78, - 2, 96, 82, 31, 23, 44, 67, 68, 69, 35, - 63, 66, 65, 50, 57, 59, 76, 72, 73, 62, - 110, 87, 30, 64, 58, 60, 74, 83, 84, 87, - 86, 0, 0, 0, 90, 91, 0, 95, 85, 92, - 93, 94, 95, 88, 89 + 3, 0, 0, 1, 0, 47, 45, 0, 40, 41, + 51, 52, 53, 54, 0, 36, 0, 9, 11, 0, + 0, 7, 0, 15, 0, 0, 0, 37, 19, 20, + 0, 0, 0, 0, 26, 27, 28, 0, 6, 30, + 22, 42, 4, 5, 0, 33, 0, 29, 0, 0, + 117, 113, 112, 0, 49, 80, 115, 83, 116, 38, + 0, 107, 108, 10, 12, 13, 14, 16, 17, 18, + 21, 24, 25, 34, 0, 114, 0, 0, 85, 87, + 105, 0, 43, 0, 0, 0, 50, 73, 76, 71, + 79, 0, 48, 65, 68, 71, 46, 64, 81, 0, + 84, 39, 110, 111, 109, 8, 89, 88, 0, 86, + 2, 106, 90, 32, 23, 44, 61, 62, 63, 35, + 57, 60, 59, 74, 0, 77, 72, 78, 66, 0, + 69, 118, 82, 121, 95, 31, 58, 75, 67, 119, + 70, 91, 92, 95, 94, 0, 0, 0, 0, 0, + 98, 56, 99, 0, 105, 93, 100, 101, 102, 103, + 104, 105, 96, 97 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = +static const yytype_int16 yypgoto[] = { - -116, -116, -116, -116, -116, -116, 120, -116, -116, -116, - -116, -116, -116, -116, 77, -116, 34, -116, -116, 43, - -116, -50, 100, -116, 75, -116, -116, -116, 21, -115, - -116, -116, 22, -116, -32, -82, -116 + -123, -123, -123, -123, -123, -123, 155, -123, -123, -123, + -123, -123, -123, -123, -123, 41, -123, -123, 112, -84, + -62, 67, -123, -83, -64, -123, -43, -123, 103, -123, + -123, -123, 33, -122, -123, -123, -45, -123, -33, -35, + -123, -123 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 2, 41, 78, 104, 73, 43, 80, 44, - 48, 47, 45, 46, 136, 113, 114, 89, 109, 110, - 111, 85, 86, 74, 75, 76, 121, 127, 128, 102, - 54, 95, 68, 77, 112, 70, 100 + -1, 1, 2, 42, 81, 114, 76, 44, 83, 45, + 49, 48, 46, 153, 119, 120, 121, 96, 92, 93, + 94, 127, 86, 87, 88, 54, 55, 77, 78, 79, + 134, 141, 142, 112, 62, 105, 56, 80, 57, 58, + 140, 110 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -748,65 +838,79 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 69, 65, -109, 71, 92, 118, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 50, 3, 90, 13, 14, - 66, 51, 143, 67, 49, 56, 52, 144, 129, 84, - 130, 26, 55, 57, 65, 126, 116, 32, 116, 58, - 93, 60, 59, 65, 65, 61, 94, 62, 72, 98, - 63, 115, 117, 131, 132, 133, 71, 119, 40, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 53, 87, - 87, 13, 14, 66, 64, 79, 67, 82, 81, -55, - 134, 115, 66, 66, 26, 67, 67, 91, 103, 120, - 32, 82, 106, 107, 108, 96, 137, 135, 101, 139, - 97, 72, 105, 122, 65, 125, 137, 140, 87, 141, - 87, 40, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 142, 42, 83, 13, 14, 15, 16, 17, 18, + 73, 89, 123, 95, 95, 50, 3, 128, -120, 74, + 98, 90, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 50, 100, 125, 14, 15, 102, 51, 59, 47, + 52, 130, 162, 50, 60, 50, 91, 27, 61, 163, + 89, 137, 89, 33, 51, 138, 95, 52, 95, 63, + 90, 122, 90, 53, 75, 108, 132, 64, 51, 125, + 51, 52, 103, 52, 41, 100, 130, 65, 104, 116, + 117, 118, 51, 125, 51, 52, 130, 52, 89, 89, + 66, 85, 67, 95, 95, 143, 122, 144, 90, 90, + 68, 69, 89, 95, 70, 71, 139, 72, 82, 100, + 84, 99, 90, 101, 106, 107, 111, 113, 115, 154, + 4, 124, 156, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 154, 129, 126, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 124, 88, 99, - 138, 0, 123, 0, 0, 36, 0, 37, 38, 0, - 0, 0, 0, 39, 40 + 29, 30, 31, 32, 33, 34, 35, 36, 133, 135, + 50, 157, 158, 159, 160, 161, 37, 43, 38, 39, + 136, 97, 131, 74, 40, 41, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 50, 155, 0, 14, 15, + 109, 0, 0, 0, 0, 145, 146, 147, 0, 0, + 0, 27, 0, 148, 149, 0, 0, 33, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, + 0, -55, 150, 0, 51, 0, 0, 52, 41, 0, + 0, 0, 0, 151, 0, 0, 0, 0, 0, 152 }; static const yytype_int16 yycheck[] = { - 32, 3, 0, 1, 3, 87, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 39, 0, 49, 16, 17, - 42, 45, 137, 45, 51, 54, 3, 142, 48, 51, - 50, 29, 3, 54, 3, 117, 86, 35, 88, 3, - 39, 3, 39, 3, 3, 3, 45, 3, 46, 47, - 3, 83, 54, 13, 14, 15, 1, 89, 56, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 45, 47, - 48, 16, 17, 42, 3, 45, 45, 51, 39, 39, - 40, 113, 42, 42, 29, 45, 45, 39, 39, 43, - 35, 51, 51, 52, 53, 50, 128, 57, 41, 131, - 50, 46, 39, 39, 3, 54, 138, 54, 86, 51, - 88, 56, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 39, 2, 46, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 113, 48, 74, - 129, -1, 109, -1, -1, 47, -1, 49, 50, -1, - -1, -1, -1, 55, 56 + 33, 46, 85, 48, 49, 3, 0, 91, 0, 1, + 53, 46, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 3, 55, 87, 16, 17, 3, 42, 39, 50, + 45, 93, 154, 3, 45, 3, 51, 29, 45, 161, + 85, 124, 87, 35, 42, 129, 91, 45, 93, 3, + 85, 84, 87, 51, 46, 47, 99, 54, 42, 123, + 42, 45, 39, 45, 56, 98, 128, 54, 45, 51, + 52, 53, 42, 137, 42, 45, 138, 45, 123, 124, + 3, 51, 39, 128, 129, 48, 119, 50, 123, 124, + 3, 3, 137, 138, 3, 3, 131, 3, 45, 132, + 39, 51, 137, 39, 50, 50, 41, 39, 39, 142, + 1, 51, 145, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 155, 51, 54, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 43, 39, + 3, 54, 51, 54, 54, 39, 47, 2, 49, 50, + 119, 49, 95, 1, 55, 56, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 3, 143, -1, 16, 17, + 77, -1, -1, -1, -1, 13, 14, 15, -1, -1, + -1, 29, -1, 21, 22, -1, -1, 35, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, + -1, 39, 40, -1, 42, -1, -1, 45, 56, -1, + -1, -1, -1, 51, -1, -1, -1, -1, -1, 57 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 59, 60, 0, 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, 47, 49, 50, 55, - 56, 61, 64, 65, 67, 70, 71, 69, 68, 51, - 39, 45, 3, 45, 88, 3, 54, 54, 3, 39, - 3, 3, 3, 3, 3, 3, 42, 45, 90, 92, - 93, 1, 46, 64, 81, 82, 83, 91, 62, 45, - 66, 39, 51, 72, 51, 79, 80, 90, 80, 75, - 92, 39, 3, 39, 45, 89, 50, 50, 47, 82, - 94, 41, 87, 39, 63, 39, 51, 52, 53, 76, - 77, 78, 92, 73, 74, 92, 79, 54, 93, 92, - 43, 84, 39, 77, 74, 54, 93, 85, 86, 48, - 50, 13, 14, 15, 40, 57, 72, 92, 86, 92, - 54, 51, 39, 87, 87 + 0, 59, 60, 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, 47, 49, 50, + 55, 56, 61, 64, 65, 67, 70, 50, 69, 68, + 3, 42, 45, 51, 83, 84, 94, 96, 97, 39, + 45, 45, 92, 3, 54, 54, 3, 39, 3, 3, + 3, 3, 3, 96, 1, 46, 64, 85, 86, 87, + 95, 62, 45, 66, 39, 51, 80, 81, 82, 94, + 97, 51, 76, 77, 78, 94, 75, 76, 84, 51, + 96, 39, 3, 39, 45, 93, 50, 50, 47, 86, + 99, 41, 91, 39, 63, 39, 51, 52, 53, 72, + 73, 74, 96, 81, 51, 82, 54, 79, 77, 51, + 78, 79, 84, 43, 88, 39, 73, 81, 77, 97, + 98, 89, 90, 48, 50, 13, 14, 15, 21, 22, + 40, 51, 57, 71, 96, 90, 96, 54, 51, 54, + 54, 39, 91, 91 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ @@ -815,15 +919,16 @@ static const yytype_uint8 yyr1[] = 0, 58, 59, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 61, 61, 61, 61, 61, 61, 61, - 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, + 61, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 66, 66, 64, 68, 67, 69, 67, 67, - 70, 71, 71, 71, 71, 72, 72, 73, 73, 74, - 74, 75, 75, 76, 76, 77, 77, 78, 78, 78, - 79, 79, 79, 79, 79, 80, 80, 81, 81, 82, - 82, 82, 84, 83, 85, 85, 85, 86, 86, 86, - 86, 86, 86, 86, 86, 87, 87, 88, 88, 89, - 89, 89, 89, 90, 90, 91, 92, 92, 93, 94, - 94 + 67, 70, 70, 70, 70, 71, 71, 72, 72, 73, + 73, 74, 74, 74, 75, 76, 76, 76, 77, 77, + 78, 79, 79, 80, 80, 80, 81, 81, 82, 82, + 83, 83, 83, 84, 84, 85, 85, 86, 86, 86, + 88, 87, 89, 89, 89, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 91, 91, 92, 93, 93, + 93, 93, 94, 94, 95, 96, 96, 97, 98, 98, + 99, 99 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -831,16 +936,17 @@ static const yytype_uint8 yyr2[] = { 0, 2, 4, 0, 2, 1, 1, 1, 3, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, - 1, 2, 0, 3, 2, 2, 1, 1, 1, 1, - 2, 1, 1, 1, 2, 3, 1, 1, 2, 3, - 1, 1, 0, 1, 3, 0, 3, 0, 3, 3, - 3, 1, 1, 1, 1, 0, 1, 1, 2, 1, - 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 3, 1, 2, 1, 2, 1, - 2, 2, 0, 4, 1, 3, 2, 0, 3, 4, - 2, 2, 3, 3, 3, 0, 1, 1, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 2 + 1, 2, 0, 3, 2, 2, 1, 1, 1, 2, + 1, 2, 1, 1, 2, 3, 1, 1, 2, 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, 4, 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 }; @@ -856,23 +962,23 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - YY_LAC_DISCARD ("YYBACKUP"); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + YY_LAC_DISCARD ("YYBACKUP"); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -995,82 +1101,106 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YY # endif switch (yytype) { - case 3: /* "string" */ -#line 189 "src/parse-gram.y" /* yacc.c:681 */ - { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).code)), yyo); } -#line 1002 "src/parse-gram.c" /* yacc.c:681 */ + case 3: /* "string" */ +#line 207 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).STRING)), yyo); } +#line 1108 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 20: /* "%error-verbose" */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).PERCENT_ERROR_VERBOSE), yyo); } +#line 1114 "src/parse-gram.c" /* yacc.c:680 */ break; case 23: /* "%<flag>" */ -#line 197 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%%%s", ((*yyvaluep).uniqstr)); } -#line 1008 "src/parse-gram.c" /* yacc.c:681 */ +#line 218 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%%%s", ((*yyvaluep).PERCENT_FLAG)); } +#line 1120 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 24: /* "%file-prefix" */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).PERCENT_FILE_PREFIX), yyo); } +#line 1126 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 28: /* "%name-prefix" */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).PERCENT_NAME_PREFIX), yyo); } +#line 1132 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 38: /* "%yacc" */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).PERCENT_YACC), yyo); } +#line 1138 "src/parse-gram.c" /* yacc.c:680 */ break; case 39: /* "{...}" */ -#line 190 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1014 "src/parse-gram.c" /* yacc.c:681 */ +#line 208 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).BRACED_CODE)); } +#line 1144 "src/parse-gram.c" /* yacc.c:680 */ break; case 40: /* "%?{...}" */ -#line 190 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1020 "src/parse-gram.c" /* yacc.c:681 */ +#line 208 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).BRACED_PREDICATE)); } +#line 1150 "src/parse-gram.c" /* yacc.c:680 */ break; case 41: /* "[identifier]" */ -#line 195 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "[%s]", ((*yyvaluep).uniqstr)); } -#line 1026 "src/parse-gram.c" /* yacc.c:681 */ +#line 216 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "[%s]", ((*yyvaluep).BRACKETED_ID)); } +#line 1156 "src/parse-gram.c" /* yacc.c:680 */ break; case 42: /* "char" */ -#line 185 "src/parse-gram.y" /* yacc.c:681 */ - { fputs (char_name (((*yyvaluep).character)), yyo); } -#line 1032 "src/parse-gram.c" /* yacc.c:681 */ +#line 204 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (char_name (((*yyvaluep).CHAR)), yyo); } +#line 1162 "src/parse-gram.c" /* yacc.c:680 */ break; case 43: /* "epilogue" */ -#line 190 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1038 "src/parse-gram.c" /* yacc.c:681 */ +#line 208 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).EPILOGUE)); } +#line 1168 "src/parse-gram.c" /* yacc.c:680 */ break; case 45: /* "identifier" */ -#line 194 "src/parse-gram.y" /* yacc.c:681 */ - { fputs (((*yyvaluep).uniqstr), yyo); } -#line 1044 "src/parse-gram.c" /* yacc.c:681 */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).ID), yyo); } +#line 1174 "src/parse-gram.c" /* yacc.c:680 */ break; case 46: /* "identifier:" */ -#line 196 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s:", ((*yyvaluep).uniqstr)); } -#line 1050 "src/parse-gram.c" /* yacc.c:681 */ +#line 217 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s:", ((*yyvaluep).ID_COLON)); } +#line 1180 "src/parse-gram.c" /* yacc.c:680 */ break; case 49: /* "%{...%}" */ -#line 190 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).code)); } -#line 1056 "src/parse-gram.c" /* yacc.c:681 */ +#line 208 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "{\n%s\n}", ((*yyvaluep).PROLOGUE)); } +#line 1186 "src/parse-gram.c" /* yacc.c:680 */ break; case 51: /* "<tag>" */ -#line 198 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); } -#line 1062 "src/parse-gram.c" /* yacc.c:681 */ +#line 219 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "<%s>", ((*yyvaluep).TAG)); } +#line 1192 "src/parse-gram.c" /* yacc.c:680 */ break; case 54: /* "integer" */ -#line 202 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%d", ((*yyvaluep).integer)); } -#line 1068 "src/parse-gram.c" /* yacc.c:681 */ +#line 222 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%d", ((*yyvaluep).INT)); } +#line 1198 "src/parse-gram.c" /* yacc.c:680 */ break; case 55: /* "%param" */ -#line 245 "src/parse-gram.y" /* yacc.c:681 */ +#line 261 "src/parse-gram.y" /* yacc.c:680 */ { - switch (((*yyvaluep).param)) + switch (((*yyvaluep).PERCENT_PARAM)) { #define CASE(In, Out) \ case param_ ## In: fputs ("%" #Out, yyo); break @@ -1081,35 +1211,107 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YY case param_none: aver (false); break; } } -#line 1085 "src/parse-gram.c" /* yacc.c:681 */ +#line 1215 "src/parse-gram.c" /* yacc.c:680 */ break; case 65: /* code_props_type */ -#line 410 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_type))); } -#line 1091 "src/parse-gram.c" /* yacc.c:681 */ +#line 397 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", code_props_type_string (((*yyvaluep).code_props_type))); } +#line 1221 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 71: /* tag.opt */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).yytype_71), yyo); } +#line 1227 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 72: /* generic_symlist */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).generic_symlist), yyo); } +#line 1233 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 73: /* generic_symlist_item */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).generic_symlist_item), yyo); } +#line 1239 "src/parse-gram.c" /* yacc.c:680 */ break; - case 74: /* symbol.prec */ -#line 206 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1097 "src/parse-gram.c" /* yacc.c:681 */ + case 74: /* tag */ +#line 219 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "<%s>", ((*yyvaluep).tag)); } +#line 1245 "src/parse-gram.c" /* yacc.c:680 */ break; - case 78: /* tag */ -#line 198 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "<%s>", ((*yyvaluep).uniqstr)); } -#line 1103 "src/parse-gram.c" /* yacc.c:681 */ + case 75: /* nterm_decls */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).nterm_decls), yyo); } +#line 1251 "src/parse-gram.c" /* yacc.c:680 */ break; - case 88: /* variable */ -#line 194 "src/parse-gram.y" /* yacc.c:681 */ - { fputs (((*yyvaluep).uniqstr), yyo); } -#line 1109 "src/parse-gram.c" /* yacc.c:681 */ + case 76: /* token_decls */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).token_decls), yyo); } +#line 1257 "src/parse-gram.c" /* yacc.c:680 */ break; - case 89: /* value */ -#line 656 "src/parse-gram.y" /* yacc.c:681 */ + case 77: /* token_decl.1 */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).yytype_77), yyo); } +#line 1263 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 78: /* token_decl */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).token_decl) ? ((*yyvaluep).token_decl)->tag : "<NULL>"); } +#line 1269 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 79: /* int.opt */ +#line 222 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%d", ((*yyvaluep).yytype_79)); } +#line 1275 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 80: /* token_decls_for_prec */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).token_decls_for_prec), yyo); } +#line 1281 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 81: /* token_decl_for_prec.1 */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).yytype_81), yyo); } +#line 1287 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 82: /* token_decl_for_prec */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).token_decl_for_prec) ? ((*yyvaluep).token_decl_for_prec)->tag : "<NULL>"); } +#line 1293 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 83: /* symbol_decls */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).symbol_decls), yyo); } +#line 1299 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 84: /* symbol_decl.1 */ +#line 231 "src/parse-gram.y" /* yacc.c:680 */ + { symbol_list_syms_print (((*yyvaluep).yytype_84), yyo); } +#line 1305 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 92: /* variable */ +#line 215 "src/parse-gram.y" /* yacc.c:680 */ + { fputs (((*yyvaluep).variable), yyo); } +#line 1311 "src/parse-gram.c" /* yacc.c:680 */ + break; + + case 93: /* value */ +#line 692 "src/parse-gram.y" /* yacc.c:680 */ { switch (((*yyvaluep).value).kind) { @@ -1118,33 +1320,38 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YY case muscle_string: fprintf (yyo, "\"%s\"", ((*yyvaluep).value).chars); break; } } -#line 1122 "src/parse-gram.c" /* yacc.c:681 */ +#line 1324 "src/parse-gram.c" /* yacc.c:680 */ break; - case 90: /* id */ -#line 206 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1128 "src/parse-gram.c" /* yacc.c:681 */ + case 94: /* id */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).id) ? ((*yyvaluep).id)->tag : "<NULL>"); } +#line 1330 "src/parse-gram.c" /* yacc.c:680 */ break; - case 91: /* id_colon */ -#line 207 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s:", ((*yyvaluep).symbol)->tag); } -#line 1134 "src/parse-gram.c" /* yacc.c:681 */ + case 95: /* id_colon */ +#line 226 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s:", ((*yyvaluep).id_colon)->tag); } +#line 1336 "src/parse-gram.c" /* yacc.c:680 */ break; - case 92: /* symbol */ -#line 206 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1140 "src/parse-gram.c" /* yacc.c:681 */ + case 96: /* symbol */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).symbol) ? ((*yyvaluep).symbol)->tag : "<NULL>"); } +#line 1342 "src/parse-gram.c" /* yacc.c:680 */ break; - case 93: /* string_as_id */ -#line 206 "src/parse-gram.y" /* yacc.c:681 */ - { fprintf (yyo, "%s", ((*yyvaluep).symbol)->tag); } -#line 1146 "src/parse-gram.c" /* yacc.c:681 */ + case 97: /* string_as_id */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).string_as_id) ? ((*yyvaluep).string_as_id)->tag : "<NULL>"); } +#line 1348 "src/parse-gram.c" /* yacc.c:680 */ break; + case 98: /* string_as_id.opt */ +#line 225 "src/parse-gram.y" /* yacc.c:680 */ + { fprintf (yyo, "%s", ((*yyvaluep).yytype_98) ? ((*yyvaluep).yytype_98)->tag : "<NULL>"); } +#line 1354 "src/parse-gram.c" /* yacc.c:680 */ + break; default: break; @@ -1210,7 +1417,7 @@ yy_reduce_print (yytype_int16 *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)]) + &yyvsp[(yyi + 1) - (yynrhs)] , &(yylsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } @@ -1546,7 +1753,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1643,10 +1853,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1674,9 +1884,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1724,7 +1935,65 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + switch (yytype) + { + case 72: /* generic_symlist */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).generic_symlist)); } +#line 1944 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 73: /* generic_symlist_item */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).generic_symlist_item)); } +#line 1950 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 75: /* nterm_decls */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).nterm_decls)); } +#line 1956 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 76: /* token_decls */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).token_decls)); } +#line 1962 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 77: /* token_decl.1 */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).yytype_77)); } +#line 1968 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 80: /* token_decls_for_prec */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).token_decls_for_prec)); } +#line 1974 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 81: /* token_decl_for_prec.1 */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).yytype_81)); } +#line 1980 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 83: /* symbol_decls */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).symbol_decls)); } +#line 1986 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + case 84: /* symbol_decl.1 */ +#line 230 "src/parse-gram.y" /* yacc.c:1257 */ + { symbol_list_free (((*yyvaluep).yytype_84)); } +#line 1992 "src/parse-gram.c" /* yacc.c:1257 */ + break; + + default: + break; + } YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1836,7 +2105,7 @@ YYLTYPE yylloc = yyloc_default; yychar = YYEMPTY; /* Cause a token to be read. */ /* User initialization code. */ -#line 109 "src/parse-gram.y" /* yacc.c:1429 */ +#line 129 "src/parse-gram.y" /* yacc.c:1431 */ { /* Bison's grammar can initial empty locations, hence a default location is needed. */ @@ -1844,27 +2113,35 @@ YYLTYPE yylloc = yyloc_default; boundary_set (&yylloc.end, current_file, 1, 1); } -#line 1848 "src/parse-gram.c" /* yacc.c:1429 */ +#line 2117 "src/parse-gram.c" /* yacc.c:1431 */ yylsp[0] = yylloc; goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1886,10 +2163,7 @@ YYLTYPE yylloc = yyloc_default; yyvs = yyvs1; yyls = yyls1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1906,12 +2180,11 @@ YYLTYPE yylloc = yyloc_default; 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); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; @@ -1923,6 +2196,7 @@ YYLTYPE yylloc = yyloc_default; if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1931,11 +2205,11 @@ YYLTYPE yylloc = yyloc_default; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -2013,7 +2287,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -2038,683 +2312,714 @@ yyreduce: switch (yyn) { case 6: -#line 281 "src/parse-gram.y" /* yacc.c:1645 */ +#line 297 "src/parse-gram.y" /* yacc.c:1652 */ { muscle_code_grow (union_seen ? "post_prologue" : "pre_prologue", - translate_code ((yyvsp[0].code), (yylsp[0]), true), (yylsp[0])); + translate_code ((yyvsp[0].PROLOGUE), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2048 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2322 "src/parse-gram.c" /* yacc.c:1652 */ break; case 7: -#line 287 "src/parse-gram.y" /* yacc.c:1645 */ +#line 303 "src/parse-gram.y" /* yacc.c:1652 */ { - muscle_percent_define_ensure ((yyvsp[0].uniqstr), (yylsp[0]), true); + muscle_percent_define_ensure ((yyvsp[0].PERCENT_FLAG), (yylsp[0]), true); } -#line 2056 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2330 "src/parse-gram.c" /* yacc.c:1652 */ break; case 8: -#line 291 "src/parse-gram.y" /* yacc.c:1645 */ +#line 307 "src/parse-gram.y" /* yacc.c:1652 */ { - muscle_percent_define_insert ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].value).kind, (yyvsp[0].value).chars, + muscle_percent_define_insert ((yyvsp[-1].variable), (yyloc), (yyvsp[0].value).kind, (yyvsp[0].value).chars, MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2065 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2339 "src/parse-gram.c" /* yacc.c:1652 */ break; case 9: -#line 295 "src/parse-gram.y" /* yacc.c:1645 */ +#line 311 "src/parse-gram.y" /* yacc.c:1652 */ { defines_flag = true; } -#line 2071 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2345 "src/parse-gram.c" /* yacc.c:1652 */ break; case 10: -#line 297 "src/parse-gram.y" /* yacc.c:1645 */ +#line 313 "src/parse-gram.y" /* yacc.c:1652 */ { defines_flag = true; - spec_defines_file = xstrdup ((yyvsp[0].code)); + spec_defines_file = xstrdup ((yyvsp[0].STRING)); } -#line 2080 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2354 "src/parse-gram.c" /* yacc.c:1652 */ break; case 11: -#line 302 "src/parse-gram.y" /* yacc.c:1645 */ - { - muscle_percent_define_insert ("parse.error", (yylsp[0]), muscle_keyword, - "verbose", - MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); - } -#line 2090 "src/parse-gram.c" /* yacc.c:1645 */ +#line 317 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_error_verbose (&(yyloc), (yyvsp[0].PERCENT_ERROR_VERBOSE)); } +#line 2360 "src/parse-gram.c" /* yacc.c:1652 */ break; case 12: -#line 307 "src/parse-gram.y" /* yacc.c:1645 */ - { expected_sr_conflicts = (yyvsp[0].integer); } -#line 2096 "src/parse-gram.c" /* yacc.c:1645 */ +#line 318 "src/parse-gram.y" /* yacc.c:1652 */ + { expected_sr_conflicts = (yyvsp[0].INT); } +#line 2366 "src/parse-gram.c" /* yacc.c:1652 */ break; case 13: -#line 308 "src/parse-gram.y" /* yacc.c:1645 */ - { expected_rr_conflicts = (yyvsp[0].integer); } -#line 2102 "src/parse-gram.c" /* yacc.c:1645 */ +#line 319 "src/parse-gram.y" /* yacc.c:1652 */ + { expected_rr_conflicts = (yyvsp[0].INT); } +#line 2372 "src/parse-gram.c" /* yacc.c:1652 */ break; case 14: -#line 309 "src/parse-gram.y" /* yacc.c:1645 */ - { spec_file_prefix = (yyvsp[0].code); } -#line 2108 "src/parse-gram.c" /* yacc.c:1645 */ +#line 320 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_file_prefix (&(yyloc), &(yylsp[-1]), (yyvsp[-1].PERCENT_FILE_PREFIX), (yyvsp[0].STRING)); } +#line 2378 "src/parse-gram.c" /* yacc.c:1652 */ break; case 15: -#line 311 "src/parse-gram.y" /* yacc.c:1645 */ +#line 322 "src/parse-gram.y" /* yacc.c:1652 */ { nondeterministic_parser = true; glr_parser = true; } -#line 2117 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2387 "src/parse-gram.c" /* yacc.c:1652 */ break; case 16: -#line 316 "src/parse-gram.y" /* yacc.c:1645 */ +#line 327 "src/parse-gram.y" /* yacc.c:1652 */ { - muscle_code_grow ("initial_action", translate_code ((yyvsp[0].code), (yylsp[0]), false), (yylsp[0])); + muscle_code_grow ("initial_action", translate_code ((yyvsp[0].BRACED_CODE), (yylsp[0]), false), (yylsp[0])); code_scanner_last_string_free (); } -#line 2126 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2396 "src/parse-gram.c" /* yacc.c:1652 */ break; case 17: -#line 320 "src/parse-gram.y" /* yacc.c:1645 */ - { language_argmatch ((yyvsp[0].code), grammar_prio, (yylsp[-1])); } -#line 2132 "src/parse-gram.c" /* yacc.c:1645 */ +#line 331 "src/parse-gram.y" /* yacc.c:1652 */ + { language_argmatch ((yyvsp[0].STRING), grammar_prio, (yylsp[-1])); } +#line 2402 "src/parse-gram.c" /* yacc.c:1652 */ break; case 18: -#line 321 "src/parse-gram.y" /* yacc.c:1645 */ - { spec_name_prefix = (yyvsp[0].code); } -#line 2138 "src/parse-gram.c" /* yacc.c:1645 */ +#line 332 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_name_prefix (&(yyloc), (yyvsp[-1].PERCENT_NAME_PREFIX), (yyvsp[0].STRING)); } +#line 2408 "src/parse-gram.c" /* yacc.c:1652 */ break; case 19: -#line 322 "src/parse-gram.y" /* yacc.c:1645 */ +#line 333 "src/parse-gram.y" /* yacc.c:1652 */ { no_lines_flag = true; } -#line 2144 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2414 "src/parse-gram.c" /* yacc.c:1652 */ break; case 20: -#line 323 "src/parse-gram.y" /* yacc.c:1645 */ +#line 334 "src/parse-gram.y" /* yacc.c:1652 */ { nondeterministic_parser = true; } -#line 2150 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2420 "src/parse-gram.c" /* yacc.c:1652 */ break; case 21: -#line 324 "src/parse-gram.y" /* yacc.c:1645 */ - { spec_outfile = (yyvsp[0].code); } -#line 2156 "src/parse-gram.c" /* yacc.c:1645 */ +#line 335 "src/parse-gram.y" /* yacc.c:1652 */ + { spec_outfile = (yyvsp[0].STRING); } +#line 2426 "src/parse-gram.c" /* yacc.c:1652 */ break; case 22: -#line 325 "src/parse-gram.y" /* yacc.c:1645 */ - { current_param = (yyvsp[0].param); } -#line 2162 "src/parse-gram.c" /* yacc.c:1645 */ +#line 336 "src/parse-gram.y" /* yacc.c:1652 */ + { current_param = (yyvsp[0].PERCENT_PARAM); } +#line 2432 "src/parse-gram.c" /* yacc.c:1652 */ break; case 23: -#line 325 "src/parse-gram.y" /* yacc.c:1645 */ +#line 336 "src/parse-gram.y" /* yacc.c:1652 */ { current_param = param_none; } -#line 2168 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2438 "src/parse-gram.c" /* yacc.c:1652 */ break; case 24: -#line 326 "src/parse-gram.y" /* yacc.c:1645 */ - { version_check (&(yylsp[0]), (yyvsp[0].code)); } -#line 2174 "src/parse-gram.c" /* yacc.c:1645 */ +#line 337 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_require (&(yylsp[0]), (yyvsp[0].STRING)); } +#line 2444 "src/parse-gram.c" /* yacc.c:1652 */ break; case 25: -#line 328 "src/parse-gram.y" /* yacc.c:1645 */ - { - char const *skeleton_user = (yyvsp[0].code); - if (strchr (skeleton_user, '/')) - { - size_t dir_length = strlen (current_file); - char *skeleton_build; - while (dir_length && current_file[dir_length - 1] != '/') - --dir_length; - while (dir_length && current_file[dir_length - 1] == '/') - --dir_length; - skeleton_build = - xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); - if (dir_length > 0) - { - memcpy (skeleton_build, current_file, dir_length); - skeleton_build[dir_length++] = '/'; - } - strcpy (skeleton_build + dir_length, skeleton_user); - skeleton_user = uniqstr_new (skeleton_build); - free (skeleton_build); - } - skeleton_arg (skeleton_user, grammar_prio, (yylsp[-1])); - } -#line 2202 "src/parse-gram.c" /* yacc.c:1645 */ +#line 338 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_skeleton (&(yylsp[0]), (yyvsp[0].STRING)); } +#line 2450 "src/parse-gram.c" /* yacc.c:1652 */ break; case 26: -#line 351 "src/parse-gram.y" /* yacc.c:1645 */ +#line 339 "src/parse-gram.y" /* yacc.c:1652 */ { token_table_flag = true; } -#line 2208 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2456 "src/parse-gram.c" /* yacc.c:1652 */ break; case 27: -#line 352 "src/parse-gram.y" /* yacc.c:1645 */ +#line 340 "src/parse-gram.y" /* yacc.c:1652 */ { report_flag |= report_states; } -#line 2214 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2462 "src/parse-gram.c" /* yacc.c:1652 */ break; case 28: -#line 353 "src/parse-gram.y" /* yacc.c:1645 */ - { yacc_flag = true; } -#line 2220 "src/parse-gram.c" /* yacc.c:1645 */ +#line 341 "src/parse-gram.y" /* yacc.c:1652 */ + { handle_yacc (&(yyloc), (yyvsp[0].PERCENT_YACC)); } +#line 2468 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 30: -#line 358 "src/parse-gram.y" /* yacc.c:1645 */ - { add_param (current_param, (yyvsp[0].code), (yylsp[0])); } -#line 2226 "src/parse-gram.c" /* yacc.c:1645 */ + case 29: +#line 342 "src/parse-gram.y" /* yacc.c:1652 */ + { current_class = unknown_sym; yyerrok; } +#line 2474 "src/parse-gram.c" /* yacc.c:1652 */ break; case 31: -#line 359 "src/parse-gram.y" /* yacc.c:1645 */ - { add_param (current_param, (yyvsp[0].code), (yylsp[0])); } -#line 2232 "src/parse-gram.c" /* yacc.c:1645 */ +#line 347 "src/parse-gram.y" /* yacc.c:1652 */ + { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); } +#line 2480 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 32: +#line 348 "src/parse-gram.y" /* yacc.c:1652 */ + { add_param (current_param, (yyvsp[0].BRACED_CODE), (yylsp[0])); } +#line 2486 "src/parse-gram.c" /* yacc.c:1652 */ break; case 34: -#line 371 "src/parse-gram.y" /* yacc.c:1645 */ +#line 359 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2240 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2494 "src/parse-gram.c" /* yacc.c:1652 */ break; case 35: -#line 375 "src/parse-gram.y" /* yacc.c:1645 */ +#line 363 "src/parse-gram.y" /* yacc.c:1652 */ { code_props code; - code_props_symbol_action_init (&code, (yyvsp[-1].code), (yylsp[-1])); + code_props_symbol_action_init (&code, (yyvsp[-1].BRACED_CODE), (yylsp[-1])); code_props_translate_code (&code); { - for (symbol_list *list = (yyvsp[0].list); list; list = list->next) - symbol_list_code_props_set (list, (yyvsp[-2].code_type), &code); - symbol_list_free ((yyvsp[0].list)); + for (symbol_list *list = (yyvsp[0].generic_symlist); list; list = list->next) + symbol_list_code_props_set (list, (yyvsp[-2].code_props_type), &code); + symbol_list_free ((yyvsp[0].generic_symlist)); } } -#line 2255 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2509 "src/parse-gram.c" /* yacc.c:1652 */ break; case 36: -#line 386 "src/parse-gram.y" /* yacc.c:1645 */ +#line 374 "src/parse-gram.y" /* yacc.c:1652 */ { default_prec = true; } -#line 2263 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2517 "src/parse-gram.c" /* yacc.c:1652 */ break; case 37: -#line 390 "src/parse-gram.y" /* yacc.c:1645 */ +#line 378 "src/parse-gram.y" /* yacc.c:1652 */ { default_prec = false; } -#line 2271 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2525 "src/parse-gram.c" /* yacc.c:1652 */ break; case 38: -#line 394 "src/parse-gram.y" /* yacc.c:1645 */ +#line 382 "src/parse-gram.y" /* yacc.c:1652 */ { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ muscle_code_grow ("percent_code()", - translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); + translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2283 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2537 "src/parse-gram.c" /* yacc.c:1652 */ break; case 39: -#line 402 "src/parse-gram.y" /* yacc.c:1645 */ +#line 390 "src/parse-gram.y" /* yacc.c:1652 */ { - muscle_percent_code_grow ((yyvsp[-1].uniqstr), (yylsp[-1]), translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); + 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 2292 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2546 "src/parse-gram.c" /* yacc.c:1652 */ break; case 40: -#line 412 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.code_type) = destructor; } -#line 2298 "src/parse-gram.c" /* yacc.c:1645 */ +#line 399 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.code_props_type) = destructor; } +#line 2552 "src/parse-gram.c" /* yacc.c:1652 */ break; case 41: -#line 413 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.code_type) = printer; } -#line 2304 "src/parse-gram.c" /* yacc.c:1645 */ +#line 400 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.code_props_type) = printer; } +#line 2558 "src/parse-gram.c" /* yacc.c:1652 */ break; case 42: -#line 423 "src/parse-gram.y" /* yacc.c:1645 */ +#line 410 "src/parse-gram.y" /* yacc.c:1652 */ {} -#line 2310 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2564 "src/parse-gram.c" /* yacc.c:1652 */ break; case 43: -#line 424 "src/parse-gram.y" /* yacc.c:1645 */ +#line 411 "src/parse-gram.y" /* yacc.c:1652 */ { muscle_percent_define_insert ("api.value.union.name", - (yylsp[0]), muscle_keyword, (yyvsp[0].uniqstr), + (yylsp[0]), muscle_keyword, (yyvsp[0].ID), MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } -#line 2318 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2572 "src/parse-gram.c" /* yacc.c:1652 */ break; case 44: -#line 431 "src/parse-gram.y" /* yacc.c:1645 */ +#line 418 "src/parse-gram.y" /* yacc.c:1652 */ { union_seen = true; - muscle_code_grow ("union_members", translate_code_braceless ((yyvsp[0].code), (yylsp[0])), (yylsp[0])); + muscle_code_grow ("union_members", translate_code_braceless ((yyvsp[0].BRACED_CODE), (yylsp[0])), (yylsp[0])); code_scanner_last_string_free (); } -#line 2328 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2582 "src/parse-gram.c" /* yacc.c:1652 */ break; case 45: -#line 442 "src/parse-gram.y" /* yacc.c:1645 */ +#line 430 "src/parse-gram.y" /* yacc.c:1652 */ { current_class = nterm_sym; } -#line 2334 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2588 "src/parse-gram.c" /* yacc.c:1652 */ break; case 46: -#line 443 "src/parse-gram.y" /* yacc.c:1645 */ +#line 431 "src/parse-gram.y" /* yacc.c:1652 */ { current_class = unknown_sym; - current_type = NULL; + symbol_list_free ((yyvsp[0].nterm_decls)); } -#line 2343 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2597 "src/parse-gram.c" /* yacc.c:1652 */ break; case 47: -#line 447 "src/parse-gram.y" /* yacc.c:1645 */ +#line 435 "src/parse-gram.y" /* yacc.c:1652 */ { current_class = token_sym; } -#line 2349 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2603 "src/parse-gram.c" /* yacc.c:1652 */ break; case 48: -#line 448 "src/parse-gram.y" /* yacc.c:1645 */ +#line 436 "src/parse-gram.y" /* yacc.c:1652 */ { current_class = unknown_sym; - current_type = NULL; + symbol_list_free ((yyvsp[0].token_decls)); } -#line 2358 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2612 "src/parse-gram.c" /* yacc.c:1652 */ break; case 49: -#line 453 "src/parse-gram.y" /* yacc.c:1645 */ +#line 441 "src/parse-gram.y" /* yacc.c:1652 */ { - tag_seen = true; - for (symbol_list *list = (yyvsp[0].list); list; list = list->next) - symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1])); - symbol_list_free ((yyvsp[0].list)); + symbol_list_free ((yyvsp[0].symbol_decls)); } -#line 2369 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2620 "src/parse-gram.c" /* yacc.c:1652 */ break; case 50: -#line 463 "src/parse-gram.y" /* yacc.c:1645 */ +#line 445 "src/parse-gram.y" /* yacc.c:1652 */ { ++current_prec; - for (symbol_list *list = (yyvsp[0].list); list; list = list->next) - { - symbol_type_set (list->content.sym, current_type, (yylsp[-1])); - symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2])); - } - symbol_list_free ((yyvsp[0].list)); - current_type = NULL; + 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 2384 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2631 "src/parse-gram.c" /* yacc.c:1652 */ break; case 51: -#line 476 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.assoc) = left_assoc; } -#line 2390 "src/parse-gram.c" /* yacc.c:1645 */ +#line 454 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.precedence_declarator) = left_assoc; } +#line 2637 "src/parse-gram.c" /* yacc.c:1652 */ break; case 52: -#line 477 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.assoc) = right_assoc; } -#line 2396 "src/parse-gram.c" /* yacc.c:1645 */ +#line 455 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.precedence_declarator) = right_assoc; } +#line 2643 "src/parse-gram.c" /* yacc.c:1652 */ break; case 53: -#line 478 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.assoc) = non_assoc; } -#line 2402 "src/parse-gram.c" /* yacc.c:1645 */ +#line 456 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.precedence_declarator) = non_assoc; } +#line 2649 "src/parse-gram.c" /* yacc.c:1652 */ break; case 54: -#line 479 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.assoc) = precedence_assoc; } -#line 2408 "src/parse-gram.c" /* yacc.c:1645 */ +#line 457 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.precedence_declarator) = precedence_assoc; } +#line 2655 "src/parse-gram.c" /* yacc.c:1652 */ break; case 55: -#line 483 "src/parse-gram.y" /* yacc.c:1645 */ - { current_type = NULL; } -#line 2414 "src/parse-gram.c" /* yacc.c:1645 */ +#line 461 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_71) = NULL; } +#line 2661 "src/parse-gram.c" /* yacc.c:1652 */ break; case 56: -#line 484 "src/parse-gram.y" /* yacc.c:1645 */ - { current_type = (yyvsp[0].uniqstr); tag_seen = true; } -#line 2420 "src/parse-gram.c" /* yacc.c:1645 */ - break; - - case 57: -#line 490 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2426 "src/parse-gram.c" /* yacc.c:1645 */ +#line 462 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_71) = (yyvsp[0].TAG); } +#line 2667 "src/parse-gram.c" /* yacc.c:1652 */ break; case 58: -#line 492 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_append ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } -#line 2432 "src/parse-gram.c" /* yacc.c:1645 */ +#line 468 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.generic_symlist) = symbol_list_append ((yyvsp[-1].generic_symlist), (yyvsp[0].generic_symlist_item)); } +#line 2673 "src/parse-gram.c" /* yacc.c:1652 */ break; case 59: -#line 497 "src/parse-gram.y" /* yacc.c:1645 */ - { - (yyval.symbol) = (yyvsp[0].symbol); - symbol_class_set ((yyvsp[0].symbol), token_sym, (yylsp[0]), false); - } -#line 2441 "src/parse-gram.c" /* yacc.c:1645 */ +#line 472 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.generic_symlist_item) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } +#line 2679 "src/parse-gram.c" /* yacc.c:1652 */ break; case 60: -#line 502 "src/parse-gram.y" /* yacc.c:1645 */ - { - (yyval.symbol) = (yyvsp[-1].symbol); - symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); - symbol_class_set ((yyvsp[-1].symbol), token_sym, (yylsp[-1]), false); - } -#line 2451 "src/parse-gram.c" /* yacc.c:1645 */ - break; - - case 61: -#line 512 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2457 "src/parse-gram.c" /* yacc.c:1645 */ +#line 473 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.generic_symlist_item) = symbol_list_type_new ((yyvsp[0].tag), (yylsp[0])); } +#line 2685 "src/parse-gram.c" /* yacc.c:1652 */ break; case 62: -#line 514 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_append ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } -#line 2463 "src/parse-gram.c" /* yacc.c:1645 */ +#line 478 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.tag) = uniqstr_new ("*"); } +#line 2691 "src/parse-gram.c" /* yacc.c:1652 */ break; case 63: -#line 518 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = (yyvsp[0].list); } -#line 2469 "src/parse-gram.c" /* yacc.c:1645 */ - break; - - case 64: -#line 519 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_append ((yyvsp[-1].list), (yyvsp[0].list)); } -#line 2475 "src/parse-gram.c" /* yacc.c:1645 */ +#line 479 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.tag) = uniqstr_new (""); } +#line 2697 "src/parse-gram.c" /* yacc.c:1652 */ break; case 65: -#line 523 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } -#line 2481 "src/parse-gram.c" /* yacc.c:1645 */ +#line 502 "src/parse-gram.y" /* yacc.c:1652 */ + { + (yyval.token_decls) = (yyvsp[0].yytype_77); + } +#line 2705 "src/parse-gram.c" /* yacc.c:1652 */ break; case 66: -#line 524 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.list) = symbol_list_type_new ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2487 "src/parse-gram.c" /* yacc.c:1645 */ +#line 506 "src/parse-gram.y" /* yacc.c:1652 */ + { + (yyval.token_decls) = symbol_list_type_set ((yyvsp[0].yytype_77), (yyvsp[-1].TAG), (yylsp[-1])); + } +#line 2713 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 67: +#line 510 "src/parse-gram.y" /* yacc.c:1652 */ + { + (yyval.token_decls) = symbol_list_append ((yyvsp[-2].token_decls), symbol_list_type_set ((yyvsp[0].yytype_77), (yyvsp[-1].TAG), (yylsp[-1]))); + } +#line 2721 "src/parse-gram.c" /* yacc.c:1652 */ break; case 68: -#line 529 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.uniqstr) = uniqstr_new ("*"); } -#line 2493 "src/parse-gram.c" /* yacc.c:1645 */ +#line 517 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_77) = symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0])); } +#line 2727 "src/parse-gram.c" /* yacc.c:1652 */ break; case 69: -#line 530 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.uniqstr) = uniqstr_new (""); } -#line 2499 "src/parse-gram.c" /* yacc.c:1645 */ +#line 518 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_77) = symbol_list_append ((yyvsp[-1].yytype_77), symbol_list_sym_new ((yyvsp[0].token_decl), (yylsp[0]))); } +#line 2733 "src/parse-gram.c" /* yacc.c:1652 */ break; case 70: -#line 536 "src/parse-gram.y" /* yacc.c:1645 */ +#line 523 "src/parse-gram.y" /* yacc.c:1652 */ { - current_type = (yyvsp[0].uniqstr); - tag_seen = true; + (yyval.token_decl) = (yyvsp[-2].id); + symbol_class_set ((yyvsp[-2].id), current_class, (yylsp[-2]), true); + if (0 <= (yyvsp[-1].yytype_79)) + symbol_user_token_number_set ((yyvsp[-2].id), (yyvsp[-1].yytype_79), (yylsp[-1])); + if ((yyvsp[0].yytype_98)) + symbol_make_alias ((yyvsp[-2].id), (yyvsp[0].yytype_98), (yylsp[0])); } -#line 2508 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2746 "src/parse-gram.c" /* yacc.c:1652 */ break; case 71: -#line 541 "src/parse-gram.y" /* yacc.c:1645 */ +#line 535 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_79) = -1; } +#line 2752 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 73: +#line 549 "src/parse-gram.y" /* yacc.c:1652 */ { - symbol_class_set ((yyvsp[0].symbol), current_class, (yylsp[0]), true); - symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0])); + (yyval.token_decls_for_prec) = (yyvsp[0].yytype_81); } -#line 2517 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2760 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 72: -#line 546 "src/parse-gram.y" /* yacc.c:1645 */ + case 74: +#line 553 "src/parse-gram.y" /* yacc.c:1652 */ { - symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true); - symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); - symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); + (yyval.token_decls_for_prec) = symbol_list_type_set ((yyvsp[0].yytype_81), (yyvsp[-1].TAG), (yylsp[-1])); } -#line 2527 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2768 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 73: -#line 552 "src/parse-gram.y" /* yacc.c:1645 */ + case 75: +#line 557 "src/parse-gram.y" /* yacc.c:1652 */ { - symbol_class_set ((yyvsp[-1].symbol), current_class, (yylsp[-1]), true); - symbol_type_set ((yyvsp[-1].symbol), current_type, (yylsp[-1])); - symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc)); + (yyval.token_decls_for_prec) = symbol_list_append ((yyvsp[-2].token_decls_for_prec), symbol_list_type_set ((yyvsp[0].yytype_81), (yyvsp[-1].TAG), (yylsp[-1]))); } -#line 2537 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2776 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 74: -#line 558 "src/parse-gram.y" /* yacc.c:1645 */ + case 76: +#line 565 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_81) = symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0])); } +#line 2782 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 77: +#line 567 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_81) = symbol_list_append ((yyvsp[-1].yytype_81), symbol_list_sym_new ((yyvsp[0].token_decl_for_prec), (yylsp[0]))); } +#line 2788 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 78: +#line 572 "src/parse-gram.y" /* yacc.c:1652 */ + { + (yyval.token_decl_for_prec) = (yyvsp[-1].id); + symbol_class_set ((yyvsp[-1].id), token_sym, (yylsp[-1]), false); + if (0 <= (yyvsp[0].yytype_79)) + symbol_user_token_number_set ((yyvsp[-1].id), (yyvsp[0].yytype_79), (yylsp[0])); + } +#line 2799 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 80: +#line 589 "src/parse-gram.y" /* yacc.c:1652 */ { - symbol_class_set ((yyvsp[-2].symbol), current_class, (yylsp[-2]), true); - symbol_type_set ((yyvsp[-2].symbol), current_type, (yylsp[-2])); - symbol_user_token_number_set ((yyvsp[-2].symbol), (yyvsp[-1].integer), (yylsp[-1])); - symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc)); + (yyval.symbol_decls) = (yyvsp[0].yytype_84); } -#line 2548 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2807 "src/parse-gram.c" /* yacc.c:1652 */ break; case 81: -#line 588 "src/parse-gram.y" /* yacc.c:1645 */ +#line 593 "src/parse-gram.y" /* yacc.c:1652 */ { - yyerrok; + (yyval.symbol_decls) = symbol_list_type_set ((yyvsp[0].yytype_84), (yyvsp[-1].TAG), (yylsp[-1])); } -#line 2556 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2815 "src/parse-gram.c" /* yacc.c:1652 */ break; case 82: -#line 594 "src/parse-gram.y" /* yacc.c:1645 */ - { current_lhs ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); } -#line 2562 "src/parse-gram.c" /* yacc.c:1645 */ +#line 597 "src/parse-gram.y" /* yacc.c:1652 */ + { + (yyval.symbol_decls) = symbol_list_append ((yyvsp[-2].symbol_decls), symbol_list_type_set ((yyvsp[0].yytype_84), (yyvsp[-1].TAG), (yylsp[-1]))); + } +#line 2823 "src/parse-gram.c" /* yacc.c:1652 */ break; case 83: -#line 595 "src/parse-gram.y" /* yacc.c:1645 */ - { - /* Free the current lhs. */ - current_lhs (0, (yylsp[-3]), 0); - } -#line 2571 "src/parse-gram.c" /* yacc.c:1645 */ +#line 604 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_84) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } +#line 2829 "src/parse-gram.c" /* yacc.c:1652 */ break; case 84: -#line 602 "src/parse-gram.y" /* yacc.c:1645 */ +#line 605 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_84) = symbol_list_append ((yyvsp[-1].yytype_84), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } +#line 2835 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 89: +#line 623 "src/parse-gram.y" /* yacc.c:1652 */ + { + yyerrok; + } +#line 2843 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 90: +#line 629 "src/parse-gram.y" /* yacc.c:1652 */ + { current_lhs ((yyvsp[-1].id_colon), (yylsp[-1]), (yyvsp[0].yytype_91)); } +#line 2849 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 91: +#line 630 "src/parse-gram.y" /* yacc.c:1652 */ + { + /* Free the current lhs. */ + current_lhs (0, (yylsp[-3]), 0); + } +#line 2858 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 92: +#line 637 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_current_rule_end ((yylsp[0])); } -#line 2577 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2864 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 85: -#line 603 "src/parse-gram.y" /* yacc.c:1645 */ + case 93: +#line 638 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_current_rule_end ((yylsp[0])); } -#line 2583 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2870 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 87: -#line 610 "src/parse-gram.y" /* yacc.c:1645 */ + case 95: +#line 645 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_current_rule_begin (current_lhs_symbol, current_lhs_location, current_lhs_named_ref); } -#line 2590 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2877 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 88: -#line 613 "src/parse-gram.y" /* yacc.c:1645 */ - { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].named_ref)); } -#line 2596 "src/parse-gram.c" /* yacc.c:1645 */ + case 96: +#line 648 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_symbol_append ((yyvsp[-1].symbol), (yylsp[-1]), (yyvsp[0].yytype_91)); } +#line 2883 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 89: -#line 615 "src/parse-gram.y" /* yacc.c:1645 */ - { grammar_current_rule_action_append ((yyvsp[-1].code), (yylsp[-1]), (yyvsp[0].named_ref), current_type); } -#line 2602 "src/parse-gram.c" /* yacc.c:1645 */ + case 97: +#line 650 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_action_append ((yyvsp[-1].BRACED_CODE), (yylsp[-1]), (yyvsp[0].yytype_91), (yyvsp[-2].yytype_71)); } +#line 2889 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 90: -#line 617 "src/parse-gram.y" /* yacc.c:1645 */ - { grammar_current_rule_predicate_append ((yyvsp[0].code), (yylsp[0])); } -#line 2608 "src/parse-gram.c" /* yacc.c:1645 */ + case 98: +#line 652 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_predicate_append ((yyvsp[0].BRACED_PREDICATE), (yylsp[0])); } +#line 2895 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 91: -#line 619 "src/parse-gram.y" /* yacc.c:1645 */ + case 99: +#line 654 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_current_rule_empty_set ((yylsp[0])); } -#line 2614 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2901 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 92: -#line 621 "src/parse-gram.y" /* yacc.c:1645 */ + case 100: +#line 656 "src/parse-gram.y" /* yacc.c:1652 */ { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); } -#line 2620 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2907 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 93: -#line 623 "src/parse-gram.y" /* yacc.c:1645 */ - { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); } -#line 2626 "src/parse-gram.c" /* yacc.c:1645 */ + case 101: +#line 658 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_dprec_set ((yyvsp[0].INT), (yylsp[0])); } +#line 2913 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 94: -#line 625 "src/parse-gram.y" /* yacc.c:1645 */ - { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2632 "src/parse-gram.c" /* yacc.c:1645 */ + case 102: +#line 660 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_merge_set ((yyvsp[0].TAG), (yylsp[0])); } +#line 2919 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 95: -#line 629 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.named_ref) = 0; } -#line 2638 "src/parse-gram.c" /* yacc.c:1645 */ + case 103: +#line 662 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_expect_sr ((yyvsp[0].INT), (yylsp[0])); } +#line 2925 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 96: -#line 630 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.named_ref) = named_ref_new ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2644 "src/parse-gram.c" /* yacc.c:1645 */ + case 104: +#line 664 "src/parse-gram.y" /* yacc.c:1652 */ + { grammar_current_rule_expect_rr ((yyvsp[0].INT), (yylsp[0])); } +#line 2931 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 98: -#line 641 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.uniqstr) = uniqstr_new ((yyvsp[0].code)); } -#line 2650 "src/parse-gram.c" /* yacc.c:1645 */ + case 105: +#line 668 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_91) = 0; } +#line 2937 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 99: -#line 666 "src/parse-gram.y" /* yacc.c:1645 */ + case 106: +#line 669 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_91) = named_ref_new ((yyvsp[0].BRACKETED_ID), (yylsp[0])); } +#line 2943 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 108: +#line 702 "src/parse-gram.y" /* yacc.c:1652 */ { (yyval.value).kind = muscle_keyword; (yyval.value).chars = ""; } -#line 2656 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2949 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 100: -#line 667 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.value).kind = muscle_keyword; (yyval.value).chars = (yyvsp[0].uniqstr); } -#line 2662 "src/parse-gram.c" /* yacc.c:1645 */ + case 109: +#line 703 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.value).kind = muscle_keyword; (yyval.value).chars = (yyvsp[0].ID); } +#line 2955 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 101: -#line 668 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.value).kind = muscle_string; (yyval.value).chars = (yyvsp[0].code); } -#line 2668 "src/parse-gram.c" /* yacc.c:1645 */ + case 110: +#line 704 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.value).kind = muscle_string; (yyval.value).chars = (yyvsp[0].STRING); } +#line 2961 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 102: -#line 669 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.value).kind = muscle_code; (yyval.value).chars = strip_braces ((yyvsp[0].code)); } -#line 2674 "src/parse-gram.c" /* yacc.c:1645 */ + case 111: +#line 705 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.value).kind = muscle_code; (yyval.value).chars = strip_braces ((yyvsp[0].BRACED_CODE)); } +#line 2967 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 103: -#line 682 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2680 "src/parse-gram.c" /* yacc.c:1645 */ + case 112: +#line 718 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.id) = symbol_from_uniqstr ((yyvsp[0].ID), (yylsp[0])); } +#line 2973 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 104: -#line 684 "src/parse-gram.y" /* yacc.c:1645 */ + case 113: +#line 720 "src/parse-gram.y" /* yacc.c:1652 */ { - (yyval.symbol) = symbol_get (char_name ((yyvsp[0].character)), (yylsp[0])); - symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false); - symbol_user_token_number_set ((yyval.symbol), (yyvsp[0].character), (yylsp[0])); + if (current_class == nterm_sym) + { + gram_error (&(yylsp[0]), + _("character literals cannot be nonterminals")); + YYERROR; + } + (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 2690 "src/parse-gram.c" /* yacc.c:1645 */ +#line 2989 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 105: -#line 692 "src/parse-gram.y" /* yacc.c:1645 */ - { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } -#line 2696 "src/parse-gram.c" /* yacc.c:1645 */ + case 114: +#line 734 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.id_colon) = symbol_from_uniqstr ((yyvsp[0].ID_COLON), (yylsp[0])); } +#line 2995 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 108: -#line 704 "src/parse-gram.y" /* yacc.c:1645 */ + case 117: +#line 746 "src/parse-gram.y" /* yacc.c:1652 */ { - (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].code)), (yylsp[0])); - symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false); + (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 2705 "src/parse-gram.c" /* yacc.c:1645 */ +#line 3004 "src/parse-gram.c" /* yacc.c:1652 */ break; - case 110: -#line 713 "src/parse-gram.y" /* yacc.c:1645 */ + case 118: +#line 754 "src/parse-gram.y" /* yacc.c:1652 */ + { (yyval.yytype_98) = NULL; } +#line 3010 "src/parse-gram.c" /* yacc.c:1652 */ + break; + + case 121: +#line 761 "src/parse-gram.y" /* yacc.c:1652 */ { - muscle_code_grow ("epilogue", translate_code ((yyvsp[0].code), (yylsp[0]), true), (yylsp[0])); + muscle_code_grow ("epilogue", translate_code ((yyvsp[0].EPILOGUE), (yylsp[0]), true), (yylsp[0])); code_scanner_last_string_free (); } -#line 2714 "src/parse-gram.c" /* yacc.c:1645 */ +#line 3019 "src/parse-gram.c" /* yacc.c:1652 */ break; -#line 2718 "src/parse-gram.c" /* yacc.c:1645 */ +#line 3023 "src/parse-gram.c" /* yacc.c:1652 */ default: break; } if (yychar_backup != yychar) @@ -2835,12 +3140,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2911,6 +3214,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2918,6 +3222,7 @@ yyabortlab: yyresult = 1; goto yyreturn; + #if 1 /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -2928,6 +3233,10 @@ yyexhaustedlab: /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2959,7 +3268,7 @@ yyreturn: #endif return yyresult; } -#line 719 "src/parse-gram.y" /* yacc.c:1903 */ +#line 767 "src/parse-gram.y" /* yacc.c:1918 */ /* Return the location of the left-hand side of a rule whose @@ -3065,7 +3374,74 @@ add_param (param_type type, char *decl, location loc) static void -version_check (location const *loc, char const *version) +handle_error_verbose (location const *loc, char const *directive) +{ + bison_directive (loc, directive); + muscle_percent_define_insert (directive, *loc, muscle_keyword, "", + MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); +} + + +static void +handle_file_prefix (location const *loc, + location const *dir_loc, + char const *directive, char const *value) +{ + bison_directive (loc, directive); + bool warned = false; + + if (location_empty (spec_file_prefix_loc)) + { + spec_file_prefix_loc = *loc; + spec_file_prefix = value; + } + else + { + duplicate_directive (directive, spec_file_prefix_loc, *loc); + warned = true; + } + + if (!warned + && STRNEQ (directive, "%file-prefix")) + deprecated_directive (dir_loc, directive, "%file-prefix"); +} + +static void +handle_name_prefix (location const *loc, + char const *directive, char const *value) +{ + bison_directive (loc, directive); + + char buf1[1024]; + size_t len1 = sizeof (buf1); + char *old = asnprintf (buf1, &len1, "%s\"%s\"", directive, value); + if (!old) + xalloc_die (); + + if (location_empty (spec_name_prefix_loc)) + { + spec_name_prefix = value; + spec_name_prefix_loc = *loc; + + char buf2[1024]; + size_t len2 = sizeof (buf2); + char *new = asnprintf (buf2, &len2, "%%define api.prefix {%s}", value); + if (!new) + xalloc_die (); + deprecated_directive (loc, old, new); + if (new != buf2) + free (new); + } + else + duplicate_directive (old, spec_file_prefix_loc, *loc); + + if (old != buf1) + free (old); +} + + +static void +handle_require (location const *loc, char const *version) { /* Changes of behavior are only on minor version changes, so "3.0.5" is the same as "3.0". */ @@ -3103,15 +3479,54 @@ version_check (location const *loc, char const *version) } static void -gram_error (location const *loc, char const *msg) +handle_skeleton (location const *loc, char const *skel) { - complain (loc, complaint, "%s", msg); + char const *skeleton_user = skel; + if (strchr (skeleton_user, '/')) + { + size_t dir_length = strlen (current_file); + while (dir_length && current_file[dir_length - 1] != '/') + --dir_length; + while (dir_length && current_file[dir_length - 1] == '/') + --dir_length; + char *skeleton_build = + xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); + if (dir_length > 0) + { + memcpy (skeleton_build, current_file, dir_length); + skeleton_build[dir_length++] = '/'; + } + strcpy (skeleton_build + dir_length, skeleton_user); + skeleton_user = uniqstr_new (skeleton_build); + free (skeleton_build); + } + skeleton_arg (skeleton_user, grammar_prio, *loc); } -char const * -token_name (int type) +static void +handle_yacc (location const *loc, char const *directive) +{ + bison_directive (loc, directive); + bool warned = false; + + if (location_empty (yacc_loc)) + yacc_loc = *loc; + else + { + duplicate_directive (directive, yacc_loc, *loc); + warned = true; + } + + if (!warned + && STRNEQ (directive, "%fixed-output-files") + && STRNEQ (directive, "%yacc")) + deprecated_directive (loc, directive, "%fixed-output-files"); +} + +static void +gram_error (location const *loc, char const *msg) { - return yytname[YYTRANSLATE (type)]; + complain (loc, complaint, "%s", msg); } static char const * diff --git a/contrib/tools/bison/src/parse-gram.h b/contrib/tools/bison/src/parse-gram.h index fe656f1d25..935488ff28 100644 --- a/contrib/tools/bison/src/parse-gram.h +++ b/contrib/tools/bison/src/parse-gram.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.1.91.31-00793. */ +/* A Bison parser, made by GNU Bison 3.2.90.23-0bbcb-dirty. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -51,11 +52,11 @@ extern int gram_debug; #endif /* "%code requires" blocks. */ -#line 21 "src/parse-gram.y" /* yacc.c:1906 */ +#line 21 "src/parse-gram.y" /* yacc.c:1921 */ #include "symlist.h" #include "symtab.h" -#line 222 "src/parse-gram.y" /* yacc.c:1906 */ +#line 239 "src/parse-gram.y" /* yacc.c:1921 */ typedef enum { @@ -64,10 +65,16 @@ extern int gram_debug; param_parse = 1 << 1, param_both = param_lex | param_parse } param_type; -#line 645 "src/parse-gram.y" /* yacc.c:1906 */ -#include "muscle-tab.h" +#line 682 "src/parse-gram.y" /* yacc.c:1921 */ -#line 71 "src/parse-gram.h" /* yacc.c:1906 */ + #include "muscle-tab.h" + typedef struct + { + char const *chars; + muscle_kind kind; + } value_type; + +#line 78 "src/parse-gram.h" /* yacc.c:1921 */ /* Token type. */ #ifndef GRAM_TOKENTYPE @@ -138,35 +145,90 @@ extern int gram_debug; union GRAM_STYPE { -#line 183 "src/parse-gram.y" /* yacc.c:1906 */ -unsigned char character; -#line 187 "src/parse-gram.y" /* yacc.c:1906 */ -char *code; -#line 192 "src/parse-gram.y" /* yacc.c:1906 */ -uniqstr uniqstr; -#line 200 "src/parse-gram.y" /* yacc.c:1906 */ -int integer; -#line 204 "src/parse-gram.y" /* yacc.c:1906 */ -symbol *symbol; -#line 209 "src/parse-gram.y" /* yacc.c:1906 */ -assoc assoc; -#line 212 "src/parse-gram.y" /* yacc.c:1906 */ -symbol_list *list; -#line 215 "src/parse-gram.y" /* yacc.c:1906 */ -named_ref *named_ref; -#line 242 "src/parse-gram.y" /* yacc.c:1906 */ -param_type param; -#line 409 "src/parse-gram.y" /* yacc.c:1906 */ -code_props_type code_type; -#line 647 "src/parse-gram.y" /* yacc.c:1906 */ - - struct - { - char const *chars; - muscle_kind kind; - } value; -#line 170 "src/parse-gram.h" /* yacc.c:1906 */ + /* 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_79; + /* named_ref.opt */ + named_ref* yytype_91; + /* "%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_98; + /* 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_77; + /* token_decls_for_prec */ + symbol_list* token_decls_for_prec; + /* token_decl_for_prec.1 */ + symbol_list* yytype_81; + /* symbol_decls */ + symbol_list* symbol_decls; + /* symbol_decl.1 */ + symbol_list* yytype_84; + /* "%error-verbose" */ + uniqstr PERCENT_ERROR_VERBOSE; + /* "%<flag>" */ + uniqstr PERCENT_FLAG; + /* "%file-prefix" */ + uniqstr PERCENT_FILE_PREFIX; + /* "%name-prefix" */ + uniqstr PERCENT_NAME_PREFIX; + /* "%yacc" */ + uniqstr PERCENT_YACC; + /* "[identifier]" */ + uniqstr BRACKETED_ID; + /* "identifier" */ + uniqstr ID; + /* "identifier:" */ + uniqstr ID_COLON; + /* "<tag>" */ + uniqstr TAG; + /* tag.opt */ + uniqstr yytype_71; + /* tag */ + uniqstr tag; + /* variable */ + uniqstr variable; + /* "char" */ + unsigned char CHAR; + /* value */ + value_type value; +#line 232 "src/parse-gram.h" /* yacc.c:1921 */ }; typedef union GRAM_STYPE GRAM_STYPE; diff --git a/contrib/tools/bison/src/print-xml.c b/contrib/tools/bison/src/print-xml.c index 3f4bc5be87..b251e1504c 100644 --- a/contrib/tools/bison/src/print-xml.c +++ b/contrib/tools/bison/src/print-xml.c @@ -1,6 +1,7 @@ /* Print an xml on generated parser, for Bison, - Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print-xml.h b/contrib/tools/bison/src/print-xml.h index abdb76355e..122c5595e7 100644 --- a/contrib/tools/bison/src/print-xml.h +++ b/contrib/tools/bison/src/print-xml.h @@ -1,6 +1,7 @@ /* Output an xml of the generated parser, for Bison. - Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print.c b/contrib/tools/bison/src/print.c index dd751d5765..60bb2b3658 100644 --- a/contrib/tools/bison/src/print.c +++ b/contrib/tools/bison/src/print.c @@ -1,7 +1,7 @@ /* Print information on generated parser, for bison, - Copyright (C) 1984, 1986, 1989, 2000-2005, 2007, 2009-2015, 2018 Free - Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 2000-2005, 2007, 2009-2015, 2018-2019 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print.h b/contrib/tools/bison/src/print.h index 61bc20552f..8352006250 100644 --- a/contrib/tools/bison/src/print.h +++ b/contrib/tools/bison/src/print.h @@ -1,6 +1,7 @@ /* Print information on generated parser, for bison, - Copyright (C) 2000, 2009-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2000, 2009-2015, 2018-2019 Free Software Foundation, + Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print_graph.c b/contrib/tools/bison/src/print_graph.c index aea418cc32..ec03278686 100644 --- a/contrib/tools/bison/src/print_graph.c +++ b/contrib/tools/bison/src/print_graph.c @@ -1,7 +1,7 @@ /* Output a graph of the generated parser, for Bison. - Copyright (C) 2001-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2001-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/print_graph.h b/contrib/tools/bison/src/print_graph.h index 4081b63d86..a3e2b6763f 100644 --- a/contrib/tools/bison/src/print_graph.h +++ b/contrib/tools/bison/src/print_graph.h @@ -1,7 +1,7 @@ /* Output a graph of the generated parser, for Bison. - Copyright (C) 2000, 2006, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2000, 2006, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/reader.c b/contrib/tools/bison/src/reader.c index d073d4ed57..8d373416df 100644 --- a/contrib/tools/bison/src/reader.c +++ b/contrib/tools/bison/src/reader.c @@ -1,7 +1,7 @@ /* Input parser for Bison Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000-2003, 2005-2007, - 2009-2015, 2018 Free Software Foundation, Inc. + 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -45,9 +45,6 @@ merger_list *merge_functions; /* Was %union seen? */ bool union_seen = false; -/* Was a tag seen? */ -bool tag_seen = false; - /* Should rules have a default precedence? */ bool default_prec = true; @@ -114,13 +111,11 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc) if (merger <= 0) return; - int merger_find; - merger_list *merge_function; - if (type == NULL) type = uniqstr_new (""); - merger_find = 1; + merger_list *merge_function; + int merger_find = 1; for (merge_function = merge_functions; merge_function != NULL && merger_find != merger; merge_function = merge_function->next) @@ -430,6 +425,11 @@ grammar_midrule_action (void) current_rule->action_props.is_predicate); code_props_none_init (¤t_rule->action_props); + midrule->expected_sr_conflicts = current_rule->expected_sr_conflicts; + midrule->expected_rr_conflicts = current_rule->expected_rr_conflicts; + current_rule->expected_sr_conflicts = -1; + current_rule->expected_rr_conflicts = -1; + if (previous_rule_end) previous_rule_end->next = midrule; else @@ -467,8 +467,8 @@ grammar_current_rule_prec_set (symbol *precsym, location loc) not defined separately as a token. */ symbol_class_set (precsym, token_sym, loc, false); if (current_rule->ruleprec) - duplicate_directive ("%prec", - current_rule->ruleprec->location, loc); + duplicate_rule_directive ("%prec", + current_rule->ruleprec->location, loc); else current_rule->ruleprec = precsym; } @@ -483,8 +483,8 @@ grammar_current_rule_empty_set (location loc) if (warning_is_unset (Wempty_rule)) warning_argmatch ("empty-rule", 0, 0); if (current_rule->percent_empty_loc.start.file) - duplicate_directive ("%empty", - current_rule->percent_empty_loc, loc); + duplicate_rule_directive ("%empty", + current_rule->percent_empty_loc, loc); else current_rule->percent_empty_loc = loc; } @@ -501,8 +501,8 @@ grammar_current_rule_dprec_set (int dprec, location loc) complain (&loc, complaint, _("%s must be followed by positive number"), "%dprec"); else if (current_rule->dprec != 0) - duplicate_directive ("%dprec", - current_rule->dprec_location, loc); + duplicate_rule_directive ("%dprec", + current_rule->dprec_location, loc); else { current_rule->dprec = dprec; @@ -520,8 +520,8 @@ grammar_current_rule_merge_set (uniqstr name, location loc) complain (&loc, Wother, _("%s affects only GLR parsers"), "%merge"); if (current_rule->merger != 0) - duplicate_directive ("%merge", - current_rule->merger_declaration_location, loc); + duplicate_rule_directive ("%merge", + current_rule->merger_declaration_location, loc); else { current_rule->merger = get_merge_function (name); @@ -573,6 +573,27 @@ grammar_current_rule_predicate_append (const char *pred, location loc) /* is_predicate */ true); } +/* Set the expected number of shift-reduce (reduce-reduce) conflicts for + * the current rule. If a midrule is encountered later, the count + * is transferred to it and reset in the current rule to -1. */ + +void +grammar_current_rule_expect_sr (int count, location loc) +{ + (void) loc; + current_rule->expected_sr_conflicts = count; +} + +void +grammar_current_rule_expect_rr (int count, location loc) +{ + if (! glr_parser) + complain (&loc, Wother, _("%s affects only GLR parsers"), + "%expect-rr"); + else + current_rule->expected_rr_conflicts = count; +} + /*---------------------------------------------------------------. | Convert the rules into the representation using RRHS, RLHS and | @@ -583,13 +604,11 @@ static void packgram (void) { unsigned itemno = 0; - rule_number ruleno = 0; - ritem = xnmalloc (nritems + 1, sizeof *ritem); - /* This sentinel is used by build_relations in gram.c. */ *ritem++ = 0; + rule_number ruleno = 0; rules = xnmalloc (nrules, sizeof *rules); for (symbol_list *p = grammar; p; p = p->next) @@ -626,6 +645,8 @@ packgram (void) rules[ruleno].action = lhs->action_props.code; rules[ruleno].action_location = lhs->action_props.location; rules[ruleno].is_predicate = lhs->action_props.is_predicate; + rules[ruleno].expected_sr_conflicts = p->expected_sr_conflicts; + rules[ruleno].expected_rr_conflicts = p->expected_rr_conflicts; /* Traverse the rhs. */ { @@ -720,11 +741,10 @@ prepare_percent_define_front_end_variables (void) /* Set %define front-end variable defaults. */ muscle_percent_define_default ("lr.keep-unreachable-state", "false"); { - char *lr_type; /* IELR would be a better default, but LALR is historically the default. */ muscle_percent_define_default ("lr.type", "lalr"); - lr_type = muscle_percent_define_get ("lr.type"); + char *lr_type = muscle_percent_define_get ("lr.type"); if (STRNEQ (lr_type, "canonical-lr")) muscle_percent_define_default ("lr.default-reduction", "most"); else diff --git a/contrib/tools/bison/src/reader.h b/contrib/tools/bison/src/reader.h index 70128be09d..9f59dc0053 100644 --- a/contrib/tools/bison/src/reader.h +++ b/contrib/tools/bison/src/reader.h @@ -1,7 +1,7 @@ /* Input parser for Bison - Copyright (C) 2000-2003, 2005-2007, 2009-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 2000-2003, 2005-2007, 2009-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -38,7 +38,6 @@ typedef struct merger_list /* From the parser. */ extern int gram_debug; int gram_parse (void); -char const *token_name (int type); /* From reader.c. */ @@ -52,6 +51,8 @@ void grammar_current_rule_empty_set (location loc); void grammar_current_rule_prec_set (symbol *precsym, location loc); void grammar_current_rule_dprec_set (int dprec, location loc); void grammar_current_rule_merge_set (uniqstr name, location loc); +void grammar_current_rule_expect_sr (int count, location loc); +void grammar_current_rule_expect_rr (int count, location loc); void grammar_current_rule_symbol_append (symbol *sym, location loc, named_ref *nref); /* Attach an ACTION to the current rule. */ @@ -67,9 +68,6 @@ extern merger_list *merge_functions; /* Was %union seen? */ extern bool union_seen; -/* Was a tag seen? */ -extern bool tag_seen; - /* Should rules have a default precedence? */ extern bool default_prec; diff --git a/contrib/tools/bison/src/reduce.c b/contrib/tools/bison/src/reduce.c index ee5118eae5..ff2f2325c0 100644 --- a/contrib/tools/bison/src/reduce.c +++ b/contrib/tools/bison/src/reduce.c @@ -1,7 +1,7 @@ /* Grammar reduction for Bison. - Copyright (C) 1988-1989, 2000-2003, 2005-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1988-1989, 2000-2003, 2005-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -259,22 +259,23 @@ reduce_grammar_tables (void) | Remove useless nonterminals. | `------------------------------*/ +symbol_number *nterm_map = NULL; + static void nonterminals_reduce (void) { + nterm_map = xnmalloc (nvars, sizeof *nterm_map); /* Map the nonterminals to their new index: useful first, useless afterwards. Kept for later report. */ - - symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap); { symbol_number n = ntokens; for (symbol_number i = ntokens; i < nsyms; ++i) if (bitset_test (V, i)) - nontermmap[i - ntokens] = n++; + nterm_map[i - ntokens] = n++; for (symbol_number i = ntokens; i < nsyms; ++i) if (!bitset_test (V, i)) { - nontermmap[i - ntokens] = n++; + nterm_map[i - ntokens] = n++; if (symbols[i]->content->status != used) complain (&symbols[i]->location, Wother, _("nonterminal useless in grammar: %s"), @@ -282,32 +283,30 @@ nonterminals_reduce (void) } } - /* Shuffle elements of tables indexed by symbol number. */ { symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted); for (symbol_number i = ntokens; i < nsyms; ++i) - symbols[i]->content->number = nontermmap[i - ntokens]; + symbols[i]->content->number = nterm_map[i - ntokens]; for (symbol_number i = ntokens; i < nsyms; ++i) - symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i]; + symbols_sorted[nterm_map[i - ntokens] - ntokens] = symbols[i]; for (symbol_number i = ntokens; i < nsyms; ++i) symbols[i] = symbols_sorted[i - ntokens]; free (symbols_sorted); } + /* Update nonterminal numbers in the RHS of the rules. LHS are + pointers to the symbol structure, they don't need renumbering. */ { for (rule_number r = 0; r < nrules; ++r) for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp) if (ISVAR (*rhsp)) - *rhsp = symbol_number_as_item_number (nontermmap[*rhsp - - ntokens]); - accept->content->number = nontermmap[accept->content->number - ntokens]; + *rhsp = symbol_number_as_item_number (nterm_map[*rhsp - ntokens]); + accept->content->number = nterm_map[accept->content->number - ntokens]; } nsyms -= nuseless_nonterminals; nvars -= nuseless_nonterminals; - - free (nontermmap); } @@ -433,4 +432,6 @@ reduce_free (void) bitset_free (V); bitset_free (V1); bitset_free (P); + free (nterm_map); + nterm_map = NULL; } diff --git a/contrib/tools/bison/src/reduce.h b/contrib/tools/bison/src/reduce.h index b1baa892bf..9814962d76 100644 --- a/contrib/tools/bison/src/reduce.h +++ b/contrib/tools/bison/src/reduce.h @@ -1,6 +1,6 @@ /* Grammar reduction for Bison. - Copyright (C) 2000-2002, 2007, 2009-2015, 2018 Free Software + Copyright (C) 2000-2002, 2007, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -32,6 +32,11 @@ bool reduce_nonterminal_useless_in_grammar (const sym_content *sym); void reduce_free (void); +/** Map initial nterm numbers to the new ones. Built by + * reduce_grammar. Size nvars + nuseless_nonterminals. */ +extern symbol_number *nterm_map; + extern unsigned nuseless_nonterminals; extern unsigned nuseless_productions; + #endif /* !REDUCE_H_ */ diff --git a/contrib/tools/bison/src/relation.c b/contrib/tools/bison/src/relation.c index 148f55400c..4371501d47 100644 --- a/contrib/tools/bison/src/relation.c +++ b/contrib/tools/bison/src/relation.c @@ -1,6 +1,6 @@ /* Binary relations. - Copyright (C) 2002, 2004-2005, 2009-2015, 2018 Free Software + Copyright (C) 2002, 2004-2005, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/relation.h b/contrib/tools/bison/src/relation.h index cc940f93e4..e6b59ff869 100644 --- a/contrib/tools/bison/src/relation.h +++ b/contrib/tools/bison/src/relation.h @@ -1,7 +1,7 @@ /* Binary relations. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/scan-code.c b/contrib/tools/bison/src/scan-code.c index d8b9ad64f2..39b16dc3fe 100644 --- a/contrib/tools/bison/src/scan-code.c +++ b/contrib/tools/bison/src/scan-code.c @@ -856,7 +856,7 @@ char *yytext; #line 1 "/Users/akim/src/gnu/bison/src/scan-code.l" /* Bison Action Scanner -*- C -*- - Copyright (C) 2006-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2006-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -874,24 +874,24 @@ char *yytext; along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 #line 24 "/Users/akim/src/gnu/bison/src/scan-code.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 code_wrap -#define code_wrap() 1 - -#define FLEX_PREFIX(Id) code_ ## Id -#include <src/flex-scanner.h> +#include <c-ctype.h> +#include <get-errno.h> +#include <quote.h> #include <src/complain.h> -#include <src/reader.h> #include <src/getargs.h> #include <src/muscle-tab.h> +#include <src/reader.h> #include <src/scan-code.h> #include <src/symlist.h> -#include <c-ctype.h> -#include <get-errno.h> -#include <quote.h> +#define FLEX_PREFIX(Id) code_ ## 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 code_wrap +#define code_wrap() 1 /* The current calling start condition: SC_RULE_ACTION or SC_SYMBOL_ACTION. */ @@ -2991,14 +2991,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) effective_rule_length = symbol_list_length (rule->next); } - /* Get the type name if explicit. */ + /* The type name if explicit, otherwise left null. */ char const *type_name = NULL; char *cp = fetch_type_name (text + 1, &type_name, dollar_loc); - int n = parse_ref (cp, effective_rule, effective_rule_length, rule->midrule_parent_rhs_index, text, dollar_loc, '$'); - - /* End type_name. */ + /* End type_name. Don't do it ealier: parse_ref depends on TEXT. */ if (type_name) cp[-1] = '\0'; @@ -3008,63 +3006,75 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc) break; case LHS_REF: - if (!type_name) - type_name = symbol_list_n_type_name_get (rule, 0); - - if (!type_name) - { - if (union_seen | tag_seen) - { - if (rule->midrule_parent_rule) - complain (&dollar_loc, complaint, - _("$$ for the midrule at $%d of %s" - " has no declared type"), - rule->midrule_parent_rhs_index, - quote (effective_rule->content.sym->tag)); - else - complain (&dollar_loc, complaint, - _("$$ of %s has no declared type"), - quote (rule->content.sym->tag)); - } - else - untyped_var_seen = true; - } + { + symbol_list *sym = symbol_list_n_get (rule, 0); + if (!type_name + && !sym->content.sym->content->type_name) + { + if (union_seen | tag_seen) + { + if (rule->midrule_parent_rule) + complain (&dollar_loc, complaint, + _("$$ for the midrule at $%d of %s" + " has no declared type"), + rule->midrule_parent_rhs_index, + quote (effective_rule->content.sym->tag)); + else + complain (&dollar_loc, complaint, + _("$$ of %s has no declared type"), + quote (rule->content.sym->tag)); + } + else + untyped_var_seen = true; + } - obstack_sgrow (&obstack_for_string, "]b4_lhs_value("); - obstack_quote (&obstack_for_string, type_name); - obstack_sgrow (&obstack_for_string, ")["); - rule->action_props.is_value_used = true; + obstack_printf (&obstack_for_string, "]b4_lhs_value(orig %d, ", + sym->content.sym->content->number); + obstack_quote (&obstack_for_string, type_name); + obstack_sgrow (&obstack_for_string, ")["); + rule->action_props.is_value_used = true; + } break; + /* Reference to a RHS symbol. */ default: - if (max_left_semantic_context < 1 - n) - max_left_semantic_context = 1 - n; - if (!type_name && 0 < n) - type_name = symbol_list_n_type_name_get (effective_rule, n); - if (!type_name) - { - if (union_seen | tag_seen) - complain (&dollar_loc, complaint, - _("$%s of %s has no declared type"), cp, - quote (effective_rule->content.sym->tag)); - else - untyped_var_seen = true; - } + { + if (max_left_semantic_context < 1 - n) + max_left_semantic_context = 1 - n; + symbol_list *sym = 0 < n ? symbol_list_n_get (effective_rule, n) : NULL; + if (!type_name + && (!sym || !sym->content.sym->content->type_name)) + { + if (union_seen | tag_seen) + complain (&dollar_loc, complaint, + _("$%s of %s has no declared type"), cp, + quote (effective_rule->content.sym->tag)); + else + untyped_var_seen = true; + } - obstack_printf (&obstack_for_string, - "]b4_rhs_value(%d, %d, ", effective_rule_length, n); - obstack_quote (&obstack_for_string, type_name); - obstack_sgrow (&obstack_for_string, ")["); - if (0 < n) - { - symbol_list *sym = symbol_list_n_get (effective_rule, n); - if (muscle_percent_define_ifdef ("api.value.automove") - && sym->action_props.is_value_used) - complain (&dollar_loc, Wother, - _("multiple occurrences of $%d with api.value.automove"), - n); - sym->action_props.is_value_used = true; - } + obstack_printf (&obstack_for_string, + "]b4_rhs_value(%d, %d, ", + effective_rule_length, n); + if (sym) + obstack_printf (&obstack_for_string, "%s%d, ", + sym->content.sym->content->class == nterm_sym ? "orig " : "", + sym->content.sym->content->number); + else + obstack_sgrow (&obstack_for_string, "[], "); + + obstack_quote (&obstack_for_string, type_name); + obstack_sgrow (&obstack_for_string, ")["); + if (0 < n) + { + if (muscle_percent_define_ifdef ("api.value.automove") + && sym->action_props.is_value_used) + complain (&dollar_loc, Wother, + _("multiple occurrences of $%d with api.value.automove"), + n); + sym->action_props.is_value_used = true; + } + } break; } } diff --git a/contrib/tools/bison/src/scan-code.h b/contrib/tools/bison/src/scan-code.h index c3df29c0ce..483fe9ba56 100644 --- a/contrib/tools/bison/src/scan-code.h +++ b/contrib/tools/bison/src/scan-code.h @@ -1,7 +1,7 @@ /* Bison code properties structure and scanner. - Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/scan-gram.c b/contrib/tools/bison/src/scan-gram.c index 8fbead0af7..49d9541887 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 130 -#define YY_END_OF_BUFFER 131 +#define YY_NUM_RULES 129 +#define YY_END_OF_BUFFER 130 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -700,71 +700,71 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[579] = +static const flex_int16_t yy_accept[573] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 93, 93, 113, 113, 113, 113, 0, 0, - 0, 0, 131, 80, 2, 2, 71, 80, 70, 80, - 1, 66, 80, 67, 67, 65, 77, 63, 66, 79, - 73, 64, 80, 90, 90, 128, 95, 94, 128, 81, - 97, 96, 84, 2, 1, 84, 83, 82, 84, 99, - 99, 100, 98, 81, 129, 119, 128, 118, 128, 128, - 128, 122, 125, 126, 128, 92, 128, 117, 116, 128, - 115, 114, 87, 2, 1, 85, 87, 87, 86, 87, - - 88, 2, 1, 88, 88, 80, 78, 62, 0, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 72, 66, 66, - 4, 3, 69, 67, 69, 0, 76, 0, 89, 112, - 110, 101, 112, 103, 104, 105, 106, 107, 108, 112, - 109, 112, 99, 99, 100, 127, 120, 121, 0, 123, - 0, 122, 124, 0, 91, 0, 0, 93, 113, 113, - 113, 113, 87, 85, 62, 0, 74, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - - 62, 62, 62, 62, 62, 62, 62, 62, 3, 69, - 68, 75, 0, 101, 0, 0, 102, 0, 0, 0, + 0, 0, 92, 92, 112, 112, 112, 112, 0, 0, + 0, 0, 130, 79, 2, 2, 70, 79, 69, 79, + 1, 65, 79, 66, 66, 64, 76, 62, 65, 78, + 72, 63, 79, 89, 89, 127, 94, 93, 127, 80, + 96, 95, 83, 2, 1, 83, 82, 81, 83, 98, + 98, 99, 97, 80, 128, 118, 127, 117, 127, 127, + 127, 121, 124, 125, 127, 91, 127, 116, 115, 127, + 114, 113, 86, 2, 1, 84, 86, 86, 85, 86, + + 87, 2, 1, 87, 87, 79, 77, 61, 0, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 71, 65, 65, + 4, 3, 68, 66, 68, 0, 75, 0, 88, 111, + 109, 100, 111, 102, 103, 104, 105, 106, 107, 111, + 108, 111, 98, 98, 99, 126, 119, 120, 0, 122, + 0, 121, 123, 0, 90, 0, 0, 92, 112, 112, + 112, 112, 86, 84, 61, 0, 73, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + + 61, 61, 61, 61, 61, 61, 61, 61, 3, 68, + 67, 74, 0, 100, 0, 0, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 0, 101, - 0, 0, 62, 7, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 23, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - - 62, 62, 36, 62, 62, 62, 62, 62, 62, 44, - 62, 47, 62, 62, 50, 0, 0, 0, 62, 8, - 62, 62, 62, 13, 14, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 26, 62, 62, 62, 62, 62, - 62, 62, 62, 32, 62, 34, 62, 62, 62, 62, - 62, 62, 41, 62, 43, 45, 48, 62, 0, 0, - 111, 6, 62, 10, 62, 62, 62, 16, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 33, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 0, 62, 11, 62, 62, - - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, - 59, 62, 62, 38, 62, 62, 40, 62, 62, 62, - 49, 5, 0, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 22, 62, 62, 62, 62, - 62, 29, 62, 58, 30, 62, 62, 62, 62, 62, - 42, 62, 62, 0, 62, 62, 62, 62, 62, 17, - 53, 62, 62, 62, 62, 62, 24, 25, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, - 0, 62, 62, 12, 62, 62, 62, 62, 62, 21, - - 62, 62, 62, 62, 62, 62, 62, 37, 62, 62, - 62, 62, 62, 62, 62, 62, 18, 62, 62, 62, - 27, 56, 62, 62, 62, 35, 39, 60, 46, 61, - 9, 51, 62, 62, 0, 54, 62, 62, 62, 0, - 56, 62, 62, 62, 15, 52, 62, 62, 62, 62, - 62, 62, 62, 62, 20, 62, 62, 62, 62, 62, - 28, 57, 62, 62, 62, 62, 62, 62, 62, 19, - 55, 62, 62, 62, 62, 62, 31, 0 + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 0, 100, + 0, 0, 61, 7, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 22, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + + 61, 61, 34, 61, 61, 61, 61, 61, 61, 42, + 61, 45, 61, 61, 48, 0, 0, 0, 61, 8, + 61, 61, 61, 13, 14, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 25, 61, 61, 61, 61, 61, + 61, 61, 30, 61, 32, 61, 61, 61, 61, 61, + 61, 39, 61, 41, 43, 46, 61, 0, 0, 110, + 6, 61, 10, 61, 61, 61, 15, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 31, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 0, 61, 11, 61, 61, 61, 61, + + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 0, 58, 61, 61, + 36, 61, 61, 38, 61, 61, 61, 47, 5, 0, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 21, 61, 61, 61, 61, 27, 61, 57, + 28, 61, 61, 61, 61, 61, 40, 61, 61, 0, + 61, 61, 61, 61, 61, 16, 53, 61, 61, 61, + 61, 61, 23, 24, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 0, 0, 61, 61, 12, 61, + 61, 61, 61, 61, 20, 61, 61, 61, 61, 61, + + 61, 35, 61, 61, 61, 61, 61, 61, 61, 61, + 17, 61, 61, 61, 50, 61, 61, 61, 33, 37, + 59, 44, 60, 9, 51, 61, 61, 0, 54, 61, + 61, 61, 50, 50, 61, 61, 61, 49, 52, 61, + 61, 61, 50, 61, 61, 61, 61, 61, 19, 61, + 61, 61, 61, 61, 26, 56, 61, 61, 61, 61, + 61, 61, 61, 18, 55, 61, 61, 61, 61, 61, + 29, 0 } ; static const YY_CHAR yy_ec[256] = @@ -809,149 +809,147 @@ static const YY_CHAR yy_meta[59] = 9, 9, 9, 9, 4, 4, 4, 1 } ; -static const flex_int16_t yy_base[605] = +static const flex_int16_t yy_base[599] = { 0, - 0, 1001, 997, 996, 56, 57, 58, 61, 63, 90, + 0, 998, 994, 993, 56, 57, 58, 61, 63, 90, 76, 87, 70, 97, 117, 121, 66, 130, 140, 144, - 79, 107, 99, 109, 153, 159, 148, 152, 201, 998, - 182, 258, 1004, 0, 1009, 1009, 1009, 265, 1009, 1009, - 1009, 320, 153, 313, 153, 1009, 61, 1009, 330, 1009, - 1009, 1009, 961, 1009, 988, 1009, 1009, 1009, 383, 1009, - 1009, 1009, 1009, 1009, 1009, 161, 1009, 1009, 959, 988, - 110, 979, 1009, 986, 1009, 1009, 940, 1009, 169, 144, - 254, 1009, 1009, 1009, 250, 1009, 187, 1009, 1009, 265, - 1009, 1009, 0, 1009, 0, 0, 261, 1009, 1009, 954, - - 1009, 1009, 1009, 266, 953, 0, 1009, 0, 320, 954, - 948, 241, 293, 952, 949, 946, 250, 953, 294, 937, - 303, 245, 150, 311, 943, 950, 953, 1009, 436, 0, - 1009, 0, 0, 346, 480, 962, 1009, 943, 1009, 1009, - 1009, 342, 0, 1009, 1009, 1009, 1009, 1009, 1009, 0, - 1009, 0, 970, 330, 961, 1009, 1009, 1009, 365, 1009, - 369, 1009, 1009, 374, 1009, 378, 382, 951, 1009, 388, - 950, 392, 0, 0, 0, 398, 1009, 934, 942, 374, - 928, 929, 926, 927, 360, 924, 931, 926, 368, 935, - 920, 924, 398, 930, 915, 916, 333, 915, 915, 923, - - 924, 927, 910, 916, 910, 915, 906, 919, 0, 0, - 0, 1009, 908, 402, 0, 0, 0, 423, 431, 453, + 79, 107, 99, 109, 153, 159, 148, 152, 201, 995, + 182, 258, 1001, 0, 1006, 1006, 1006, 265, 1006, 1006, + 1006, 320, 153, 313, 153, 1006, 61, 1006, 330, 1006, + 1006, 1006, 958, 1006, 985, 1006, 1006, 1006, 383, 1006, + 1006, 1006, 1006, 1006, 1006, 161, 1006, 1006, 956, 985, + 110, 976, 1006, 983, 1006, 1006, 937, 1006, 169, 144, + 254, 1006, 1006, 1006, 250, 1006, 187, 1006, 1006, 265, + 1006, 1006, 0, 1006, 0, 0, 261, 1006, 1006, 951, + + 1006, 1006, 1006, 266, 950, 0, 1006, 0, 320, 951, + 945, 241, 293, 949, 946, 943, 250, 950, 294, 934, + 303, 245, 150, 311, 940, 947, 950, 1006, 436, 0, + 1006, 0, 0, 346, 480, 959, 1006, 940, 1006, 1006, + 1006, 342, 0, 1006, 1006, 1006, 1006, 1006, 1006, 0, + 1006, 0, 967, 330, 958, 1006, 1006, 1006, 365, 1006, + 369, 1006, 1006, 374, 1006, 378, 382, 948, 1006, 388, + 947, 392, 0, 0, 0, 398, 1006, 931, 939, 374, + 925, 926, 923, 924, 360, 921, 928, 923, 368, 932, + 917, 921, 398, 927, 912, 913, 333, 912, 912, 920, + + 921, 924, 907, 913, 907, 912, 903, 916, 0, 0, + 0, 1006, 905, 402, 0, 0, 0, 423, 431, 453, 410, 459, 443, 465, 390, 471, 475, 479, 483, 379, - 919, 914, 898, 81, 898, 911, 896, 900, 908, 907, - 906, 929, 890, 901, 888, 925, 904, 897, 898, 415, - 448, 412, 885, 886, 420, 897, 886, 893, 877, 888, - 884, 877, 881, 887, 886, 876, 887, 885, 882, 1009, - 0, 0, 869, 0, 878, 864, 870, 865, 878, 857, - 862, 875, 896, 872, 860, 865, 853, 0, 857, 852, - 865, 333, 864, 859, 862, 857, 847, 859, 851, 842, - - 849, 855, 854, 839, 467, 848, 837, 850, 835, 0, - 840, 0, 839, 837, 0, 876, 0, 0, 826, 0, - 837, 842, 826, 0, 0, 475, 826, 829, 477, 842, - 841, 840, 839, 830, 0, 823, 822, 830, 822, 828, - 820, 814, 812, 0, 811, 0, 848, 824, 822, 811, - 810, 807, 0, 804, 0, 479, 0, 804, 484, 0, - 1009, 0, 802, 802, 816, 797, 796, 480, 799, 801, - 800, 796, 801, 804, 793, 795, 791, 790, 805, 800, - 803, 798, 788, 796, 516, 785, 794, 781, 796, 795, - 790, 780, 774, 773, 786, 519, 495, 0, 771, 784, - - 783, 770, 769, 780, 764, 763, 764, 800, 775, 778, - 765, 772, 771, 755, 756, 753, 754, 768, 753, 525, - 1009, 768, 755, 0, 750, 749, 0, 752, 763, 762, - 0, 1009, 787, 746, 745, 745, 741, 740, 739, 738, - 748, 734, 733, 746, 749, 0, 737, 730, 741, 740, - 734, 0, 733, 0, 0, 731, 725, 738, 722, 721, - 0, 736, 735, 761, 718, 717, 716, 730, 729, 0, - 0, 721, 714, 713, 710, 723, 0, 0, 716, 715, - 704, 703, 712, 719, 714, 705, 701, 683, 679, 710, - 499, 675, 673, 0, 663, 660, 651, 639, 619, 0, - - 616, 611, 607, 511, 513, 615, 615, 0, 607, 606, - 617, 616, 615, 614, 598, 540, 536, 538, 537, 546, - 545, 549, 539, 538, 543, 0, 0, 0, 0, 0, - 0, 0, 546, 545, 556, 1009, 531, 533, 535, 569, - 1009, 531, 530, 527, 0, 0, 538, 532, 524, 531, - 529, 513, 516, 515, 0, 499, 498, 491, 467, 461, - 0, 0, 459, 439, 435, 434, 389, 381, 378, 0, - 0, 390, 366, 347, 350, 307, 0, 1009, 590, 601, - 612, 623, 634, 645, 656, 662, 671, 682, 693, 702, - 708, 713, 722, 729, 286, 277, 259, 187, 179, 173, - - 135, 133, 87, 738 + 916, 911, 895, 81, 895, 908, 893, 897, 905, 904, + 903, 926, 887, 898, 885, 922, 901, 894, 895, 415, + 448, 412, 882, 883, 420, 894, 883, 890, 874, 885, + 881, 874, 878, 884, 883, 873, 884, 882, 879, 1006, + 0, 0, 866, 0, 875, 861, 867, 862, 875, 854, + 859, 872, 893, 869, 857, 862, 850, 0, 854, 849, + 862, 333, 861, 856, 859, 854, 844, 856, 848, 839, + + 846, 852, 851, 836, 467, 845, 834, 847, 832, 0, + 837, 0, 836, 834, 0, 873, 0, 0, 823, 0, + 834, 839, 823, 0, 0, 475, 823, 826, 477, 839, + 838, 837, 836, 827, 0, 820, 828, 820, 826, 818, + 812, 810, 0, 809, 0, 846, 822, 820, 809, 808, + 805, 0, 802, 0, 479, 0, 802, 484, 0, 1006, + 0, 800, 800, 814, 795, 794, 480, 797, 799, 798, + 794, 799, 802, 791, 793, 789, 804, 799, 802, 797, + 787, 795, 516, 784, 793, 780, 795, 794, 789, 779, + 773, 772, 785, 519, 495, 0, 770, 783, 782, 769, + + 768, 779, 763, 762, 763, 799, 774, 777, 764, 771, + 755, 756, 753, 754, 768, 753, 525, 1006, 768, 755, + 0, 750, 749, 0, 752, 763, 762, 0, 1006, 787, + 746, 745, 745, 741, 740, 739, 738, 748, 734, 733, + 746, 749, 0, 737, 730, 741, 735, 0, 734, 0, + 0, 732, 726, 739, 723, 722, 0, 737, 736, 762, + 719, 718, 717, 731, 730, 0, 0, 722, 715, 714, + 711, 724, 0, 0, 717, 706, 705, 714, 721, 716, + 715, 714, 707, 706, 741, 499, 710, 709, 0, 699, + 698, 689, 690, 681, 0, 678, 663, 511, 513, 668, + + 664, 0, 654, 652, 663, 660, 661, 647, 612, 608, + 536, 605, 601, 610, 545, 603, 600, 605, 0, 0, + 0, 0, 0, 0, 0, 608, 607, 549, 1006, 531, + 533, 595, 556, 569, 591, 590, 527, 0, 0, 538, + 532, 524, 576, 531, 529, 513, 516, 515, 0, 499, + 498, 491, 467, 461, 0, 0, 459, 439, 435, 434, + 389, 381, 378, 0, 0, 390, 366, 347, 350, 307, + 0, 1006, 581, 592, 603, 614, 625, 636, 647, 653, + 662, 673, 684, 693, 699, 704, 713, 720, 286, 277, + 259, 187, 179, 173, 135, 133, 87, 729 + } ; -static const flex_int16_t yy_def[605] = +static const flex_int16_t yy_def[599] = { 0, - 578, 1, 579, 579, 580, 580, 580, 580, 581, 581, - 582, 582, 580, 580, 580, 580, 580, 580, 580, 580, - 580, 580, 580, 580, 580, 580, 580, 580, 578, 29, - 583, 583, 578, 584, 578, 578, 578, 578, 578, 578, - 578, 585, 578, 586, 586, 578, 578, 578, 585, 578, - 578, 578, 584, 578, 578, 578, 578, 578, 587, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 588, - 588, 578, 578, 588, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 589, - 578, 578, 590, 578, 590, 591, 578, 578, 578, 590, - - 578, 578, 578, 578, 578, 584, 578, 592, 578, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 578, 585, 49, - 578, 593, 594, 586, 594, 578, 578, 578, 578, 578, - 578, 578, 595, 578, 578, 578, 578, 578, 578, 596, - 578, 597, 588, 588, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 590, 591, 592, 578, 578, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - - 592, 592, 592, 592, 592, 592, 592, 592, 593, 594, - 135, 578, 578, 578, 598, 599, 597, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 589, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 578, 578, - 600, 601, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 578, 602, 603, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 578, 596, - 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 578, 592, 592, 592, 592, - - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 578, - 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 578, 578, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 604, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 604, - 604, 592, 592, 592, 592, 592, 592, 592, 592, 592, - - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 578, 578, 592, 592, 592, 578, - 578, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 592, 592, 592, - 592, 592, 592, 592, 592, 592, 592, 0, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - - 578, 578, 578, 578 + 572, 1, 573, 573, 574, 574, 574, 574, 575, 575, + 576, 576, 574, 574, 574, 574, 574, 574, 574, 574, + 574, 574, 574, 574, 574, 574, 574, 574, 572, 29, + 577, 577, 572, 578, 572, 572, 572, 572, 572, 572, + 572, 579, 572, 580, 580, 572, 572, 572, 579, 572, + 572, 572, 578, 572, 572, 572, 572, 572, 581, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 582, + 582, 572, 572, 582, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 583, + 572, 572, 584, 572, 584, 585, 572, 572, 572, 584, + + 572, 572, 572, 572, 572, 578, 572, 586, 572, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 572, 579, 49, + 572, 587, 588, 580, 588, 572, 572, 572, 572, 572, + 572, 572, 589, 572, 572, 572, 572, 572, 572, 590, + 572, 591, 582, 582, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 584, 585, 586, 572, 572, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + + 586, 586, 586, 586, 586, 586, 586, 586, 587, 588, + 135, 572, 572, 572, 592, 593, 591, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 583, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 572, 572, + 594, 595, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 572, 596, 597, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 572, 590, 572, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 572, 586, 586, 586, 586, 586, 586, + + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 572, 572, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 572, 572, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 598, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 598, 598, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 572, 572, 586, + 586, 586, 572, 572, 586, 586, 586, 586, 586, 586, + 586, 586, 572, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, + 586, 0, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572 + } ; -static const flex_int16_t yy_nxt[1068] = +static const flex_int16_t yy_nxt[1065] = { 0, 34, 35, 36, 34, 35, 37, 34, 38, 39, 40, 41, 34, 42, 43, 44, 45, 45, 34, 46, 47, @@ -962,12 +960,12 @@ static const flex_int16_t yy_nxt[1068] = 61, 58, 58, 61, 64, 36, 62, 64, 75, 62, 136, 76, 75, 65, 78, 76, 66, 77, 78, 79, 67, 75, 137, 79, 59, 59, 59, 71, 85, 59, - 68, 64, 36, 361, 64, 72, 69, 73, 71, 75, + 68, 64, 36, 360, 64, 72, 69, 73, 71, 75, 65, 86, 76, 66, 77, 78, 72, 67, 73, 75, 79, 86, 276, 60, 60, 60, 85, 68, 60, 75, 277, 154, 76, 75, 80, 78, 76, 87, 80, 78, - 79, 153, 75, 74, 79, 76, 81, 87, 78, 360, + 79, 153, 75, 74, 79, 76, 81, 87, 78, 359, 81, 318, 75, 79, 74, 76, 75, 80, 78, 76, 91, 80, 78, 79, 91, 88, 92, 79, 89, 81, 92, 88, 131, 81, 89, 160, 132, 134, 134, 134, @@ -989,90 +987,90 @@ static const flex_int16_t yy_nxt[1068] = 113, 114, 115, 108, 116, 108, 117, 118, 119, 120, 121, 108, 122, 123, 124, 125, 126, 108, 127, 128, 106, 176, 176, 106, 176, 192, 106, 134, 134, 134, - 578, 129, 129, 578, 196, 182, 578, 106, 193, 135, - 183, 154, 106, 194, 336, 184, 203, 578, 106, 106, - 197, 153, 578, 198, 577, 204, 214, 214, 578, 578, - 134, 134, 134, 337, 205, 135, 218, 219, 256, 218, + 572, 129, 129, 572, 196, 182, 572, 106, 193, 135, + 183, 154, 106, 194, 336, 184, 203, 572, 106, 106, + 197, 153, 572, 198, 571, 204, 214, 214, 572, 572, + 134, 134, 134, 336, 205, 135, 218, 219, 256, 218, 220, 221, 257, 220, 177, 222, 223, 106, 222, 224, - 225, 578, 224, 167, 168, 576, 167, 578, 141, 227, - 171, 141, 227, 229, 230, 575, 229, 142, 142, 176, + 225, 572, 224, 167, 168, 570, 167, 572, 141, 227, + 171, 141, 227, 229, 230, 569, 229, 142, 142, 176, 176, 240, 176, 165, 245, 141, 233, 172, 143, 250, - 234, 141, 241, 574, 144, 145, 270, 270, 166, 146, - 246, 573, 235, 572, 218, 219, 147, 218, 251, 571, - 148, 160, 149, 150, 151, 152, 106, 570, 161, 106, - 157, 252, 106, 297, 158, 569, 298, 129, 129, 293, + 234, 141, 241, 568, 144, 145, 270, 270, 166, 146, + 246, 567, 235, 566, 218, 219, 147, 218, 251, 565, + 148, 160, 149, 150, 151, 152, 106, 564, 161, 106, + 157, 252, 106, 297, 158, 563, 298, 129, 129, 293, 162, 301, 177, 106, 220, 221, 294, 220, 106, 159, 222, 223, 163, 222, 106, 106, 224, 225, 302, 224, - 568, 164, 167, 168, 567, 167, 227, 171, 350, 227, - 227, 171, 295, 227, 229, 230, 366, 229, 370, 296, - 393, 402, 566, 106, 211, 211, 211, 351, 396, 396, - - 396, 432, 565, 211, 491, 367, 434, 371, 564, 394, - 403, 211, 211, 211, 211, 211, 211, 420, 420, 420, - 420, 432, 523, 433, 524, 435, 420, 420, 420, 420, - 563, 562, 561, 396, 396, 396, 421, 535, 535, 535, - 535, 524, 547, 524, 548, 421, 540, 540, 540, 540, - 540, 540, 540, 540, 560, 559, 536, 535, 535, 535, - 535, 548, 558, 548, 557, 541, 556, 555, 554, 541, - 540, 540, 540, 540, 553, 552, 536, 551, 550, 549, - 546, 545, 544, 543, 542, 539, 538, 537, 534, 541, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - - 54, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 106, 533, 532, 531, 106, - 106, 530, 529, 528, 527, 106, 130, 526, 525, 522, - 130, 130, 130, 521, 130, 520, 130, 133, 133, 519, - 133, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 153, 153, 153, 153, 153, 153, 153, 518, - 153, 153, 153, 169, 169, 169, 169, 169, 169, 169, - - 169, 169, 173, 517, 516, 173, 173, 515, 514, 173, - 513, 173, 174, 174, 174, 491, 174, 175, 175, 175, - 512, 175, 209, 209, 511, 209, 209, 209, 209, 209, - 209, 209, 209, 210, 210, 210, 510, 210, 490, 490, - 509, 490, 490, 490, 490, 490, 490, 490, 490, 508, - 507, 506, 505, 504, 503, 502, 501, 500, 499, 498, - 497, 496, 495, 494, 493, 492, 491, 489, 488, 487, - 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, - 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, - 466, 465, 464, 463, 462, 461, 460, 459, 458, 457, - - 456, 455, 454, 453, 452, 451, 450, 449, 448, 447, - 446, 445, 444, 443, 442, 441, 440, 439, 438, 437, - 436, 431, 430, 429, 428, 427, 426, 425, 424, 423, - 422, 419, 418, 417, 416, 415, 414, 413, 412, 411, - 410, 409, 408, 407, 406, 405, 404, 401, 400, 399, - 398, 397, 395, 392, 391, 390, 389, 388, 387, 386, - 385, 384, 383, 382, 381, 380, 379, 378, 377, 376, - 375, 374, 373, 372, 369, 368, 365, 364, 363, 362, - 359, 358, 357, 356, 355, 354, 353, 352, 349, 348, - 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, - - 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, - 325, 324, 323, 322, 321, 320, 319, 316, 315, 314, - 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, - 303, 300, 299, 292, 291, 290, 289, 288, 287, 286, - 285, 284, 283, 282, 281, 280, 279, 278, 275, 274, - 273, 269, 268, 267, 266, 265, 264, 263, 262, 261, - 260, 259, 258, 255, 254, 253, 249, 248, 247, 244, - 243, 242, 239, 238, 237, 236, 232, 231, 228, 226, - 155, 154, 213, 212, 208, 207, 206, 195, 191, 187, - 186, 185, 179, 178, 138, 138, 156, 154, 155, 154, - - 138, 139, 138, 578, 100, 55, 55, 53, 33, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578 + 562, 164, 167, 168, 561, 167, 227, 171, 349, 227, + 227, 171, 295, 227, 229, 230, 365, 229, 369, 296, + 391, 400, 560, 106, 211, 211, 211, 350, 394, 394, + + 394, 429, 559, 211, 486, 366, 431, 370, 558, 392, + 401, 211, 211, 211, 211, 211, 211, 417, 417, 417, + 417, 429, 516, 430, 517, 432, 417, 417, 417, 417, + 557, 556, 555, 394, 394, 394, 418, 528, 528, 528, + 528, 517, 540, 517, 541, 418, 533, 533, 533, 533, + 528, 528, 528, 528, 554, 553, 529, 533, 533, 533, + 533, 541, 552, 541, 551, 534, 550, 549, 548, 529, + 543, 543, 543, 543, 547, 546, 534, 543, 543, 543, + 543, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 56, 56, 56, 56, 56, 56, 56, 56, + + 56, 56, 56, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 70, 70, 70, 70, 70, 70, + 70, 70, 70, 70, 70, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 106, 545, 544, 542, + 106, 106, 539, 538, 537, 536, 106, 130, 535, 532, + 531, 130, 130, 130, 530, 130, 527, 130, 133, 133, + 526, 133, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 153, 153, 153, 153, 153, 153, 153, + 525, 153, 153, 153, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 173, 524, 523, 173, 173, 522, 521, + + 173, 520, 173, 174, 174, 174, 519, 174, 175, 175, + 175, 518, 175, 209, 209, 515, 209, 209, 209, 209, + 209, 209, 209, 209, 210, 210, 210, 514, 210, 485, + 485, 513, 485, 485, 485, 485, 485, 485, 485, 485, + 512, 511, 510, 509, 508, 507, 486, 506, 505, 504, + 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, + 493, 492, 491, 490, 489, 488, 487, 486, 484, 483, + 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, + 472, 471, 470, 469, 468, 467, 466, 465, 464, 463, + 462, 461, 460, 459, 458, 457, 456, 455, 454, 453, + + 452, 451, 450, 449, 448, 447, 446, 445, 444, 443, + 442, 441, 440, 439, 438, 437, 436, 435, 434, 433, + 428, 427, 426, 425, 424, 423, 422, 421, 420, 419, + 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, + 406, 405, 404, 403, 402, 399, 398, 397, 396, 395, + 393, 390, 389, 388, 387, 386, 385, 384, 383, 382, + 381, 380, 379, 378, 377, 376, 375, 374, 373, 372, + 371, 368, 367, 364, 363, 362, 361, 358, 357, 356, + 355, 354, 353, 352, 351, 348, 347, 346, 345, 344, + 343, 342, 341, 340, 339, 338, 337, 335, 334, 333, + + 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, + 322, 321, 320, 319, 316, 315, 314, 313, 312, 311, + 310, 309, 308, 307, 306, 305, 304, 303, 300, 299, + 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, + 282, 281, 280, 279, 278, 275, 274, 273, 269, 268, + 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, + 255, 254, 253, 249, 248, 247, 244, 243, 242, 239, + 238, 237, 236, 232, 231, 228, 226, 155, 154, 213, + 212, 208, 207, 206, 195, 191, 187, 186, 185, 179, + 178, 138, 138, 156, 154, 155, 154, 138, 139, 138, + + 572, 100, 55, 55, 53, 33, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572 } ; -static const flex_int16_t yy_chk[1068] = +static const flex_int16_t yy_chk[1065] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1083,18 +1081,18 @@ static const flex_int16_t yy_chk[1068] = 7, 5, 6, 8, 9, 9, 7, 9, 17, 8, 47, 17, 13, 9, 17, 13, 9, 13, 13, 17, 9, 21, 47, 13, 5, 6, 7, 11, 21, 8, - 9, 10, 10, 603, 10, 11, 10, 11, 12, 14, + 9, 10, 10, 597, 10, 11, 10, 11, 12, 14, 10, 23, 14, 10, 14, 14, 12, 10, 12, 22, 14, 24, 234, 5, 6, 7, 22, 10, 8, 15, 234, 71, 15, 16, 15, 15, 16, 23, 16, 16, - 15, 71, 18, 11, 16, 18, 15, 24, 18, 602, - 16, 601, 19, 18, 12, 19, 20, 19, 19, 20, + 15, 71, 18, 11, 16, 18, 15, 24, 18, 596, + 16, 595, 19, 18, 12, 19, 20, 19, 19, 20, 27, 20, 20, 19, 28, 25, 27, 20, 25, 19, 28, 26, 43, 20, 26, 80, 43, 45, 45, 45, - 66, 15, 80, 15, 66, 16, 27, 16, 79, 600, - 28, 25, 79, 31, 31, 599, 31, 26, 87, 87, - 123, 87, 31, 598, 19, 31, 19, 79, 20, 123, + 66, 15, 80, 15, 66, 16, 27, 16, 79, 594, + 28, 25, 79, 31, 31, 593, 31, 26, 87, 87, + 123, 87, 31, 592, 19, 31, 19, 79, 20, 123, 20, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, @@ -1102,95 +1100,95 @@ static const flex_int16_t yy_chk[1068] = 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, 32, - 32, 81, 32, 85, 32, 597, 90, 90, 32, 90, + 32, 81, 32, 85, 32, 591, 90, 90, 32, 90, 97, 32, 38, 81, 97, 104, 112, 38, 85, 104, - 122, 117, 81, 596, 122, 117, 112, 38, 38, 38, - 38, 38, 595, 90, 117, 38, 38, 38, 38, 38, + 122, 117, 81, 590, 122, 117, 112, 38, 38, 38, + 38, 38, 589, 90, 117, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 42, 109, 109, 42, 109, 119, 42, 44, 44, 44, 49, 42, 42, 49, 121, 113, 49, 42, 119, 44, 113, 154, 42, 119, 292, 113, 124, 49, 42, 42, - 121, 154, 49, 121, 576, 124, 142, 142, 49, 49, + 121, 154, 49, 121, 570, 124, 142, 142, 49, 49, 134, 134, 134, 292, 124, 44, 159, 159, 197, 159, 161, 161, 197, 161, 109, 164, 164, 42, 164, 166, - 166, 230, 166, 167, 167, 575, 167, 49, 59, 170, - 170, 59, 170, 172, 172, 574, 172, 59, 59, 176, + 166, 230, 166, 167, 167, 569, 167, 49, 59, 170, + 170, 59, 170, 172, 172, 568, 172, 59, 59, 176, 176, 185, 176, 225, 189, 59, 180, 230, 59, 193, - 180, 59, 185, 573, 59, 59, 214, 214, 225, 59, - 189, 572, 180, 569, 218, 218, 59, 218, 193, 568, - 59, 221, 59, 59, 59, 59, 129, 567, 221, 129, - 219, 193, 129, 252, 219, 566, 252, 129, 129, 250, + 180, 59, 185, 567, 59, 59, 214, 214, 225, 59, + 189, 566, 180, 563, 218, 218, 59, 218, 193, 562, + 59, 221, 59, 59, 59, 59, 129, 561, 221, 129, + 219, 193, 129, 252, 219, 560, 252, 129, 129, 250, 223, 255, 176, 129, 220, 220, 250, 220, 129, 219, 222, 222, 223, 222, 129, 129, 224, 224, 255, 224, - 565, 223, 226, 226, 564, 226, 227, 227, 305, 227, + 559, 223, 226, 226, 558, 226, 227, 227, 305, 227, 228, 228, 251, 228, 229, 229, 326, 229, 329, 251, - 356, 368, 563, 129, 135, 135, 135, 305, 359, 359, - - 359, 491, 560, 135, 491, 326, 397, 329, 559, 356, - 368, 135, 135, 135, 135, 135, 135, 385, 385, 385, - 385, 396, 504, 396, 505, 397, 420, 420, 420, 420, - 558, 557, 556, 396, 396, 396, 385, 517, 517, 517, - 517, 504, 537, 505, 538, 420, 521, 521, 521, 521, - 522, 522, 522, 522, 554, 553, 517, 535, 535, 535, - 535, 537, 552, 538, 551, 521, 550, 549, 548, 522, - 540, 540, 540, 540, 547, 544, 535, 543, 542, 539, - 534, 533, 525, 524, 523, 520, 519, 518, 516, 540, - 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, - - 579, 580, 580, 580, 580, 580, 580, 580, 580, 580, - 580, 580, 581, 581, 581, 581, 581, 581, 581, 581, + 355, 367, 557, 129, 135, 135, 135, 305, 358, 358, + + 358, 486, 554, 135, 486, 326, 395, 329, 553, 355, + 367, 135, 135, 135, 135, 135, 135, 383, 383, 383, + 383, 394, 498, 394, 499, 395, 417, 417, 417, 417, + 552, 551, 550, 394, 394, 394, 383, 511, 511, 511, + 511, 498, 530, 499, 531, 417, 515, 515, 515, 515, + 528, 528, 528, 528, 548, 547, 511, 533, 533, 533, + 533, 530, 546, 531, 545, 515, 544, 542, 541, 528, + 534, 534, 534, 534, 540, 537, 533, 543, 543, 543, + 543, 573, 573, 573, 573, 573, 573, 573, 573, 573, + 573, 573, 574, 574, 574, 574, 574, 574, 574, 574, + + 574, 574, 574, 575, 575, 575, 575, 575, 575, 575, + 575, 575, 575, 575, 576, 576, 576, 576, 576, 576, + 576, 576, 576, 576, 576, 577, 577, 577, 577, 577, + 577, 577, 577, 577, 577, 577, 578, 536, 535, 532, + 578, 578, 527, 526, 518, 517, 578, 579, 516, 514, + 513, 579, 579, 579, 512, 579, 510, 579, 580, 580, + 509, 580, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 582, 582, 582, 582, 582, 582, 582, - 582, 582, 582, 582, 583, 583, 583, 583, 583, 583, - 583, 583, 583, 583, 583, 584, 515, 514, 513, 584, - 584, 512, 511, 510, 509, 584, 585, 507, 506, 503, - 585, 585, 585, 502, 585, 501, 585, 586, 586, 499, - 586, 587, 587, 587, 587, 587, 587, 587, 587, 587, - 587, 587, 588, 588, 588, 588, 588, 588, 588, 498, - 588, 588, 588, 589, 589, 589, 589, 589, 589, 589, - - 589, 589, 590, 497, 496, 590, 590, 495, 493, 590, - 492, 590, 591, 591, 591, 490, 591, 592, 592, 592, - 489, 592, 593, 593, 488, 593, 593, 593, 593, 593, - 593, 593, 593, 594, 594, 594, 487, 594, 604, 604, - 486, 604, 604, 604, 604, 604, 604, 604, 604, 485, - 484, 483, 482, 481, 480, 479, 476, 475, 474, 473, - 472, 469, 468, 467, 466, 465, 464, 463, 462, 460, - 459, 458, 457, 456, 453, 451, 450, 449, 448, 447, - 445, 444, 443, 442, 441, 440, 439, 438, 437, 436, - 435, 434, 433, 430, 429, 428, 426, 425, 423, 422, - - 419, 418, 417, 416, 415, 414, 413, 412, 411, 410, - 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, - 399, 395, 394, 393, 392, 391, 390, 389, 388, 387, - 386, 384, 383, 382, 381, 380, 379, 378, 377, 376, - 375, 374, 373, 372, 371, 370, 369, 367, 366, 365, - 364, 363, 358, 354, 352, 351, 350, 349, 348, 347, - 345, 343, 342, 341, 340, 339, 338, 337, 336, 334, - 333, 332, 331, 330, 328, 327, 323, 322, 321, 319, - 316, 314, 313, 311, 309, 308, 307, 306, 304, 303, - 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, - - 291, 290, 289, 287, 286, 285, 284, 283, 282, 281, - 280, 279, 278, 277, 276, 275, 273, 269, 268, 267, - 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, - 256, 254, 253, 249, 248, 247, 246, 245, 244, 243, - 242, 241, 240, 239, 238, 237, 236, 235, 233, 232, - 231, 213, 208, 207, 206, 205, 204, 203, 202, 201, - 200, 199, 198, 196, 195, 194, 192, 191, 190, 188, - 187, 186, 184, 183, 182, 181, 179, 178, 171, 168, - 155, 153, 138, 136, 127, 126, 125, 120, 118, 116, - 115, 114, 111, 110, 105, 100, 77, 74, 72, 70, - - 69, 55, 53, 33, 30, 4, 3, 2, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - 578, 578, 578, 578, 578, 578, 578 + 508, 582, 582, 582, 583, 583, 583, 583, 583, 583, + 583, 583, 583, 584, 507, 506, 584, 584, 505, 504, + + 584, 503, 584, 585, 585, 585, 501, 585, 586, 586, + 586, 500, 586, 587, 587, 497, 587, 587, 587, 587, + 587, 587, 587, 587, 588, 588, 588, 496, 588, 598, + 598, 494, 598, 598, 598, 598, 598, 598, 598, 598, + 493, 492, 491, 490, 488, 487, 485, 484, 483, 482, + 481, 480, 479, 478, 477, 476, 475, 472, 471, 470, + 469, 468, 465, 464, 463, 462, 461, 460, 459, 458, + 456, 455, 454, 453, 452, 449, 447, 446, 445, 444, + 442, 441, 440, 439, 438, 437, 436, 435, 434, 433, + 432, 431, 430, 427, 426, 425, 423, 422, 420, 419, + + 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, + 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, + 393, 392, 391, 390, 389, 388, 387, 386, 385, 384, + 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, + 372, 371, 370, 369, 368, 366, 365, 364, 363, 362, + 357, 353, 351, 350, 349, 348, 347, 346, 344, 342, + 341, 340, 339, 338, 337, 336, 334, 333, 332, 331, + 330, 328, 327, 323, 322, 321, 319, 316, 314, 313, + 311, 309, 308, 307, 306, 304, 303, 302, 301, 300, + 299, 298, 297, 296, 295, 294, 293, 291, 290, 289, + + 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, + 277, 276, 275, 273, 269, 268, 267, 266, 265, 264, + 263, 262, 261, 260, 259, 258, 257, 256, 254, 253, + 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, + 239, 238, 237, 236, 235, 233, 232, 231, 213, 208, + 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, + 196, 195, 194, 192, 191, 190, 188, 187, 186, 184, + 183, 182, 181, 179, 178, 171, 168, 155, 153, 138, + 136, 127, 126, 125, 120, 118, 116, 115, 114, 111, + 110, 105, 100, 77, 74, 72, 70, 69, 55, 53, + + 33, 30, 4, 3, 2, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572 } ; static yy_state_type yy_last_accepting_state; @@ -1199,22 +1197,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[130] = +static const flex_int16_t yy_rule_linenum[129] = { 0, - 186, 189, 190, 191, 199, 217, 218, 219, 220, 221, - 222, 223, 224, 225, 226, 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, - 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, - 274, 276, 280, 281, 282, 284, 291, 295, 302, 307, - 310, 313, 316, 324, 331, 332, 333, 339, 346, 353, - 373, 383, 398, 403, 422, 435, 451, 466, 483, 484, - 495, 506, 507, 519, 527, 537, 556, 568, 582, 583, - - 594, 603, 613, 614, 615, 616, 617, 618, 619, 622, - 624, 632, 650, 655, 656, 662, 663, 674, 680, 686, - 692, 708, 709, 713, 720, 737, 758, 791, 792 + 190, 193, 194, 195, 203, 221, 222, 223, 224, 225, + 226, 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, 267, 271, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 285, 289, 290, 291, 293, 300, 301, 305, 310, 313, + 316, 319, 327, 334, 335, 336, 342, 349, 356, 376, + 386, 401, 406, 425, 438, 454, 469, 486, 487, 498, + 509, 510, 522, 531, 541, 560, 572, 586, 587, 598, + + 608, 618, 619, 620, 621, 622, 623, 624, 627, 629, + 637, 655, 660, 661, 667, 668, 679, 685, 691, 697, + 713, 714, 718, 725, 741, 761, 792, 793 } ; /* The intent behind this definition is that it'll catch @@ -1228,7 +1226,7 @@ char *yytext; #line 1 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -1246,27 +1244,26 @@ char *yytext; along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define YY_NO_INPUT 1 #line 24 "/Users/akim/src/gnu/bison/src/scan-gram.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 gram_wrap -#define gram_wrap() 1 - -#define FLEX_PREFIX(Id) gram_ ## Id -#include <src/flex-scanner.h> +#include <c-ctype.h> +#include <mbswidth.h> +#include <quote.h> +#include <quotearg.h> #include <src/complain.h> #include <src/files.h> #include <src/getargs.h> #include <src/gram.h> -#include <quotearg.h> #include <src/reader.h> +#include <src/scan-gram.h> #include <src/uniqstr.h> -#include <c-ctype.h> -#include <mbswidth.h> -#include <quote.h> +#define FLEX_PREFIX(Id) gram_ ## Id +#include <src/flex-scanner.h> -#include <src/scan-gram.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 gram_wrap +#define gram_wrap() 1 #define YY_DECL GRAM_LEX_DECL @@ -1278,15 +1275,19 @@ static boundary scanner_cursor; static size_t no_cr_read (FILE *, char *, size_t); #define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size)) -#define RETURN_PERCENT_PARAM(Value) \ - RETURN_VALUE(PERCENT_PARAM, param, param_ ## Value) +/* Report that yytext is an extension, and evaluate to its token type. */ +#define BISON_DIRECTIVE(Directive) \ + (bison_directive (loc, yytext), PERCENT_ ## Directive) + +#define RETURN_PERCENT_PARAM(Value) \ + RETURN_VALUE(PERCENT_PARAM, param_ ## Value) -#define RETURN_PERCENT_FLAG(Value) \ - RETURN_VALUE(PERCENT_FLAG, uniqstr, uniqstr_new (Value)) +#define RETURN_PERCENT_FLAG(Value) \ + RETURN_VALUE(PERCENT_FLAG, uniqstr_new (Value)) -#define RETURN_VALUE(Token, Field, Value) \ +#define RETURN_VALUE(Token, Value) \ do { \ - val->Field = Value; \ + val->Token = Value; \ return Token; \ } while (0) @@ -1298,18 +1299,17 @@ static size_t no_cr_read (FILE *, char *, size_t); #define DEPRECATED(Msg) \ do { \ - size_t i; \ deprecated_directive (loc, yytext, Msg); \ scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \ - for (i = strlen (Msg); i != 0; --i) \ + for (size_t i = strlen (Msg); i != 0; --i) \ unput (Msg[i - 1]); \ } while (0) /* A string representing the most recently saved token. */ -static char *last_string; +static char *last_string = NULL; /* Bracketed identifier. */ -static uniqstr bracketed_id_str = 0; +static uniqstr bracketed_id_str = NULL; static location bracketed_id_loc; static boundary bracketed_id_start; static int bracketed_id_context_state = 0; @@ -1327,7 +1327,7 @@ static void unexpected_eof (boundary, char const *); static void unexpected_newline (boundary, char const *); #line 1329 "src/scan-gram.c" -#line 106 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 108 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* A C-like comment in directives/rules. */ /* Strings and characters in directives/rules. */ @@ -1655,7 +1655,7 @@ YY_DECL { /* %% [7.0] user's declarations go here */ -#line 147 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 151 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Nesting level. Either for nested braces, or nested angle brackets @@ -1722,13 +1722,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 >= 579 ) + if ( yy_current_state >= 573 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 578 ); + while ( yy_current_state != 572 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1747,13 +1747,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 < 130 ) + else if ( yy_act < 129 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 130 ) + else if ( yy_act == 129 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); - else if ( yy_act == 131 ) + else if ( yy_act == 130 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -1772,23 +1772,23 @@ do_action: /* This label is used only to access EOF actions. */ /* Comments and white space. */ case 1: YY_RULE_SETUP -#line 186 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 190 "/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 190 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 194 "/Users/akim/src/gnu/bison/src/scan-gram.l" case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 190 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 194 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case 4: YY_RULE_SETUP -#line 191 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 195 "/Users/akim/src/gnu/bison/src/scan-gram.l" { token_start = loc->start; context_state = YY_START; @@ -1800,7 +1800,7 @@ YY_RULE_SETUP case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 199 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 203 "/Users/akim/src/gnu/bison/src/scan-gram.l" { handle_syncline (yytext + sizeof "#line " - 1, *loc); } @@ -1818,367 +1818,360 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP -#line 217 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NONASSOC; +#line 221 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (NONASSOC); YY_BREAK case 7: YY_RULE_SETUP -#line 218 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_CODE; +#line 222 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (CODE); YY_BREAK case 8: YY_RULE_SETUP -#line 219 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_FLAG("parse.trace"); +#line 223 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_FLAG ("parse.trace"); YY_BREAK case 9: YY_RULE_SETUP -#line 220 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_DEFAULT_PREC; +#line 224 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (DEFAULT_PREC); YY_BREAK case 10: YY_RULE_SETUP -#line 221 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_DEFINE; +#line 225 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (DEFINE); YY_BREAK case 11: YY_RULE_SETUP -#line 222 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_DEFINES; +#line 226 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (DEFINES); YY_BREAK case 12: YY_RULE_SETUP -#line 223 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_DESTRUCTOR; +#line 227 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (DESTRUCTOR); YY_BREAK case 13: YY_RULE_SETUP -#line 224 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_DPREC; +#line 228 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (DPREC); YY_BREAK case 14: YY_RULE_SETUP -#line 225 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_EMPTY; +#line 229 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (EMPTY); YY_BREAK case 15: YY_RULE_SETUP -#line 226 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_ERROR_VERBOSE; +#line 230 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (EXPECT); YY_BREAK case 16: YY_RULE_SETUP -#line 227 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_EXPECT; +#line 231 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (EXPECT_RR); YY_BREAK case 17: YY_RULE_SETUP -#line 228 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_EXPECT_RR; +#line 232 "/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 229 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_FILE_PREFIX; +#line 233 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext)); YY_BREAK case 19: YY_RULE_SETUP -#line 230 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_YACC; +#line 234 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (INITIAL_ACTION); YY_BREAK case 20: YY_RULE_SETUP -#line 231 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_INITIAL_ACTION; +#line 235 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (GLR_PARSER); YY_BREAK case 21: YY_RULE_SETUP -#line 232 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_GLR_PARSER; +#line 236 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (LANGUAGE); YY_BREAK case 22: YY_RULE_SETUP -#line 233 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_LANGUAGE; +#line 237 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_LEFT; YY_BREAK case 23: YY_RULE_SETUP -#line 234 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_LEFT; +#line 238 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_PARAM (lex); YY_BREAK case 24: YY_RULE_SETUP -#line 235 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_PARAM(lex); +#line 239 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_FLAG ("locations"); YY_BREAK case 25: YY_RULE_SETUP -#line 236 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_FLAG("locations"); +#line 240 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (MERGE); YY_BREAK case 26: YY_RULE_SETUP -#line 237 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_MERGE; +#line 241 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (NO_DEFAULT_PREC); YY_BREAK case 27: YY_RULE_SETUP -#line 238 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NAME_PREFIX; +#line 242 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (NO_LINES); YY_BREAK case 28: YY_RULE_SETUP -#line 239 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NO_DEFAULT_PREC; +#line 243 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_NONASSOC; YY_BREAK case 29: YY_RULE_SETUP -#line 240 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NO_LINES; +#line 244 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (NONDETERMINISTIC_PARSER); YY_BREAK case 30: YY_RULE_SETUP -#line 241 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NONASSOC; +#line 245 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (NTERM); YY_BREAK case 31: YY_RULE_SETUP -#line 242 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NONDETERMINISTIC_PARSER; +#line 246 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (OUTPUT); YY_BREAK case 32: YY_RULE_SETUP -#line 243 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_NTERM; +#line 247 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_PARAM (both); YY_BREAK case 33: YY_RULE_SETUP -#line 244 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_OUTPUT; +#line 248 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_PARAM (parse); YY_BREAK case 34: YY_RULE_SETUP -#line 245 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_PARAM(both); +#line 249 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_PREC; YY_BREAK case 35: YY_RULE_SETUP -#line 246 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_PARAM(parse); +#line 250 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (PRECEDENCE); YY_BREAK case 36: YY_RULE_SETUP -#line 247 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_PREC; +#line 251 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (PRINTER); YY_BREAK case 37: YY_RULE_SETUP -#line 248 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_PRECEDENCE; +#line 252 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_PERCENT_FLAG ("api.pure"); YY_BREAK case 38: YY_RULE_SETUP -#line 249 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_PRINTER; +#line 253 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (REQUIRE); YY_BREAK case 39: YY_RULE_SETUP -#line 250 "/Users/akim/src/gnu/bison/src/scan-gram.l" -RETURN_PERCENT_FLAG("api.pure"); +#line 254 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_RIGHT; YY_BREAK case 40: YY_RULE_SETUP -#line 251 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_REQUIRE; +#line 255 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (SKELETON); YY_BREAK case 41: YY_RULE_SETUP -#line 252 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_RIGHT; +#line 256 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_START; YY_BREAK case 42: YY_RULE_SETUP -#line 253 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_SKELETON; +#line 257 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (TOKEN); YY_BREAK case 43: YY_RULE_SETUP -#line 254 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_START; +#line 258 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_TOKEN; YY_BREAK case 44: YY_RULE_SETUP -#line 255 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_TOKEN; +#line 259 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (TOKEN_TABLE); YY_BREAK case 45: YY_RULE_SETUP -#line 256 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_TOKEN; +#line 260 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_TYPE; YY_BREAK case 46: YY_RULE_SETUP -#line 257 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_TOKEN_TABLE; +#line 261 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return PERCENT_UNION; YY_BREAK case 47: YY_RULE_SETUP -#line 258 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_TYPE; +#line 262 "/Users/akim/src/gnu/bison/src/scan-gram.l" +return BISON_DIRECTIVE (VERBOSE); YY_BREAK case 48: YY_RULE_SETUP -#line 259 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_UNION; +#line 263 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext)); YY_BREAK +/* Deprecated since Bison 3.0 (2013-07-25), but the warning is + issued only since Bison 3.3. */ case 49: YY_RULE_SETUP -#line 260 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_VERBOSE; +#line 267 "/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 + issued only since Bison 3.3. */ case 50: +/* rule 50 can match eol */ YY_RULE_SETUP -#line 261 "/Users/akim/src/gnu/bison/src/scan-gram.l" -return PERCENT_YACC; +#line 271 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_NAME_PREFIX, uniqstr_new (yytext)); YY_BREAK -/* deprecated */ +/* Deprecated since Bison 2.7.90, 2012. */ case 51: YY_RULE_SETUP -#line 264 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%default-prec"); +#line 274 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%default-prec"); YY_BREAK case 52: YY_RULE_SETUP -#line 265 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%define parse.error verbose"); +#line 275 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext)); YY_BREAK case 53: YY_RULE_SETUP -#line 266 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%expect-rr"); +#line 276 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%expect-rr"); YY_BREAK case 54: /* rule 54 can match eol */ YY_RULE_SETUP -#line 267 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%file-prefix"); +#line 277 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext)); YY_BREAK case 55: YY_RULE_SETUP -#line 268 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%fixed-output-files"); +#line 278 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext)); YY_BREAK case 56: -/* rule 56 can match eol */ YY_RULE_SETUP -#line 269 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%name-prefix"); +#line 279 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%no-default-prec"); YY_BREAK case 57: YY_RULE_SETUP -#line 270 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%no-default-prec"); +#line 280 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%no-lines"); YY_BREAK case 58: +/* rule 58 can match eol */ YY_RULE_SETUP -#line 271 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%no-lines"); +#line 281 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%output"); YY_BREAK case 59: -/* rule 59 can match eol */ YY_RULE_SETUP -#line 272 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%output"); +#line 282 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%pure-parser"); YY_BREAK case 60: YY_RULE_SETUP -#line 273 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%pure-parser"); +#line 283 "/Users/akim/src/gnu/bison/src/scan-gram.l" +DEPRECATED ("%token-table"); YY_BREAK case 61: YY_RULE_SETUP -#line 274 "/Users/akim/src/gnu/bison/src/scan-gram.l" -DEPRECATED("%token-table"); - YY_BREAK -case 62: -YY_RULE_SETUP -#line 276 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 285 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, _("invalid directive: %s"), quote (yytext)); } YY_BREAK -case 63: +case 62: YY_RULE_SETUP -#line 280 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 289 "/Users/akim/src/gnu/bison/src/scan-gram.l" return EQUAL; YY_BREAK -case 64: +case 63: YY_RULE_SETUP -#line 281 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 290 "/Users/akim/src/gnu/bison/src/scan-gram.l" return PIPE; YY_BREAK -case 65: +case 64: YY_RULE_SETUP -#line 282 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 291 "/Users/akim/src/gnu/bison/src/scan-gram.l" return SEMICOLON; YY_BREAK -case 66: +case 65: YY_RULE_SETUP -#line 284 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 293 "/Users/akim/src/gnu/bison/src/scan-gram.l" { - val->uniqstr = uniqstr_new (yytext); + val->ID = uniqstr_new (yytext); id_loc = *loc; bracketed_id_str = NULL; BEGIN SC_AFTER_IDENTIFIER; } YY_BREAK -case 67: +case 66: YY_RULE_SETUP -#line 291 "/Users/akim/src/gnu/bison/src/scan-gram.l" -{ - val->integer = scan_integer (yytext, 10, *loc); - return INT; - } +#line 300 "/Users/akim/src/gnu/bison/src/scan-gram.l" +RETURN_VALUE (INT, scan_integer (yytext, 10, *loc)); YY_BREAK -case 68: +case 67: YY_RULE_SETUP -#line 295 "/Users/akim/src/gnu/bison/src/scan-gram.l" -{ - val->integer = scan_integer (yytext, 16, *loc); - return INT; - } +#line 301 "/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 69: +case 68: YY_RULE_SETUP -#line 302 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 305 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, _("invalid identifier: %s"), quote (yytext)); } YY_BREAK /* Characters. */ -case 70: +case 69: YY_RULE_SETUP -#line 307 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 310 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER; YY_BREAK /* Strings. */ -case 71: +case 70: YY_RULE_SETUP -#line 310 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 313 "/Users/akim/src/gnu/bison/src/scan-gram.l" token_start = loc->start; BEGIN SC_ESCAPED_STRING; YY_BREAK /* Prologue. */ -case 72: +case 71: YY_RULE_SETUP -#line 313 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 316 "/Users/akim/src/gnu/bison/src/scan-gram.l" code_start = loc->start; BEGIN SC_PROLOGUE; YY_BREAK /* Code in between braces. */ -case 73: +case 72: YY_RULE_SETUP -#line 316 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 319 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; nesting = 0; @@ -2187,10 +2180,10 @@ YY_RULE_SETUP } YY_BREAK /* Semantic predicate. */ -case 74: -/* rule 74 can match eol */ +case 73: +/* rule 73 can match eol */ YY_RULE_SETUP -#line 324 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 327 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; code_start = loc->start; @@ -2198,28 +2191,28 @@ YY_RULE_SETUP } YY_BREAK /* A type. */ -case 75: +case 74: YY_RULE_SETUP -#line 331 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 334 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_ANY; YY_BREAK -case 76: +case 75: YY_RULE_SETUP -#line 332 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 335 "/Users/akim/src/gnu/bison/src/scan-gram.l" return TAG_NONE; YY_BREAK -case 77: +case 76: YY_RULE_SETUP -#line 333 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 336 "/Users/akim/src/gnu/bison/src/scan-gram.l" { nesting = 0; token_start = loc->start; BEGIN SC_TAG; } YY_BREAK -case 78: +case 77: YY_RULE_SETUP -#line 339 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 342 "/Users/akim/src/gnu/bison/src/scan-gram.l" { static int percent_percent_count; if (++percent_percent_count == 2) @@ -2227,9 +2220,9 @@ YY_RULE_SETUP return PERCENT_PERCENT; } YY_BREAK -case 79: +case 78: YY_RULE_SETUP -#line 346 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 349 "/Users/akim/src/gnu/bison/src/scan-gram.l" { bracketed_id_str = NULL; bracketed_id_start = loc->start; @@ -2237,9 +2230,9 @@ YY_RULE_SETUP BEGIN SC_BRACKETED_ID; } YY_BREAK -case 80: +case 79: YY_RULE_SETUP -#line 353 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 356 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", ngettext ("invalid character", "invalid characters", yyleng), @@ -2247,7 +2240,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 359 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 362 "/Users/akim/src/gnu/bison/src/scan-gram.l" { loc->start = loc->end = scanner_cursor; yyterminate (); @@ -2260,9 +2253,9 @@ case YY_STATE_EOF(INITIAL): `--------------------------------------------------------------*/ -case 81: +case 80: YY_RULE_SETUP -#line 373 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 376 "/Users/akim/src/gnu/bison/src/scan-gram.l" complain (loc, complaint, _("invalid null character")); YY_BREAK @@ -2271,9 +2264,9 @@ complain (loc, complaint, _("invalid null character")); `-----------------------------------------------------------------*/ -case 82: +case 81: YY_RULE_SETUP -#line 383 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 386 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { @@ -2290,18 +2283,18 @@ YY_RULE_SETUP } } YY_BREAK -case 83: +case 82: YY_RULE_SETUP -#line 398 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 401 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); *loc = id_loc; return ID_COLON; } YY_BREAK -case 84: +case 83: YY_RULE_SETUP -#line 403 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 406 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); @@ -2310,7 +2303,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_AFTER_IDENTIFIER): -#line 409 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 412 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN (bracketed_id_str ? SC_RETURN_BRACKETED_ID : INITIAL); *loc = id_loc; @@ -2323,9 +2316,9 @@ case YY_STATE_EOF(SC_AFTER_IDENTIFIER): `--------------------------------*/ -case 85: +case 84: YY_RULE_SETUP -#line 422 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 425 "/Users/akim/src/gnu/bison/src/scan-gram.l" { if (bracketed_id_str) { @@ -2340,16 +2333,16 @@ YY_RULE_SETUP } } YY_BREAK -case 86: +case 85: YY_RULE_SETUP -#line 435 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 438 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; if (bracketed_id_str) { if (INITIAL == bracketed_id_context_state) { - val->uniqstr = bracketed_id_str; + val->BRACKETED_ID = bracketed_id_str; bracketed_id_str = 0; *loc = bracketed_id_loc; return BRACKETED_ID; @@ -2359,9 +2352,9 @@ YY_RULE_SETUP complain (loc, complaint, _("an identifier expected")); } YY_BREAK -case 87: +case 86: YY_RULE_SETUP -#line 451 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 454 "/Users/akim/src/gnu/bison/src/scan-gram.l" { complain (loc, complaint, "%s: %s", ngettext ("invalid character in bracketed name", @@ -2370,7 +2363,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(SC_BRACKETED_ID): -#line 458 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 461 "/Users/akim/src/gnu/bison/src/scan-gram.l" { BEGIN bracketed_id_context_state; unexpected_eof (bracketed_id_start, "]"); @@ -2379,12 +2372,12 @@ case YY_STATE_EOF(SC_BRACKETED_ID): -case 88: +case 87: YY_RULE_SETUP -#line 466 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 469 "/Users/akim/src/gnu/bison/src/scan-gram.l" { ROLLBACK_CURRENT_TOKEN; - val->uniqstr = bracketed_id_str; + val->BRACKETED_ID = bracketed_id_str; bracketed_id_str = 0; *loc = bracketed_id_loc; BEGIN INITIAL; @@ -2397,19 +2390,19 @@ YY_RULE_SETUP `---------------------------------------------------------------*/ -case 89: +case 88: YY_RULE_SETUP -#line 483 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 486 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK -case 90: -/* rule 90 can match eol */ +case 89: +/* rule 89 can match eol */ YY_RULE_SETUP -#line 484 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 487 "/Users/akim/src/gnu/bison/src/scan-gram.l" continue; YY_BREAK case YY_STATE_EOF(SC_YACC_COMMENT): -#line 485 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 488 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2418,14 +2411,14 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `------------------------------------------------------------*/ -case 91: -/* rule 91 can match eol */ +case 90: +/* rule 90 can match eol */ YY_RULE_SETUP -#line 495 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 498 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK case YY_STATE_EOF(SC_COMMENT): -#line 496 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 499 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "*/"); BEGIN context_state; YY_BREAK @@ -2434,20 +2427,20 @@ unexpected_eof (token_start, "*/"); BEGIN context_state; `--------------------------------------------------------------*/ -case 92: -/* rule 92 can match eol */ +case 91: +/* rule 91 can match eol */ YY_RULE_SETUP -#line 506 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 509 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 93: -/* rule 93 can match eol */ +case 92: +/* rule 92 can match eol */ YY_RULE_SETUP -#line 507 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 510 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK case YY_STATE_EOF(SC_LINE_COMMENT): -#line 508 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 511 "/Users/akim/src/gnu/bison/src/scan-gram.l" BEGIN context_state; YY_BREAK @@ -2457,25 +2450,26 @@ BEGIN context_state; `------------------------------------------------*/ -case 94: +case 93: YY_RULE_SETUP -#line 519 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 522 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; - loc->start = token_start; - val->code = last_string; BEGIN INITIAL; - return STRING; + loc->start = token_start; + complain (loc, Wyacc, + _("POSIX Yacc does not support string literals")); + RETURN_VALUE (STRING, last_string); } YY_BREAK case YY_STATE_EOF(SC_ESCAPED_STRING): -#line 526 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 530 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK -case 95: -/* rule 95 can match eol */ +case 94: +/* rule 94 can match eol */ YY_RULE_SETUP -#line 527 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 531 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK @@ -2485,20 +2479,20 @@ unexpected_newline (token_start, "\""); `----------------------------------------------------------*/ -case 96: +case 95: YY_RULE_SETUP -#line 537 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 541 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = token_start; - val->character = last_string[0]; + 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->character = '\''; + val->CHAR = '\''; } else if (last_string[1] != '\0') complain (loc, Wother, @@ -2508,14 +2502,14 @@ YY_RULE_SETUP return CHAR; } YY_BREAK -case 97: -/* rule 97 can match eol */ +case 96: +/* rule 96 can match eol */ YY_RULE_SETUP -#line 556 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 560 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_ESCAPED_CHARACTER): -#line 557 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 561 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK @@ -2524,16 +2518,16 @@ unexpected_eof (token_start, "'"); `--------------------------------------------------------------*/ -case 98: +case 97: YY_RULE_SETUP -#line 568 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 572 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) { STRING_FINISH; loc->start = token_start; - val->uniqstr = uniqstr_new (last_string); + val->TAG = uniqstr_new (last_string); STRING_FREE; BEGIN INITIAL; return TAG; @@ -2541,19 +2535,19 @@ YY_RULE_SETUP STRING_GROW; } YY_BREAK -case 99: -/* rule 99 can match eol */ +case 98: +/* rule 98 can match eol */ YY_RULE_SETUP -#line 582 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 586 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 100: +case 99: YY_RULE_SETUP -#line 583 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 587 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting += yyleng; YY_BREAK case YY_STATE_EOF(SC_TAG): -#line 585 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 589 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, ">"); YY_BREAK @@ -2562,88 +2556,89 @@ unexpected_eof (token_start, ">"); `----------------------------*/ -case 101: +case 100: YY_RULE_SETUP -#line 594 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 598 "/Users/akim/src/gnu/bison/src/scan-gram.l" { + verify (UCHAR_MAX < ULONG_MAX); unsigned long c = strtoul (yytext + 1, NULL, 8); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), - yytext+1); + yytext+1); else obstack_1grow (&obstack_for_string, c); } YY_BREAK -case 102: +case 101: YY_RULE_SETUP -#line 603 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 608 "/Users/akim/src/gnu/bison/src/scan-gram.l" { verify (UCHAR_MAX < ULONG_MAX); unsigned long c = strtoul (yytext + 2, NULL, 16); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), - yytext+1); + yytext+1); else obstack_1grow (&obstack_for_string, c); } YY_BREAK -case 103: +case 102: YY_RULE_SETUP -#line 613 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 618 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\a'); YY_BREAK -case 104: +case 103: YY_RULE_SETUP -#line 614 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 619 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\b'); YY_BREAK -case 105: +case 104: YY_RULE_SETUP -#line 615 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 620 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\f'); YY_BREAK -case 106: +case 105: YY_RULE_SETUP -#line 616 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 621 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\n'); YY_BREAK -case 107: +case 106: YY_RULE_SETUP -#line 617 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 622 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\r'); YY_BREAK -case 108: +case 107: YY_RULE_SETUP -#line 618 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 623 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, '\t'); YY_BREAK -case 109: +case 108: YY_RULE_SETUP -#line 619 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 624 "/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 110: +case 109: YY_RULE_SETUP -#line 622 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 627 "/Users/akim/src/gnu/bison/src/scan-gram.l" obstack_1grow (&obstack_for_string, yytext[1]); YY_BREAK -case 111: +case 110: YY_RULE_SETUP -#line 624 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 629 "/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); + yytext+1); else obstack_1grow (&obstack_for_string, c); } YY_BREAK -case 112: -/* rule 112 can match eol */ +case 111: +/* rule 111 can match eol */ YY_RULE_SETUP -#line 632 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 637 "/Users/akim/src/gnu/bison/src/scan-gram.l" { char const *p = yytext + 1; /* Quote only if escaping won't make the character visible. */ @@ -2652,7 +2647,7 @@ YY_RULE_SETUP else p = quotearg_style_mem (escape_quoting_style, p, 1); complain (loc, complaint, _("invalid character after \\-escape: %s"), - p); + p); } YY_BREAK @@ -2661,46 +2656,46 @@ YY_RULE_SETUP `--------------------------------------------*/ -case 113: -/* rule 113 can match eol */ +case 112: +/* rule 112 can match eol */ YY_RULE_SETUP -#line 650 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 655 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 114: +case 113: YY_RULE_SETUP -#line 655 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 660 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 115: -/* rule 115 can match eol */ +case 114: +/* rule 114 can match eol */ YY_RULE_SETUP -#line 656 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 661 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "'"); YY_BREAK case YY_STATE_EOF(SC_CHARACTER): -#line 657 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 662 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "'"); YY_BREAK -case 116: +case 115: YY_RULE_SETUP -#line 662 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 667 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; BEGIN context_state; YY_BREAK -case 117: -/* rule 117 can match eol */ +case 116: +/* rule 116 can match eol */ YY_RULE_SETUP -#line 663 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 668 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_newline (token_start, "\""); YY_BREAK case YY_STATE_EOF(SC_STRING): -#line 664 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 669 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (token_start, "\""); YY_BREAK @@ -2709,9 +2704,9 @@ unexpected_eof (token_start, "\""); `---------------------------------------------------*/ -case 118: +case 117: YY_RULE_SETUP -#line 674 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 679 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2719,9 +2714,9 @@ YY_RULE_SETUP BEGIN SC_CHARACTER; } YY_BREAK -case 119: +case 118: YY_RULE_SETUP -#line 680 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 685 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2729,10 +2724,10 @@ YY_RULE_SETUP BEGIN SC_STRING; } YY_BREAK -case 120: -/* rule 120 can match eol */ +case 119: +/* rule 119 can match eol */ YY_RULE_SETUP -#line 686 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 691 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2740,10 +2735,10 @@ YY_RULE_SETUP BEGIN SC_COMMENT; } YY_BREAK -case 121: -/* rule 121 can match eol */ +case 120: +/* rule 120 can match eol */ YY_RULE_SETUP -#line 692 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 697 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_GROW; context_state = YY_START; @@ -2757,37 +2752,37 @@ YY_RULE_SETUP `-----------------------------------------------------------*/ -case 122: -/* rule 122 can match eol */ +case 121: +/* rule 121 can match eol */ YY_RULE_SETUP -#line 708 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 713 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting++; YY_BREAK -case 123: -/* rule 123 can match eol */ +case 122: +/* rule 122 can match eol */ YY_RULE_SETUP -#line 709 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 714 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; nesting--; YY_BREAK /* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly (as '<' '<%'). */ -case 124: -/* rule 124 can match eol */ +case 123: +/* rule 123 can match eol */ YY_RULE_SETUP -#line 713 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 718 "/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 715 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 720 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "}"); YY_BREAK -case 125: +case 124: YY_RULE_SETUP -#line 720 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 725 "/Users/akim/src/gnu/bison/src/scan-gram.l" { obstack_1grow (&obstack_for_string, '}'); @@ -2796,27 +2791,25 @@ YY_RULE_SETUP { STRING_FINISH; loc->start = code_start; - val->code = last_string; BEGIN INITIAL; - return BRACED_CODE; + RETURN_VALUE (BRACED_CODE, last_string); } } YY_BREAK -case 126: +case 125: YY_RULE_SETUP -#line 737 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 741 "/Users/akim/src/gnu/bison/src/scan-gram.l" { --nesting; if (nesting < 0) { STRING_FINISH; loc->start = code_start; - val->code = last_string; BEGIN INITIAL; - return BRACED_PREDICATE; + RETURN_VALUE (BRACED_PREDICATE, last_string); } else obstack_1grow (&obstack_for_string, '}'); @@ -2828,19 +2821,18 @@ YY_RULE_SETUP `--------------------------------------------------------------*/ -case 127: +case 126: YY_RULE_SETUP -#line 758 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 761 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; - val->code = last_string; BEGIN INITIAL; - return PROLOGUE; + RETURN_VALUE (PROLOGUE, last_string); } YY_BREAK case YY_STATE_EOF(SC_PROLOGUE): -#line 766 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 768 "/Users/akim/src/gnu/bison/src/scan-gram.l" unexpected_eof (code_start, "%}"); YY_BREAK @@ -2851,33 +2843,32 @@ unexpected_eof (code_start, "%}"); case YY_STATE_EOF(SC_EPILOGUE): -#line 777 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 779 "/Users/akim/src/gnu/bison/src/scan-gram.l" { STRING_FINISH; loc->start = code_start; - val->code = last_string; BEGIN INITIAL; - return EPILOGUE; + RETURN_VALUE (EPILOGUE, last_string); } YY_BREAK /*-----------------------------------------------------. | By default, grow the string obstack with the input. | `-----------------------------------------------------*/ +case 127: +#line 793 "/Users/akim/src/gnu/bison/src/scan-gram.l" case 128: -#line 792 "/Users/akim/src/gnu/bison/src/scan-gram.l" -case 129: -/* rule 129 can match eol */ +/* rule 128 can match eol */ YY_RULE_SETUP -#line 792 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 793 "/Users/akim/src/gnu/bison/src/scan-gram.l" STRING_GROW; YY_BREAK -case 130: +case 129: YY_RULE_SETUP -#line 794 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 795 "/Users/akim/src/gnu/bison/src/scan-gram.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2880 "src/scan-gram.c" +#line 2871 "src/scan-gram.c" case YY_STATE_EOF(SC_RETURN_BRACKETED_ID): yyterminate(); @@ -3199,7 +3190,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 >= 579 ) + if ( yy_current_state >= 573 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -3232,11 +3223,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 >= 579 ) + if ( yy_current_state >= 573 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 578); + yy_is_jam = (yy_current_state == 572); return yy_is_jam ? 0 : yy_current_state; } @@ -4029,7 +4020,7 @@ void yyfree (void * ptr ) /* %ok-for-header */ -#line 794 "/Users/akim/src/gnu/bison/src/scan-gram.l" +#line 795 "/Users/akim/src/gnu/bison/src/scan-gram.l" /* Read bytes from FP into buffer BUF of size SIZE. Return the @@ -4088,12 +4079,16 @@ static unsigned long scan_integer (char const *number, int base, location loc) { verify (INT_MAX < ULONG_MAX); + if (base == 16) + complain (&loc, Wyacc, + _("POSIX Yacc does not support hexadecimal literals")); + unsigned long num = strtoul (number, NULL, base); if (INT_MAX < num) { complain (&loc, complaint, _("integer out of range: %s"), - quote (number)); + quote (number)); num = INT_MAX; } @@ -4197,7 +4192,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end) loc.end = scanner_cursor; size_t i = strlen (token_end); -/* Adjust scanner cursor so that any later message does not count + /* Adjust scanner cursor so that any later message does not count the characters about to be inserted. */ scanner_cursor.column -= i; @@ -4208,7 +4203,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end) /* Instead of '\'', display "'". */ if (STREQ (token_end, "'\\''")) token_end = "\"'\""; - complain (&loc, complaint, _(msgid), token_end); + complain (&loc, complaint, msgid, token_end); } @@ -4221,7 +4216,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end) static void unexpected_eof (boundary start, char const *token_end) { - unexpected_end (start, N_("missing %s at end of file"), token_end); + unexpected_end (start, _("missing %s at end of file"), token_end); } @@ -4232,7 +4227,7 @@ unexpected_eof (boundary start, char const *token_end) static void unexpected_newline (boundary start, char const *token_end) { - unexpected_end (start, N_("missing %s at end of line"), token_end); + unexpected_end (start, _("missing %s at end of line"), token_end); } diff --git a/contrib/tools/bison/src/scan-gram.h b/contrib/tools/bison/src/scan-gram.h index f135959e3c..f25d183f1e 100644 --- a/contrib/tools/bison/src/scan-gram.h +++ b/contrib/tools/bison/src/scan-gram.h @@ -1,7 +1,7 @@ /* Bison Grammar Scanner - Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/scan-skel.h b/contrib/tools/bison/src/scan-skel.h index f76abde10d..20fa09da8e 100644 --- a/contrib/tools/bison/src/scan-skel.h +++ b/contrib/tools/bison/src/scan-skel.h @@ -1,7 +1,7 @@ /* Scan Bison Skeletons. - Copyright (C) 2005-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2005-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/state.c b/contrib/tools/bison/src/state.c index 7037b358ea..0fc9320601 100644 --- a/contrib/tools/bison/src/state.c +++ b/contrib/tools/bison/src/state.c @@ -1,7 +1,7 @@ /* Type definitions for the finite state machine for Bison. - Copyright (C) 2001-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2001-2007, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -143,7 +143,7 @@ state_new (symbol_number accessing_symbol, res->reductions = NULL; res->errs = NULL; res->state_list = NULL; - res->consistent = 0; + res->consistent = false; res->solved_conflicts = NULL; res->solved_conflicts_xml = NULL; diff --git a/contrib/tools/bison/src/state.h b/contrib/tools/bison/src/state.h index 9fb968f761..5b37ed6a47 100644 --- a/contrib/tools/bison/src/state.h +++ b/contrib/tools/bison/src/state.h @@ -1,6 +1,6 @@ /* Type definitions for the finite state machine for Bison. - Copyright (C) 1984, 1989, 2000-2004, 2007, 2009-2015, 2018 Free + Copyright (C) 1984, 1989, 2000-2004, 2007, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -81,6 +81,8 @@ #ifndef STATE_H_ # define STATE_H_ +# include <stdbool.h> + # include <bitset.h> # include "gram.h" @@ -117,7 +119,7 @@ typedef struct /* What is the symbol labelling the transition to TRANSITIONS->states[Num]? Can be a token (amongst which the error - token), or non terminals in case of gotos. */ + token), or nonterminals in case of gotos. */ # define TRANSITION_SYMBOL(Transitions, Num) \ (Transitions->states[Num]->accessing_symbol) @@ -208,9 +210,9 @@ struct state store in this member a reference to the node containing each state. */ struct state_list *state_list; - /* If non-zero, then no lookahead sets on reduce actions are needed to - decide what to do in state S. */ - char consistent; + /* Whether no lookahead sets on reduce actions are needed to decide + what to do in state S. */ + bool consistent; /* If some conflicts were solved thanks to precedence/associativity, a human readable description of the resolution. */ diff --git a/contrib/tools/bison/src/symlist.c b/contrib/tools/bison/src/symlist.c index 201ddabdba..c5947cc890 100644 --- a/contrib/tools/bison/src/symlist.c +++ b/contrib/tools/bison/src/symlist.c @@ -1,6 +1,6 @@ /* Lists of symbols for Bison - Copyright (C) 2002, 2005-2007, 2009-2015, 2018 Free Software + Copyright (C) 2002, 2005-2007, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -49,6 +49,8 @@ symbol_list_sym_new (symbol *sym, location loc) res->dprec_location = empty_location; res->merger = 0; res->merger_declaration_location = empty_location; + res->expected_sr_conflicts = -1; + res->expected_rr_conflicts = -1; res->next = NULL; @@ -79,6 +81,15 @@ symbol_list_type_new (uniqstr type_name, location loc) } +symbol_list * +symbol_list_type_set (symbol_list *syms, uniqstr type_name, location loc) +{ + for (symbol_list *l = syms; l; l = l->next) + symbol_type_set (l->content.sym, type_name, loc); + return syms; +} + + /*-----------------------------------------------------------------------. | Print this list, for which every content_type must be SYMLIST_SYMBOL. | `-----------------------------------------------------------------------*/ @@ -172,9 +183,8 @@ symbol_list_length (symbol_list const *l) symbol_list * symbol_list_n_get (symbol_list *l, int n) { - int i; aver (0 <= n); - for (i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) { l = l->next; aver (l); diff --git a/contrib/tools/bison/src/symlist.h b/contrib/tools/bison/src/symlist.h index 3ade17049a..d8ae90c97d 100644 --- a/contrib/tools/bison/src/symlist.h +++ b/contrib/tools/bison/src/symlist.h @@ -1,6 +1,6 @@ /* Lists of symbols for Bison - Copyright (C) 2002, 2005-2007, 2009-2015, 2018 Free Software + Copyright (C) 2002, 2005-2007, 2009-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -87,6 +87,11 @@ typedef struct symbol_list int merger; location merger_declaration_location; + /* Counts of the number of expected conflicts for this rule, or -1 if none + given. */ + int expected_sr_conflicts; + int expected_rr_conflicts; + /* The list. */ struct symbol_list *next; } symbol_list; @@ -98,6 +103,11 @@ symbol_list *symbol_list_sym_new (symbol *sym, location loc); /** Create a list containing \c type_name at \c loc. */ symbol_list *symbol_list_type_new (uniqstr type_name, location loc); +/** Assign the type \c type_name to all the members of \c syms. + ** \returns \c syms */ +symbol_list *symbol_list_type_set (symbol_list *syms, + uniqstr type_name, location loc); + /** Print this list. \pre For every node \c n in the list, <tt>n->content_type = diff --git a/contrib/tools/bison/src/symtab.c b/contrib/tools/bison/src/symtab.c index a91ac3f860..b9a934f726 100644 --- a/contrib/tools/bison/src/symtab.c +++ b/contrib/tools/bison/src/symtab.c @@ -1,7 +1,7 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000-2002, 2004-2015, 2018 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2004-2015, 2018-2019 Free + Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -46,17 +46,14 @@ symbol *accept = NULL; symbol *startsymbol = NULL; location startsymbol_location; -/*---------------------------. -| Precedence relation graph. | -`---------------------------*/ - +/* Precedence relation graph. */ static symgraph **prec_nodes; -/*-----------------------------------. -| Store which associativity is used. | -`-----------------------------------*/ +/* Store which associativity is used. */ +static bool *used_assoc = NULL; + +bool tag_seen = false; -bool *used_assoc = NULL; /*--------------------------. | Create a new sym_content. | @@ -213,11 +210,11 @@ semantic_type_new (uniqstr tag, const location *loc) `-----------------*/ #define SYMBOL_ATTR_PRINT(Attr) \ - if (s->content->Attr) \ + if (s->content && s->content->Attr) \ fprintf (f, " %s { %s }", #Attr, s->content->Attr) #define SYMBOL_CODE_PRINT(Attr) \ - if (s->content->props[Attr].code) \ + if (s->content && s->content->props[Attr].code) \ fprintf (f, " %s { %s }", #Attr, s->content->props[Attr].code) void @@ -277,8 +274,8 @@ symbol_id_get (symbol const *sym) `------------------------------------------------------------------*/ static void -symbol_redeclaration (symbol *s, const char *what, location first, - location second) +complain_symbol_redeclared (symbol *s, const char *what, location first, + location second) { unsigned i = 0; locations_sort (&first, &second); @@ -290,8 +287,8 @@ symbol_redeclaration (symbol *s, const char *what, location first, } static void -semantic_type_redeclaration (semantic_type *s, const char *what, location first, - location second) +complain_semantic_type_redeclared (semantic_type *s, const char *what, location first, + location second) { unsigned i = 0; locations_sort (&first, &second); @@ -302,6 +299,19 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first, _("previous declaration")); } +static void +complain_class_redeclared (symbol *sym, symbol_class class, location second) +{ + unsigned i = 0; + complain_indent (&second, complaint, &i, + class == token_sym + ? _("symbol %s redeclared as a token") + : _("symbol %s redeclared as a nonterminal"), sym->tag); + i += SUB_INDENT; + complain_indent (&sym->location, complaint, &i, + _("previous definition")); +} + void symbol_location_as_lhs_set (symbol *sym, location loc) @@ -321,8 +331,10 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc) { if (type_name) { + tag_seen = true; if (sym->content->type_name) - symbol_redeclaration (sym, "%type", sym->content->type_location, loc); + complain_symbol_redeclared (sym, "%type", + sym->content->type_location, loc); else { uniqstr_assert (type_name); @@ -341,9 +353,9 @@ symbol_code_props_set (symbol *sym, code_props_type kind, code_props const *code) { if (sym->content->props[kind].code) - symbol_redeclaration (sym, code_props_type_string (kind), - sym->content->props[kind].location, - code->location); + complain_symbol_redeclared (sym, code_props_type_string (kind), + sym->content->props[kind].location, + code->location); else sym->content->props[kind] = *code; } @@ -358,9 +370,9 @@ semantic_type_code_props_set (semantic_type *type, code_props const *code) { if (type->props[kind].code) - semantic_type_redeclaration (type, code_props_type_string (kind), - type->props[kind].location, - code->location); + complain_semantic_type_redeclared (type, code_props_type_string (kind), + type->props[kind].location, + code->location); else type->props[kind] = *code; } @@ -408,8 +420,8 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc) { sym_content *s = sym->content; if (s->prec) - symbol_redeclaration (sym, assoc_to_string (a), - s->prec_location, loc); + complain_symbol_redeclared (sym, assoc_to_string (a), + s->prec_location, loc); else { s->prec = prec; @@ -430,27 +442,25 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc) void symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) { - bool warned = false; - if (sym->content->class != unknown_sym && sym->content->class != class) + aver (class != unknown_sym); + sym_content *s = sym->content; + if (s->class != unknown_sym && s->class != class) + complain_class_redeclared (sym, class, loc); + else { - complain (&loc, complaint, _("symbol %s redefined"), sym->tag); - /* Don't report both "redefined" and "redeclared". */ - warned = true; - } + if (class == nterm_sym && s->class != nterm_sym) + s->number = nvars++; + else if (class == token_sym && s->number == NUMBER_UNDEFINED) + s->number = ntokens++; + s->class = class; - if (class == nterm_sym && sym->content->class != nterm_sym) - sym->content->number = nvars++; - else if (class == token_sym && sym->content->number == NUMBER_UNDEFINED) - sym->content->number = ntokens++; - - sym->content->class = class; - - if (declaring) - { - if (sym->content->status == declared && !warned) - complain (&loc, Wother, _("symbol %s redeclared"), sym->tag); - else - sym->content->status = declared; + if (declaring) + { + if (s->status == declared) + complain (&loc, Wother, _("symbol %s redeclared"), sym->tag); + else + s->status = declared; + } } } @@ -462,24 +472,27 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) void symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) { - int *user_token_numberp; - - user_token_numberp = &sym->content->user_token_number; - if (*user_token_numberp != USER_NUMBER_UNDEFINED - && *user_token_numberp != user_token_number) + 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")); + else if (*user_token_numberp != USER_NUMBER_UNDEFINED + && *user_token_numberp != user_token_number) complain (&loc, complaint, _("redefining user token number of %s"), sym->tag); - - *user_token_numberp = user_token_number; - /* User defined $end token? */ - if (user_token_number == 0) + else { - endtoken = sym->content->symbol; - /* It is always mapped to 0, so it was already counted in - NTOKENS. */ - if (endtoken->content->number != NUMBER_UNDEFINED) - --ntokens; - endtoken->content->number = 0; + *user_token_numberp = user_token_number; + /* User defined $end token? */ + if (user_token_number == 0) + { + endtoken = sym->content->symbol; + /* It is always mapped to 0, so it was already counted in + NTOKENS. */ + if (endtoken->content->number != NUMBER_UNDEFINED) + --ntokens; + endtoken->content->number = 0; + } } } @@ -596,7 +609,10 @@ symbol_merge_properties (symbol *sym, symbol *str) void symbol_make_alias (symbol *sym, symbol *str, location loc) { - if (str->alias) + if (sym->content->class != token_sym) + complain (&loc, complaint, + _("nonterminals cannot be given a string alias")); + else if (str->alias) complain (&loc, Wother, _("symbol %s used more than once as a literal string"), str->tag); else if (sym->alias) @@ -638,7 +654,7 @@ symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED) } static void -user_token_number_redeclaration (int num, symbol *first, symbol *second) +complain_user_token_number_redeclared (int num, symbol *first, symbol *second) { unsigned i = 0; symbols_sort (&first, &second); @@ -658,14 +674,14 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second) static inline bool symbol_translation (symbol *this) { - /* Non-terminal? */ + /* Nonterminal? */ if (this->content->class == token_sym && !this->is_alias) { /* A token which translation has already been set?*/ if (token_translations[this->content->user_token_number] != undeftoken->content->number) - user_token_number_redeclaration + complain_user_token_number_redeclared (this->content->user_token_number, symbols[token_translations[this->content->user_token_number]], this); else diff --git a/contrib/tools/bison/src/symtab.h b/contrib/tools/bison/src/symtab.h index 71ade8a7cf..c22811265d 100644 --- a/contrib/tools/bison/src/symtab.h +++ b/contrib/tools/bison/src/symtab.h @@ -1,6 +1,6 @@ /* Definitions for symtab.c and callers, part of Bison. - Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2015, 2018 Free + Copyright (C) 1984, 1989, 1992, 2000-2002, 2004-2015, 2018-2019 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -40,7 +40,7 @@ typedef enum { unknown_sym, /**< Undefined. */ token_sym, /**< Terminal. */ - nterm_sym /**< Non-terminal. */ + nterm_sym /**< Nonterminal. */ } symbol_class; @@ -137,6 +137,10 @@ struct sym_content location prec_location; int prec; assoc assoc; + + /** The user specified token number. + + E.g., %token FOO 42.*/ int user_token_number; symbol_class class; @@ -212,7 +216,10 @@ code_props *symbol_code_props_get (symbol *sym, code_props_type kind); Do nothing if invoked with \c undef_assoc as \c assoc. */ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc); -/** Set the \c class associated with \c sym. */ +/** Set the \c class associated with \c sym. + + Whether \c declaring means whether this class definition comes + from %nterm or %token. */ void symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring); @@ -241,6 +248,8 @@ extern symbol *startsymbol; /** The location of the \c \%start declaration. */ extern location startsymbol_location; +/** Whether a symbol declared with a type tag. */ +extern bool tag_seen; /*-------------------. diff --git a/contrib/tools/bison/src/system.h b/contrib/tools/bison/src/system.h index fa7a060d38..8a82c788e0 100644 --- a/contrib/tools/bison/src/system.h +++ b/contrib/tools/bison/src/system.h @@ -1,7 +1,7 @@ /* System-dependent definitions for Bison. - Copyright (C) 2000-2007, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2000-2007, 2009-2015, 2018-2019 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 diff --git a/contrib/tools/bison/src/tables.c b/contrib/tools/bison/src/tables.c index 3c35b6f10b..30849c33b5 100644 --- a/contrib/tools/bison/src/tables.c +++ b/contrib/tools/bison/src/tables.c @@ -1,7 +1,7 @@ /* Output the generated parsing program for Bison. - Copyright (C) 1984, 1986, 1989, 1992, 2000-2006, 2009-2015, 2018 Free - Software Foundation, Inc. + Copyright (C) 1984, 1986, 1989, 1992, 2000-2006, 2009-2015, 2018-2019 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/tables.h b/contrib/tools/bison/src/tables.h index 0eb0e5cd23..0504e38c46 100644 --- a/contrib/tools/bison/src/tables.h +++ b/contrib/tools/bison/src/tables.h @@ -1,7 +1,7 @@ /* Prepare the LALR and GLR parser tables. - Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/uniqstr.c b/contrib/tools/bison/src/uniqstr.c index b4f6e9463d..f654d55ef1 100644 --- a/contrib/tools/bison/src/uniqstr.c +++ b/contrib/tools/bison/src/uniqstr.c @@ -1,7 +1,7 @@ /* Keep a unique copy of strings. - Copyright (C) 2002-2005, 2009-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2005, 2009-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/src/uniqstr.h b/contrib/tools/bison/src/uniqstr.h index 5247242158..1fd731807f 100644 --- a/contrib/tools/bison/src/uniqstr.h +++ b/contrib/tools/bison/src/uniqstr.h @@ -1,7 +1,7 @@ /* Keeping a unique copy of strings. - Copyright (C) 2002-2003, 2008-2015, 2018 Free Software Foundation, - Inc. + Copyright (C) 2002-2003, 2008-2015, 2018-2019 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/contrib/tools/bison/ya.make b/contrib/tools/bison/ya.make index 8e78546b4c..1fc51ad5ab 100644 --- a/contrib/tools/bison/ya.make +++ b/contrib/tools/bison/ya.make @@ -10,9 +10,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(3.2.4) +VERSION(3.3.2) -ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.2.4.tar.gz) +ORIGINAL_SOURCE(mirror://gnu/bison/bison-3.3.2.tar.gz) PEERDIR( contrib/tools/bison/lib @@ -28,6 +28,8 @@ NO_COMPILER_WARNINGS() NO_RUNTIME() CFLAGS( + -DEXEEXT=\"\" + -DINSTALLDIR=\"/var/empty/bison-3.3.2/bin\" -DBISON_DATA_DIR=contrib/tools/bison/data ) @@ -43,6 +45,7 @@ SRCS( src/conflicts.c src/derives.c src/files.c + src/fixits.c src/getargs.c src/gram.c src/graphviz.c |