Compare commits

...
58 Commits
Author SHA1 Message Date
Akim Demaille d57eab87e8 version 3.4.92
* NEWS: Record release date.
2019-12-08 09:12:30 +01:00
Akim Demaille bb901beb68 news: fixes
Reported by Paul Eggert.
https://lists.gnu.org/archive/html/bison-patches/2019-12/msg00014.html

* NEWS: here.
2019-12-08 09:12:07 +01:00
Akim Demaille fa00c56c17 doc: minor changes
* README-hacking.md: here.
2019-12-07 18:23:08 +01:00
Akim Demaille 5359c479bc gnulib: update 2019-12-07 15:29:43 +01:00
Akim Demaille 20107b77c0 doc: clearly deprecate YYPRINT
* doc/bison.texi (Prologue): Stop using YYPRINT as an example.
(The YYPRINT Macro): Clearly show this macro is deprecated.
2019-12-07 15:29:43 +01:00
Akim Demaille 5e71eef267 doc: formatting changes
* doc/bison.texi: here.
No change in content.
2019-12-07 15:29:43 +01:00
Akim Demaille 472531dc72 news: update 2019-12-07 15:29:43 +01:00
Akim Demaille 046f238826 d: obey parse.error
* data/skeletons/lalr1.d (yysyntax_error): Let the dispatch be
bison-time, not runtime.
2019-12-07 13:23:45 +01:00
Akim Demaille 9bf06f6963 c++: also prefer YY_ASSERT to YYASSERT
Like the other skeletons.

* data/skeletons/variant.hh: here.
2019-12-07 13:23:45 +01:00
Akim Demaille 357336d254 glr.c: obey the parse.assert %define variable
* data/skeletons/glr.c (YYASSERT): Rename as...
(YY_ASSERT): this, for consistency with yacc.c, and also to emphasize
the fact that this is not for the end user (YY_ prefix).
* tests/glr-regression.at: Define parse.assert.
2019-12-07 13:23:45 +01:00
Akim Demaille d4a6c3c58a c++: beware of short ranges for state numbers
Now that we use small integral types, possibly unsigned (e.g.,
unsigned char), to store state numbers, using -1 to denote an empty
state (i.e., a state that stores no semantical value) is very
dangerous: it will be confused with state 255, which might be
non-empty.

Rather than allocating a larger range of state numbers to keep the
empty-state apart, let's use the number of a state known to store no
value.  The initial state, numbered 0, seems to fit perfectly the job.

Reported by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html

* data/skeletons/lalr1.cc (empty_state): Be 0.
2019-12-07 09:22:55 +01:00
Akim Demaille 8976e0f567 api.token.raw: check it against api.token.constructor
* tests/scanner.at: here.
2019-12-07 08:57:14 +01:00
Akim Demaille 6dca1eb950 regen 2019-12-06 08:27:55 +01:00
Akim Demaille f8d82ff039 warnings: enable -Wuseless-cast, and eliminate warnings
Prompted by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html.

* configure.ac (warn_cxx): Add -Wuseless-cast.
* data/skeletons/c.m4 (b4_attribute_define): Define
YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END.
* data/skeletons/glr.c (YY_FPRINTF): New, replaces YYFPRINTF, wrapped
with YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END.
(YY_DPRINTF): Likewise.
* tests/actions.at: Remove useless cast.
* tests/headers.at: Adjust.
2019-12-06 08:27:55 +01:00
Akim Demaille 9e9e49224f diagnostics: style changes
* src/complain.h, src/complain.c: Comment changes.
* src/scan-skel.l: Reduce scopes.
* data/skeletons/bison.m4: Factor diagnostic functions.
2019-12-02 19:35:01 +01:00
Akim Demaille 8b53f4e022 glr.c: style changes
* data/skeletons/glr.c (yysplitStack): Reduce scopes.
* tests/atlocal.in: Formatting changes.
2019-12-02 19:34:48 +01:00
Akim Demaille 8c87a62308 c++: get rid of symbol_type::token ()
It is not used.  And its implementation was wrong when api.token.raw
was defined, as it was still mapping to the external token numbers,
instead of the internal ones.  Besides it was provided only when
api.token.constructor is defined, yet always declared.

* data/skeletons/c++.m4 (by_type::token): Remove, useless.
2019-12-01 10:05:48 +01:00
Akim Demaille 478cb5cf12 c++: remove useless cast about user_token_number_max_
Reported by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html

The cast is needed when yytranslate_'s argument type is token_type,
i.e., when api.token.constructor is defined.

    373. types.at:138: testing lalr1.cc api.value.type=variant api.token.constructor ...
    ======== Testing with C++ standard flags: ''
    ../../tests/types.at:138: bison --color=no -fno-caret  -o test.cc test.y
    ../../tests/types.at:138: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o test test.cc $LIBS
    stderr:
    test.cc:966:16: error: result of comparison of constant 257 with
                    expression of type 'yy::parser::token_type'
                   (aka 'yy::parser::token::yytokentype') is always true
                   [-Werror,-Wtautological-constant-out-of-range-compare]
        else if (t <= user_token_number_max_)
                 ~ ^  ~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

It is because it is expected that when api.token.constructor is
defined, only symbol constructors will be used, that yytranslate_ then
takes a token_type.  But it is wrong: we still allow literal
characters in this case, as demonstrated by test 373 for instance.

    %define api.value.type variant
    %define api.token.constructor
    %token <std::pair<int, int>> '1' '2';
    [...]
    static yy::parser::symbol_type yylex ()
    {
      static char const input[] = "12";
      int res = input[toknum++];
      typedef yy::parser::symbol_type symbol;
      if (res)
        return symbol (res, std::make_pair (res - '0', res - '0' + 1));
      else
        return symbol (res);
    }

So let yytranslate_ always take an int, which makes the cast truly
useless.

* data/skeletons/c++.m4, data/skeletons/lalr1.cc (yytranslate_): here.
2019-12-01 08:53:58 +01:00
Akim Demaille 94f70bd861 c++: clean a few issues wrt special tokens
The C++ implementation of LAC did not skip the $undefined token,
probably because it was not exposed.  Expose it, and use clearer
names.

* data/skeletons/c++.m4: Don't define undef_token_ in yytranslate_,
but...
* data/skeletons/lalr1.cc (yy_undef_token_): here.
Use a more precise type to define yy_undef_token_ and yy_error_token_.
Unfortunately we move from a compile-time value defined via an enum to
a static const member.  Eventually we should make it constexpr.
Make LAC implementation more alike yacc.c's one.
2019-12-01 08:08:19 +01:00
Akim Demaille 9b4f0970fe d, java: improve yytranslate and neighbors
* data/skeletons/lalr1.d, data/skeletons/lalr1.java: Don't expose
yyuser_token_number_max_ and yyundef_token_.  Do as in C++: scope them
into yytranslate_, and only when api.token.raw is not defined.
(yyterror_): Rename as...
(yy_error_token_): this.
* data/skeletons/lalr1.d (token_number_type): New.
Use it.
Can't be done in the Java backend, as Java does not have type aliases.
2019-12-01 07:59:23 +01:00
Akim Demaille 869028a66d d, java: get rid of a useless table
* data/skeletons/lalr1.d, data/skeletons/lalr1.java (yytoken_number_):
Remove, useless.
Was used in ancient C skeletons to support YYPRINT, long obsoleted by
%printer.
2019-12-01 07:38:31 +01:00
Akim Demaille 6f92a7f664 c++, d, java: remove yyerrcode
It is not used at all.  We will remove it also from yacc.c, but
later (see TODO).

* data/skeletons/lalr1.cc, data/skeletons/lalr1.d,
* data/skeletons/lalr1.java (yyerrcode_):
Remove.
2019-11-30 17:30:48 +01:00
Akim Demaille 6a61b6b17e c++: improve typing
* data/skeletons/lalr1.cc (yysyntax_error_): symbol_type::type_get
returns a symbol_number_type (which is indeed an int).
2019-11-30 17:30:48 +01:00
Akim Demaille a4bf7cdf9e c++: remove useless cast about yyeof_
Reported by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html

* data/skeletons/c++.m4 (b4_yytranslate_define): Don't use yyeof_ as
if it had two different types.
It is used once against the input argument, which is the value
returned by yylex, which is an "external token number", typically an
int.  It is also used as output type, an "internal symbol number".
It turns out that in both cases we mean "0", but let's keep yyeof_
only for the case "internal symbol number", i.e., _after_ conversion
by yytranslate.
This frees us from one cast.
2019-11-30 17:30:48 +01:00
Akim Demaille 9471a5ffe9 glr: style change
* data/skeletons/glr.c (YYDPRINTF): Expand into an empty statement,
instead of nothing.
Simplify callers.
2019-11-30 14:41:16 +01:00
Akim Demaille 24c5214ae8 glr: remove useless casts
Reported by GCC's -Wuseless-cast.

* data/skeletons/glr.c: Don't cast to yybool, it's useless.
2019-11-30 14:41:16 +01:00
Akim Demaille 2f7097d1b1 yacc.c, glr.c: fix crash when reporting errors in consistent states
The current code for yysyntax_error for %define parse.error verbose is
fishy (given that YYEMPTY is -2, invalid argument for yytname[]):

    static int
    yysyntax_error ([...])
    {
      YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
    [...]
      if (yytoken != YYEMPTY)

A nearby comment reports

    The only way there can be no lookahead present (in yychar) is if
    this state is a consistent state with a default action.  Thus,
    detecting the absence of a lookahead is sufficient to determine
    that there is no unexpected or expected token to report.  In that
    case, just report a simple "syntax error".

So it _is_ possible to call yysyntax_error with yytoken == YYEMPTY,
albeit quite difficult when meaning to, so virtually impossible by
accident (after all, there was never a bug report about this).

I failed to produce a test case, but Joel E. Denny provided me with
one (added to the test suite below).  The yacc.c skeleton fails on
this, and once fixed dies on a second problem.  The glr.c skeleton was
also dying, but immediately of this second problem.

Indeed we were not allocating space for the error message's final \0.
This was hidden by the fact that we only had error messages with at
least an unexpected token displayed, so with at least one "%s" in the
format string, whose size (2) was included (incorrectly) in the final
size of the message (where the %s have been replaced by the actual
content).

* data/skeletons/glr.c, data/skeletons/yacc.c (yysyntax_error):
Do not invoke yytnamerr on YYEMPTY.
Clarify the computation of the length of the _final_ error message,
with the NUL terminator but without the '%s's.
* tests/conflicts.at (Syntax error in consistent error state):
New, contributed by Joel E. Denny.
2019-11-29 18:21:43 +01:00
Akim Demaille 28369ecb5d tests: avoid creating files whose name collide with standard headers
Having a file named "exception" is risky: the compiler might use that
file in #include.
Reported by 马俊 <[email protected]>.

* tests/local.at (AT_SKIP_IF_EXCEPTION_SUPPORT_IS_POOR): Generate
'exceptions', not 'exception'.
2019-11-26 08:05:32 +01:00
Akim Demaille b92f064e9b doc: more details about the test suite
* README-hacking.md: here.
2019-11-22 09:02:06 +01:00
Akim Demaille 98f19578aa maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-11-20 07:49:44 +01:00
Akim Demaille 7d9839c4a8 version 3.4.91
* NEWS: Record release date.
2019-11-20 07:13:38 +01:00
Akim Demaille ad32ec64c8 style: pacify syntax-check
* cfg.mk: No need to translate *.md files.
* data/skeletons/glr.c, data/skeletons/yacc.c: Fix space issues.
2019-11-20 07:10:27 +01:00
Akim Demaille 44cdc0f001 gnulib: update 2019-11-19 21:15:00 +01:00
Akim Demaille ca796220ec doc: don't promote dangling aliases
String literals as tokens serve two distinct purposes: freeing from
having to implement the keyword matching in the scanner, and improving
error messages.  Most of the time both can be achieved at the same
time, but on occasions, it does not work so well.

We promote their use for error messages.  We will also still support
the former case, but it is _not_ the recommended approach.

* doc/bison.texi (Tokens from Literals): Clearly state that we don't
recommend looking up the token types in the list of token names.
2019-11-18 09:15:35 +01:00
Akim Demaille 8a910107b3 diagnostics: complain about undeclared string tokens
String literals, which allow for better error messages, are (too)
liberally accepted by Bison, which might result in silent errors.  For
instance

    %type <exVal> cond "condition"

does not define “condition” as a string alias to 'cond' (nonterminal
symbols do not have string aliases).  It is rather equivalent to

    %nterm <exVal> cond
    %token <exVal> "condition"

i.e., it gives the type 'exVal' to the "condition" token, which was
clearly not the intention.

Introduce -Wdangling-alias to catch this.

* src/complain.h, src/complain.c: Add support for -Wdangling-alias.
(argmatch_warning_args): Sort.
* src/symtab.c (symbol_check_defined): Complain about dangling
aliases.
* doc/bison.texi: Document it.
* tests/input.at (Dangling aliases): New test.
2019-11-17 18:27:42 +01:00
Akim Demaille 28d1ca8f48 diagnostics: yacc reserves %type to nonterminals
On

    %token TOKEN1
    %type  <ival> TOKEN1 TOKEN2 't'
    %token TOKEN2
    %%
    expr:

bison -Wyacc gives

    input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |               ^~~~~~
    input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |                             ^~~
    input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
        2 | %type  <ival> TOKEN1 TOKEN2 't'
          |                      ^~~~~~

The messages appear to be out of order, but they are emitted when the
error is found.

* src/symtab.h (symbol_class): Add pct_type_sym, used to denote
symbols appearing in %type.
* src/symtab.c (complain_pct_type_on_token): New.
(symbol_class_set): Check that %type is not applied to tokens.
(symbol_check_defined): pct_type_sym also means undefined.
* src/parse-gram.y (symbol_decl.1): Set the class to pct_type_sym.
* src/reader.c (grammar_current_rule_begin): pct_type_sym also means
undefined.
* tests/input.at (Yacc's %type): New.
2019-11-17 09:45:25 +01:00
Akim Demaille 1817b475a6 doc: promote %nterm over %type
As an extension to POSIX Yacc, Bison's %type accepts tokens.
Unfortunately with string literals as implicit tokens, this is
misleading, and led some users to write

    %type <exVal> cond "condition"

believing that "condition" would be associated to the 'cond'
nonterminal (see https://github.com/apache/httpd/pull/72).

* doc/bison.texi: Promote %nterm rather than %type to declare the type
of nonterminals.
2019-11-16 12:54:44 +01:00
Akim Demaille 22ca07defa doc: formatting changes
* doc/bison.texi: No visible changes.
2019-11-16 12:54:44 +01:00
Akim Demaille dbd6975b5c doc: work around warnings when Flex C output is compiled in C++
* doc/bison.texi (calc++/scanner.ll): here.
While at it, clarify clang vs. warnings.
2019-11-16 12:54:44 +01:00
Akim Demaille cd726fdc4d tests: be robust to old Perl versions on Cygwin
Reported by Denis Excoffier.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00008.html.

* tests/output.at: Be sure to remove back up files.
2019-11-16 12:54:44 +01:00
Akim Demaille 60ebd8e210 regen 2019-11-16 12:54:44 +01:00
kaneko yandAkim Demaille 3765e3e790 gram.c: Fix condition of aver
* src/gram.c (grammar_dump): Fix condition of aver.
What we want to check is that rhs is followed by its rule.
2019-11-12 08:39:28 +01:00
Akim Demaille c313360deb doc: clarify build instructions
* README: A few fixes.
Explain how to install color support.
* README-hacking: Rename as...
* README-hacking.md: this, and convert to Markdown.
Improve typography.
Improve explanations about update-test.
2019-11-11 15:59:53 +01:00
Akim Demaille 25698b58c0 gnulib: update 2019-11-11 15:41:29 +01:00
Yuichiro KanekoandAkim Demaille 17d34c231b gram.c: also print terminals in grammar_dump
* src/gram.c (grammar_dump): Print terminals likewise non terminals.
* tests/sets.at (Reduced Grammar): Update test case to catch up the
change and add a test case where prec and assoc are used.
2019-11-11 10:37:30 +01:00
Akim Demaille af000bab11 doc: work around Texinfo 6.7 bug
When @code is used in a @deftype... definition, it issues quotes.
Remove them.
See https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html.

* doc/local.mk: here.
2019-11-10 14:59:11 +01:00
Akim Demaille b2347a3c3e doc: formatting changes
* doc/bison.texi: Wrap lines.
No semantical difference.
2019-11-09 07:57:05 +01:00
Akim Demaille 008d927f71 doc: use upper case for tokens
* doc/bison.texi: here.
2019-11-09 07:54:32 +01:00
Akim Demaille 1650c729d9 doc: type-face fixes
* doc/bison.texi: Use @code for types in function definitions.
2019-11-07 07:13:40 +01:00
Akim Demaille 7bdf7246fb c++: expose the type used to store line and column numbers
* data/skeletons/location.cc (position::counter_type)
(location::counter_type): New.
Use them.
* doc/bison.texi (C++ position, C++ location): Adjust.
2019-11-06 18:20:15 +01:00
Akim Demaille 583c193ffa tests: fix comment and adjust to locale names on GNU/Linux
Reported by Denis Excoffier.

* tests/diagnostics.at: here.
2019-11-03 10:32:22 +01:00
Akim Demaille 47b9ada6fa tests: really check complaints from m4
* tests/diagnostics.at (Locations from M4, Tabulations and multibyte
characters from M4): These tests are actually checking a message
coming from C, not from M4.  Replace with...
(Complaints from M4): This.
2019-11-03 10:32:22 +01:00
Akim Demaille dcd5bb26e3 tests: simplify prologue
* tests/testsuite.h: We no longer load gnulib in the tests.
2019-11-03 10:32:22 +01:00
Akim Demaille cce6c998b6 diagnostics: add missing translation
* src/muscle-tab.c (muscle_percent_define_check_kind): Here.
2019-11-03 09:24:12 +01:00
Akim Demaille 3398b0fa90 c++: fix old cast warnings
We still have a few old C casts in lalr1.cc, let's get rid of them.
Reported by Frank Heckenbach.

Actually, let's monitor all our casts using easy to grep macros.
Let's use these macros to use the C++ standard casts when we are in
C++.

* data/skeletons/c.m4 (b4_cast_define): New.
* data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/lalr1.cc, data/skeletons/stack.hh,
* data/skeletons/yacc.c:
Use it and/or its casts.

* tests/actions.at, tests/cxx-type.at,
* tests/glr-regression.at, tests/headers.at, tests/torture.at,
* tests/types.at:
Use YY_CAST instead of C casts.

* configure.ac (warn_cxx): Add -Wold-style-cast.
* doc/bison.texi: Disable it.
2019-11-02 16:40:50 +01:00
Akim Demaille 2bd1d9e20f tests: be robust to tput errors
Reported by Denis Excoffier.

* tests/bison.in: here.
2019-11-01 12:04:13 +01:00
Akim Demaille 1f2546396e git: update ignores
I don't understand what happened in
10acc148bb.
2019-11-01 12:04:13 +01:00
Akim Demaille 809268c1a4 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-10-29 21:58:53 +01:00
54 changed files with 1831 additions and 1119 deletions
+1 -1
View File
@@ -1 +1 @@
3.4.2
3.4.91
+115 -2
View File
@@ -1,5 +1,115 @@
GNU Bison NEWS
* Noteworthy changes in release 3.4.92 (2019-12-08) [beta]
** Deprecated features
The YYPRINT macro, which works only with yacc.c and only for tokens, was
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
It is deprecated and its support will be removed eventually.
** New Features
*** A skeleton for the D programming language
For the last few releases, Bison has shipped a stealth experimental
skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
H. S. Teoh.
However, because nobody has committed to improving, testing, and
documenting this skeleton, it is not clear that it will be supported in
the future.
The lalr1.d skeleton *is functional*, and works well, as demonstrated in
examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
** Changes
*** Debugging glr.c and glr.cc
The glr.c skeleton always had asserts to check its own behavior (not the
user's). These assertions are now under the control of the parse.assert
%define variable (disabled by default).
*** Clean up
Several new compiler warnings in the generated output have been avoided.
Some unused features are no longer emitted. Cleaner generated code in
general.
** Bug Fixes
*** Crashes when reporting verbose error messages
In theory, parsers using %nonassoc could crash. This unlikely bug has been
fixed.
* Noteworthy changes in release 3.4.91 (2019-11-20) [beta]
** New Features
*** New diagnostic: -Wdangling-alias
String literals, which allow for better error messages, are (too)
liberally accepted by Bison, which might result in silent errors. For
instance
%type <exVal> cond "condition"
does not define "condition" as a string alias to 'cond' (nonterminal
symbols do not have string aliases). It is rather equivalent to
%nterm <exVal> cond
%token <exVal> "condition"
i.e., it gives the type 'exVal' to the "condition" token, which was
clearly not the intention.
Also, because string aliases need not be defined, typos such as "baz"
instead of "bar" will be not reported.
The option -Wdangling-alias catches these situations. On
%token BAR "bar"
%type <ival> foo "foo"
%%
foo: "baz" {}
bison -Wdangling-alias reports
warning: string literal not attached to a symbol
| %type <ival> foo "foo"
| ^~~~~
warning: string literal not attached to a symbol
| foo: "baz" {}
| ^~~~~
The -Wall option does not (yet?) include -Wdangling-alias.
*** Better POSIX Yacc compatibility diagnostics
POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
-Wyacc.
%token TOKEN1
%type <ival> TOKEN1 TOKEN2 't'
%token TOKEN2
%%
expr:
gives, with -Wyacc
input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~~~~
input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~
input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
2 | %type <ival> TOKEN1 TOKEN2 't'
| ^~~~~~
* Noteworthy changes in release 3.4.90 (2019-10-29) [beta]
** Backward incompatible changes
@@ -11,7 +121,8 @@ GNU Bison NEWS
In C++, line numbers and columns are now represented as 'int' not
'unsigned', so that integer overflow on positions is easily checkable via
'gcc -fsanitize=undefined' and the like. This affects the API for
positions.
positions. The default position and location classes now expose
'counter_type' (int), used to define line and column numbers.
** Bug fixes
@@ -3754,7 +3865,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 backend
LocalWords: noexcept constexpr ispell american deprecations backend Teoh
LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata
Local Variables:
ispell-dictionary: "american"
+36 -15
View File
@@ -7,20 +7,41 @@ Here are basic installation instructions for a repository checkout:
$ git submodule update --init
$ ./bootstrap
then proceed with the usual 'configure && make' steps.
then proceed with the usual `configure && make` steps.
Be sure to read README-hacking, which contains all the needed information
about building, modifying and checking Bison.
The file README-hacking.md is about building, modifying and checking Bison.
## Build from tarball
See the file INSTALL for generic compilation and installation instructions.
Bison requires GNU m4 1.4.6 or later. See:
Bison requires GNU m4 1.4.6 or later. See
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz
## Colored diagnostics
As an experimental feature, diagnostics are now colored, controlled by the
`--color` and `--style` options.
To use them, install the libtextstyle library before configuring Bison. It
is available from https://alpha.gnu.org/gnu/gettext/, for instance
https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz.
The option --color supports the following arguments:
- always, yes: Enable colors.
- never, no: Disable colors.
- auto, tty (default): Enable colors if the output device is a tty.
To customize the styles, create a CSS file, say `bison-bw.css`, similar to
/* bison-bw.css */
.warning { }
.error { font-weight: 800; text-decoration: underline; }
.note { }
then invoke bison with `--style=bison-bw.css`, or set the `BISON_STYLE`
environment variable to `bison-bw.css`.
## Relocatability
If you pass '--enable-relocatable' to 'configure', Bison is 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.
@@ -42,15 +63,15 @@ 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".
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 <[email protected]>.
# Bug reports
Please send bug reports to <[email protected]>. Be sure to include the
version number from 'bison --version', and a complete, self-contained test
version number from `bison --version`, and a complete, self-contained test
case in each bug report.
# Copyright statements
@@ -59,12 +80,6 @@ that the range specifies every single year in that closed interval.
<!--
Local Variables:
mode: markdown
fill-column: 76
ispell-dictionary: "american"
End:
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2019 Free
Software Foundation, Inc.
@@ -83,6 +98,12 @@ 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/>.
Local Variables:
mode: markdown
fill-column: 76
ispell-dictionary: "american"
End:
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
LocalWords: MERCHANTABILITY
+188 -162
View File
@@ -2,20 +2,19 @@ This file attempts to describe the rules to use when hacking Bison.
Don't put this file into the distribution.
Everything related to the development of Bison is on Savannah:
http://savannah.gnu.org/projects/bison/
http://savannah.gnu.org/projects/bison/.
* Administrivia
# Administrivia
** If you incorporate a change from somebody on the net:
## If you incorporate a change from somebody on the net:
First, if it is a large change, you must make sure they have signed the
appropriate paperwork. Second, be sure to add their name and email address
to THANKS.
** If a change fixes a test, mention the test in the commit message.
## If a change fixes a test, mention the test in the commit message.
** Bug reports
## Bug reports
If somebody reports a new bug, mention his name in the commit message and in
the test case you write. Put him into THANKS.
@@ -24,18 +23,18 @@ demonstrates the bug. Then fix the bug, re-run the test suite, and check
everything in.
* Hacking
# Hacking
** Visible changes
## Visible changes
Which include serious bug fixes, must be mentioned in NEWS.
** Translations
## Translations
Only user visible strings are to be translated: error messages, bits of the
.output file etc. This excludes impossible error messages (comparable to
assert/abort), and all the --trace output which is meant for the maintainers
only.
** Horizontal tabs
## Horizontal tabs
Do not add horizontal tab characters to any file in Bison's repository
except where required. For example, do not use tabs to format C code.
However, make files, ChangeLog, and some regular expressions require tabs.
@@ -43,12 +42,12 @@ Also, test cases might need to contain tabs to check that Bison properly
processes tabs in its input.
* Working from the repository
# Working from the repository
These notes intend to help people working on the checked-out sources. These
requirements do not apply when building from a distribution tarball.
** Requirements
## Requirements
We've opted to keep only the highest-level sources in the repository. This
eases our maintenance burden, (fewer merges etc.), but imposes more
@@ -75,8 +74,8 @@ If you're using a GNU/Linux distribution, the easiest way to install the
above packages depends on your system. The following shell command should
work for Debian-based systems such as Ubuntu:
sudo apt-get install \
autoconf automake autopoint flex graphviz help2man texinfo valgrind
sudo apt-get install \
autoconf automake autopoint flex graphviz help2man texinfo valgrind
Bison is written using Bison grammars, so there are bootstrapping issues.
The bootstrap script attempts to discover when the C code generated from the
@@ -89,53 +88,51 @@ after synchronizing from the repository a plain 'make' should be sufficient.
Note, however, that when gnulib is updated, running './bootstrap' again
might be needed.
** First checkout
## First checkout
Obviously, if you are reading these notes, you did manage to check out this
package from the repository. For the record, you will find all the relevant
information on:
http://savannah.gnu.org/git/?group=bison
information on http://savannah.gnu.org/git/?group=bison.
Bison uses Git submodules: subscriptions to other Git repositories. In
particular it uses gnulib, the GNU portability library. To ask Git to
perform the first checkout of the submodules, run
$ git submodule update --init
$ git submodule update --init
The next step is to get other files needed to build, which are extracted
from other source packages:
$ ./bootstrap
$ ./bootstrap
Bootstrapping updates the submodules to the versions registered in the
top-level directory. To change gnulib, first check out the version you want
in `gnulib`, then commit this change in Bison's repository, and finally run
bootstrap.
If it fails with missing symbols (e.g., "error: possibly undefined macro:
AC_PROG_GNU_M4"), you are likely to have forgotten the submodule
If it fails with missing symbols (e.g., `error: possibly undefined macro:
AC_PROG_GNU_M4`), you are likely to have forgotten the submodule
initialization part. To recover from it, run `git reset --hard HEAD`, and
restart with the submodule initialization. Otherwise, there you are! Just
$ ./configure
$ make
$ make check
$ ./configure
$ make
$ make check
At this point, there should be no difference between your local copy, and
the master copy:
$ git diff
$ git diff
should output no difference.
Enjoy!
** Updating
## Updating
If you have git at version 1.8.2 or later, the command
$ git submodule update --recursive --remote
$ git submodule update --recursive --remote
will be useful for updating to the latest version of all submodules.
@@ -143,109 +140,132 @@ Under earlier versions, use of submodules make things somewhat different
because git does not yet support recursive operations: submodules must be
taken care of explicitly.
*** Updating Bison
### Updating Bison
If you pull a newer version of a branch, say via "git pull", you might
import requests for updated submodules. A simple "git diff" will reveal if
If you pull a newer version of a branch, say via `git pull`, you might
import requests for updated submodules. A simple `git diff` will reveal if
the current version of the submodule (i.e., the actual contents of the
gnulib directory) and the current request from the subscriber (i.e., the
reference of the version of gnulib that the Bison repository requests)
differ. To upgrade the submodules (i.e., to check out the version that is
actually requested by the subscriber, run "git submodule update".
actually requested by the subscriber, run `git submodule update`.
$ git pull
$ git submodule update
$ git pull
$ git submodule update
*** Updating a submodule
### Updating a submodule
To update a submodule, say gnulib, do as follows:
Get the most recent version of the master branch from git.
$ cd gnulib
$ git fetch
$ git checkout -b master --track origin/master
$ cd gnulib
$ git fetch
$ git checkout -b master --track origin/master
Make sure Bison can live with that version of gnulib.
$ cd ..
$ ./bootstrap
$ make distcheck
$ cd ..
$ ./bootstrap
$ make distcheck
Register your changes.
$ git checkin ...
$ git commit ...
For a suggestion of what gnulib commit might be stable enough for a formal
release, see the ChangeLog in the latest gnulib snapshot at:
http://erislabs.net/ianb/projects/gnulib/
release, see the ChangeLog in the latest gnulib snapshot at
http://erislabs.net/ianb/projects/gnulib/.
The Autoconf files we use are currently:
m4/m4.m4
lib/m4sugar/m4sugar.m4
lib/m4sugar/foreach.m4
- m4/m4.m4
- lib/m4sugar/m4sugar.m4
- lib/m4sugar/foreach.m4
These files don't change very often in Autoconf, so it should be relatively
straight-forward to examine the differences in order to decide whether to
update.
* Test suite
# Test Suite
** make check
Use liberally.
## make check
Consume without moderation. It is composed of two kinds of tests: the
examples, and the main test suite.
** Updating the expectations
Sometimes some changes have a large impact on the test suite (e.g., when we
added the "[-Wother]" part to all the warnings). Part of the update can be
done with a crude tool: tests/update-test. Read it for more information.
### The Examples
In examples/, there is a number of ready-to-use examples (see
examples/README.md). These examples have small test suites run by `make
check`. The test results are in local `*.log` files (e.g.,
`$build/examples/c/calc/calc.log`).
** TESTSUITEFLAGS
To run just the testsuite (not the tests related to the examples), run `make
check-local`.
### The Main Test Suite
The main test suite, in tests/, is written on top of GNU Autotest, which is
part of Autoconf. Run `info autoconf 'Using Autotest'` to read the
documentation, not only about how to write tests, but also where are the
logs, how to read them etc.
The main test suite generates a log for each test (e.g.,
`$build/tests/testsuite.dir/004/testsuite.log` for test #4), and a main log
file in `$build/tests/testsuite.log`. The latter is meant for end users: it
contains lots of details that should help diagnosing issues, including build
issues. The per-test logs are more convenient when working locally.
#### TESTSUITEFLAGS
To run just the main test suite, run `make check-local`.
The default is for make check-local to run all tests sequentially. This can
be very time consuming when checking repeatedly or on slower setups. This
can be sped up in two ways:
Using -j, in a make-like fashion, for example:
$ make check-local TESTSUITEFLAGS='-j8'
$ make check-local TESTSUITEFLAGS='-j8'
Actually, when using GNU Make, TESTSUITEFLAGS defaults to the -jN passed to
it, so you may simply run
$ make check-local -j8
$ make check-local -j8
Running only the tests of a certain category, as specified in the AT files
with AT_KEYWORDS([[category]]). Categories include:
- c++, for c++ parsers
- deprec, for tests concerning deprecated constructs.
- glr, for glr parsers
- java, for java parsers
- report, for automaton dumps
- c++, for c++ parsers
- deprec, for tests concerning deprecated constructs.
- glr, for glr parsers
- java, for java parsers
- report, for automaton dumps
To get a list of all the tests (and their keywords for -k), run
$ ./tests/testsuite -l
To run a specific set of tests, use -k (for "keyword"). For example:
$ make check-local TESTSUITEFLAGS='-k c++'
$ make check-local TESTSUITEFLAGS='-k c++'
Both can be combined.
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
$ make check-local TESTSUITEFLAGS='-j8 -k c++'
To rerun the tests that failed:
$ make recheck -j5
** Typical errors
If the test suite shows failures such as the following one
$ make recheck -j5
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
#### Updating the Expectations
Sometimes some changes have a large impact on the test suite (e.g., when we
added the `[-Wother]` part to all the warnings). Part of the update can be
done with a crude tool: `build-aux/update-test`.
it probably means that some file was compiled without
AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
pick up gnulib's replacement headers, such as getopt.h, and this will go
wrong if config.h was not included first.
Once you ran the test suite, and therefore have many `testsuite.log` files,
run, from the source tree:
See tests/local.at for details.
$ ./build-aux/update-test $build/tests/testsuite.dir/*/testsuite.log
** make maintainer-check-valgrind
where `$build` would be your build tree. This will hopefully update most
tests. Re-run the test suite. It might be interesting to run `update-test`
again, since some early failures may stop latter tests from being run. Yet
at some point, you'll have to fix remaining issues by hand...
## make maintainer-check-valgrind
This target uses valgrind both to check bison, and the generated parsers.
This is not mature on Mac OS X. First, Valgrind does support the way bison
@@ -256,13 +276,13 @@ bison. build-aux/darwin11.4.0.valgrind addresses some of them.
Third, valgrind issues warnings such as:
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
--99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
which cause the test to fail uselessly. It is hard to ignore these errors
with a major overhaul of the way instrumentation is performed in the test
suite. So currently, do not try to run valgrind on Mac OS X.
** Release checks
## Release checks
Try to run the test suite with more severe conditions before a
release:
@@ -274,25 +294,25 @@ release:
its warnings; there's no need to obey blindly to it
(<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
- Check with "make syntax-check" if there are issues diagnosed by gnulib.
- Check with `make syntax-check` if there are issues diagnosed by gnulib.
- run "make maintainer-check" which:
- runs "valgrind -q bison" to run Bison under Valgrind.
- run `make maintainer-check` which:
- runs `valgrind -q bison` to run Bison under Valgrind.
- runs the parsers under Valgrind.
- runs the test suite with G++ as C compiler...
- run "make maintainer-check-push", which runs "make maintainer-check" while
- run `make maintainer-check-push`, which runs `make maintainer-check` while
activating the push implementation and its pull interface wrappers in many
test cases that were originally written to exercise only the pull
implementation. This makes certain the push implementation can perform
every task the pull implementation can.
- run "make maintainer-check-xml", which runs "make maintainer-check" while
- run `make maintainer-check-xml`, which runs `make maintainer-check` while
checking Bison's XML automaton report for every working grammar passed to
Bison in the test suite. The check just diffs the output of Bison's
included XSLT style sheets with the output of --report=all and --graph.
- running "make maintainer-check-release" takes care of running
- running `make maintainer-check-release` takes care of running
maintainer-check, maintainer-check-push and maintainer-check-xml.
- Change tests/atlocal/CFLAGS to add your preferred options.
@@ -300,7 +320,7 @@ release:
- Test with a very recent version of GCC for both C and C++. Testing with
older versions that are still in use is nice too.
** gnulib
## gnulib
To run tests on gnulib components (e.g., on bitset):
cd gnulib
@@ -319,58 +339,58 @@ re-run the tests, run:
./configure -C CC='gcc-mp-8 -fsanitize=undefined' CFLAGS='-ggdb'
make check
* Release Procedure
# Release Procedure
This section needs to be updated to take into account features from gnulib.
In particular, be sure to read README-release.
** Update the submodules. See above.
## Update the submodules. See above.
** Update maintainer tools, such as Autoconf. See above.
## Update maintainer tools, such as Autoconf. See above.
** Try to get the *.pot files to the Translation Project at least one
## Try to get the *.pot files to the Translation Project at least one
week before a stable release, to give them time to translate them. Before
generating the *.pot files, make sure that po/POTFILES.in and
runtime-po/POTFILES.in list all files with translatable strings. This
helps: grep -l '\<_(' *.
helps: `grep -l '\<_(' *`.
** Tests
## Tests
See above.
** Update the foreign files
Running "./bootstrap" in the top level should update them all for you. This
## Update the foreign files
Running `./bootstrap` in the top level should update them all for you. This
covers PO files too. Sometimes a PO file contains problems that causes it
to be rejected by recent Gettext releases; please report these to the
Translation Project.
** Update README
## Update README
Make sure the information in README is current. Most notably, make sure it
recommends a version of GNU M4 that is compatible with the latest Bison
sources.
** Check copyright years.
## Check copyright years.
We update years in copyright statements throughout Bison once at the start
of every year by running "make update-copyright". However, before a
of every year by running `make update-copyright`. However, before a
release, it's good to verify that it's actually been run. Besides the
copyright statement for each Bison file, check the copyright statements that
the skeletons insert into generated parsers, and check all occurrences of
PACKAGE_COPYRIGHT_YEAR in configure.ac.
`PACKAGE_COPYRIGHT_YEAR` in configure.ac.
** Update NEWS, commit and tag.
## Update NEWS, commit and tag.
See do-release-commit-and-tag in README-release. For a while, we used beta
names such as "2.6_rc1". Now that we use gnulib in the release procedure,
we must use "2.5.90", which has the additional benefit of being properly
sorted in "git tag -l".
names such as `2.6_rc1`. Now that we use gnulib in the release procedure,
we must use `2.5.90`, which has the additional benefit of being properly
sorted in `git tag -l`.
** make alpha, beta, or stable
## make alpha, beta, or stable
See README-release.
** Upload
## Upload
There are two ways to upload the tarballs to the GNU servers: using gnupload
(from gnulib), or by hand. Obviously prefer the former. But in either
case, be sure to read the following paragraph.
*** Setup
You need "gnupg".
### Setup
You need `gnupg`.
Make sure your public key has been uploaded at least to keys.gnupg.net. You
can upload it with:
@@ -379,106 +399,105 @@ can upload it with:
where F125BDF3 should be replaced with your key ID.
*** Using gnupload
You need "ncftp".
### Using gnupload
You need `ncftp`.
At the end "make stable" (or alpha/beta) will display the procedure to run.
At the end `make stable` (or alpha/beta) will display the procedure to run.
Just copy and paste it in your shell.
*** By hand
### By hand
The generic GNU upload procedure is at:
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
The generic GNU upload procedure is at
http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads.
Follow the instructions there to register your information so you're permitted
to upload.
Here's a brief reminder of how to roll the tarballs and upload them:
*** make distcheck
*** gpg -b bison-2.3b.tar.gz
*** In a file named "bison-2.3b.tar.gz.directive", type:
### make distcheck
### gpg -b bison-2.3b.tar.gz
### In a file named `bison-2.3b.tar.gz.directive`, type:
version: 1.1
directory: bison
filename: bison-2.3b.tar.gz
version: 1.1
directory: bison
filename: bison-2.3b.tar.gz
*** gpg --clearsign bison-2.3b.tar.gz.directive
*** ftp ftp-upload.gnu.org # Log in as anonymous.
*** cd /incoming/alpha # cd /incoming/ftp for full release.
*** put bison-2.3b.tar.gz # This can take a while.
*** put bison-2.3b.tar.gz.sig
*** put bison-2.3b.tar.gz.directive.asc
*** Repeat all these steps for bison-2.3b.tar.xz.
### gpg --clearsign bison-2.3b.tar.gz.directive
### ftp ftp-upload.gnu.org # Log in as anonymous.
### cd /incoming/alpha # cd /incoming/ftp for full release.
### put bison-2.3b.tar.gz # This can take a while.
### put bison-2.3b.tar.gz.sig
### put bison-2.3b.tar.gz.directive.asc
### Repeat all these steps for bison-2.3b.tar.xz.
** Update Bison manual on www.gnu.org.
## Update Bison manual on www.gnu.org.
The instructions below are obsolete, and left in case one would like to run
the commands by hand. Today, one just needs to run
$ make web-manual-update
$ make web-manual-update
See README-release.
*** You need a non-anonymous checkout of the web pages directory.
### You need a non-anonymous checkout of the web pages directory.
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
$ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
*** Get familiar with the instructions for web page maintainers.
### Get familiar with the instructions for web page maintainers.
http://www.gnu.org/server/standards/readme_index.html
http://www.gnu.org/server/standards/README.software.html
especially the note about symlinks.
*** Build the web pages.
### Build the web pages.
Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
BISON_WWW_CHECKOUT refers to the web directory created above, do:
$ cd $BISON_CHECKOUT/doc
$ make stamp-vti
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
bison "Bison - GNU parser generator"
$ cd $BISON_WWW_CHECKOUT
$ cd $BISON_CHECKOUT/doc
$ make stamp-vti
$ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
bison "Bison - GNU parser generator"
$ cd $BISON_WWW_CHECKOUT
Verify that the result looks sane.
*** Commit the modified and the new files.
### Commit the modified and the new files.
*** Remove old files.
### Remove old files.
Find the files which have not been overwritten (because they belonged to
sections that have been removed or renamed):
$ cd manual/html_node
$ ls -lt
$ cd manual/html_node
$ ls -lt
Remove these files and commit their removal to CVS. For each of these
files, add a line to the file .symlinks. This will ensure that hyperlinks
to the removed files will redirect to the entire manual; this is better than
a 404 error.
** Announce
## Announce
The "make release" command just created a template,
$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
`$HOME/announce-bison-X.Y`. Otherwise, to generate it, run:
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
where alpha can be replaced by beta or stable and F125BDF3 should be
where alpha can be replaced by `beta` or `table` and F125BDF3 should be
replaced with your key ID.
Complete/fix the announcement file. The generated list of recipients
(info-gnu@gnu.org, bug-bison@gnu.org, help-bison@gnu.org,
bison-patches@gnu.org, and coordinator@translationproject.org) is
appropriate for a stable release or a "serious beta". For any other
release, drop at least info-gnu@gnu.org. For an example of how to fill out
the rest of the template, search the mailing list archives for the most
recent release announcement.
(info-gnu@gnu.org, bison-announce@gnu.org, bug-bison@gnu.org,
help-bison@gnu.org, bison-patches@gnu.org, and
coordinator@translationproject.org) is appropriate for a stable release or a
"serious beta". For any other release, drop at least info-gnu@gnu.org. For
an example of how to fill out the rest of the template, search the mailing
list archives for the most recent release announcement.
For a stable release, send the same announcement on the comp.compilers
newsgroup by sending email to compilers@iecc.com. Do not make any Cc as the
moderator will throw away anything cross-posted or Cc'ed. It really needs
to be a separate message.
** Prepare NEWS
## Prepare NEWS
So that developers don't accidentally add new items to the old NEWS entry,
create a new empty entry in line 3 (without the two leading spaces):
@@ -486,7 +505,7 @@ create a new empty entry in line 3 (without the two leading spaces):
Push these changes.
-----
<!--
Copyright (C) 2002-2005, 2007-2015, 2018-2019 Free Software Foundation,
Inc.
@@ -506,13 +525,20 @@ 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/>.
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
LocalWords: symlinks vti html lt POSIX Cc'ed
Local Variables:
mode: outline
mode: markdown
fill-column: 76
ispell-dictionary: "american"
End:
LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
LocalWords: submodule init cd distcheck ChangeLog valgrind sigreturn sudo
LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
LocalWords: symlinks vti html lt POSIX Cc'ed Graphviz Texinfo autoconf jN
LocalWords: automake autopoint graphviz texinfo PROG Wother parsers
LocalWords: TESTSUITEFLAGS deprec struct gnulib's getopt config ggdb
LocalWords: bitset fsanitize symlink CFLAGS MERCHANTABILITY ispell
LocalWords: american
-->
+2 -1
View File
@@ -205,8 +205,9 @@ Wwp [email protected]
xolodho [email protected]
Yuichiro Kaneko [email protected]
Zack Weinberg [email protected]
長田偉伸 [email protected]
江 祖铭 [email protected]
長田偉伸 [email protected]
马俊 [email protected]
Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date.
+3
View File
@@ -134,6 +134,9 @@ $ ./tests/testsuite -l | grep errors | sed q
38: input.at:1730 errors
* Short term
** Get rid of YYPRINT and b4_toknum
Besides yytoknum is wrong when api.token.raw is defined.
** Stop indentation in diagnostics
Before Bison 2.7, we printed "flatly" the dependencies in long diagnostics:
+2
View File
@@ -60,6 +60,8 @@ gnulib_modules='
vsnprintf-posix vsprintf-posix
'
checkout_only_file=README-hacking.md
# Additional xgettext options to use. Use "\\\newline" to break lines.
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--from-code=UTF-8\\\
+4 -2
View File
@@ -1,8 +1,10 @@
#! /usr/bin/env python
# usage:
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
#
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
#
# from your source tree.
import argparse
import os
import re
+1 -1
View File
@@ -156,7 +156,7 @@ exclude = \
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
cast_of_argument_to_free=^src/muscle-tab.c$$ \
po_check=^po/POTFILES.in$$ \
po_check=(^po/POTFILES.in|.md)$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
+11 -4
View File
@@ -107,7 +107,8 @@ if test "$enable_gcc_warnings" = yes; then
-Wpointer-arith -Wshadow
-Wwrite-strings'
warn_c='-Wbad-function-cast -Wstrict-prototypes'
warn_cxx='-Wextra-semi -Wnoexcept -Wundefined-func-template -Wweak-vtables'
warn_cxx='-Wextra-semi -Wnoexcept -Wold-style-cast -Wundefined-func-template
-Wweak-vtables'
# Warnings for the test suite only.
#
# -fno-color-diagnostics: Clang's use of colors in the error
@@ -150,8 +151,6 @@ if test "$enable_gcc_warnings" = yes; then
# Warnings for the test suite, and maybe for bison if GCC is modern
# enough.
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
test $lv_cv_gcc_pragma_push_works = yes &&
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
@@ -178,6 +177,14 @@ if test "$enable_gcc_warnings" = yes; then
[[if (sizeof (long) < sizeof (int)) return 1;]])])
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
[AC_LANG_PROGRAM([], [nullptr])])
# Before GCC6, the pragmas don't work well enough to neutralize
# this warning.
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
[AC_LANG_PROGRAM([], [
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
syntax error
#endif
])])
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
# Warnings for the test suite only.
for i in $warn_tests;
@@ -278,7 +285,7 @@ uname=`uname`
case $VALGRIND:$uname in
'':*) ;;
*:Darwin)
# See README-hacking.
# See README-hacking.md.
VALGRIND=;;
*:*)
suppfile=build-aux/$uname.valgrind
+3 -4
View File
@@ -192,7 +192,7 @@ m4_define([b4_error],
# @warn(1@)
# @warn(1@,2@)
m4_define([b4_warn],
[b4_error([[warn]], [], [], $@)])
[b4_warn_at([], [], $@)])
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# ---------------------------------------------------
@@ -210,7 +210,7 @@ m4_define([b4_warn_at],
#
# See b4_warn example.
m4_define([b4_complain],
[b4_error([[complain]], [], [], $@)])
[b4_complain_at([], [], $@)])
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# -------------------------------------------------------
@@ -226,8 +226,7 @@ m4_define([b4_complain_at],
#
# See b4_warn example.
m4_define([b4_fatal],
[b4_error([[fatal]], [], [], $@)dnl
m4_exit(1)])
[b4_fatal_at([], [], $@)])
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# ----------------------------------------------------
+5 -25
View File
@@ -367,9 +367,6 @@ m4_define([b4_symbol_type_define],
/// \a empty when empty.
symbol_number_type type_get () const YY_NOEXCEPT;
/// The token.
token_type token () const YY_NOEXCEPT;
/// The symbol type.
/// \a empty_symbol when empty.
/// An int, not token_number_type, to be able to store empty_symbol.
@@ -498,22 +495,7 @@ m4_define([b4_public_types_define],
{
return type;
}
]b4_token_ctor_if([[
]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). */
static
const ]b4_int_type_for([b4_toknum])[
yytoken_number_[] =
{
]b4_toknum[
};
return token_type (yytoken_number_[type]);
}
]])[]dnl
])
]])
# b4_token_constructor_define
@@ -529,8 +511,7 @@ m4_define([b4_token_constructor_define], [])
# sometimes in the cc file.
m4_define([b4_yytranslate_define],
[ b4_inline([$1])b4_parser_class[::token_number_type
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
[int])[ t)
]b4_parser_class[::yytranslate_ (int t)
{
]b4_api_token_raw_if(
[[ return static_cast<yy::parser::token_number_type> (t);]],
@@ -543,14 +524,13 @@ m4_define([b4_yytranslate_define],
]b4_translate[
};
const int user_token_number_max_ = ]b4_user_token_number_max[;
const token_number_type undef_token_ = ]b4_undef_token_number[;
if (static_cast<int> (t) <= yyeof_)
if (t <= 0)
return yyeof_;
else if (static_cast<int> (t) <= user_token_number_max_)
else if (t <= user_token_number_max_)
return translate_table[t];
else
return undef_token_;]])[
return yy_undef_token_;]])[
}
]])
+31 -4
View File
@@ -327,11 +327,11 @@ m4_define([b4_attribute_define],
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
@@ -343,9 +343,36 @@ m4_define([b4_attribute_define],
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
]])
# b4_cast_define
# --------------
m4_define([b4_cast_define],
[# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast<Type> (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif[]dnl
])
# b4_null_define
# --------------
# Portability issues: define a YY_NULLPTR appropriate for the current
+210 -179
View File
@@ -125,7 +125,7 @@ m4_define([b4_lhs_value],
# -----------------------------
# See README.
m4_define([b4_rhs_data],
[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
[YY_CAST (yyGLRStackItem const *, yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
@@ -235,7 +235,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
#define yylloc ]b4_prefix[lloc]])]))[
]b4_user_pre_prologue[
]b4_cast_define[
]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
@@ -289,7 +289,8 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
# define YYREALLOC realloc
#endif
#define YYSIZEMAX (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : (ptrdiff_t) SIZE_MAX)
#define YYSIZEMAX \
(PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
#ifdef __cplusplus
typedef bool yybool;
@@ -310,15 +311,20 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
# define YYLONGJMP(Env, Val) \
do { \
longjmp (Env, Val); \
YYASSERT (0); \
YY_ASSERT (0); \
} while (yyfalse)
#endif
]b4_attribute_define([noreturn])[
#ifndef YYASSERT
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
]b4_parse_assert_if([[#ifdef NDEBUG
# define YY_ASSERT(E) ((void) (0 && (E)))
#else
# include <assert.h> /* INFRINGES ON USER NAME SPACE */
# define YY_ASSERT(E) assert (E)
#endif
]],
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
/* YYFINAL -- State number of the termination state. */
#define YYFINAL ]b4_final_state_number[
@@ -469,23 +475,36 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
# define YYFPRINTF fprintf
# endif
]b4_yy_location_print_define[
# define YY_FPRINTF \
YY_IGNORE_USELESS_CAST_BEGIN YY_FPRINTF_
# define YYDPRINTF(Args) \
# define YY_FPRINTF_(Args) \
do { \
YYFPRINTF Args; \
YY_IGNORE_USELESS_CAST_END \
} while (0)
# define YY_DPRINTF \
YY_IGNORE_USELESS_CAST_BEGIN YY_DPRINTF_
# define YY_DPRINTF_(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
YY_IGNORE_USELESS_CAST_END \
} while (0)
]b4_yy_location_print_define[
]b4_yy_symbol_print_define[
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
YY_FPRINTF ((stderr, "%s ", Title)); \
yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
YYFPRINTF (stderr, "\n"); \
YY_FPRINTF ((stderr, "\n")); \
} \
} while (0)
@@ -501,7 +520,7 @@ static void yypdumpstack (struct yyGLRStack* yystackp)
#else /* !]b4_api_PREFIX[DEBUG */
# define YYDPRINTF(Args)
# define YY_DPRINTF(Args) do {} while (yyfalse)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#endif /* !]b4_api_PREFIX[DEBUG */
@@ -617,7 +636,7 @@ yytnamerr (char *yyres, const char *yystr)
if (yyres)
return yystpcpy (yyres, yystr) - yyres;
else
return (ptrdiff_t) strlen (yystr);
return YY_CAST (ptrdiff_t, strlen (yystr));
}
# endif
@@ -742,10 +761,7 @@ yyMemoryExhausted (yyGLRStack* yystackp)
static inline const char*
yytokenName (yySymbol yytoken)
{
if (yytoken == YYEMPTY)
return "";
return yytname[yytoken];
return yytoken == YYEMPTY ? "" : yytname[yytoken];
}
#endif
@@ -785,7 +801,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
]b4_parse_param_use()dnl
[ if (*yycharp == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));]b4_glr_cc_if([[
YY_DPRINTF ((stderr, "Reading a token: "));]b4_glr_cc_if([[
#if YY_EXCEPTIONS
try
{
@@ -795,7 +811,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
}
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
{
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
yylloc = yyexc.location;])[
yyerror (]b4_lyyerror_args[yyexc.what ());
// Map errors caught in the scanner to the undefined token
@@ -809,7 +825,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
if (*yycharp <= YYEOF)
{
*yycharp = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
YY_DPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
@@ -845,7 +861,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
yyGLRStack* yystackp,
YYSTYPE* yyvalp]b4_locuser_formals[)
{
yybool yynormal YY_ATTRIBUTE_UNUSED = (yybool) (yystackp->yysplitPoint == YY_NULLPTR);
yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
int yylow;
]b4_parse_param_use([yyvalp], [yylocp])dnl
[ YYUSE (yyrhslen);
@@ -891,7 +907,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
}
catch (const syntax_error& yyexc)
{
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
*yylocp = yyexc.location;])[
yyerror (]b4_yyerror_args[yyexc.what ());
YYERROR;
@@ -945,9 +961,9 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
if (yydebug)
{
if (yys->yysemantics.yyfirstVal)
YYFPRINTF (stderr, "%s unresolved", yymsg);
YY_FPRINTF ((stderr, "%s unresolved", yymsg));
else
YYFPRINTF (stderr, "%s incomplete", yymsg);
YY_FPRINTF ((stderr, "%s incomplete", yymsg));
YY_SYMBOL_PRINT ("", yystos[yys->yylrState], YY_NULLPTR, &yys->yyloc);
}
#endif
@@ -980,7 +996,7 @@ yylhsNonterm (yyRuleNum yyrule)
static inline yybool
yyisDefaultedState (yyStateNum yystate)
{
return (yybool) yypact_value_is_default (yypact[yystate]);
return yypact_value_is_default (yypact[yystate]);
}
/** The default reduction for YYSTATE, assuming it has one. */
@@ -1040,13 +1056,13 @@ yyLRgotoState (yyStateNum yystate, yySymbol yysym)
static inline yybool
yyisShiftAction (int yyaction)
{
return (yybool) (0 < yyaction);
return 0 < yyaction;
}
static inline yybool
yyisErrorAction (int yyaction)
{
return (yybool) (yyaction == 0);
return yyaction == 0;
}
/* GLRStates */
@@ -1076,7 +1092,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate,
{
yySemanticOption* yynewOption =
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
YYASSERT (!yynewOption->yyisState);
YY_ASSERT (!yynewOption->yyisState);
yynewOption->yystate = yyrhs;
yynewOption->yyrule = yyrule;
if (yystackp->yytops.yylookaheadNeeds[yyk])
@@ -1102,21 +1118,24 @@ yyinitStateSet (yyGLRStateSet* yyset)
yyset->yysize = 1;
yyset->yycapacity = 16;
yyset->yystates
= (yyGLRState**) YYMALLOC ((size_t) yyset->yycapacity
* sizeof yyset->yystates[0]);
= YY_CAST (yyGLRState**,
YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
* sizeof yyset->yystates[0]));
if (! yyset->yystates)
return yyfalse;
yyset->yystates[0] = YY_NULLPTR;
yyset->yylookaheadNeeds
= (yybool*) YYMALLOC ((size_t) yyset->yycapacity
* sizeof yyset->yylookaheadNeeds[0]);
= YY_CAST (yybool*,
YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
* sizeof yyset->yylookaheadNeeds[0]));
if (! yyset->yylookaheadNeeds)
{
YYFREE (yyset->yystates);
return yyfalse;
}
memset (yyset->yylookaheadNeeds,
0, (size_t) yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
0,
YY_CAST (size_t, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
return yytrue;
}
@@ -1134,9 +1153,10 @@ yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
yystackp->yyerrState = 0;
yynerrs = 0;
yystackp->yyspaceLeft = yysize;
yystackp->yyitems =
(yyGLRStackItem*) YYMALLOC ((size_t) yysize
* sizeof yystackp->yynextFree[0]);
yystackp->yyitems
= YY_CAST (yyGLRStackItem*,
YYMALLOC (YY_CAST (size_t, yysize)
* sizeof yystackp->yynextFree[0]));
if (!yystackp->yyitems)
return yyfalse;
yystackp->yynextFree = yystackp->yyitems;
@@ -1147,8 +1167,9 @@ yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
#if YYSTACKEXPANDABLE
# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
# define YYRELOC(YYFROMITEMS, YYTOITEMS, YYX, YYTYPE) \
&((YYTOITEMS) \
- ((YYFROMITEMS) - YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX))))->YYTYPE
/** If *YYSTACKP is expandable, extend it. WARNING: Pointers into the
stack from outside should be considered invalid after this call.
@@ -1168,8 +1189,10 @@ yyexpandGLRStack (yyGLRStack* yystackp)
yynewSize = 2*yysize;
if (YYMAXDEPTH < yynewSize)
yynewSize = YYMAXDEPTH;
yynewItems = (yyGLRStackItem*) YYMALLOC ((size_t) yynewSize
* sizeof yynewItems[0]);
yynewItems
= YY_CAST (yyGLRStackItem*,
YYMALLOC (YY_CAST (size_t, yynewSize)
* sizeof yynewItems[0]));
if (! yynewItems)
yyMemoryExhausted (yystackp);
for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
@@ -1177,7 +1200,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
yyn -= 1, yyp0 += 1, yyp1 += 1)
{
*yyp1 = *yyp0;
if (*(yybool *) yyp0)
if (*YY_REINTERPRET_CAST (yybool *, yyp0))
{
yyGLRState* yys0 = &yyp0->yystate;
yyGLRState* yys1 = &yyp1->yystate;
@@ -1250,7 +1273,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
return;
yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
yystackp->yytops.yysize = 1;
YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
YY_DPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
yystackp->yylastDeleted = YY_NULLPTR;
}
@@ -1264,9 +1287,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
if (yystackp->yytops.yystates[yyi] == YY_NULLPTR)
{
if (yyi == yyj)
{
YYDPRINTF ((stderr, "Removing dead stacks.\n"));
}
YY_DPRINTF ((stderr, "Removing dead stacks.\n"));
yystackp->yytops.yysize -= 1;
}
else
@@ -1280,10 +1301,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
yystackp->yytops.yylookaheadNeeds[yyj] =
yystackp->yytops.yylookaheadNeeds[yyi];
if (yyj != yyi)
{
YYDPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
(long) yyi, (long) yyj));
}
YY_DPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
YY_CAST (long, yyi), YY_CAST (long, yyj)));
yyj += 1;
}
yyi += 1;
@@ -1319,7 +1338,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
{
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
YYASSERT (yynewState->yyisState);
YY_ASSERT (yynewState->yyisState);
yynewState->yylrState = yylrState;
yynewState->yyposn = yyposn;
@@ -1352,22 +1371,22 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
int yylow = 1;])[
int yyi;
YYFPRINTF (stderr, "Reducing stack %ld by rule %d (line %d):\n",
(long) yyk, yyrule - 1, yyrline[yyrule]);
YY_FPRINTF ((stderr, "Reducing stack %ld by rule %d (line %d):\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]));
if (! yynormal)
yyfillin (yyvsp, 1, -yynrhs);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
YY_FPRINTF ((stderr, " $%d = ", yyi + 1));
yy_symbol_print (stderr,
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([,
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[);
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
YYFPRINTF (stderr, " (unresolved)");
YYFPRINTF (stderr, "\n");
YY_FPRINTF ((stderr, " (unresolved)"));
YY_FPRINTF ((stderr, "\n"));
}
}
#endif
@@ -1387,8 +1406,9 @@ yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
if (yystackp->yysplitPoint == YY_NULLPTR)
{
/* Standard special case: single stack. */
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
YYASSERT (yyk == 0);
yyGLRStackItem* yyrhs
= YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yytops.yystates[yyk]);
YY_ASSERT (yyk == 0);
yystackp->yynextFree -= yynrhs;
yystackp->yyspaceLeft += yynrhs;
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
@@ -1408,7 +1428,7 @@ yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
for (yyi = 0; yyi < yynrhs; yyi += 1)
{
yys = yys->yypred;
YYASSERT (yys);
YY_ASSERT (yys);
}
yyupdateSplit (yystackp, yys);
yystackp->yytops.yystates[yyk] = yys;
@@ -1442,11 +1462,9 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
{
YYDPRINTF ((stderr,
"Parse on stack %ld rejected by rule %d (line %d).\n",
(long) yyk, yyrule - 1, yyrline[yyrule - 1]));
}
YY_DPRINTF ((stderr,
"Parse on stack %ld rejected by rule %d (line %d).\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1]));
if (yyflag != yyok)
return yyflag;
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
@@ -1466,14 +1484,15 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
0 < yyn; yyn -= 1)
{
yys = yys->yypred;
YYASSERT (yys);
YY_ASSERT (yys);
}
yyupdateSplit (yystackp, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
YYDPRINTF ((stderr,
"Reduced stack %ld by rule %d (line %d); action deferred. "
"Now in state %d.\n",
(long) yyk, yyrule - 1, yyrline[yyrule - 1], yynewLRState));
YY_DPRINTF ((stderr,
"Reduced stack %ld by rule %d (line %d); action deferred. "
"Now in state %d.\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1],
yynewLRState));
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
{
@@ -1485,8 +1504,8 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
{
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
yymarkStackDeleted (yystackp, yyk);
YYDPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
(long) yyk, (long) yyi));
YY_DPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
YY_CAST (long, yyk), YY_CAST (long, yyi)));
return yyok;
}
yyp = yyp->yypred;
@@ -1503,42 +1522,45 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
{
if (yystackp->yysplitPoint == YY_NULLPTR)
{
YYASSERT (yyk == 0);
YY_ASSERT (yyk == 0);
yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
}
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize)
{
yyGLRState** yynewStates = YY_NULLPTR;
yybool* yynewLookaheadNeeds;
ptrdiff_t state_size = sizeof yynewStates[0];
ptrdiff_t state_size = sizeof yystackp->yytops.yystates[0];
ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
if (half_max_capacity < yystackp->yytops.yycapacity)
yyMemoryExhausted (yystackp);
yystackp->yytops.yycapacity *= 2;
yynewStates =
(yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
((size_t) yystackp->yytops.yycapacity
* sizeof yynewStates[0]));
if (yynewStates == YY_NULLPTR)
yyMemoryExhausted (yystackp);
yystackp->yytops.yystates = yynewStates;
{
yyGLRState** yynewStates
= YY_CAST (yyGLRState**,
YYREALLOC (yystackp->yytops.yystates,
(YY_CAST (size_t, yystackp->yytops.yycapacity)
* sizeof yynewStates[0])));
if (yynewStates == YY_NULLPTR)
yyMemoryExhausted (yystackp);
yystackp->yytops.yystates = yynewStates;
}
yynewLookaheadNeeds =
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
((size_t) yystackp->yytops.yycapacity
* sizeof yynewLookaheadNeeds[0]));
if (yynewLookaheadNeeds == YY_NULLPTR)
yyMemoryExhausted (yystackp);
yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
{
yybool* yynewLookaheadNeeds
= YY_CAST (yybool*,
YYREALLOC (yystackp->yytops.yylookaheadNeeds,
(YY_CAST (size_t, yystackp->yytops.yycapacity)
* sizeof yynewLookaheadNeeds[0])));
if (yynewLookaheadNeeds == YY_NULLPTR)
yyMemoryExhausted (yystackp);
yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
}
}
yystackp->yytops.yystates[yystackp->yytops.yysize]
= yystackp->yytops.yystates[yyk];
yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
= yystackp->yytops.yylookaheadNeeds[yyk];
yystackp->yytops.yysize += 1;
return yystackp->yytops.yysize-1;
return yystackp->yytops.yysize - 1;
}
/** True iff YYY0 and YYY1 represent identical options at the top level.
@@ -1572,7 +1594,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
int yyn;
for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
yyn = yyrhsLength (yyy0->yyrule);
yyn > 0;
0 < yyn;
yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
{
if (yys0 == yys1)
@@ -1654,7 +1676,7 @@ yyresolveStates (yyGLRState* yys, int yyn,
{
if (0 < yyn)
{
YYASSERT (yys->yypred);
YY_ASSERT (yys->yypred);
YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[));
if (! yys->yyresolved)
YYCHK (yyresolveValue (yys, yystackp]b4_user_args[));
@@ -1725,26 +1747,26 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
yystates[0] = yys;
if (yyx->yystate->yyposn < yys->yyposn + 1)
YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1);
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, empty>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1));
else
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1, (long) (yys->yyposn + 1),
(long) yyx->yystate->yyposn);
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1),
YY_CAST (long, yyx->yystate->yyposn)));
for (yyi = 1; yyi <= yynrhs; yyi += 1)
{
if (yystates[yyi]->yyresolved)
{
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState]));
YY_FPRINTF ((stderr, "%*s%s <empty>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState])));
else
YYFPRINTF (stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState]),
(long) (yystates[yyi-1]->yyposn + 1),
(long) yystates[yyi]->yyposn);
YY_FPRINTF ((stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState]),
YY_CAST (long, yystates[yyi-1]->yyposn + 1),
YY_CAST (long, yystates[yyi]->yyposn)));
}
else
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
@@ -1760,12 +1782,12 @@ yyreportAmbiguity (yySemanticOption* yyx0,
YYUSE (yyx1);
#if ]b4_api_PREFIX[DEBUG
YYFPRINTF (stderr, "Ambiguity detected.\n");
YYFPRINTF (stderr, "Option 1,\n");
YY_FPRINTF ((stderr, "Ambiguity detected.\n"));
YY_FPRINTF ((stderr, "Option 1,\n"));
yyreportTree (yyx0, 2);
YYFPRINTF (stderr, "\nOption 2,\n");
YY_FPRINTF ((stderr, "\nOption 2,\n"));
yyreportTree (yyx1, 2);
YYFPRINTF (stderr, "\n");
YY_FPRINTF ((stderr, "\n"));
#endif
yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
@@ -1787,7 +1809,7 @@ yyresolveLocations (yyGLRState *yys1, int yyn1,
yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
int yynrhs;
yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
YYASSERT (yyoption);
YY_ASSERT (yyoption);
yynrhs = yyrhsLength (yyoption->yyrule);
if (0 < yynrhs)
{
@@ -1862,7 +1884,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
yymerge = yyfalse;
break;
default:
/* This cannot happen so it is not worth a YYASSERT (yyfalse),
/* This cannot happen so it is not worth a YY_ASSERT (yyfalse),
but some compilers complain if the default case is
omitted. */
break;
@@ -1940,7 +1962,7 @@ yycompressStack (yyGLRStack* yystackp)
yyp->yypred = yyr;
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
yystackp->yynextFree = YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yysplitPoint) + 1;
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
yystackp->yysplitPoint = YY_NULLPTR;
yystackp->yylastDeleted = YY_NULLPTR;
@@ -1963,9 +1985,9 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
{
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
YYDPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate));
YY_DPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate));
YYASSERT (yystate != YYFINAL);
YY_ASSERT (yystate != YYFINAL);
if (yyisDefaultedState (yystate))
{
@@ -1973,17 +1995,17 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyRuleNum yyrule = yydefaultAction (yystate);
if (yyrule == 0)
{
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk);
return yyok;
}
yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
if (yyflag == yyerr)
{
YYDPRINTF ((stderr,
"Stack %ld dies "
"(predicate failure or explicit user error).\n",
(long) yyk));
YY_DPRINTF ((stderr,
"Stack %ld dies "
"(predicate failure or explicit user error).\n",
YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk);
return yyok;
}
@@ -2001,8 +2023,8 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
{
YYRESULTTAG yyflag;
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
YYDPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
(long) yynewStack, (long) yyk));
YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
yyflag = yyglrReduce (yystackp, yynewStack,
*yyconflicts,
yyimmediate[*yyconflicts]]b4_user_args[);
@@ -2011,7 +2033,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyposn]b4_pure_args[));
else if (yyflag == yyerr)
{
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yynewStack));
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yynewStack)));
yymarkStackDeleted (yystackp, yynewStack);
}
else
@@ -2023,7 +2045,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
break;
else if (yyisErrorAction (yyaction))
{
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk);
break;
}
@@ -2033,10 +2055,10 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyimmediate[-yyaction]]b4_user_args[);
if (yyflag == yyerr)
{
YYDPRINTF ((stderr,
"Stack %ld dies "
"(predicate failure or explicit user error).\n",
(long) yyk));
YY_DPRINTF ((stderr,
"Stack %ld dies "
"(predicate failure or explicit user error).\n",
YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk);
break;
}
@@ -2058,18 +2080,18 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
#else
{
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
ptrdiff_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
ptrdiff_t yysize = yysize0;
yybool yysize_overflow = yyfalse;
char* yymsg = YY_NULLPTR;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
/* Arguments of yyformat: reported tokens (one for the "unexpected",
one per "expected"). */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
/* Actual size of YYARG. */
int yycount = 0;
/* Cumulated lengths of YYARG. */
ptrdiff_t yysize = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
@@ -2097,6 +2119,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
if (yytoken != YYEMPTY)
{
int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
ptrdiff_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
yysize = yysize0;
yyarg[yycount++] = yytokenName (yytoken);
if (!yypact_value_is_default (yyn))
{
@@ -2147,7 +2171,9 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
}
{
ptrdiff_t yysz = (ptrdiff_t) strlen (yyformat);
/* Don't count the "%s"s in the final size, but reserve room for
the terminator. */
ptrdiff_t yysz = YY_CAST (ptrdiff_t, strlen (yyformat)) - 2 * yycount + 1;
if (YYSIZEMAX - yysize < yysz)
yysize_overflow = yytrue;
else
@@ -2155,7 +2181,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
}
if (!yysize_overflow)
yymsg = (char *) YYMALLOC ((size_t) yysize);
yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (size_t, yysize)));
if (yymsg)
{
@@ -2170,8 +2196,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
}
else
{
yyp++;
yyformat++;
++yyp;
++yyformat;
}
}
yyerror (]b4_lyyerror_args[yymsg);
@@ -2308,7 +2334,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyGLRStack* const yystackp = &yystack;
ptrdiff_t yyposn;
YYDPRINTF ((stderr, "Starting parse\n"));
YY_DPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY;
yylval = yyval_default;]b4_locations_if([
@@ -2339,7 +2365,7 @@ b4_dollar_popdef])[]dnl
while (yytrue)
{
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_DPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
goto yyacceptlab;
if (yyisDefaultedState (yystate))
@@ -2389,7 +2415,7 @@ b4_dollar_popdef])[]dnl
ptrdiff_t yys;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
/* yyprocessOneStack returns one of three things:
@@ -2419,7 +2445,7 @@ b4_dollar_popdef])[]dnl
if (yystack.yytops.yysize == 0)
yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[
YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
yyreportSyntaxError (&yystack]b4_user_args[);
goto yyuser_error;
@@ -2440,19 +2466,19 @@ b4_dollar_popdef])[]dnl
int yyaction = yygetLRActions (yystate, yytoken_to_shift,
&yyconflicts);
/* Note that yyconflicts were handled by yyprocessOneStack. */
YYDPRINTF ((stderr, "On stack %ld, ", (long) yys));
YY_DPRINTF ((stderr, "On stack %ld, ", YY_CAST (long, yys)));
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
yyglrShift (&yystack, yys, yyaction, yyposn,
&yylval]b4_locations_if([, &yylloc])[);
YYDPRINTF ((stderr, "Stack %ld now in state #%d\n",
(long) yys,
yystack.yytops.yystates[yys]->yylrState));
YY_DPRINTF ((stderr, "Stack %ld now in state #%d\n",
YY_CAST (long, yys),
yystack.yytops.yystates[yys]->yylrState));
}
if (yystack.yytops.yysize == 1)
{
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));
yycompressStack (&yystack);
break;
}
@@ -2468,7 +2494,7 @@ b4_dollar_popdef])[]dnl
goto yyreturn;
yybuglab:
YYASSERT (yyfalse);
YY_ASSERT (yyfalse);
goto yyabortlab;
yyabortlab:
@@ -2525,19 +2551,19 @@ yy_yypstack (yyGLRState* yys)
if (yys->yypred)
{
yy_yypstack (yys->yypred);
YYFPRINTF (stderr, " -> ");
YY_FPRINTF ((stderr, " -> "));
}
YYFPRINTF (stderr, "%d@@%ld", yys->yylrState, (long) yys->yyposn);
YY_FPRINTF ((stderr, "%d@@%ld", yys->yylrState, YY_CAST (long, yys->yyposn)));
}
static void
yypstates (yyGLRState* yyst)
{
if (yyst == YY_NULLPTR)
YYFPRINTF (stderr, "<null>");
YY_FPRINTF ((stderr, "<null>"));
else
yy_yypstack (yyst);
YYFPRINTF (stderr, "\n");
YY_FPRINTF ((stderr, "\n"));
}
static void
@@ -2546,48 +2572,53 @@ yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
yypstates (yystackp->yytops.yystates[yyk]);
}
#define YYINDEX(YYX) \
((YYX) == YY_NULLPTR ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
static void
yypdumpstack (yyGLRStack* yystackp)
{
#define YYINDEX(YYX) \
YY_CAST (long, \
((YYX) \
? YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX)) - yystackp->yyitems \
: -1))
yyGLRStackItem* yyp;
ptrdiff_t yyi;
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
{
YYFPRINTF (stderr, "%3ld. ",
(long) (yyp - yystackp->yyitems));
if (*(yybool *) yyp)
YY_FPRINTF ((stderr, "%3ld. ",
YY_CAST (long, yyp - yystackp->yyitems)));
if (*YY_REINTERPRET_CAST (yybool *, yyp))
{
YYASSERT (yyp->yystate.yyisState);
YYASSERT (yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
yyp->yystate.yyresolved, yyp->yystate.yylrState,
(long) yyp->yystate.yyposn,
(long) YYINDEX (yyp->yystate.yypred));
YY_ASSERT (yyp->yystate.yyisState);
YY_ASSERT (yyp->yyoption.yyisState);
YY_FPRINTF ((stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
yyp->yystate.yyresolved, yyp->yystate.yylrState,
YY_CAST (long, yyp->yystate.yyposn),
YYINDEX (yyp->yystate.yypred)));
if (! yyp->yystate.yyresolved)
YYFPRINTF (stderr, ", firstVal: %ld",
(long) YYINDEX (yyp->yystate
.yysemantics.yyfirstVal));
YY_FPRINTF ((stderr, ", firstVal: %ld",
YYINDEX (yyp->yystate.yysemantics.yyfirstVal)));
}
else
{
YYASSERT (!yyp->yystate.yyisState);
YYASSERT (!yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
yyp->yyoption.yyrule - 1,
(long) YYINDEX (yyp->yyoption.yystate),
(long) YYINDEX (yyp->yyoption.yynext));
YY_ASSERT (!yyp->yystate.yyisState);
YY_ASSERT (!yyp->yyoption.yyisState);
YY_FPRINTF ((stderr, "Option. rule: %d, state: %ld, next: %ld",
yyp->yyoption.yyrule - 1,
YYINDEX (yyp->yyoption.yystate),
YYINDEX (yyp->yyoption.yynext)));
}
YYFPRINTF (stderr, "\n");
YY_FPRINTF ((stderr, "\n"));
}
YYFPRINTF (stderr, "Tops:");
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
YYFPRINTF (stderr, "%ld: %ld; ", (long) yyi,
(long) YYINDEX (yystackp->yytops.yystates[yyi]));
YYFPRINTF (stderr, "\n");
YY_FPRINTF ((stderr, "Tops:"));
{
ptrdiff_t yyi;
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
YYINDEX (yystackp->yytops.yystates[yyi])));
YY_FPRINTF ((stderr, "\n"));
}
#undef YYINDEX
}
#endif
+8
View File
@@ -257,6 +257,14 @@ b4_percent_code_get([[requires]])[
]b4_attribute_define[
]b4_null_define[
// This skeleton is based on C, yet compiles it as C++.
// So expect warnings about C style casts.
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
# pragma clang diagnostic ignored "-Wold-style-cast"
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
// Whether we are compiled with exception support.
#ifndef YY_EXCEPTIONS
# if defined __GNUC__ && !defined __EXCEPTIONS
+18 -11
View File
@@ -174,6 +174,7 @@ m4_define([b4_shared_declarations],
]b4_variant_if([b4_variant_includes])[
]b4_attribute_define[
]b4_cast_define[
]b4_null_define[
]b4_YYDEBUG_define[
@@ -267,7 +268,9 @@ m4_define([b4_shared_declarations],
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
/// Convert a scanner token number \a t to a symbol number.
static token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t);
/// In theory \a t should be a token_type, but character literals
/// are valid, yet not member of the token_type enum.
static token_number_type yytranslate_ (int t);
// Tables.
]b4_parser_tables_declare[]b4_error_verbose_if([
@@ -332,7 +335,8 @@ m4_define([b4_shared_declarations],
symbol_number_type type_get () const YY_NOEXCEPT;
/// The state number used to denote an empty symbol.
enum { empty_state = -1 };
/// We use the initial state, as it does not have a value.
enum { empty_state = 0 };
/// The state.
/// \a empty when empty.
@@ -396,6 +400,10 @@ m4_define([b4_shared_declarations],
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
/// Some specific tokens.
static const token_number_type yy_error_token_ = 1;
static const token_number_type yy_undef_token_ = ]b4_undef_token_number[;
/// Constants.
enum
{
@@ -403,8 +411,6 @@ m4_define([b4_shared_declarations],
yylast_ = ]b4_last[, ///< Last index in yytable_.
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = ]b4_tokens_number[ ///< Number of tokens.
};
@@ -1054,8 +1060,8 @@ b4_dollar_popdef])[]dnl
yyn = yypact_[yystack_[0].state];
if (!yy_pact_value_is_default_ (yyn))
{
yyn += yyterror_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
yyn += yy_error_token_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -1195,10 +1201,10 @@ b4_dollar_popdef])[]dnl
{
std::ptrdiff_t yylen = yyr2_[yyrule];
// First pop from the LAC stack as many tokens as possible.
std::ptrdiff_t lac_size = (std::ptrdiff_t) yylac_stack_.size ();
std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
if (yylen < lac_size)
{
yylac_stack_.resize ((std::size_t) (lac_size - yylen));
yylac_stack_.resize (std::size_t (lac_size - yylen));
yylen = 0;
}
else if (lac_size)
@@ -1329,7 +1335,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
*/
if (!yyla.empty ())
{
int yytoken = yyla.type_get ();
symbol_number_type yytoken = yyla.type_get ();
yyarg[yycount++] = yytname_[yytoken];]b4_lac_if([[
#if ]b4_api_PREFIX[DEBUG
@@ -1343,7 +1349,8 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
if (!yy_pact_value_is_default_ (yyn))
{]b4_lac_if([[
for (int yyx = 0; yyx < yyntokens_; ++yyx)
if (yyx != yyterror_ && yy_lac_check_(yyx))
if (yyx != yy_error_token_ && yyx != yy_undef_token_
&& yy_lac_check_ (yyx))
{]], [[
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
@@ -1353,7 +1360,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
if (yycheck_[yyx + yyn] == yyx && yyx != yy_error_token_
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
{]])[
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+80 -92
View File
@@ -187,9 +187,6 @@ b4_user_union_members
{
]b4_identification[
/** True if verbose error messages are enabled. */
public bool errorVerbose = ]b4_flag_value([error_verbose])[;
]b4_locations_if([[
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
{
@@ -400,7 +397,8 @@ b4_user_union_members
ref ]b4_yystype[ yyvaluep]dnl
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
{
if (0 < yydebug) {
if (0 < yydebug)
{
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
~ yytname_[yytype] ~ " ("]b4_locations_if([
~ yylocationp.toString() ~ ": "])[;
@@ -619,8 +617,8 @@ m4_popdef([b4_at_dollar])])dnl
yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
yyn += yyterror_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
yyn += yy_error_token_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -667,78 +665,74 @@ m4_popdef([b4_at_dollar])])dnl
// Generate an error message.
private final string yysyntax_error (int yystate, int tok)
{
if (errorVerbose)
{]b4_error_verbose_if([[
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider.
See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action,
then the only way this function was invoked is if the
default action is an error action. In that case, don't
check for expected tokens because there are none.
- The only way there can be no lookahead present (in tok) is
if this state is a consistent state with a default action.
Thus, detecting the absence of a lookahead is sufficient to
determine that there is no unexpected or expected token to
report. In that case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this
state is a consistent state with a default action. There
might have been a previous inconsistent state, consistent
state with a non-default action, or user semantic action
that manipulated yychar. (However, yychar is currently out
of scope during semantic actions.)
- Of course, the expected token list depends on states to
have correct lookahead information, and it depends on the
parser not to perform extra reductions after fetching a
lookahead from the scanner and before detecting a syntax
error. Thus, state merging (from LALR or IELR) and default
reductions corrupt the expected token list. However, the
list is correct for canonical LR with one exception: it
will still contain any token that will not be accepted due
to an error action in a later state.
*/
if (tok != yyempty_)
{
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider.
See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action,
then the only way this function was invoked is if the
default action is an error action. In that case, don't
check for expected tokens because there are none.
- The only way there can be no lookahead present (in tok) is
if this state is a consistent state with a default action.
Thus, detecting the absence of a lookahead is sufficient to
determine that there is no unexpected or expected token to
report. In that case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this
state is a consistent state with a default action. There
might have been a previous inconsistent state, consistent
state with a non-default action, or user semantic action
that manipulated yychar. (However, yychar is currently out
of scope during semantic actions.)
- Of course, the expected token list depends on states to
have correct lookahead information, and it depends on the
parser not to perform extra reductions after fetching a
lookahead from the scanner and before detecting a syntax
error. Thus, state merging (from LALR or IELR) and default
reductions corrupt the expected token list. However, the
list is correct for canonical LR with one exception: it
will still contain any token that will not be accepted due
to an error action in a later state.
*/
if (tok != yyempty_)
// FIXME: This method of building the message is not compatible
// with internationalization.
string res = "syntax error, unexpected ";
res ~= yytnamerr_ (yytname_[tok]);
int yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
// FIXME: This method of building the message is not compatible
// with internationalization.
string res = "syntax error, unexpected ";
res ~= yytnamerr_ (yytname_[tok]);
int yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
/* Start YYX at -YYN if negative to avoid negative
indexes in YYCHECK. In other words, skip the first
-YYN actions for this state because they are default
actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
++count;
if (count < 5)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
{
res ~= count++ == 0 ? ", expecting " : " or ";
res ~= yytnamerr_ (yytname_[x]);
}
}
}
return res;
/* Start YYX at -YYN if negative to avoid negative
indexes in YYCHECK. In other words, skip the first
-YYN actions for this state because they are default
actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yy_error_token_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
++count;
if (count < 5)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yy_error_token_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
{
res ~= count++ == 0 ? ", expecting " : " or ";
res ~= yytnamerr_ (yytname_[x]);
}
}
}
}
return res;
}]])[
return "syntax error";
}
@@ -771,14 +765,6 @@ m4_popdef([b4_at_dollar])])dnl
]b4_parser_tables_define[
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
to YYLEX-NUM. */
private static immutable ]b4_int_type_for([b4_toknum])[[]
yytoken_number_ =
@{
]b4_toknum[
@};
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
private static immutable string[] yytname_ =
@@ -814,36 +800,38 @@ m4_popdef([b4_at_dollar])])dnl
}
]])[
private static ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
private static token_number_type yytranslate_ (int t)
{
]b4_api_token_raw_if(
[[ import std.conv : to;
return to!byte (t);]],
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
immutable ]b4_int_type_for([b4_translate])[[] translate_table =
immutable token_number_type[] translate_table =
@{
]b4_translate[
@};
immutable int user_token_number_max_ = ]b4_user_token_number_max[;
immutable token_number_type undef_token_ = ]b4_undef_token_number[;
if (t <= 0)
return YYTokenType.EOF;
else if (t <= yyuser_token_number_max_)
else if (t <= user_token_number_max_)
return translate_table[t];
else
return yyundef_token_;]])[
return undef_token_;]])[
}
alias ]b4_int_type_for([b4_translate])[ token_number_type;
private static immutable token_number_type yy_error_token_ = 1;
private static immutable int yylast_ = ]b4_last[;
private static immutable int yynnts_ = ]b4_nterms_number[;
private static immutable int yyempty_ = -2;
private static immutable int yyfinal_ = ]b4_final_state_number[;
private static immutable int yyterror_ = 1;
private static immutable int yyerrcode_ = 256;
private static immutable int yyntokens_ = ]b4_tokens_number[;
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
private final struct YYStackElement {
int state;
]b4_yystype[ value;]b4_locations_if(
+11 -14
View File
@@ -751,8 +751,8 @@ b4_dollar_popdef[]dnl
yyn = yypact_[yystate];
if (!yyPactValueIsDefault (yyn))
{
yyn += yyterror_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
yyn += yy_error_token_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yy_error_token_)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -931,14 +931,14 @@ b4_dollar_popdef[]dnl
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
if (yycheck_[x + yyn] == x && x != yy_error_token_
&& !yyTableValueIsError (yytable_[x + yyn]))
++count;
if (count < 5)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
if (yycheck_[x + yyn] == x && x != yy_error_token_
&& !yyTableValueIsError (yytable_[x + yyn]))
{
res.append (count++ == 0 ? ", expecting " : " or ");
@@ -976,9 +976,6 @@ b4_dollar_popdef[]dnl
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
]b4_parser_tables_define[
]b4_integral_parser_table_define([token_number], [b4_toknum],
[[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding
to YYLEX-NUM.]])[
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
@@ -1018,27 +1015,27 @@ b4_dollar_popdef[]dnl
}
]],
[[ {
int user_token_number_max_ = ]b4_user_token_number_max[;
]b4_int_type_for([b4_translate])[ undef_token_ = ]b4_undef_token_number[;
if (t <= 0)
return Lexer.EOF;
else if (t <= yyuser_token_number_max_)
else if (t <= user_token_number_max_)
return yytranslate_table_[t];
else
return yyundef_token_;
return undef_token_;
}
]b4_integral_parser_table_define([translate_table], [b4_translate])[
]])[
private static final ]b4_int_type_for([b4_translate])[ yy_error_token_ = 1;
private static final int yylast_ = ]b4_last[;
private static final int yynnts_ = ]b4_nterms_number[;
private static final int yyempty_ = -2;
private static final int yyfinal_ = ]b4_final_state_number[;
private static final int yyterror_ = 1;
private static final int yyerrcode_ = 256;
private static final int yyntokens_ = ]b4_tokens_number[;
private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
private static final int yyundef_token_ = ]b4_undef_token_number[;
/* User implementation code. */
]b4_percent_code_get[]dnl
+39 -27
View File
@@ -62,11 +62,14 @@ m4_define([b4_location_define],
[[ /// A point in a source file.
class position
{
public:]m4_ifdef([b4_location_constructors], [[
public:
/// Type for line and column numbers.
typedef int counter_type;
]m4_ifdef([b4_location_constructors], [[
/// Construct a position.
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[)
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
: filename (f)
, line (l)
, column (c)
@@ -75,8 +78,8 @@ m4_define([b4_location_define],
]])[
/// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[)
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
{
filename = fn;
line = l;
@@ -86,7 +89,7 @@ m4_define([b4_location_define],
/** \name Line and Column related manipulators
** \{ */
/// (line related) Advance to the COUNT next lines.
void lines (int count = 1)
void lines (counter_type count = 1)
{
if (count)
{
@@ -96,7 +99,7 @@ m4_define([b4_location_define],
}
/// (column related) Advance to the COUNT next columns.
void columns (int count = 1)
void columns (counter_type count = 1)
{
column = add_ (column, count, ]b4_location_initial_column[);
}
@@ -105,13 +108,13 @@ m4_define([b4_location_define],
/// File name to which this position refers.
]b4_percent_define_get([[filename_type]])[* filename;
/// Current line number.
int line;
counter_type line;
/// Current column number.
int column;
counter_type column;
private:
/// Compute max (min, lhs+rhs).
static int add_ (int lhs, int rhs, int min)
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
{
return lhs + rhs < min ? min : lhs + rhs;
}
@@ -119,7 +122,7 @@ m4_define([b4_location_define],
/// Add \a width columns, in place.
inline position&
operator+= (position& res, int width)
operator+= (position& res, position::counter_type width)
{
res.columns (width);
return res;
@@ -127,21 +130,21 @@ m4_define([b4_location_define],
/// Add \a width columns.
inline position
operator+ (position res, int width)
operator+ (position res, position::counter_type width)
{
return res += width;
}
/// Subtract \a width columns, in place.
inline position&
operator-= (position& res, int width)
operator-= (position& res, position::counter_type width)
{
return res += -width;
}
/// Subtract \a width columns.
inline position
operator- (position res, int width)
operator- (position res, position::counter_type width)
{
return res -= width;
}
@@ -181,6 +184,8 @@ m4_define([b4_location_define],
class location
{
public:
/// Type for line and column numbers.
typedef position::counter_type counter_type;
]m4_ifdef([b4_location_constructors], [
/// Construct a location from \a b to \a e.
location (const position& b, const position& e)
@@ -196,8 +201,8 @@ m4_define([b4_location_define],
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (]b4_percent_define_get([[filename_type]])[* f,
int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[)
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
: begin (f, l, c)
, end (f, l, c)
{}
@@ -205,8 +210,8 @@ m4_define([b4_location_define],
])[
/// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[)
counter_type l = ]b4_location_initial_line[,
counter_type c = ]b4_location_initial_column[)
{
begin.initialize (f, l, c);
end = begin;
@@ -222,13 +227,13 @@ m4_define([b4_location_define],
}
/// Extend the current location to the COUNT next columns.
void columns (int count = 1)
void columns (counter_type count = 1)
{
end += count;
}
/// Extend the current location to the COUNT next lines.
void lines (int count = 1)
void lines (counter_type count = 1)
{
end.lines (count);
}
@@ -243,39 +248,45 @@ m4_define([b4_location_define],
};
/// Join two locations, in place.
inline location& operator+= (location& res, const location& end)
inline location&
operator+= (location& res, const location& end)
{
res.end = end.end;
return res;
}
/// Join two locations.
inline location operator+ (location res, const location& end)
inline location
operator+ (location res, const location& end)
{
return res += end;
}
/// Add \a width columns to the end position, in place.
inline location& operator+= (location& res, int width)
inline location&
operator+= (location& res, location::counter_type width)
{
res.columns (width);
return res;
}
/// Add \a width columns to the end position.
inline location operator+ (location res, int width)
inline location
operator+ (location res, location::counter_type width)
{
return res += width;
}
/// Subtract \a width columns to the end position, in place.
inline location& operator-= (location& res, int width)
inline location&
operator-= (location& res, location::counter_type width)
{
return res += -width;
}
/// Subtract \a width columns to the end position.
inline location operator- (location res, int width)
inline location
operator- (location res, location::counter_type width)
{
return res -= width;
}
@@ -304,7 +315,8 @@ m4_define([b4_location_define],
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
location::counter_type end_col
= 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin;
if (loc.end.filename
&& (!loc.begin.filename
+2 -1
View File
@@ -90,10 +90,11 @@ m4_define([b4_stack_define],
{
return index_type (seq_.size ());
}
std::ptrdiff_t
ssize () const YY_NOEXCEPT
{
return (std::ptrdiff_t) size ();
return std::ptrdiff_t (size ());
}
/// Iterator on top of the stack (going downwards).
+20 -20
View File
@@ -72,9 +72,9 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
# The needed includes for variants support.
m4_define([b4_variant_includes],
[b4_parse_assert_if([[#include <typeinfo>]])[
#ifndef YYASSERT
#ifndef YY_ASSERT
# include <cassert>
# define YYASSERT assert
# define YY_ASSERT assert
#endif
]])
@@ -111,14 +111,14 @@ m4_define([b4_value_type_declare],
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[
{
YYASSERT (sizeof (T) <= size);
YY_ASSERT (sizeof (T) <= size);
new (yyas_<T> ()) T (YY_MOVE (t));
}
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YY_ASSERT (!yytypeid_);
])[}
# if 201103L <= YY_CPLUSPLUS
@@ -127,8 +127,8 @@ m4_define([b4_value_type_declare],
T&
emplace (U&&... u)
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size);
YY_ASSERT (!yytypeid_);
YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
}
@@ -138,8 +138,8 @@ m4_define([b4_value_type_declare],
T&
emplace ()
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size);
YY_ASSERT (!yytypeid_);
YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T ();
}
@@ -149,8 +149,8 @@ m4_define([b4_value_type_declare],
T&
emplace (const T& t)
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size);
YY_ASSERT (!yytypeid_);
YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (t);
}
@@ -179,9 +179,9 @@ m4_define([b4_value_type_declare],
T&
as () YY_NOEXCEPT
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= size);])[
YY_ASSERT (yytypeid_);
YY_ASSERT (*yytypeid_ == typeid (T));
YY_ASSERT (sizeof (T) <= size);])[
return *yyas_<T> ();
}
@@ -190,9 +190,9 @@ m4_define([b4_value_type_declare],
const T&
as () const YY_NOEXCEPT
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= size);])[
YY_ASSERT (yytypeid_);
YY_ASSERT (*yytypeid_ == typeid (T));
YY_ASSERT (sizeof (T) <= size);])[
return *yyas_<T> ();
}
@@ -208,8 +208,8 @@ m4_define([b4_value_type_declare],
void
swap (self_type& that) YY_NOEXCEPT
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == *that.yytypeid_);])[
YY_ASSERT (yytypeid_);
YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
std::swap (as<T> (), that.as<T> ());
}
@@ -401,7 +401,7 @@ m4_define([_b4_token_constructor_define],
b4_symbol_if([$1], [has_type], [std::move (v)]),
b4_locations_if([std::move (l)]))[)
{
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
}
#else
symbol_type (]b4_join(
@@ -413,7 +413,7 @@ m4_define([_b4_token_constructor_define],
b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l]))[)
{
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
}
#endif
]])])
+47 -29
View File
@@ -339,13 +339,13 @@ m4_if(b4_api_prefix, [yy], [],
#define yylex ]b4_prefix[lex
#define yyerror ]b4_prefix[error
#define yydebug ]b4_prefix[debug
#define yynerrs ]b4_prefix[nerrs
]]b4_pure_if([], [[
#define yynerrs ]b4_prefix[nerrs]]b4_pure_if([], [[
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
]b4_user_pre_prologue[
]b4_cast_define[
]b4_null_define[
/* Enabling verbose error messages. */
@@ -400,10 +400,13 @@ m4_if(b4_api_prefix, [yy], [],
# endif
#endif
#define YYSIZE_MAXIMUM ((YYPTRDIFF_T) (YYPTRDIFF_MAXIMUM < (YYSIZE_T) -1 \
? YYPTRDIFF_MAXIMUM : (YYSIZE_T) -1))
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) ((YYPTRDIFF_T) sizeof (X))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
@@ -557,7 +560,7 @@ union yyalloc
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (YYSIZE_T) (Count) * sizeof (*(Src)))
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
@@ -832,8 +835,9 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
if (YYMAXDEPTH < yyalloc)
yyalloc = YYMAXDEPTH;
yybottom_new =
(yy_state_t *) YYSTACK_ALLOC ((YYSIZE_T)
(yyalloc * YYSIZEOF (*yybottom_new)));
YY_CAST (yy_state_t *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
yyalloc * YYSIZEOF (*yybottom_new))));
if (!yybottom_new)
{
YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
@@ -850,8 +854,10 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
*yybottom = yybottom_new;
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
[full], [[
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
(long) yyalloc, yydebug_suffix));]])[
YY_CAST (long, yyalloc), yydebug_suffix));
YY_IGNORE_USELESS_CAST_END]])[
}
return 0;
}
@@ -1008,7 +1014,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
if (yyesp == yyes_prev)
{
yyesp = *yyes;
*yyesp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
}
else
{
@@ -1021,7 +1029,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
YYDPRINTF ((stderr, "\n"));
return 2;
}
*++yyesp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*++yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
}
YYDPRINTF ((stderr, " G%d", yystate));
}
@@ -1033,7 +1043,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen(S) ((YYPTRDIFF_T) strlen (S))
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
# else
/* Return the length of YYSTR. */
]b4_function_define([yystrlen], [static YYPTRDIFF_T],
@@ -1133,16 +1143,16 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
]b4_lac_if([[yy_state_t *yyesa, yy_state_t **yyes,
YYPTRDIFF_T *yyes_capacity, ]])[yy_state_t *yyssp, int yytoken)
{
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYPTRDIFF_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
/* Arguments of yyformat: reported tokens (one for the "unexpected",
one per "expected"). */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
/* Actual size of YYARG. */
int yycount = 0;
/* Cumulated lengths of YYARG. */
YYPTRDIFF_T yysize = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
@@ -1174,7 +1184,9 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];]b4_lac_if([[
int yyn = yypact[*yyssp];
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
yysize = yysize0;]b4_lac_if([[
YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
@@ -1213,8 +1225,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
yyarg[yycount++] = yytname[yyx];
{
YYPTRDIFF_T yysize1 = yysize + yytnamerr (YY_NULLPTR,
yytname[yyx]);
YYPTRDIFF_T yysize1
= yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
@@ -1245,7 +1257,9 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
{
YYPTRDIFF_T yysize1 = yysize + yystrlen (yyformat);
/* Don't count the "%s"s in the final size, but reserve room for
the terminator. */
YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
@@ -1275,8 +1289,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
else
{
yyp++;
yyformat++;
++yyp;
++yyformat;
}
}
return 0;
@@ -1342,7 +1356,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated)
return YY_NULLPTR;]])[
yyps = (yypstate *) malloc (sizeof *yyps);
yyps = YY_CAST (yypstate *, malloc (sizeof *yyps));
if (!yyps)
return YY_NULLPTR;
yyps->yynew = 1;]b4_pure_if([], [[
@@ -1484,7 +1498,9 @@ yynewstate:
yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
*yyssp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
@@ -1527,8 +1543,8 @@ yysetstate:
{
yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC ((YYSIZE_T)
YYSTACK_BYTES (yystacksize));
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
@@ -1544,8 +1560,10 @@ yysetstate:
yyvsp = yyvs + yysize - 1;]b4_locations_if([
yylsp = yyls + yysize - 1;])[
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
(long) yystacksize));
YY_CAST (long, yystacksize)));
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
@@ -1758,7 +1776,7 @@ yyerrlab:
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC ((YYSIZE_T) yymsg_alloc);
yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
if (!yymsg)
{
yymsg = yymsgbuf;
+376 -314
View File
File diff suppressed because it is too large Load Diff
+17
View File
@@ -54,6 +54,23 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
$(AM_V_at)mv $@.tmp $@
MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI)
# Fix Info's @code in @deftype
# https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html
all: $(srcdir)/$(doc_bison).info.bak
$(srcdir)/$(doc_bison).info.bak: $(srcdir)/$(doc_bison).info
$(AM_V_GEN) $(PERL) -pi.bak -0777 \
-e 's{(^ --.*\n(?: {10}.*\n)*)}' \
-e '{' \
-e ' $$def = $$1;' \
-e ' $$def =~ s/|//g;' \
-e ' $$def;' \
-e '}gem;' $(srcdir)/$(doc_bison).info
@ touch $@
EXTRA_DIST += $(srcdir)/$(doc_bison).info.bak
MAINTAINERCLEANFILES += $(srcdir)/$(doc_bison).info.bak
## ---------- ##
## Ref card. ##
## ---------- ##
+1 -1
Submodule gnulib updated: 56ca994d47...b943dd6649
+2
View File
@@ -16,6 +16,7 @@
/argmatch.c
/argmatch.h
/asnprintf.c
/asprintf.c
/assure.h
/basename-lgpl.c
/basename.c
@@ -303,6 +304,7 @@
/unsetenv.c
/vasnprintf.c
/vasnprintf.h
/vasprintf.c
/verify.h
/vfprintf.c
/vsnprintf.c
+18
View File
@@ -43,14 +43,23 @@
/getopt.m4
/getprogname.m4
/getrusage.m4
/gettext.m4
/gettime.m4
/gettimeofday.m4
/glibc2.m4
/glibc21.m4
/gnulib-cache.m4
/gnulib-common.m4
/gnulib-comp.m4
/gnulib-tool.m4
/host-cpu-c-abi.m4
/iconv.m4
/include_next.m4
/intdiv0.m4
/intl.m4
/intldir.m4
/intlmacosx.m4
/intmax.m4
/intmax_t.m4
/inttypes-pri.m4
/inttypes.m4
@@ -65,6 +74,7 @@
/jm-winsz1.m4
/jm-winsz2.m4
/largefile.m4
/lcmessage.m4
/ldexp.m4
/ldexpl.m4
/lib-ld.m4
@@ -98,6 +108,7 @@
/msvc-inval.m4
/msvc-nothrow.m4
/multiarch.m4
/nls.m4
/nocrash.m4
/non-recursive-gnulib-prefix-hack.m4
/obstack-printf.m4
@@ -109,11 +120,14 @@
/pathmax.m4
/perror.m4
/pipe2.m4
/po.m4
/posix_spawn.m4
/printf-frexp.m4
/printf-frexpl.m4
/printf-posix-rpl.m4
/printf-posix.m4
/printf.m4
/progtest.m4
/pthread_rwlock_rdlock.m4
/quote.m4
/quotearg.m4
@@ -169,12 +183,16 @@
/time_h.m4
/timespec.m4
/tls.m4
/uintmax_t.m4
/unistd-safer.m4
/unistd_h.m4
/unlink.m4
/unlocked-io.m4
/vasnprintf.m4
/vasprintf-posix.m4
/vasprintf.m4
/vfprintf-posix.m4
/visibility.m4
/vsnprintf-posix.m4
/vsnprintf.m4
/vsprintf-posix.m4
+12 -8
View File
@@ -113,13 +113,14 @@ static const argmatch_warning_doc argmatch_warning_docs[] =
{
{ "conflicts-sr", N_("S/R conflicts (enabled by default)") },
{ "conflicts-rr", N_("R/R conflicts (enabled by default)") },
{ "dangling-alias", N_("string aliases not attached to a symbol") },
{ "deprecated", N_("obsolete constructs") },
{ "empty-rule", N_("empty rules without %empty") },
{ "midrule-values", N_("unset or unused midrule values") },
{ "precedence", N_("useless precedence and associativity") },
{ "yacc", N_("incompatibilities with POSIX Yacc") },
{ "other", N_("all other warnings (enabled by default)") },
{ "all", N_("all the warnings except 'yacc'") },
{ "all", N_("all the warnings except 'dangling-alias' and 'yacc'") },
{ "no-CATEGORY", N_("turn off warnings in CATEGORY") },
{ "none", N_("turn off all the warnings") },
{ "error[=CATEGORY]", N_("treat warnings as errors") },
@@ -128,17 +129,18 @@ static const argmatch_warning_doc argmatch_warning_docs[] =
static const argmatch_warning_arg argmatch_warning_args[] =
{
{ "none", Wnone },
{ "midrule-values", Wmidrule_values },
{ "yacc", Wyacc },
{ "conflicts-sr", Wconflicts_sr },
{ "all", Wall },
{ "conflicts-rr", Wconflicts_rr },
{ "conflicts-sr", Wconflicts_sr },
{ "dangling-alias", Wdangling_alias },
{ "deprecated", Wdeprecated },
{ "empty-rule", Wempty_rule },
{ "precedence", Wprecedence },
{ "other", Wother },
{ "all", Wall },
{ "everything", Weverything },
{ "midrule-values", Wmidrule_values },
{ "none", Wnone },
{ "other", Wother },
{ "precedence", Wprecedence },
{ "yacc", Wyacc },
{ NULL, Wnone }
};
@@ -223,6 +225,7 @@ warnings_argmatch (char *args)
}
}
/* Color style for this type of message. */
static const char*
severity_style (severity s)
{
@@ -240,6 +243,7 @@ severity_style (severity s)
abort ();
}
/* Prefix for this type of message. */
static const char*
severity_prefix (severity s)
{
+5 -1
View File
@@ -47,6 +47,7 @@ typedef enum
{
warning_conflicts_rr,
warning_conflicts_sr,
warning_dangling_alias,
warning_deprecated,
warning_empty_rule,
warning_midrule_values,
@@ -60,6 +61,7 @@ typedef enum
/** Whether -Werror was set. */
extern bool warnings_are_errors;
/** Document --warning arguments. */
void warning_usage (FILE *out);
/** Decode a single argument from -W.
@@ -98,12 +100,14 @@ void complain_free (void);
/** Initialize support for colored messages. */
void complain_init_color (void);
/** Flags passed to diagnostics functions. */
typedef enum
{
Wnone = 0, /**< Issue no warnings. */
Wconflicts_rr = 1 << warning_conflicts_rr,
Wconflicts_sr = 1 << warning_conflicts_sr,
Wdangling_alias = 1 << warning_dangling_alias,
Wdeprecated = 1 << warning_deprecated,
Wempty_rule = 1 << warning_empty_rule,
Wmidrule_values = 1 << warning_midrule_values,
@@ -118,7 +122,7 @@ typedef enum
/**< All above warnings. */
Weverything = ~complaint & ~fatal & ~silent,
Wall = Weverything & ~Wyacc
Wall = Weverything & ~Wdangling_alias & ~Wyacc
} warnings;
/** Whether the warnings of \a flags are all unset.
+13 -4
View File
@@ -259,12 +259,11 @@ grammar_dump (FILE *out, const char *title)
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
ntokens, nvars, nsyms, nrules, nritems);
fprintf (out, "Variables\n---------\n\n");
fprintf (out, "Tokens\n------\n\n");
{
fprintf (out, "Value Sprec Sassoc Tag\n");
for (symbol_number i = ntokens; i < nsyms; i++)
for (symbol_number i = 0; i < ntokens; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
symbols[i]->content->prec, symbols[i]->content->assoc,
@@ -272,6 +271,16 @@ grammar_dump (FILE *out, const char *title)
fprintf (out, "\n\n");
}
fprintf (out, "Non terminals\n-------------\n\n");
{
fprintf (out, "Value Tag\n");
for (symbol_number i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %s\n",
i, symbols[i]->tag);
fprintf (out, "\n\n");
}
fprintf (out, "Rules\n-----\n\n");
{
fprintf (out,
@@ -282,7 +291,7 @@ grammar_dump (FILE *out, const char *title)
rule const *rule_i = &rules[i];
int const rhs_itemno = rule_i->rhs - ritem;
int length = rule_rhs_length (rule_i);
aver (item_number_as_rule_number (rule_i->rhs[length] == i));
aver (item_number_as_rule_number (rule_i->rhs[length]) == i);
fprintf (out, "%3d (%2d, %2d, %2s, %2s) %2d -> (%2u-%2u)",
i,
rule_i->prec ? rule_i->prec->prec : 0,
+4 -4
View File
@@ -21,13 +21,13 @@
#include "system.h"
#include <hash.h>
#include <quote.h>
#include "complain.h"
#include "files.h"
#include "fixits.h"
#include "getargs.h"
#include "muscle-tab.h"
#include "quote.h"
muscle_kind
muscle_kind_new (char const *k)
@@ -626,17 +626,17 @@ muscle_percent_define_check_kind (char const *variable, muscle_kind kind)
{
case muscle_code:
complain (&loc, Wdeprecated,
"%%define variable '%s' requires '{...}' values",
_("%%define variable '%s' requires '{...}' values"),
variable);
break;
case muscle_keyword:
complain (&loc, Wdeprecated,
"%%define variable '%s' requires keyword values",
_("%%define variable '%s' requires keyword values"),
variable);
break;
case muscle_string:
complain (&loc, Wdeprecated,
"%%define variable '%s' requires '\"...\"' values",
_("%%define variable '%s' requires '\"...\"' values"),
variable);
break;
}
+79 -38
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.4.2.213-aa24. */
/* A Bison parser, made by GNU Bison 3.4.91.18-42a6c. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.4.2.213-aa24"
#define YYBISON_VERSION "3.4.91.18-42a6c"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -78,7 +78,15 @@
#define yynerrs gram_nerrs
# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast<Type> (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
@@ -289,10 +297,13 @@ typedef int yytype_uint16;
# endif
#endif
#define YYSIZE_MAXIMUM ((YYPTRDIFF_T) (YYPTRDIFF_MAXIMUM < (YYSIZE_T) -1 \
? YYPTRDIFF_MAXIMUM : (YYSIZE_T) -1))
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) ((YYPTRDIFF_T) sizeof (X))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */
typedef yytype_uint8 yy_state_t;
@@ -337,12 +348,19 @@ typedef int yy_state_fast_t;
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
# if defined __cplusplus
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
# endif
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
@@ -350,6 +368,10 @@ typedef int yy_state_fast_t;
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
@@ -451,7 +473,7 @@ union yyalloc
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (YYSIZE_T) (Count) * sizeof (*(Src)))
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
@@ -499,11 +521,11 @@ static const yytype_int16 yyrline[] =
453, 457, 467, 468, 469, 470, 474, 475, 480, 481,
485, 486, 490, 491, 492, 505, 514, 518, 522, 530,
531, 535, 548, 549, 561, 565, 569, 577, 579, 584,
591, 601, 605, 609, 617, 618, 626, 627, 633, 634,
635, 642, 642, 650, 651, 652, 657, 660, 662, 664,
666, 668, 670, 672, 674, 676, 681, 682, 691, 715,
716, 717, 718, 730, 732, 759, 764, 765, 770, 779,
780, 784, 785
591, 601, 605, 609, 617, 622, 634, 635, 641, 642,
643, 650, 650, 658, 659, 660, 665, 668, 670, 672,
674, 676, 678, 680, 682, 684, 689, 690, 699, 723,
724, 725, 726, 738, 740, 767, 772, 773, 778, 787,
788, 792, 793
};
#endif
@@ -1225,8 +1247,9 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
if (YYMAXDEPTH < yyalloc)
yyalloc = YYMAXDEPTH;
yybottom_new =
(yy_state_t *) YYSTACK_ALLOC ((YYSIZE_T)
(yyalloc * YYSIZEOF (*yybottom_new)));
YY_CAST (yy_state_t *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
yyalloc * YYSIZEOF (*yybottom_new))));
if (!yybottom_new)
{
YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
@@ -1398,7 +1421,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
if (yyesp == yyes_prev)
{
yyesp = *yyes;
*yyesp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
}
else
{
@@ -1411,7 +1436,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
YYDPRINTF ((stderr, "\n"));
return 2;
}
*++yyesp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*++yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
}
YYDPRINTF ((stderr, " G%d", yystate));
}
@@ -1423,7 +1450,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen(S) ((YYPTRDIFF_T) strlen (S))
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
# else
/* Return the length of YYSTR. */
static YYPTRDIFF_T
@@ -1523,16 +1550,16 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
yy_state_t *yyesa, yy_state_t **yyes,
YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken)
{
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYPTRDIFF_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
/* Arguments of yyformat: reported tokens (one for the "unexpected",
one per "expected"). */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
/* Actual size of YYARG. */
int yycount = 0;
/* Cumulated lengths of YYARG. */
YYPTRDIFF_T yysize = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
@@ -1557,6 +1584,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
yysize = yysize0;
YYDPRINTF ((stderr, "Constructing syntax error message\n"));
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
@@ -1582,8 +1611,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
yyarg[yycount++] = yytname[yyx];
{
YYPTRDIFF_T yysize1 = yysize + yytnamerr (YY_NULLPTR,
yytname[yyx]);
YYPTRDIFF_T yysize1
= yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
@@ -1614,7 +1643,9 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
{
YYPTRDIFF_T yysize1 = yysize + yystrlen (yyformat);
/* Don't count the "%s"s in the final size, but reserve room for
the terminator. */
YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
@@ -1644,8 +1675,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
}
else
{
yyp++;
yyformat++;
++yyp;
++yyformat;
}
}
return 0;
@@ -1845,7 +1876,9 @@ yynewstate:
yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
*yyssp = (yy_state_t) yystate;
YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
@@ -1888,8 +1921,8 @@ yysetstate:
{
yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC ((YYSIZE_T)
YYSTACK_BYTES (yystacksize));
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
@@ -1905,8 +1938,10 @@ yysetstate:
yyvsp = yyvs + yysize - 1;
yylsp = yyls + yysize - 1;
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
(long) yystacksize));
YY_CAST (long, yystacksize)));
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
@@ -2399,11 +2434,17 @@ yyreduce:
break;
case 84:
{ (yyval.yytype_86) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); }
{
symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
(yyval.yytype_86) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]));
}
break;
case 85:
{ (yyval.yytype_86) = symbol_list_append ((yyvsp[-1].yytype_86), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); }
{
symbol_class_set ((yyvsp[0].symbol), pct_type_sym, (yylsp[0]), false);
(yyval.yytype_86) = symbol_list_append ((yyvsp[-1].yytype_86), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])));
}
break;
case 90:
@@ -2619,7 +2660,7 @@ yyerrlab:
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC ((YYSIZE_T) yymsg_alloc);
yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
if (!yymsg)
{
yymsg = yymsgbuf;
+1 -1
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.4.2.213-aa24. */
/* A Bison parser, made by GNU Bison 3.4.91.18-42a6c. */
/* Bison interface for Yacc-like parsers in C
+15 -7
View File
@@ -592,11 +592,11 @@ token_decl_for_prec:
;
/*-----------------------.
| symbol_decls (%type). |
`-----------------------*/
/*-----------------------------------.
| symbol_decls (argument of %type). |
`-----------------------------------*/
// A non empty list of typed symbols.
// A non empty list of typed symbols (for %type).
symbol_decls:
symbol_decl.1[syms]
{
@@ -612,10 +612,18 @@ symbol_decls:
}
;
// One or more token declarations.
// One or more token declarations (for %type).
symbol_decl.1:
symbol { $$ = symbol_list_sym_new ($1, @1); }
| symbol_decl.1 symbol { $$ = symbol_list_append ($1, symbol_list_sym_new ($2, @2)); }
symbol
{
symbol_class_set ($symbol, pct_type_sym, @symbol, false);
$$ = symbol_list_sym_new ($symbol, @symbol);
}
| symbol_decl.1 symbol
{
symbol_class_set ($symbol, pct_type_sym, @symbol, false);
$$ = symbol_list_append ($1, symbol_list_sym_new ($symbol, @symbol));
}
;
/*------------------------------------------.
+2 -6
View File
@@ -232,12 +232,8 @@ grammar_current_rule_begin (symbol *lhs, location loc,
assign_named_ref (current_rule, named_ref_copy (lhs_name));
/* Mark the rule's lhs as a nonterminal if not already so. */
if (lhs->content->class == unknown_sym)
{
lhs->content->class = nterm_sym;
lhs->content->number = nvars;
++nvars;
}
if (lhs->content->class == unknown_sym || lhs->content->class == pct_type_sym)
symbol_class_set (lhs, nterm_sym, empty_loc, false);
else if (lhs->content->class == token_sym)
complain (&loc, complaint, _("rule given for %s, which is a token"),
lhs->tag);
+7 -6
View File
@@ -209,22 +209,23 @@ at_basename (int argc, char *argv[], char **out_namep, int *out_linenop)
static void
at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
{
static int indent;
warnings w = flag (argv[1]);
location loc;
location *locp = NULL;
if (argc < 4)
fail_for_at_directive_too_few_args (argv[0]);
(void) out_namep;
(void) out_linenop;
if (argc < 4)
fail_for_at_directive_too_few_args (argv[0]);
warnings w = flag (argv[1]);
location loc;
location *locp = NULL;
if (argv[2] && argv[2][0])
{
boundary_set_from_string (&loc.start, argv[2]);
boundary_set_from_string (&loc.end, argv[3]);
locp = &loc;
}
static int indent;
if (w & silent)
indent += SUB_INDENT;
else
+36 -5
View File
@@ -26,13 +26,12 @@
#include <assure.h>
#include <fstrcmp.h>
#include <hash.h>
#include <quote.h>
#include "complain.h"
#include "getargs.h"
#include "gram.h"
#include "intprops.h"
#include "quote.h"
static struct hash_table *symbol_table = NULL;
static struct hash_table *semantic_type_table = NULL;
@@ -233,7 +232,14 @@ symbol_print (symbol const *s, FILE *f)
{
if (s)
{
fputs (s->tag, f);
symbol_class c = s->content->class;
fprintf (f, "%s: %s",
c == unknown_sym ? "unknown"
: c == pct_type_sym ? "%type"
: c == token_sym ? "token"
: c == nterm_sym ? "nterm"
: NULL, /* abort. */
s->tag);
SYMBOL_ATTR_PRINT (type_name);
SYMBOL_CODE_PRINT (destructor);
SYMBOL_CODE_PRINT (printer);
@@ -502,15 +508,33 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
| Set the CLASS associated with SYM. |
`------------------------------------*/
static void
complain_pct_type_on_token (location *loc)
{
complain (loc, Wyacc,
_("POSIX yacc reserves %%type to nonterminals"));
}
void
symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
{
aver (class != unknown_sym);
sym_content *s = sym->content;
if (s->class != unknown_sym && s->class != class)
if (class == pct_type_sym)
{
if (s->class == token_sym)
complain_pct_type_on_token (&loc);
else if (s->class == unknown_sym)
s->class = class;
}
else if (s->class != unknown_sym && s->class != pct_type_sym
&& s->class != class)
complain_class_redeclared (sym, class, loc);
else
{
if (class == token_sym && s->class == pct_type_sym)
complain_pct_type_on_token (&sym->location);
if (class == nterm_sym && s->class != nterm_sym)
s->number = nvars++;
else if (class == token_sym && s->number == NUMBER_UNDEFINED)
@@ -579,13 +603,20 @@ static void
symbol_check_defined (symbol *sym)
{
sym_content *s = sym->content;
if (s->class == unknown_sym)
if (s->class == unknown_sym || s->class == pct_type_sym)
{
complain_symbol_undeclared (sym);
s->class = nterm_sym;
s->number = nvars++;
}
if (s->class == token_sym
&& sym->tag[0] == '"'
&& !sym->is_alias)
complain (&sym->location, Wdangling_alias,
_("string literal %s not attached to a symbol"),
sym->tag);
for (int i = 0; i < 2; ++i)
symbol_code_props_get (sym, i)->is_used = true;
+10 -4
View File
@@ -38,9 +38,15 @@
/** Symbol classes. */
typedef enum
{
unknown_sym, /**< Undefined. */
token_sym, /**< Terminal. */
nterm_sym /**< Nonterminal. */
/** Undefined. */
unknown_sym,
/** Declared with %type: same as Undefined, but triggered a Wyacc if
applied to a terminal. */
pct_type_sym,
/** Terminal. */
token_sym,
/** Nonterminal. */
nterm_sym
} symbol_class;
@@ -219,7 +225,7 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
/** Set the \c class associated with \c sym.
Whether \c declaring means whether this class definition comes
from %nterm or %token. */
from %nterm or %token (but not %type, prec/assoc, etc.). */
void symbol_class_set (symbol *sym, symbol_class class, location loc,
bool declaring);
+5 -5
View File
@@ -473,7 +473,7 @@ AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java.
## FIXME: test Java and D.
m4_map_args([AT_TEST], [yacc.c], [glr.c], [lalr1.cc], [glr.cc])
m4_popdef([AT_TEST])
@@ -772,10 +772,10 @@ static
static int counter = 0;
int c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++;
assert (c <= YY_CAST (int, strlen (source)));
/* As in BASIC, line numbers go from 10 to 10. */
]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = (10 * c);
]AT_LOC_LAST_LINE[ = ]AT_LOC_LAST_COLUMN[ = ]AT_LOC_FIRST_LINE[ + 9;
assert (c <= (int) strlen (source));
if (source[c])
fprintf (stderr, "sending: '%c'", source[c]);
else
@@ -1780,7 +1780,8 @@ float: UNTYPED INT
yy::parser::token::INT,
EOF}]],
[[{UNTYPED, INT, EOF}]]),
[AT_VAL.ival = (int) toknum * 10; AT_VAL.fval = (float) toknum / 10.0f;])[
[AT_VAL.ival = toknum * 10;
AT_VAL.fval = YY_CAST (float, toknum) / 10.0f;])[
]AT_MAIN_DEFINE[
]])
@@ -1805,7 +1806,6 @@ AT_CLEANUP
])
m4_map_args([AT_TEST], [yacc.c], [glr.c], [lalr1.cc], [glr.cc])
m4_popdef([AT_TEST])
## -------------------------------------------------- ##
@@ -1897,7 +1897,7 @@ exp:
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (int) ((toknum + 1) * 10)])[
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (toknum + 1) * 10])[
]AT_MAIN_DEFINE[
]])
AT_BISON_OPTION_POPDEFS
+2 -2
View File
@@ -117,9 +117,9 @@ fi
: ${DC='@DC@'}
: ${DCFLAGS='@DCFLAGS@'}
if test x"$DC" = x; then
BISON_DC_WORKS=false
BISON_DC_WORKS=false
else
BISON_DC_WORKS=true
BISON_DC_WORKS=true
fi
# Empty if no javac was found
+1 -1
View File
@@ -37,7 +37,7 @@ fi
# We redirect stderr, which breaks the computation of the terminal
# screen width. So export COLUMNS to Bison, hoping for the shell to
# have defined it.
: ${COLUMNS=`tput cols || echo 132`}
: ${COLUMNS=`(tput cols) 2>/dev/null || echo 132`}
export COLUMNS
$PREBISON "$abs_top_builddir/src/bison" ${1+"$@"} 2>"$stderr"
status=$?
+60
View File
@@ -1019,6 +1019,66 @@ input.y:12.3-18: warning: rule useless in parser due to conflicts [-Wother]
AT_CLEANUP
## ---------------------------------------- ##
## Syntax error in consistent error state. ##
## ---------------------------------------- ##
# AT_TEST(SKELETON-NAME)
# ----------------------
# Make sure yysyntax_error does nothing silly when called on yytoken
# == YYEMPTY.
m4_pushdef([AT_TEST],
[AT_SETUP([Syntax error in consistent error state: $1])
AT_BISON_OPTION_PUSHDEFS([%skeleton "$1"])
AT_DATA_GRAMMAR([input.y],
[[%define parse.error verbose
%skeleton "$1"
%%
%nonassoc 'a';
start: 'a' consistent-error-on-a-a 'a';
consistent-error-on-a-a:
'a' default-reduction
| 'a' default-reduction 'a'
;
default-reduction: %empty;
%code {
#include <stdio.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
};
%%
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE("aa")[
]AT_MAIN_DEFINE[
]])
AT_BISON_CHECK([-o input.AT_LANG_EXT input.y], 0, [],
[[input.y:17.5-25: warning: rule useless in parser due to conflicts [-Wother]
input.y:18.5-29: warning: rule useless in parser due to conflicts [-Wother]
]])
AT_LANG_COMPILE([input])
AT_PARSER_CHECK([[input]], 1, [],
[[syntax error
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
])
## FIXME: test Java and D.
m4_map_args([AT_TEST], [yacc.c], [glr.c], [lalr1.cc], [glr.cc])
m4_popdef([AT_TEST])
## -------------------------------- ##
## Defaulted Conflicted Reduction. ##
## -------------------------------- ##
+18 -21
View File
@@ -178,7 +178,7 @@ main (int argc, char **argv)
do
{
buffer[i++] = (char) c;
buffer[i++] = YY_CAST (char, c);
colNum += 1;
assert (i != sizeof buffer - 1);
c = getchar ();
@@ -187,8 +187,8 @@ main (int argc, char **argv)
ungetc (c, stdin);
buffer[i++] = 0;
tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
yylval = new_term (strcpy ((char *) malloc (i), buffer));
tok = isupper (YY_CAST (unsigned char, buffer[0])) ? TYPENAME : ID;
yylval = new_term (strcpy (YY_CAST (char *, malloc (i)), buffer));
}
else
{
@@ -206,7 +206,7 @@ main (int argc, char **argv)
static Node *
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
{
Node *node = (Node *) malloc (sizeof (Node));
Node *node = YY_CAST (Node *, malloc (sizeof (Node)));
node->nterm.isNterm = 1;
node->nterm.parents = 0;
node->nterm.form = form;
@@ -225,7 +225,7 @@ new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
static Node *
new_term (char *text)
{
Node *node = (Node *) malloc (sizeof (Node));
Node *node = YY_CAST (Node *, malloc (sizeof (Node)));
node->term.isNterm = 0;
node->term.parents = 0;
node->term.text = text;
@@ -255,30 +255,27 @@ free_node (Node *node)
static char *
node_to_string (Node *node)
{
char *child0;
char *child1;
char *child2;
char *buffer;
char *res;
if (!node)
{
buffer = (char *) malloc (1);
buffer[0] = 0;
res = YY_CAST (char *, malloc (1));
res[0] = 0;
}
else if (node->nodeInfo.isNterm == 1)
{
child0 = node_to_string (node->nterm.children[0]);
child1 = node_to_string (node->nterm.children[1]);
child2 = node_to_string (node->nterm.children[2]);
buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
+ strlen (child1) + strlen (child2) + 1);
sprintf (buffer, node->nterm.form, child0, child1, child2);
free (child0);
free (child1);
char *child0 = node_to_string (node->nterm.children[0]);
char *child1 = node_to_string (node->nterm.children[1]);
char *child2 = node_to_string (node->nterm.children[2]);
res = YY_CAST (char *, malloc (strlen (node->nterm.form) + strlen (child0)
+ strlen (child1) + strlen (child2) + 1));
sprintf (res, node->nterm.form, child0, child1, child2);
free (child2);
free (child1);
free (child0);
}
else
buffer = strdup (node->term.text);
return buffer;
res = strdup (node->term.text);
return res;
}
]]
+20 -42
View File
@@ -1,4 +1,4 @@
# Checking diagnotics. -*- Autotest -*-
# Checking diagnostics. -*- Autotest -*-
# Copyright (C) 2019 Free Software Foundation, Inc.
@@ -30,7 +30,8 @@ AT_KEYWORDS([diagnostics])
# We need UTF-8 support for correct screen-width computation of UTF-8
# characters. Skip the test if not available.
AT_SKIP_IF([! locale -a | grep '^en_US.UTF-8$'])
locale=`locale -a | $EGREP '^en_US\.(UTF-8|utf8)$' | sed 1q`
AT_SKIP_IF([test x == x"$locale"])
AT_BISON_OPTION_PUSHDEFS
@@ -45,7 +46,7 @@ fi
AT_DATA([experr], [$4])
AT_CHECK([LC_ALL=en_US.UTF-8 $5 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
AT_CHECK([LC_ALL="$locale" $5 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
# When no style, same messages, but without style.
AT_PERL_REQUIRE([-pi -e 's{(</?(-|\w)+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' experr])
@@ -53,7 +54,7 @@ AT_PERL_REQUIRE([-pi -e 's{(</?(-|\w)+>)}{ $[]1 eq "<tag>" ? $[]1 : "" }ge' expe
# Cannot use AT_BISON_CHECK easily as we need to change the
# environment.
# FIXME: Enhance AT_BISON_CHECK.
AT_CHECK([LC_ALL=en_US.UTF-8 $5 bison -fcaret -Wall input.y], [$3], [], [experr])
AT_CHECK([LC_ALL="$locale" $5 bison -fcaret -Wall input.y], [$3], [], [experr])
AT_BISON_OPTION_POPDEFS
@@ -233,49 +234,26 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
]])
## ------------------- ##
## Locations from M4. ##
## ------------------- ##
## -------------------- ##
## Complaints from M4. ##
## -------------------- ##
# Locations coming from m4 need the byte-column for diagnostics.
# Complaints issued m4 need complete locations (byte and column) for
# diagnostics.
AT_TEST([[Locations from M4]],
[[%define api.prefix {foo}
%define api.prefix {bar}
AT_TEST([[Complaints from M4]],
[[%define error1 {e}
%define error2 {é}
%%
exp:;
exp: %empty;
]],
[1],
[[input.y:10.1-24: <error>error:</error> %define variable 'api.prefix' redefined
10 | <error>%define api.prefix {bar}</error>
| <error>^~~~~~~~~~~~~~~~~~~~~~~~</error>
input.y:9.1-24: previous definition
9 | <note>%define api.prefix {foo}</note>
| <note>^~~~~~~~~~~~~~~~~~~~~~~~</note>
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]])
## ---------------------------------------------- ##
## Tabulations and multibyte characters from M4. ##
## ---------------------------------------------- ##
# Locations coming from m4 need the byte-column for diagnostics.
AT_TEST([[Tabulations and multibyte characters from M4]],
[[%define api.prefix {sun}
%define api.prefix {🌞}
%%
exp:;
]],
[1],
[[input.y:10.1-35: <error>error:</error> %define variable 'api.prefix' redefined
10 | <error>%define api.prefix {🌞}</error>
| <error>^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</error>
input.y:9.1-37: previous definition
9 | <note>%define api.prefix {sun}</note>
| <note>^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</note>
input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
[[input.y:9.1-27: <error>error:</error> %define variable 'error1' is not used
9 | <error>%define error1 {e}</error>
| <error>^~~~~~~~~~~~~~~~~~~~~~~~~~~</error>
input.y:10.1-27: <error>error:</error> %define variable 'error2' is not used
10 | <error>%define error2 {é}</error>
| <error>^~~~~~~~~~~~~~~~~~~~~~~~~~~</error>
]])
+43 -23
View File
@@ -41,9 +41,9 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
%}
%define parse.assert
%glr-parser
/* -------- productions ------ */
%%
@@ -128,6 +128,7 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
]AT_YYLEX_DECLARE[
%}
%define parse.assert
%glr-parser
%%
@@ -153,7 +154,7 @@ var_list:
{ $$ = $1; }
| var ',' var_list
{
char *s = (char *) realloc ($1, strlen ($1) + 1 + strlen ($3) + 1);
char *s = YY_CAST (char *, realloc ($1, strlen ($1) + 1 + strlen ($3) + 1));
strcat (s, ",");
strcat (s, $3);
free ($3);
@@ -172,7 +173,6 @@ int
yylex (void)
{
char buf[50];
char *s;
assert (!feof (stdin));
switch (fscanf (input, " %1[a-z,]", buf))
{
@@ -181,15 +181,19 @@ yylex (void)
case EOF:
return 0;
default:
if (fscanf (input, "%49s", buf) != 1)
return 0;
else
{
char *s;
assert (strlen (buf) < sizeof buf - 1);
s = YY_CAST (char *, malloc (strlen (buf) + 1));
strcpy (s, buf);
yylval = s;
return 'V';
}
break;
}
if (fscanf (input, "%49s", buf) != 1)
return 0;
assert (strlen (buf) < sizeof buf - 1);
s = (char *) malloc (strlen (buf) + 1);
strcpy (s, buf);
yylval = s;
return 'V';
}
int
@@ -262,6 +266,7 @@ static int MergeRule (int x0, int x1);
%}
%define parse.assert
%glr-parser
%token BAD_CHAR
@@ -367,6 +372,7 @@ AT_SETUP([Duplicate representation of merged trees])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr4.y],
[[
%define parse.assert
%union { char *ptr; }
%type <ptr> S A A1 A2 B
%glr-parser
@@ -419,7 +425,7 @@ make_value (char const *parent, char const *child)
{
char const format[] = "%s <- %s";
char *value = *ptrs_next++ =
(char *) malloc (strlen (parent) + strlen (child) + sizeof format);
YY_CAST (char *, malloc (strlen (parent) + strlen (child) + sizeof format));
sprintf (value, format, parent, child);
return value;
}
@@ -429,7 +435,7 @@ merge (YYSTYPE s1, YYSTYPE s2)
{
char const format[] = "merge{ %s and %s }";
char *value = *ptrs_next++ =
(char *) malloc (strlen (s1.ptr) + strlen (s2.ptr) + sizeof format);
YY_CAST (char *, malloc (strlen (s1.ptr) + strlen (s2.ptr) + sizeof format));
sprintf (value, format, s1.ptr, s2.ptr);
return value;
}
@@ -466,6 +472,7 @@ AT_DATA_GRAMMAR([glr-regr5.y],
enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
%}
%define parse.assert
%glr-parser
%union { int value; }
%type <value> start
@@ -521,6 +528,7 @@ AT_DATA_GRAMMAR([glr-regr6.y],
]AT_YYLEX_DECLARE[
%}
%define parse.assert
%glr-parser
%union { int value; }
%type <value> 'a'
@@ -577,6 +585,7 @@ AT_DATA_GRAMMAR([glr-regr7.y],
static count_node *tail;
%}
%define parse.assert
%glr-parser
%union { count_node *node; }
%type <node> 'a'
@@ -601,7 +610,7 @@ stack2: 'a' ;
static int
yylex (void)
{
yylval.node = (count_node*) malloc (sizeof *yylval.node);
yylval.node = YY_CAST (count_node*, malloc (sizeof *yylval.node));
if (!yylval.node)
{
fprintf (stderr, "Test inconclusive.\n");
@@ -664,6 +673,7 @@ AT_DATA_GRAMMAR([glr-regr8.y],
%token T_PORT
%token T_SIGNAL
%define parse.assert
%glr-parser
%%
@@ -753,6 +763,7 @@ AT_DATA_GRAMMAR([glr-regr9.y],
# define USE(Var)
%}
%define parse.assert
%glr-parser
%union { int dummy; }
%type <dummy> 'a'
@@ -828,6 +839,7 @@ AT_DATA_GRAMMAR([glr-regr10.y],
static char garbage[GARBAGE_SIZE];
%}
%define parse.assert
%glr-parser
%union { char *ptr; }
%type <ptr> start
@@ -881,6 +893,7 @@ AT_DATA_GRAMMAR([glr-regr11.y],
# define USE(val)
%}
%define parse.assert
%glr-parser
%union { int dummy; }
%type <int> 'a'
@@ -931,6 +944,7 @@ AT_SETUP([Leaked semantic values if user action cuts parse])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr12.y],
[[
%define parse.assert
%glr-parser
%union { int dummy; }
%token PARENT_RHS_AFTER
@@ -1070,6 +1084,7 @@ AT_DATA_GRAMMAR([glr-regr13.y],
#define USE(value)
%}
%define parse.assert
%union { char value; }
%type <value> 'a' 'b'
%glr-parser
@@ -1118,7 +1133,7 @@ change_lookahead:
]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["ab"],
[yylval.value = (char) (res + 'A' - 'a')])[
[yylval.value = YY_CAST (char, res + 'A' - 'a')])[
static void
print_lookahead (char const *reduction)
@@ -1210,6 +1225,7 @@ AT_DATA_GRAMMAR([glr-regr14.y],
#define USE(value)
%}
%define parse.assert
%type <value> 'a' 'b' 'c' 'd' stack_explosion
%glr-parser
%locations
@@ -1319,10 +1335,10 @@ yylex (void)
{
static char const input[] = "abcdddd";
static int toknum = 0;
assert (toknum < (int) sizeof input);
assert (toknum < YY_CAST (int, sizeof input));
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = (char) (input[toknum] + 'A' - 'a');
yylval.value = YY_CAST (char, input[toknum] + 'A' - 'a');
return input[toknum++];
}
@@ -1349,7 +1365,7 @@ print_lookahead (char const *reduction)
static char
merge (union YYSTYPE s1, union YYSTYPE s2)
{
return (char) (s1.value + s2.value);
return YY_CAST (char, s1.value + s2.value);
}
int
@@ -1394,6 +1410,7 @@ AT_SETUP([Leaked semantic values when reporting ambiguity])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr15.y],
[[
%define parse.assert
%glr-parser
%destructor { parent_rhs_before_value = 0; } parent_rhs_before
@@ -1476,6 +1493,7 @@ AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr16.y],
[[
%define parse.assert
%glr-parser
%destructor { lookahead_value = 0; } 'b'
@@ -1537,6 +1555,7 @@ AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure])
AT_DATA_GRAMMAR([glr-regr17.y],
[[
%define parse.assert
%glr-parser
%locations
%define api.pure
@@ -1577,7 +1596,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static char const input[] = "ab";
static int toknum = 0;
assert (toknum < (int) sizeof input);
assert (toknum < YY_CAST (int, sizeof input));
lvalp->dummy = 0;
llocp->first_line = llocp->last_line = 2;
llocp->first_column = toknum + 1;
@@ -1609,7 +1628,8 @@ AT_SETUP([Missed %merge type warnings when LHS type is declared later])
AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([glr-regr18.y],
[[%glr-parser
[[%define parse.assert
%glr-parser
%{
#include <stdlib.h>
@@ -1622,7 +1642,6 @@ AT_DATA_GRAMMAR([glr-regr18.y],
int type2;
int type3;
}
%%
sym1: sym2 %merge<merge> { $$ = $1; } ;
@@ -1658,14 +1677,14 @@ AT_SETUP([Ambiguity reports])
AT_BISON_OPTION_PUSHDEFS([%debug])
AT_DATA_GRAMMAR([input.y],
[[
%{
[[%{
#include <stdio.h>
#include <stdlib.h>
]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[
%}
%define parse.assert
%debug
%glr-parser
@@ -1759,7 +1778,8 @@ AT_CLEANUP
AT_SETUP([Predicates])
AT_DATA_GRAMMAR([input.y],
[[%glr-parser
[[%define parse.assert
%glr-parser
%define parse.error verbose
%expect-rr 1
%code requires
+2 -1
View File
@@ -322,10 +322,11 @@ AT_PERL_CHECK([[-n -0777 -e '
|YYPUSH_MORE(?:_DEFINED)?
|YYUSE
|YY_ATTRIBUTE(?:_PURE|_UNUSED)
|YY(?:_REINTERPRET)?_CAST
|YY_CONSTEXPR
|YY_COPY
|YY_CPLUSPLUS
|YY_IGNORE_MAYBE_UNINITIALIZED_(?:BEGIN|END)
|YY_IGNORE_(?:MAYBE_UNINITIALIZED|USELESS_CAST)_(?:BEGIN|END)
|YY_INITIAL_VALUE
|YY_MOVE
|YY_MOVE_OR_COPY
+74
View File
@@ -195,6 +195,55 @@ input.y:7.4-9: warning: POSIX Yacc does not support %empty [-Wyacc]
AT_CLEANUP
## -------------- ##
## Yacc's %type. ##
## -------------- ##
AT_SETUP([Yacc's %type])
AT_DATA([input.y],
[[%token TOKEN1
%nterm nterm1
%type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
%token TOKEN2
%nterm nterm2
%%
expr: nterm1 nterm2 nterm3
nterm1: TOKEN1
nterm2: TOKEN2
nterm3: "TOKEN3"
]])
AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [],
[[input.y:2.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc]
2 | %nterm nterm1
| ^~~~~~
input.y:3.14-19: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
3 | %type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
| ^~~~~~
input.y:3.28-35: warning: POSIX Yacc does not support string literals [-Wyacc]
3 | %type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
| ^~~~~~~~
input.y:3.28-35: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
3 | %type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
| ^~~~~~~~
input.y:3.58-60: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
3 | %type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
| ^~~
input.y:5.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc]
5 | %nterm nterm2
| ^~~~~~
input.y:3.21-26: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
3 | %type <ival> TOKEN1 TOKEN2 "TOKEN3" nterm1 nterm2 nterm3 '+'
| ^~~~~~
input.y:10.9-16: warning: POSIX Yacc does not support string literals [-Wyacc]
10 | nterm3: "TOKEN3"
| ^~~~~~~~
]])
AT_CLEANUP
## ----------------------------- ##
## Invalid symbol declarations. ##
## ----------------------------- ##
@@ -249,6 +298,31 @@ input.y:8.14: error: syntax error, unexpected integer
AT_CLEANUP
## ------------------ ##
## Dangling aliases. ##
## ------------------ ##
AT_SETUP([Dangling aliases])
AT_DATA([input.y],
[[%token FOO "foo"
%type <val> "bar"
%%
expr: "foo" "bar" "baz"
]])
AT_BISON_CHECK([-fcaret -Wdangling input.y], [0], [],
[[input.y:2.13-17: warning: string literal "bar" not attached to a symbol [-Wdangling-alias]
2 | %type <val> "bar"
| ^~~~~
input.y:4.19-23: warning: string literal "baz" not attached to a symbol [-Wdangling-alias]
4 | expr: "foo" "bar" "baz"
| ^~~~~
]])
AT_CLEANUP
## --------------------- ##
## Symbol declarations. ##
## --------------------- ##
+4 -5
View File
@@ -1199,7 +1199,7 @@ m4_ifval([$2],
# Check that we can expect exceptions to be handled properly.
# GCC 4.3 and 4.4 fail https://trac.macports.org/ticket/40853.
m4_define([AT_SKIP_IF_EXCEPTION_SUPPORT_IS_POOR],
[AT_DATA_SOURCE([exception.cc],
[AT_DATA_SOURCE([exceptions.cc],
[[#include <iostream>
#include <stdexcept>
@@ -1230,10 +1230,9 @@ int main ()
return 1;
}
]])
AT_COMPILE_CXX([exception])
# The "empty" quadrigraph is to protect from cfg.mk's
# sc_at_parser_check.
AT_CHECK([@&t@./exception || exit 77], [0], [], [ignore])
AT_COMPILE_CXX([exceptions])
# The "empty" quadrigraph is to protect from cfg.mk's sc_at_parser_check.
AT_CHECK([@&t@./exceptions || exit 77], [0], [], [ignore])
])
+6 -2
View File
@@ -47,8 +47,12 @@ done
foo: '0' {};
]])
# There is not AT_DATA_UNQUOTED.
AT_PERL_REQUIRE([-pi -e 's{\$at_dir}'"{$at_group_dir}g" $1])
# There is no AT_DATA_UNQUOTED.
if $EGREP 'at_dir' $1 >/dev/null; then
AT_PERL_REQUIRE([-pi -e 's{\$at_dir}'"{$at_group_dir}g" $1])
# On Cygwin, up to Perl 5.28, 'perl -pi' left a foo.bak file.
AT_CHECK([rm -f $1.bak])
fi
AT_BISON_CHECK([$3 $1], [$5], [], [ignore])[
+49 -10
View File
@@ -43,20 +43,51 @@ AT_YYLEX_PROTOTYPE[
case '8':
case '9':
]AT_VAL[.val = c - '0';
return ]AT_CXX_IF([yy::parser::token::])[NUM;
case '+': return ]AT_CXX_IF([yy::parser::token::])[PLUS;
case '-': return ]AT_CXX_IF([yy::parser::token::])[MINUS;
case '*': return ]AT_CXX_IF([yy::parser::token::])[STAR;
case '/': return ]AT_CXX_IF([yy::parser::token::])[SLASH;
case '(': return ]AT_CXX_IF([yy::parser::token::])[LPAR;
case ')': return ]AT_CXX_IF([yy::parser::token::])[RPAR;
case 0: return 0;
return NUM;
case '+': return PLUS;
case '-': return MINUS;
case '*': return STAR;
case '/': return SLASH;
case '(': return LPAR;
case ')': return RPAR;
case 0: return 0;
}
abort ();
}
]])
m4_copy([AT_RAW_YYLEX(c)], [AT_RAW_YYLEX(c++)])
m4_define([AT_RAW_YYLEX(c++)],
[#include <stdlib.h> /* abort */
AT_YYLEX_PROTOTYPE[
{
static const char* input = "0-(1+2)*3/9";
int c = *input++;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':]AT_TOKEN_CTOR_IF([[
return yy::parser::make_NUM (c - '0');]], [[
]AT_VAL[.val = c - '0';
return yy::parser::token::NUM;]])[
case '+': return yy::parser::]AT_TOKEN_CTOR_IF([make_PLUS ()], [token::PLUS])[;
case '-': return yy::parser::]AT_TOKEN_CTOR_IF([make_MINUS ()], [token::MINUS])[;
case '*': return yy::parser::]AT_TOKEN_CTOR_IF([make_STAR ()], [token::STAR])[;
case '/': return yy::parser::]AT_TOKEN_CTOR_IF([make_SLASH ()], [token::SLASH])[;
case '(': return yy::parser::]AT_TOKEN_CTOR_IF([make_LPAR ()], [token::LPAR])[;
case ')': return yy::parser::]AT_TOKEN_CTOR_IF([make_RPAR ()], [token::RPAR])[;
case 0: return yy::parser::]AT_TOKEN_CTOR_IF([make_END ()], [token::END])[;
}
abort ();
}
]])
m4_define([AT_RAW_YYLEX(d)],
[[import std.range.primitives;
@@ -147,10 +178,17 @@ AT_DATA_GRAMMAR([[input.y]],
]AT_YYLEX_DECLARE[
}]])[
]AT_VARIANT_IF([[
%token <int> NUM "number"
%nterm <int> exp
]], [[
%union {
int val;
}
%token <val> NUM "number"
%nterm <val> exp
]])[
%token
PLUS "+"
MINUS "-"
@@ -158,7 +196,7 @@ AT_DATA_GRAMMAR([[input.y]],
SLASH "/"
LPAR "("
RPAR ")"
%nterm <val> exp
END 0
%left "+" "-"
%left "*" "/"
@@ -206,6 +244,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc], [lalr1.d]],
[AT_TEST([%skeleton "]b4_skel["])
AT_TEST([%skeleton "]b4_skel[" %define api.token.raw])])
AT_TEST([%skeleton "lalr1.cc" %define api.token.raw %define api.value.type variant %define api.token.constructor])])
m4_popdef([AT_MAIN_DEFINE(d)])
m4_popdef([AT_TEST])
+105 -6
View File
@@ -329,14 +329,27 @@ Reduced Grammar
ntokens = 7, nvars = 4, nsyms = 11, nrules = 6, nritems = 17
Variables
---------
Tokens
------
Value Sprec Sassoc Tag
7 0 0 $accept
8 0 0 expr
9 0 0 term
10 0 0 fact
0 0 0 $end
1 0 0 error
2 0 0 $undefined
3 0 0 "+"
4 0 0 "*"
5 0 0 "useless"
6 0 0 "num"
Non terminals
-------------
Value Tag
7 $accept
8 expr
9 term
10 fact
Rules
@@ -368,3 +381,89 @@ reduced input.y defines 7 terminals, 4 nonterminals, and 6 productions.
]])
AT_CLEANUP
## ------------------------------------- ##
## Reduced Grammar with prec and assoc. ##
## ------------------------------------- ##
# Check information about the grammar, once reduced.
AT_SETUP([Reduced Grammar with prec and assoc])
AT_DATA([input.y],
[[%nonassoc '<' '>'
%left '+' '-'
%right '^' '='
%%
exp:
exp '<' exp
| exp '>' exp
| exp '+' exp
| exp '-' exp
| exp '^' exp
| exp '=' exp
| "exp"
;
]])
AT_BISON_CHECK([[--trace=grammar -o input.c input.y]], [], [],
[[Reduced Grammar
ntokens = 10, nvars = 2, nsyms = 12, nrules = 8, nritems = 29
Tokens
------
Value Sprec Sassoc Tag
0 0 0 $end
1 0 0 error
2 0 0 $undefined
3 1 3 '<'
4 1 3 '>'
5 2 2 '+'
6 2 2 '-'
7 3 1 '^'
8 3 1 '='
9 0 0 "exp"
Non terminals
-------------
Value Tag
10 $accept
11 exp
Rules
-----
Num (Prec, Assoc, Useful, UselessChain) Lhs -> (Ritem Range) Rhs
0 ( 0, 0, t, f) 10 -> ( 0- 1) 11 0
1 ( 1, 3, t, f) 11 -> ( 3- 5) 11 3 11
2 ( 1, 3, t, f) 11 -> ( 7- 9) 11 4 11
3 ( 2, 2, t, f) 11 -> (11-13) 11 5 11
4 ( 2, 2, t, f) 11 -> (15-17) 11 6 11
5 ( 3, 1, t, f) 11 -> (19-21) 11 7 11
6 ( 3, 1, t, f) 11 -> (23-25) 11 8 11
7 ( 0, 0, t, t) 11 -> (27-27) 9
Rules interpreted
-----------------
0 $accept: exp $end
1 exp: exp '<' exp
2 exp: exp '>' exp
3 exp: exp '+' exp
4 exp: exp '-' exp
5 exp: exp '^' exp
6 exp: exp '=' exp
7 exp: "exp"
reduced input.y defines 10 terminals, 2 nonterminals, and 8 productions.
]])
AT_CLEANUP
+4 -5
View File
@@ -1,11 +1,10 @@
/* We don't need perfect functions for these tests. */
#undef malloc
#undef memcmp
#undef realloc
/* Common definitions to include in the generated parsers. See
AT_DATA_SOURCE_PROLOGUE. */
/* In C++ pre C++11 it is standard practice to use 0 for the null
pointer. But GCC -std=c++98 with -Wzero-as-null-pointer-constant
warns about this. Warning introduced in GCC 4.7. */
warns about this, although this is just no alternative! Warning
introduced in GCC 4.7. */
#if defined __cplusplus && __cplusplus < 201103L
# if defined __GNUC__ && ! defined __clang__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
+1 -1
View File
@@ -446,7 +446,7 @@ get_args (int argc, const char **argv)
assert (0 <= res);
assert (res <= INT_MAX);
assert (errno != ERANGE);
return (int) res;
return YY_CAST (int, res);
}
int
+2 -2
View File
@@ -166,7 +166,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
[if (res)
{
AT_VAL.ival = (res - '0') * 10;
AT_VAL.fval = (float) (res - '0') / 10.f;
AT_VAL.fval = YY_CAST (float, res - '0') / 10.f;
}],
[30 0.3])
@@ -197,7 +197,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
["12"],
[if (res)
{
AT_VAL.up = (struct u *) malloc (sizeof *AT_VAL.up);
AT_VAL.up = YY_CAST (struct u *, malloc (sizeof *AT_VAL.up));
assert (AT_VAL.up);
AT_VAL.up->ival = res - '0';
}