mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 18:25:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ac1584946 | ||
|
|
40a1cd37f3 | ||
|
|
468455e12b | ||
|
|
a4eb820f17 | ||
|
|
6eb8f74f8f | ||
|
|
cc5a986ce4 | ||
|
|
ae2199381e | ||
|
|
7b70847e58 | ||
|
|
19d9b60787 | ||
|
|
8f8439cee1 | ||
|
|
fa5303b8ff | ||
|
|
39845e8e40 | ||
|
|
5b34bb3110 | ||
|
|
c955769a75 | ||
|
|
82443642d2 | ||
|
|
e272d9dc80 | ||
|
|
9a50c55af7 | ||
|
|
e28ce5def0 | ||
|
|
7aa15a0026 | ||
|
|
90b1335aed | ||
|
|
ddbd0c40dc | ||
|
|
c473e022d9 | ||
|
|
6192d2c6de | ||
|
|
3746fc33c4 | ||
|
|
36cdaaac53 | ||
|
|
63fec1eeba | ||
|
|
6b4cb804b5 | ||
|
|
53425dbfaa | ||
|
|
403ddfb7e0 | ||
|
|
76e5017732 | ||
|
|
592bdad15e | ||
|
|
457bf91968 | ||
|
|
2e350a617f | ||
|
|
d740d2b541 | ||
|
|
e411069eee | ||
|
|
ae62d0fc4f | ||
|
|
e3f8c4ef69 | ||
|
|
933ec5449f | ||
|
|
e1eeecd384 | ||
|
|
43ca804096 | ||
|
|
dcd5344dcd | ||
|
|
62a58c14bd | ||
|
|
e39eff37e2 | ||
|
|
06f2ac78d7 | ||
|
|
1914a78115 | ||
|
|
d6e2a57964 | ||
|
|
a0c45dd5d2 | ||
|
|
c9d546b2a8 | ||
|
|
d61e59ea0e | ||
|
|
aaf63e45b6 | ||
|
|
dbfcf7a89f | ||
|
|
8c707b10e7 | ||
|
|
9c26b8fc03 | ||
|
|
77b214ef48 | ||
|
|
d35d6dd2cd | ||
|
|
466a2de317 | ||
|
|
4acc22e5cf | ||
|
|
7b18c11231 | ||
|
|
e6cab382c5 | ||
|
|
cd735a8c6c | ||
|
|
d6a44ffd00 | ||
|
|
93e3dbab95 | ||
|
|
1c292035e1 | ||
|
|
263137264f | ||
|
|
e20e6a50d5 | ||
|
|
4d24ffb75e | ||
|
|
a74a3158d4 | ||
|
|
4982f078bf | ||
|
|
65a99eca25 | ||
|
|
9a86ee6058 | ||
|
|
0e164d43d1 | ||
|
|
d511fbd576 | ||
|
|
9c46ba16e3 | ||
|
|
55e075f229 | ||
|
|
0bb672d87c | ||
|
|
8617d87e24 | ||
|
|
0601c3bf0f | ||
|
|
eea7239a23 | ||
|
|
e58782294d | ||
|
|
c1cc91bdcd | ||
|
|
13b712d7d4 | ||
|
|
dba9149595 | ||
|
|
9b8585410a | ||
|
|
f9b8635172 | ||
|
|
733d4546ce | ||
|
|
aaf6103699 | ||
|
|
d0d3313d10 | ||
|
|
a4107f24bc |
+1
-1
@@ -11,6 +11,7 @@
|
||||
/INSTALL
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/README-release
|
||||
/_*
|
||||
/a.exe
|
||||
/a.out
|
||||
@@ -31,4 +32,3 @@
|
||||
/patches
|
||||
/releases
|
||||
/stamp-h*
|
||||
/README-release
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2.5.91
|
||||
2.6.3
|
||||
|
||||
@@ -1,5 +1,107 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
|
||||
|
||||
Bison 2.6.3's --version was incorrect. This release fixes this issue.
|
||||
|
||||
* Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Bugs and portability issues in the test suite have been fixed.
|
||||
|
||||
Some errors in translations have been addressed, and --help now directs
|
||||
users to the appropriate place to report them.
|
||||
|
||||
Stray Info files shipped by accident are removed.
|
||||
|
||||
Incorrect definitions of YY_, issued by yacc.c when no parser header is
|
||||
generated, are removed.
|
||||
|
||||
All the generated headers are self-contained.
|
||||
|
||||
** Header guards (yacc.c, glr.c, glr.cc)
|
||||
|
||||
In order to avoid collisions, the header guards are now
|
||||
YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
|
||||
For instance the header generated from
|
||||
|
||||
%define api.prefix "calc"
|
||||
%defines "lib/parse.h"
|
||||
|
||||
will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
|
||||
|
||||
** Fix compiler warnings in the generated parser (yacc.c, glr.c)
|
||||
|
||||
The compilation of pure parsers (%define api.pure) can trigger GCC
|
||||
warnings such as:
|
||||
|
||||
input.c: In function 'yyparse':
|
||||
input.c:1503:12: warning: 'yylval' may be used uninitialized in this
|
||||
function [-Wmaybe-uninitialized]
|
||||
*++yyvsp = yylval;
|
||||
^
|
||||
|
||||
This is now fixed; pragmas to avoid these warnings are no longer needed.
|
||||
|
||||
Warnings from clang ("equality comparison with extraneous parentheses" and
|
||||
"function declared 'noreturn' should not return") have also been
|
||||
addressed.
|
||||
|
||||
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Buffer overruns, complaints from Flex, and portability issues in the test
|
||||
suite have been fixed.
|
||||
|
||||
** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
|
||||
|
||||
Trailing end-of-lines in %parse-param or %lex-param would result in
|
||||
invalid C++. This is fixed.
|
||||
|
||||
** Spurious spaces and end-of-lines
|
||||
|
||||
The generated files no longer end (nor start) with empty lines.
|
||||
|
||||
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
|
||||
|
||||
Bison no longer executes user-specified M4 code when processing a grammar.
|
||||
|
||||
** Future Changes
|
||||
|
||||
In addition to the removal of the features announced in Bison 2.6, the
|
||||
next major release will remove the "Temporary hack for adding a semicolon
|
||||
to the user action", as announced in the release 2.5. Instead of:
|
||||
|
||||
exp: exp "+" exp { $$ = $1 + $3 };
|
||||
|
||||
write:
|
||||
|
||||
exp: exp "+" exp { $$ = $1 + $3; };
|
||||
|
||||
** Bug fixes
|
||||
|
||||
*** Type names are now properly escaped.
|
||||
|
||||
*** glr.cc: set_debug_level and debug_level work as expected.
|
||||
|
||||
*** Stray @ or $ in actions
|
||||
|
||||
While Bison used to warn about stray $ or @ in action rules, it did not
|
||||
for other actions such as printers, destructors, or initial actions. It
|
||||
now does.
|
||||
|
||||
** Type names in actions
|
||||
|
||||
For consistency with rule actions, it is now possible to qualify $$ by a
|
||||
type-name in destructors, printers, and initial actions. For instance:
|
||||
|
||||
%printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
|
||||
|
||||
will display two values for each typed and untyped symbol (provided
|
||||
that YYSTYPE has both "ival" and "fval" fields).
|
||||
|
||||
* Noteworthy changes in release 2.6 (2012-07-19) [stable]
|
||||
|
||||
** Future Changes
|
||||
@@ -7,7 +109,7 @@ GNU Bison NEWS
|
||||
The next major release of Bison will drop support for the following
|
||||
deprecated features. Please report disagreements to [email protected].
|
||||
|
||||
*** K&C parsers
|
||||
*** K&R C parsers
|
||||
|
||||
Support for generating parsers in K&R C will be removed. Parsers
|
||||
generated for C support ISO C90, and are tested with ISO C99 and ISO C11
|
||||
@@ -1803,7 +1905,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
|
||||
LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
|
||||
LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
|
||||
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp
|
||||
LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval
|
||||
|
||||
Local Variables:
|
||||
mode: outline
|
||||
|
||||
@@ -168,6 +168,19 @@ decide whether to update.
|
||||
** make check
|
||||
Use liberally.
|
||||
|
||||
** Typical errors
|
||||
If the test suite shows failures such as the following one
|
||||
|
||||
.../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
|
||||
/usr/include/getopt.h:54:8: error: previous definition of 'struct option'
|
||||
|
||||
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.
|
||||
|
||||
See tests/local.at for details.
|
||||
|
||||
** make maintainer-check-valgrind
|
||||
This target uses valgrind both to check bison, and the generated parsers.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Alexandre Duret-Lutz adl@src.lip6.fr
|
||||
Alexandre Duret-Lutz adl@lrde.epita.fr
|
||||
Andreas Schwab [email protected]
|
||||
Andrew Suffield [email protected]
|
||||
Angelo Borsotti [email protected]
|
||||
@@ -13,6 +13,7 @@ Anthony Heading [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Art Haas [email protected]
|
||||
Baron Schwartz [email protected]
|
||||
Ben Pfaff [email protected]
|
||||
Benoit Perrot [email protected]
|
||||
Bernd Kiefer [email protected]
|
||||
Bert Deknuydt [email protected]
|
||||
@@ -92,6 +93,7 @@ R Blake [email protected]
|
||||
Raja R Harinath [email protected]
|
||||
Ralf Wildenhues [email protected]
|
||||
Richard Stallman [email protected]
|
||||
Rob Vermaas [email protected]
|
||||
Robert Anisko [email protected]
|
||||
Satya Kiran Popuri [email protected]
|
||||
Sebastian Setzer [email protected]
|
||||
@@ -100,7 +102,7 @@ Sergei Steshenko [email protected]
|
||||
Shura [email protected]
|
||||
Stefano Lattarini [email protected]
|
||||
Steve Murphy [email protected]
|
||||
Summum Bonum [email protected]
|
||||
Sum Wu [email protected]
|
||||
Thiru Ramakrishnan [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tim Landscheidt [email protected]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2012-07-10.09; # UTC
|
||||
scriptversion=2012-07-19.14; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -214,6 +214,8 @@ use_git=true
|
||||
# otherwise find the first of the NAMES that can be run (i.e.,
|
||||
# supports --version). If found, set ENVVAR to the program name,
|
||||
# die otherwise.
|
||||
#
|
||||
# FIXME: code duplication, see also gnu-web-doc-update.
|
||||
find_tool ()
|
||||
{
|
||||
find_tool_envvar=$1
|
||||
|
||||
+4
-1
@@ -24,7 +24,10 @@ gnulib_modules='
|
||||
gettext git-version-gen gitlog-to-changelog
|
||||
gpl-3.0 hash inttypes isnan javacomp-script
|
||||
javaexec-script ldexpl malloc-gnu mbschr mbsrchr
|
||||
mbswidth obstack perror progname
|
||||
mbswidth
|
||||
obstack
|
||||
obstack-printf
|
||||
perror progname
|
||||
quote quotearg
|
||||
readme-release
|
||||
realloc-posix
|
||||
|
||||
@@ -65,12 +65,13 @@ exclude = \
|
||||
$(call exclude, \
|
||||
bindtextdomain=^lib/main.c$$ \
|
||||
program_name=^lib/main.c$$ \
|
||||
prohibit_always-defined_macros=^data/yacc.c|^djgpp/ \
|
||||
prohibit_always-defined_macros=^data/yacc.c$$|^djgpp/ \
|
||||
prohibit_always-defined_macros+=?|^lib/timevar.c$$ \
|
||||
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
|
||||
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
|
||||
prohibit_defined_have_decl_tests=?|^lib/timevar.c$$ \
|
||||
prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$ \
|
||||
prohibit_magic_number_exit=^doc/bison.texi$$ \
|
||||
prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$ \
|
||||
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
|
||||
space_tab=^tests/(input|c\+\+)\.at$$ \
|
||||
trailing_blank=^src/parse-gram.[ch]$$ \
|
||||
|
||||
+5
-1
@@ -123,6 +123,10 @@ AC_PROG_GNU_M4
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||
AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
|
||||
supports -g, otherwise to "".])
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
if test -z "$PERL"; then
|
||||
AC_MSG_ERROR([perl not found])
|
||||
fi
|
||||
AM_MISSING_PROG([HELP2MAN], [help2man])
|
||||
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
||||
AC_SUBST([XSLTPROC])
|
||||
@@ -170,7 +174,7 @@ case $VALGRIND:$host_os in
|
||||
# VALGRIND+=' --suppressions=$(abs_top_srcdir)/build-aux/darwin11.4.0.valgrind'
|
||||
VALGRIND=;;
|
||||
*:*)
|
||||
AC_SUBST([VALGRIND_PREBISON], [$VALGRIND -q]);;
|
||||
AC_SUBST([VALGRIND_PREBISON], ["$VALGRIND -q"]);;
|
||||
esac
|
||||
|
||||
AM_MISSING_PROG([AUTOM4TE], [autom4te])
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dist_pkgdata_DATA = README bison.m4 \
|
||||
c-like.m4 \
|
||||
c-skel.m4 c.m4 yacc.c glr.c \
|
||||
c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \
|
||||
java-skel.m4 java.m4 lalr1.java
|
||||
|
||||
+2
-2
@@ -259,8 +259,8 @@ m4_define([b4_basename],
|
||||
# b4_syncline(LINE, FILE)
|
||||
# -----------------------
|
||||
m4_define([b4_syncline],
|
||||
[b4_flag_if([synclines], [
|
||||
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||
[b4_flag_if([synclines],
|
||||
[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
||||
b4_sync_start([$1], [$2])])])
|
||||
|
||||
m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
-*- Autoconf -*-
|
||||
|
||||
# Common code for C-like languages (C, C++, Java, etc.)
|
||||
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
|
||||
# ----------------------------------------------
|
||||
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||
# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a
|
||||
# pointer.
|
||||
m4_define([b4_dollar_dollar_],
|
||||
[m4_if([$2], [[]],
|
||||
[m4_ifval([$3], [($1.$3)],
|
||||
[$1])],
|
||||
[($1.$2)])])
|
||||
|
||||
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
|
||||
# b4_dollar_popdef
|
||||
# ---------------------------------------------------------
|
||||
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
|
||||
# and b4_at_dollar for LOCATION.
|
||||
m4_define([b4_dollar_pushdef],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl
|
||||
m4_pushdef([b4_at_dollar], [$3])dnl
|
||||
])
|
||||
m4_define([b4_dollar_popdef],
|
||||
[m4_popdef([b4_at_dollar])dnl
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
])
|
||||
@@ -17,6 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_include(b4_pkgdatadir/[c-like.m4])
|
||||
|
||||
# b4_tocpp(STRING)
|
||||
# ----------------
|
||||
@@ -29,19 +30,21 @@ m4_define([b4_tocpp],
|
||||
# ------------------
|
||||
# A valid C macro name to use as a CPP header guard for FILE.
|
||||
m4_define([b4_cpp_guard],
|
||||
[b4_tocpp(m4_defn([b4_prefix])/[$1])])
|
||||
[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]])
|
||||
|
||||
|
||||
# b4_cpp_guard_open(FILE)
|
||||
# b4_cpp_guard_close(FILE)
|
||||
# ------------------------
|
||||
# Open/close CPP inclusion guards for FILE.
|
||||
# If FILE does not expand to nothing, open/close CPP inclusion guards for FILE.
|
||||
m4_define([b4_cpp_guard_open],
|
||||
[m4_ifval(m4_quote($1),
|
||||
[#ifndef b4_cpp_guard([$1])
|
||||
# define b4_cpp_guard([$1])])
|
||||
# define b4_cpp_guard([$1])])])
|
||||
|
||||
m4_define([b4_cpp_guard_close],
|
||||
[#endif b4_comment([!b4_cpp_guard([$1])])])
|
||||
[m4_ifval(m4_quote($1),
|
||||
[#endif b4_comment([!b4_cpp_guard([$1])])])])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
@@ -181,7 +184,7 @@ m4_define([b4_table_value_equals],
|
||||
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
||||
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
||||
[[YYID (0)]],
|
||||
[[((]$2[) == (]$3[))]])])
|
||||
[(!!(($2) == ($3)))])])
|
||||
|
||||
|
||||
## ---------##
|
||||
@@ -421,17 +424,18 @@ $2
|
||||
# SYMBOL-TAG, SYMBOL-NUM,
|
||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||
# -------------------------------------------------
|
||||
# Issue the code for a symbol action (e.g., %printer).
|
||||
#
|
||||
# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
|
||||
# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
|
||||
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
||||
[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
|
||||
case $4: /* $3 */
|
||||
b4_syncline([$2], [$1])
|
||||
$5;
|
||||
b4_syncline([@oline@], [@ofile@])
|
||||
break;
|
||||
m4_popdef([b4_at_dollar])dnl
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
b4_dollar_popdef[]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
+19
-22
@@ -241,24 +241,24 @@ b4_percent_code_get[]dnl
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
||||
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
|
||||
# endif
|
||||
# endif
|
||||
# ifndef YY_
|
||||
# define YY_(msgid) msgid
|
||||
# define YY_(Msgid) Msgid
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Suppress unused-variable warnings by "using" E. */
|
||||
#if ! defined lint || defined __GNUC__
|
||||
# define YYUSE(e) ((void) (e))
|
||||
# define YYUSE(E) ((void) (E))
|
||||
#else
|
||||
# define YYUSE(e) /* empty */
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
/* Identity function, used to suppress warnings about constant conditions. */
|
||||
#ifndef lint
|
||||
# define YYID(n) (n)
|
||||
# define YYID(N) (N)
|
||||
#else
|
||||
]b4_c_function_def([YYID], [static int], [[int i], [i]])[
|
||||
{
|
||||
@@ -289,8 +289,9 @@ b4_percent_code_get[]dnl
|
||||
#ifndef YYSETJMP
|
||||
# include <setjmp.h>
|
||||
# define YYJMP_BUF jmp_buf
|
||||
# define YYSETJMP(env) setjmp (env)
|
||||
# define YYLONGJMP(env, val) longjmp (env, val)
|
||||
# define YYSETJMP(Env) setjmp (Env)
|
||||
// Pacify clang.
|
||||
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
|
||||
#endif
|
||||
|
||||
/*-----------------.
|
||||
@@ -313,7 +314,7 @@ b4_percent_code_get[]dnl
|
||||
#endif])[
|
||||
|
||||
#ifndef YYASSERT
|
||||
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
|
||||
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
|
||||
#endif
|
||||
|
||||
/* YYFINAL -- State number of the termination state. */
|
||||
@@ -972,8 +973,8 @@ yylhsNonterm (yyRuleNum yyrule)
|
||||
return yyr1[yyrule];
|
||||
}
|
||||
|
||||
#define yypact_value_is_default(yystate) \
|
||||
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
||||
#define yypact_value_is_default(Yystate) \
|
||||
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
|
||||
|
||||
/** True iff LR state STATE has only a default reduction (regardless
|
||||
* of token). */
|
||||
@@ -990,8 +991,8 @@ yydefaultAction (yyStateNum yystate)
|
||||
return yydefact[yystate];
|
||||
}
|
||||
|
||||
#define yytable_value_is_error(yytable_value) \
|
||||
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|
||||
#define yytable_value_is_error(Yytable_value) \
|
||||
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
|
||||
|
||||
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
|
||||
* Result R means
|
||||
@@ -2302,12 +2303,10 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
#endif
|
||||
])
|
||||
m4_ifdef([b4_initial_action], [
|
||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef])[]dnl
|
||||
[
|
||||
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
||||
goto yyexhaustedlab;
|
||||
@@ -2601,9 +2600,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
]
|
||||
|
||||
b4_epilogue
|
||||
]b4_epilogue[]dnl
|
||||
dnl
|
||||
dnl glr.cc produces its own header.
|
||||
dnl
|
||||
@@ -2616,5 +2613,5 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]])])
|
||||
]])])dnl
|
||||
m4_divert_pop(0)
|
||||
|
||||
+5
-7
@@ -131,7 +131,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||
:])[
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[
|
||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||
#endif]b4_parse_param_cons[
|
||||
{
|
||||
@@ -199,20 +199,19 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
]b4_parser_class_name[::debug_level_type
|
||||
]b4_parser_class_name[::debug_level () const
|
||||
{
|
||||
return yydebug_;
|
||||
return yydebug;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
||||
{
|
||||
yydebug_ = l;
|
||||
// Actually, it is yydebug which is really used.
|
||||
yydebug = l;
|
||||
}
|
||||
|
||||
#endif
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
b4_namespace_close[
|
||||
|
||||
]])
|
||||
b4_namespace_close])
|
||||
|
||||
|
||||
# Let glr.c believe that the user arguments include the parser itself.
|
||||
@@ -320,7 +319,6 @@ b4_user_stype
|
||||
const location_type* yylocationp);
|
||||
private:
|
||||
/* Debugging. */
|
||||
int yydebug_;
|
||||
std::ostream* yycdebug_;
|
||||
# endif
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_include(b4_pkgdatadir/[c-like.m4])
|
||||
|
||||
# b4_comment(TEXT)
|
||||
# ----------------
|
||||
|
||||
+5
-7
@@ -536,12 +536,10 @@ do { \
|
||||
YYCDEBUG << "Starting parse" << std::endl;
|
||||
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef])[]dnl
|
||||
|
||||
[ /* Initialize the stacks. The initial state will be pushed in
|
||||
yynewstate, since the latter expects the semantical and the
|
||||
@@ -1106,5 +1104,5 @@ b4_error_verbose_if([int yystate, int yytoken],
|
||||
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
|
||||
|
||||
]b4_namespace_close[
|
||||
]b4_epilogue
|
||||
]b4_epilogue[]dnl
|
||||
m4_divert_pop(0)
|
||||
|
||||
+4
-6
@@ -458,12 +458,10 @@ b4_lexer_if([[
|
||||
yyerrstatus_ = 0;
|
||||
|
||||
]m4_ifdef([b4_initial_action], [
|
||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
b4_dollar_pushdef([yylval], [], [yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
b4_dollar_popdef])[]dnl
|
||||
|
||||
[ /* Initialize the stack. */
|
||||
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
||||
|
||||
+1
-3
@@ -30,7 +30,7 @@ b4_copyright([Positions for Bison parsers in C++],
|
||||
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
|
||||
|
||||
# include <algorithm> // std::max
|
||||
# include <iosfwd>
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
]b4_null_define[
|
||||
@@ -159,8 +159,6 @@ b4_copyright([Locations for Bison parsers in C++],
|
||||
|
||||
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
# include "position.hh"
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
+48
-21
@@ -170,6 +170,28 @@ m4_define([b4_declare_scanner_communication_variables], [[
|
||||
/* The lookahead symbol. */
|
||||
int yychar;
|
||||
|
||||
]b4_pure_if([[
|
||||
#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#else
|
||||
/* Default value used for initialization, for pacifying older GCCs
|
||||
or non-GCC compilers. */
|
||||
static YYSTYPE yyval_default;
|
||||
# define YYLVAL_INITIALIZE() (yylval = yyval_default)
|
||||
#endif]])[
|
||||
#ifndef YYLVAL_INITIALIZE
|
||||
# define YYLVAL_INITIALIZE()
|
||||
#endif
|
||||
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
#endif
|
||||
|
||||
/* The semantic value of the lookahead symbol. */
|
||||
YYSTYPE yylval;]b4_locations_if([[
|
||||
|
||||
@@ -345,9 +367,11 @@ m4_if(b4_api_prefix, [yy], [],
|
||||
# define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
||||
#endif
|
||||
|
||||
/* In a future release of Bison, this section will be replaced
|
||||
]m4_ifval(m4_quote(b4_spec_defines_file),
|
||||
[[/* In a future release of Bison, this section will be replaced
|
||||
by #include "@basename(]b4_spec_defines_file[@)". */
|
||||
]b4_shared_declarations[
|
||||
]])dnl
|
||||
b4_shared_declarations[
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
]b4_user_post_prologue
|
||||
@@ -402,24 +426,24 @@ typedef short int yytype_int16;
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
||||
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
|
||||
# endif
|
||||
# endif
|
||||
# ifndef YY_
|
||||
# define YY_(msgid) msgid
|
||||
# define YY_(Msgid) Msgid
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Suppress unused-variable warnings by "using" E. */
|
||||
#if ! defined lint || defined __GNUC__
|
||||
# define YYUSE(e) ((void) (e))
|
||||
# define YYUSE(E) ((void) (E))
|
||||
#else
|
||||
# define YYUSE(e) /* empty */
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
/* Identity function, used to suppress warnings about constant conditions. */
|
||||
#ifndef lint
|
||||
# define YYID(n) (n)
|
||||
# define YYID(N) (N)
|
||||
#else
|
||||
]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
|
||||
{
|
||||
@@ -678,11 +702,11 @@ static const ]b4_int_type_for([b4_table])[ yytable[] =
|
||||
]b4_table[
|
||||
};
|
||||
|
||||
#define yypact_value_is_default(yystate) \
|
||||
]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[
|
||||
#define yypact_value_is_default(Yystate) \
|
||||
]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
|
||||
|
||||
#define yytable_value_is_error(yytable_value) \
|
||||
]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|
||||
#define yytable_value_is_error(Yytable_value) \
|
||||
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
|
||||
|
||||
static const ]b4_int_type_for([b4_check])[ yycheck[] =
|
||||
{
|
||||
@@ -1513,7 +1537,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
||||
int yyn;
|
||||
int yyresult;
|
||||
/* Lookahead token as an internal (translated) token number. */
|
||||
int yytoken;
|
||||
int yytoken = 0;
|
||||
/* The variables used to return semantic value and location from the
|
||||
action routines. */
|
||||
YYSTYPE yyval;]b4_locations_if([[
|
||||
@@ -1538,7 +1562,6 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
||||
goto yyread_pushed_token;
|
||||
}]])[
|
||||
|
||||
yytoken = 0;
|
||||
yyss = yyssa;
|
||||
yyvs = yyvsa;]b4_locations_if([[
|
||||
yyls = yylsa;]])[
|
||||
@@ -1562,25 +1585,25 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
|
||||
The wasted elements are never initialized. */
|
||||
yyssp = yyss;
|
||||
yyvsp = yyvs;]b4_locations_if([[
|
||||
yylsp = yyls;
|
||||
yylsp = yyls;]])[
|
||||
|
||||
YYLVAL_INITIALIZE ();]b4_locations_if([[
|
||||
#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||
/* Initialize the default location before parsing starts. */
|
||||
yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
||||
yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
||||
#endif]])
|
||||
m4_ifdef([b4_initial_action],[
|
||||
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
|
||||
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
|
||||
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
|
||||
[m4_define([b4_at_dollar_used])yylloc])dnl
|
||||
/* User initialization code. */
|
||||
b4_user_initial_action
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
m4_popdef([b4_at_dollar])])dnl
|
||||
b4_dollar_popdef[]dnl
|
||||
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
||||
]])dnl
|
||||
m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
||||
]])[
|
||||
goto yysetstate;
|
||||
]])])dnl
|
||||
[ goto yysetstate;
|
||||
|
||||
/*------------------------------------------------------------.
|
||||
| yynewstate -- Push a new state, which is found in yystate. |
|
||||
@@ -1750,7 +1773,9 @@ yyread_pushed_token:]])[
|
||||
YY_LAC_DISCARD ("shift");]])[
|
||||
|
||||
yystate = yyn;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
*++yyvsp = yylval;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
]b4_locations_if([ *++yylsp = yylloc;])[
|
||||
goto yynewstate;
|
||||
|
||||
@@ -1970,7 +1995,9 @@ yyerrlab1:
|
||||
current lookahead token, the shift below will for sure. */
|
||||
YY_LAC_DISCARD ("error recovery");]])[
|
||||
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
||||
*++yyvsp = yylval;
|
||||
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
||||
]b4_locations_if([[
|
||||
yyerror_range[2] = yylloc;
|
||||
/* Using YYLLOC is tempting, but would change the location of
|
||||
@@ -2046,7 +2073,7 @@ yypushreturn:]])[
|
||||
}
|
||||
|
||||
|
||||
]b4_epilogue
|
||||
]b4_epilogue[]dnl
|
||||
b4_defines_if(
|
||||
[@output(b4_spec_defines_file@)@
|
||||
b4_copyright([Bison interface for Yacc-like parsers in C],
|
||||
|
||||
+1
-1
@@ -1,4 +1,3 @@
|
||||
/*.info*
|
||||
/*~
|
||||
/.dirstamp
|
||||
/Makefile
|
||||
@@ -10,6 +9,7 @@
|
||||
/bison.dvi
|
||||
/bison.fn
|
||||
/bison.html
|
||||
/bison.info
|
||||
/bison.ky
|
||||
/bison.log
|
||||
/bison.pdf
|
||||
|
||||
+1
-1
@@ -940,7 +940,7 @@ EXTERNAL_GROUPS = YES
|
||||
# The PERL_PATH should be the absolute path and name of the perl script
|
||||
# interpreter (i.e. the result of `which perl').
|
||||
|
||||
PERL_PATH = /usr/bin/perl
|
||||
PERL_PATH = @PERL@
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ $(srcdir)/cross-options.texi: $(top_srcdir)/src/getargs.c $(CROSS_OPTIONS_PL)
|
||||
$(AM_V_at)rm -f $@.tmp
|
||||
$(AM_V_at)cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) bison
|
||||
$(AM_V_at)$(top_builddir)/src/bison --help \
|
||||
| perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||
| $(PERL) $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||
$(AM_V_at)diff -u $@~ $@.tmp || true
|
||||
$(AM_V_at)mv $@.tmp $@
|
||||
MAINTAINERCLEANFILES = $(srcdir)/cross-options.texi
|
||||
|
||||
+53
-24
@@ -110,7 +110,7 @@ Reference sections:
|
||||
* Glossary:: Basic concepts are explained.
|
||||
* Copying This Manual:: License for copying this manual.
|
||||
* Bibliography:: Publications cited in this manual.
|
||||
* Index:: Cross-references to the text.
|
||||
* Index of Terms:: Cross-references to the text.
|
||||
|
||||
@detailmenu
|
||||
--- The Detailed Node Listing ---
|
||||
@@ -4552,9 +4552,9 @@ code.
|
||||
@deffn {Directive} %initial-action @{ @var{code} @}
|
||||
@findex %initial-action
|
||||
Declare that the braced @var{code} must be invoked before parsing each time
|
||||
@code{yyparse} is called. The @var{code} may use @code{$$} and
|
||||
@code{@@$} --- initial value and location of the lookahead --- and the
|
||||
@code{%parse-param}.
|
||||
@code{yyparse} is called. The @var{code} may use @code{$$} (or
|
||||
@code{$<@var{tag}>$}) and @code{@@$} --- initial value and location of the
|
||||
lookahead --- and the @code{%parse-param}.
|
||||
@end deffn
|
||||
|
||||
For instance, if your locations use a file name, you may use
|
||||
@@ -4592,11 +4592,11 @@ symbol is automatically discarded.
|
||||
@deffn {Directive} %destructor @{ @var{code} @} @var{symbols}
|
||||
@findex %destructor
|
||||
Invoke the braced @var{code} whenever the parser discards one of the
|
||||
@var{symbols}.
|
||||
Within @var{code}, @code{$$} designates the semantic value associated
|
||||
with the discarded symbol, and @code{@@$} designates its location.
|
||||
The additional parser parameters are also available (@pxref{Parser Function, ,
|
||||
The Parser Function @code{yyparse}}).
|
||||
@var{symbols}. Within @var{code}, @code{$$} (or @code{$<@var{tag}>$})
|
||||
designates the semantic value associated with the discarded symbol, and
|
||||
@code{@@$} designates its location. The additional parser parameters are
|
||||
also available (@pxref{Parser Function, , The Parser Function
|
||||
@code{yyparse}}).
|
||||
|
||||
When a symbol is listed among @var{symbols}, its @code{%destructor} is called a
|
||||
per-symbol @code{%destructor}.
|
||||
@@ -4734,10 +4734,11 @@ Decl, , Freeing Discarded Symbols}).
|
||||
@c This is the same text as for %destructor.
|
||||
Invoke the braced @var{code} whenever the parser displays one of the
|
||||
@var{symbols}. Within @var{code}, @code{yyoutput} denotes the output stream
|
||||
(a @code{FILE*} in C, and an @code{std::ostream&} in C++),
|
||||
@code{$$} designates the semantic value associated with the symbol, and
|
||||
@code{@@$} its location. The additional parser parameters are also
|
||||
available (@pxref{Parser Function, , The Parser Function @code{yyparse}}).
|
||||
(a @code{FILE*} in C, and an @code{std::ostream&} in C++), @code{$$} (or
|
||||
@code{$<@var{tag}>$}) designates the semantic value associated with the
|
||||
symbol, and @code{@@$} its location. The additional parser parameters are
|
||||
also available (@pxref{Parser Function, , The Parser Function
|
||||
@code{yyparse}}).
|
||||
|
||||
The @var{symbols} are defined as for @code{%destructor} (@pxref{Destructor
|
||||
Decl, , Freeing Discarded Symbols}.): they can be per-type (e.g.,
|
||||
@@ -5075,7 +5076,7 @@ default location or at the location specified by @var{qualifier}.
|
||||
|
||||
@deffn {Directive} %debug
|
||||
In the parser implementation file, define the macro @code{YYDEBUG} (or
|
||||
@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}), see
|
||||
@code{@var{prefix}DEBUG} with @samp{%define api.prefix @var{prefix}}, see
|
||||
@ref{Multiple Parsers, ,Multiple Parsers in the Same Program}) to 1 if it is
|
||||
not already defined, so that the debugging facilities are compiled.
|
||||
@xref{Tracing, ,Tracing Your Parser}.
|
||||
@@ -5123,6 +5124,23 @@ Values, ,Semantic Values of Tokens}.
|
||||
If you have declared @code{%code requires} or @code{%code provides}, the output
|
||||
header also contains their code.
|
||||
@xref{%code Summary}.
|
||||
|
||||
@cindex Header guard
|
||||
The generated header is protected against multiple inclusions with a C
|
||||
preprocessor guard: @samp{YY_@var{PREFIX}_@var{FILE}_INCLUDED}, where
|
||||
@var{PREFIX} and @var{FILE} are the prefix (@pxref{Multiple Parsers,
|
||||
,Multiple Parsers in the Same Program}) and generated file name turned
|
||||
uppercase, with each series of non alphanumerical characters converted to a
|
||||
single underscore.
|
||||
|
||||
For instance with @samp{%define api.prefix "calc"} and @samp{%defines
|
||||
"lib/parse.h"}, the header will be guarded as follows.
|
||||
@example
|
||||
#ifndef YY_CALC_LIB_PARSE_H_INCLUDED
|
||||
# define YY_CALC_LIB_PARSE_H_INCLUDED
|
||||
...
|
||||
#endif /* ! YY_CALC_LIB_PARSE_H_INCLUDED */
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Directive} %defines @var{defines-file}
|
||||
@@ -8501,8 +8519,8 @@ Prologue}).
|
||||
If the @code{%define} variable @code{api.prefix} is used (@pxref{Multiple
|
||||
Parsers, ,Multiple Parsers in the Same Program}), for instance @samp{%define
|
||||
api.prefix x}, then if @code{CDEBUG} is defined, its value controls the
|
||||
tracing feature (enabled iff nonzero); otherwise tracing is enabled iff
|
||||
@code{YYDEBUG} is nonzero.
|
||||
tracing feature (enabled if and only if nonzero); otherwise tracing is
|
||||
enabled if and only if @code{YYDEBUG} is nonzero.
|
||||
|
||||
@item the option @option{-t} (POSIX Yacc compliant)
|
||||
@itemx the option @option{--debug} (Bison extension)
|
||||
@@ -9054,13 +9072,23 @@ separated list of @var{things} among:
|
||||
Description of the grammar, conflicts (resolved and unresolved), and
|
||||
parser's automaton.
|
||||
|
||||
@item itemset
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
the full set of items for each state, instead of its core only.
|
||||
|
||||
@item lookahead
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
each rule's lookahead set.
|
||||
|
||||
@item itemset
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
the full set of items for each state, instead of its core only.
|
||||
@item solved
|
||||
Implies @code{state}. Explain how conflicts were solved thanks to
|
||||
precedence and associativity directives.
|
||||
|
||||
@item all
|
||||
Enable all the items.
|
||||
|
||||
@item none
|
||||
Do not generate the report.
|
||||
@end table
|
||||
|
||||
@item --report-file=@var{file}
|
||||
@@ -11704,8 +11732,8 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
||||
@uref{http://www.cs.rhul.ac.uk/research/languages/publications/tomita_style_1.ps}
|
||||
@end table
|
||||
|
||||
@node Index
|
||||
@unnumbered Index
|
||||
@node Index of Terms
|
||||
@unnumbered Index of Terms
|
||||
|
||||
@printindex cp
|
||||
|
||||
@@ -11760,10 +11788,11 @@ London, Department of Computer Science, TR-00-12 (December 2000).
|
||||
@c LocalWords: toString deftypeivar deftypeivarx deftypeop YYParser strictfp
|
||||
@c LocalWords: superclasses boolean getErrorVerbose setErrorVerbose deftypecv
|
||||
@c LocalWords: getDebugStream setDebugStream getDebugLevel setDebugLevel url
|
||||
@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos
|
||||
@c LocalWords: bisonVersion deftypecvx bisonSkeleton getStartPos getEndPos uint
|
||||
@c LocalWords: getLVal defvar deftypefn deftypefnx gotos msgfmt Corbett LALR's
|
||||
@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy
|
||||
@c LocalWords: Scannerless ispell american
|
||||
@c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy ints
|
||||
@c LocalWords: Scannerless ispell american ChangeLog smallexample CSTYPE CLTYPE
|
||||
@c LocalWords: clval CDEBUG cdebug deftypeopx yyterminate
|
||||
|
||||
@c Local Variables:
|
||||
@c ispell-dictionary: "american"
|
||||
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
external: gnulib
|
||||
+1
-1
Submodule gnulib updated: cabce6b8f2...d245e6ddd6
@@ -268,3 +268,7 @@
|
||||
/xmemdup0.c
|
||||
/xmemdup0.h
|
||||
/sys_types.in.h
|
||||
/obstack_printf.c
|
||||
/binary-io.c
|
||||
/mbuiter.c
|
||||
/xsize.c
|
||||
|
||||
@@ -179,3 +179,5 @@
|
||||
/xalloc.m4
|
||||
/xsize.m4
|
||||
/xstrndup.m4
|
||||
/obstack-printf.m4
|
||||
/extern-inline.m4
|
||||
|
||||
+16
-16
@@ -73,7 +73,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
{
|
||||
case shift_resolution:
|
||||
case right_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as shift"),
|
||||
r->number,
|
||||
@@ -82,7 +82,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
|
||||
case reduce_resolution:
|
||||
case left_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as reduce"),
|
||||
r->number,
|
||||
@@ -90,7 +90,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as an error"),
|
||||
r->number,
|
||||
@@ -102,33 +102,33 @@ log_resolution (rule *r, symbol_number token,
|
||||
switch (resolution)
|
||||
{
|
||||
case shift_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
r->prec->tag,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case reduce_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
symbols[token]->tag,
|
||||
r->prec->tag);
|
||||
break;
|
||||
|
||||
case left_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
" (%%left %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case right_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
" (%%right %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
obstack_printf (&solved_conflicts_obstack,
|
||||
" (%%nonassoc %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
@@ -145,7 +145,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
{
|
||||
case shift_resolution:
|
||||
case right_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||
" type=\"shift\">",
|
||||
r->number,
|
||||
@@ -154,7 +154,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
|
||||
case reduce_resolution:
|
||||
case left_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||
" type=\"reduce\">",
|
||||
r->number,
|
||||
@@ -162,7 +162,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
" <resolution rule=\"%d\" symbol=\"%s\""
|
||||
" type=\"error\">",
|
||||
r->number,
|
||||
@@ -174,33 +174,33 @@ log_resolution (rule *r, symbol_number token,
|
||||
switch (resolution)
|
||||
{
|
||||
case shift_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
"%s < %s",
|
||||
xml_escape_n (0, r->prec->tag),
|
||||
xml_escape_n (1, symbols[token]->tag));
|
||||
break;
|
||||
|
||||
case reduce_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
"%s < %s",
|
||||
xml_escape_n (0, symbols[token]->tag),
|
||||
xml_escape_n (1, r->prec->tag));
|
||||
break;
|
||||
|
||||
case left_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
"%%left %s",
|
||||
xml_escape (symbols[token]->tag));
|
||||
break;
|
||||
|
||||
case right_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
"%%right %s",
|
||||
xml_escape (symbols[token]->tag));
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_xml_obstack,
|
||||
obstack_printf (&solved_conflicts_xml_obstack,
|
||||
"%%nonassoc %s",
|
||||
xml_escape (symbols[token]->tag));
|
||||
break;
|
||||
|
||||
+19
-1
@@ -361,7 +361,25 @@ THINGS is a list of comma separated words that can include:\n\
|
||||
`none' disable the report\n\
|
||||
"), stdout);
|
||||
|
||||
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
||||
putc ('\n', stdout);
|
||||
printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
||||
printf (_("%s home page: <%s>.\n"), PACKAGE_NAME, PACKAGE_URL);
|
||||
fputs (_("General help using GNU software: "
|
||||
"<http://www.gnu.org/gethelp/>.\n"),
|
||||
stdout);
|
||||
/* Don't output this redundant message for English locales.
|
||||
Note we still output for 'C' so that it gets included in the
|
||||
man page. */
|
||||
const char *lc_messages = setlocale (LC_MESSAGES, NULL);
|
||||
if (lc_messages && strcmp (lc_messages, "en_"))
|
||||
/* TRANSLATORS: Replace LANG_CODE in this URL with your language
|
||||
code <http://translationproject.org/team/LANG_CODE.html> to
|
||||
form one of the URLs at http://translationproject.org/team/.
|
||||
Otherwise, replace the entire URL with your translation team's
|
||||
email address. */
|
||||
fputs (_("Report translation bugs to "
|
||||
"<http://translationproject.org/team/>.\n"), stdout);
|
||||
fputs (_("For complete documentation, run: info bison.\n"), stdout);
|
||||
}
|
||||
|
||||
exit (status);
|
||||
|
||||
+53
-45
@@ -177,10 +177,10 @@ static void
|
||||
muscle_syncline_grow (char const *key, location loc)
|
||||
{
|
||||
char *extension = NULL;
|
||||
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
||||
quotearg_style (c_quoting_style, loc.start.file));
|
||||
obstack_sgrow (&muscle_obstack, "]])[");
|
||||
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
|
||||
obstack_quote (&muscle_obstack,
|
||||
quotearg_style (c_quoting_style, loc.start.file));
|
||||
obstack_sgrow (&muscle_obstack, ")[");
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
extension = obstack_finish (&muscle_obstack);
|
||||
muscle_grow (key, extension, "");
|
||||
@@ -205,11 +205,11 @@ void muscle_pair_list_grow (const char *muscle,
|
||||
const char *a1, const char *a2)
|
||||
{
|
||||
char *pair;
|
||||
obstack_sgrow (&muscle_obstack, "[[[");
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
|
||||
obstack_sgrow (&muscle_obstack, "]], [[");
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
|
||||
obstack_sgrow (&muscle_obstack, "]]]");
|
||||
obstack_sgrow (&muscle_obstack, "[");
|
||||
obstack_quote (&muscle_obstack, a1);
|
||||
obstack_sgrow (&muscle_obstack, ", ");
|
||||
obstack_quote (&muscle_obstack, a2);
|
||||
obstack_sgrow (&muscle_obstack, "]");
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
pair = obstack_finish (&muscle_obstack);
|
||||
muscle_grow (muscle, pair, ",\n");
|
||||
@@ -259,53 +259,61 @@ muscle_find (char const *key)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
|
||||
digraphs for special characters in the file name. */
|
||||
|
||||
static void
|
||||
muscle_boundary_grow (char const *key, boundary bound)
|
||||
{
|
||||
char *extension;
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
|
||||
obstack_1grow (&muscle_obstack, ':');
|
||||
obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
|
||||
obstack_1grow (&muscle_obstack, '.');
|
||||
obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
|
||||
obstack_1grow (&muscle_obstack, '\0');
|
||||
obstack_sgrow (&muscle_obstack, "[[");
|
||||
obstack_escape (&muscle_obstack, bound.file);
|
||||
obstack_1grow (&muscle_obstack, ':');
|
||||
obstack_printf (&muscle_obstack, "%d", bound.line);
|
||||
obstack_1grow (&muscle_obstack, '.');
|
||||
obstack_printf (&muscle_obstack, "%d", bound.column);
|
||||
obstack_sgrow (&muscle_obstack, "]]");
|
||||
obstack_1grow (&muscle_obstack, '\0');
|
||||
extension = obstack_finish (&muscle_obstack);
|
||||
muscle_grow (key, extension, "");
|
||||
obstack_free (&muscle_obstack, extension);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
|
||||
append LOC to MUSCLE. Use digraphs for special characters in each
|
||||
file name. */
|
||||
|
||||
static void
|
||||
muscle_location_grow (char const *key, location loc)
|
||||
{
|
||||
muscle_grow (key, "[[", "");
|
||||
muscle_boundary_grow (key, loc.start);
|
||||
muscle_grow (key, "]], [[", "");
|
||||
muscle_grow (key, "", ", ");
|
||||
muscle_boundary_grow (key, loc.end);
|
||||
muscle_grow (key, "]]", "");
|
||||
}
|
||||
|
||||
#define MUSCLE_COMMON_DECODE(Value) \
|
||||
case '$': \
|
||||
aver (*++(Value) == ']'); \
|
||||
aver (*++(Value) == '['); \
|
||||
obstack_sgrow (&muscle_obstack, "$"); \
|
||||
break; \
|
||||
case '@': \
|
||||
switch (*++(Value)) \
|
||||
{ \
|
||||
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
|
||||
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
|
||||
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
|
||||
default: aver (false); break; \
|
||||
} \
|
||||
break; \
|
||||
default: \
|
||||
obstack_1grow (&muscle_obstack, *(Value)); \
|
||||
#define COMMON_DECODE(Value) \
|
||||
case '$': \
|
||||
aver (*++(Value) == ']'); \
|
||||
aver (*++(Value) == '['); \
|
||||
obstack_sgrow (&muscle_obstack, "$"); \
|
||||
break; \
|
||||
case '@': \
|
||||
switch (*++(Value)) \
|
||||
{ \
|
||||
case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
|
||||
case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
|
||||
case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
|
||||
default: aver (false); break; \
|
||||
} \
|
||||
break; \
|
||||
default: \
|
||||
obstack_1grow (&muscle_obstack, *(Value)); \
|
||||
break;
|
||||
|
||||
/* Reverse of MUSCLE_OBSTACK_SGROW. */
|
||||
/* Reverse of obstack_escape. */
|
||||
static char *
|
||||
muscle_string_decode (char const *key)
|
||||
string_decode (char const *key)
|
||||
{
|
||||
char const *value;
|
||||
char *value_decoded;
|
||||
@@ -317,7 +325,7 @@ muscle_string_decode (char const *key)
|
||||
do {
|
||||
switch (*value)
|
||||
{
|
||||
MUSCLE_COMMON_DECODE (value)
|
||||
COMMON_DECODE (value)
|
||||
case '[':
|
||||
case ']':
|
||||
aver (false);
|
||||
@@ -332,7 +340,7 @@ muscle_string_decode (char const *key)
|
||||
|
||||
/* Reverse of muscle_location_grow. */
|
||||
static location
|
||||
muscle_location_decode (char const *key)
|
||||
location_decode (char const *key)
|
||||
{
|
||||
location loc;
|
||||
char const *value = muscle_find_const (key);
|
||||
@@ -342,7 +350,7 @@ muscle_location_decode (char const *key)
|
||||
while (*++value)
|
||||
switch (*value)
|
||||
{
|
||||
MUSCLE_COMMON_DECODE (value)
|
||||
COMMON_DECODE (value)
|
||||
case '[':
|
||||
aver (false);
|
||||
break;
|
||||
@@ -455,7 +463,7 @@ muscle_percent_define_get (char const *variable)
|
||||
variable, ")");
|
||||
|
||||
muscle_insert (usage_name, "");
|
||||
value = muscle_string_decode (name);
|
||||
value = string_decode (name);
|
||||
if (!value)
|
||||
value = xstrdup ("");
|
||||
return value;
|
||||
@@ -469,7 +477,7 @@ muscle_percent_define_get_loc (char const *variable)
|
||||
if (!muscle_find_const (loc_name))
|
||||
fatal(_("%s: undefined %%define variable %s"),
|
||||
"muscle_percent_define_get_loc", quote (variable));
|
||||
return muscle_location_decode (loc_name);
|
||||
return location_decode (loc_name);
|
||||
}
|
||||
|
||||
char const *
|
||||
@@ -573,7 +581,7 @@ muscle_percent_define_check_values (char const * const *values)
|
||||
|
||||
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
|
||||
|
||||
value = muscle_string_decode (name);
|
||||
value = string_decode (name);
|
||||
if (value)
|
||||
{
|
||||
for (++values; *values; ++values)
|
||||
|
||||
+37
-60
@@ -35,62 +35,47 @@ void muscle_free (void);
|
||||
/* An obstack dedicated to receive muscle keys and values. */
|
||||
extern struct obstack muscle_obstack;
|
||||
|
||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||
do { \
|
||||
int v = Value; \
|
||||
MUSCLE_INSERT_INT (Key, v); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||
do { \
|
||||
int v = Value; \
|
||||
MUSCLE_INSERT_INT (Key, v); \
|
||||
} while (0)
|
||||
|
||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_printf (&muscle_obstack, "%d", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while (0)
|
||||
|
||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_printf (&muscle_obstack, "%ld", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while (0)
|
||||
|
||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||
do { \
|
||||
obstack_sgrow (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||
do { \
|
||||
obstack_sgrow (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while (0)
|
||||
|
||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||
do { \
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||
do { \
|
||||
obstack_escape (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while (0)
|
||||
|
||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
||||
do { \
|
||||
char const *p; \
|
||||
for (p = Value; *p; p++) \
|
||||
switch (*p) \
|
||||
{ \
|
||||
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
||||
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
||||
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
||||
default: obstack_1grow (Obstack, *p); break; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||
do { \
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
||||
quotearg_style (c_quoting_style, \
|
||||
Value)); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||
do { \
|
||||
obstack_escape (&muscle_obstack, \
|
||||
quotearg_style (c_quoting_style, Value)); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while (0)
|
||||
|
||||
/* Append VALUE to the current value of KEY. If KEY did not already
|
||||
exist, create it. Use MUSCLE_OBSTACK. De-allocate the previously
|
||||
@@ -110,15 +95,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
|
||||
muscle values are output *double* quoted, one needs to strip the first level
|
||||
of quotes to reach the list itself. */
|
||||
void muscle_pair_list_grow (const char *muscle,
|
||||
const char *a1, const char *a2);
|
||||
|
||||
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
|
||||
LOC to MUSCLE. Use digraphs for special characters in each file name. */
|
||||
void muscle_location_grow (char const *key, location loc);
|
||||
|
||||
/* In the format `file_name:line.column', append BOUND to MUSCLE. Use digraphs
|
||||
for special characters in the file name. */
|
||||
void muscle_boundary_grow (char const *key, boundary bound);
|
||||
const char *a1, const char *a2);
|
||||
|
||||
/* Grow KEY for the occurrence of the name USER_NAME at LOC appropriately for
|
||||
use with b4_check_user_names in ../data/bison.m4. USER_NAME is not escaped
|
||||
|
||||
+30
-17
@@ -70,7 +70,7 @@ Name (char const *name, \
|
||||
int i; \
|
||||
int j = 1; \
|
||||
\
|
||||
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
||||
obstack_printf (&format_obstack, "%6d", first); \
|
||||
for (i = begin; i < end; ++i) \
|
||||
{ \
|
||||
obstack_1grow (&format_obstack, ','); \
|
||||
@@ -81,7 +81,7 @@ Name (char const *name, \
|
||||
} \
|
||||
else \
|
||||
++j; \
|
||||
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
||||
obstack_printf (&format_obstack, "%6d", table_data[i]); \
|
||||
if (table_data[i] < min) \
|
||||
min = table_data[i]; \
|
||||
if (max < table_data[i]) \
|
||||
@@ -93,10 +93,10 @@ Name (char const *name, \
|
||||
lmin = min; \
|
||||
lmax = max; \
|
||||
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
||||
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
||||
obstack_printf (&format_obstack, "%s_min", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
||||
obstack_printf (&format_obstack, "%s_max", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||
}
|
||||
@@ -110,29 +110,39 @@ GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
|
||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| Print to OUT a representation of STRING escaped both for C and M4. |
|
||||
`--------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------.
|
||||
| Print to OUT a representation of CP quoted and escaped for M4. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
escaped_output (FILE *out, char const *string)
|
||||
quoted_output (FILE *out, char const *cp)
|
||||
{
|
||||
char const *p;
|
||||
fprintf (out, "[[");
|
||||
|
||||
for (p = quotearg_style (c_quoting_style, string); *p; p++)
|
||||
switch (*p)
|
||||
for (; *cp; cp++)
|
||||
switch (*cp)
|
||||
{
|
||||
case '$': fputs ("$][", out); break;
|
||||
case '@': fputs ("@@", out); break;
|
||||
case '[': fputs ("@{", out); break;
|
||||
case ']': fputs ("@}", out); break;
|
||||
default: fputc (*p, out); break;
|
||||
default: fputc (*cp, out); break;
|
||||
}
|
||||
|
||||
fprintf (out, "]]");
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------.
|
||||
| Print to OUT a representation of STRING quoted and escaped both |
|
||||
| for C and M4. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
string_output (FILE *out, char const *string)
|
||||
{
|
||||
quoted_output (out, quotearg_style (c_quoting_style, string));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Prepare the muscles related to the symbols: translate, tname, and |
|
||||
@@ -175,7 +185,7 @@ prepare_symbols (void)
|
||||
|
||||
if (i)
|
||||
obstack_1grow (&format_obstack, ' ');
|
||||
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
||||
obstack_escape (&format_obstack, cp);
|
||||
free (cp);
|
||||
obstack_1grow (&format_obstack, ',');
|
||||
j += width;
|
||||
@@ -299,7 +309,7 @@ user_actions_output (FILE *out)
|
||||
{
|
||||
fprintf (out, "b4_case(%d, [b4_syncline(%d, ", r + 1,
|
||||
rules[r].action_location.start.line);
|
||||
escaped_output (out, rules[r].action_location.start.file);
|
||||
string_output (out, rules[r].action_location.start.file);
|
||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||
}
|
||||
fputs ("])\n\n", out);
|
||||
@@ -405,12 +415,15 @@ symbol_code_props_output (FILE *out, char const *what,
|
||||
code, optional typename. */
|
||||
fprintf (out, "%s[", sep);
|
||||
sep = ",\n";
|
||||
escaped_output (out, loc.start.file);
|
||||
string_output (out, loc.start.file);
|
||||
fprintf (out, ", %d, ", loc.start.line);
|
||||
escaped_output (out, sym->tag);
|
||||
quoted_output (out, sym->tag);
|
||||
fprintf (out, ", %d, [[%s]]", sym->number, code);
|
||||
if (sym->type_name)
|
||||
fprintf (out, ", [[%s]]", sym->type_name);
|
||||
{
|
||||
fputs (", ", out);
|
||||
quoted_output (out, sym->type_name);
|
||||
}
|
||||
fputc (']', out);
|
||||
}
|
||||
}
|
||||
|
||||
+598
-509
File diff suppressed because it is too large
Load Diff
+9
-11
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 2.5.1.19-ced26-dirty. */
|
||||
/* A Bison parser, made by GNU Bison 2.6.3.3-b10d3. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef GRAM__________SRC_PARSE_GRAM_H
|
||||
# define GRAM__________SRC_PARSE_GRAM_H
|
||||
#ifndef YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
|
||||
# define YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 1
|
||||
@@ -167,9 +167,8 @@ extern int gram_debug;
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 2063 of yacc.c */
|
||||
#line 114 "parse-gram.y"
|
||||
/* Line 2077 of yacc.c */
|
||||
#line 115 "parse-gram.y"
|
||||
|
||||
symbol *symbol;
|
||||
symbol_list *list;
|
||||
@@ -182,9 +181,8 @@ typedef union YYSTYPE
|
||||
named_ref *named_ref;
|
||||
|
||||
|
||||
|
||||
/* Line 2063 of yacc.c */
|
||||
#line 188 "parse-gram.h"
|
||||
/* Line 2077 of yacc.c */
|
||||
#line 186 "parse-gram.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@@ -204,6 +202,7 @@ typedef struct YYLTYPE
|
||||
# define YYLTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int gram_parse (void *YYPARSE_PARAM);
|
||||
@@ -218,5 +217,4 @@ int gram_parse ();
|
||||
#endif
|
||||
#endif /* ! YYPARSE_PARAM */
|
||||
|
||||
|
||||
#endif /* !GRAM__________SRC_PARSE_GRAM_H */
|
||||
#endif /* !YY_GRAM__________SRC_PARSE_GRAM_H_INCLUDED */
|
||||
|
||||
+25
-12
@@ -20,6 +20,7 @@
|
||||
#include <config.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "c-ctype.h"
|
||||
#include "complain.h"
|
||||
#include "conflicts.h"
|
||||
#include "files.h"
|
||||
@@ -347,17 +348,27 @@ grammar_declaration:
|
||||
}
|
||||
| "%destructor" "{...}" generic_symlist
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_destructor_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
code_props code;
|
||||
code_props_symbol_action_init (&code, $2, @2);
|
||||
code_props_translate_code (&code);
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_destructor_set (list, &code);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
}
|
||||
| "%printer" "{...}" generic_symlist
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_printer_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
code_props code;
|
||||
code_props_symbol_action_init (&code, $2, @2);
|
||||
code_props_translate_code (&code);
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_printer_set (list, &code);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
}
|
||||
| "%default-prec"
|
||||
{
|
||||
@@ -724,11 +735,13 @@ add_param (char const *type, char *decl, location loc)
|
||||
|
||||
/* Strip the surrounding '{' and '}', and any blanks just inside
|
||||
the braces. */
|
||||
while (*--p == ' ' || *p == '\t')
|
||||
continue;
|
||||
--p;
|
||||
while (c_isspace ((unsigned char) *p))
|
||||
--p;
|
||||
p[1] = '\0';
|
||||
while (*++decl == ' ' || *decl == '\t')
|
||||
continue;
|
||||
++decl;
|
||||
while (c_isspace ((unsigned char) *decl))
|
||||
++decl;
|
||||
|
||||
if (! name_start)
|
||||
complain_at (loc, _("missing identifier in parameter declaration"));
|
||||
|
||||
+5
-5
@@ -54,7 +54,7 @@ print_core (struct obstack *oout, state *s)
|
||||
snritems = nitemset;
|
||||
}
|
||||
|
||||
obstack_fgrow1 (oout, "%d", s->number);
|
||||
obstack_printf (oout, "%d", s->number);
|
||||
for (i = 0; i < snritems; i++)
|
||||
{
|
||||
item_number *sp;
|
||||
@@ -68,15 +68,15 @@ print_core (struct obstack *oout, state *s)
|
||||
|
||||
r = item_number_as_rule_number (*sp);
|
||||
|
||||
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
|
||||
obstack_printf (oout, "\n%s -> ", rules[r].lhs->tag);
|
||||
|
||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
|
||||
obstack_printf (oout, "%s ", symbols[*sp]->tag);
|
||||
|
||||
obstack_1grow (oout, '.');
|
||||
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
|
||||
obstack_printf (oout, " %s", symbols[*sp]->tag);
|
||||
|
||||
/* Experimental feature: display the lookahead tokens. */
|
||||
if (report_flag & report_lookahead_tokens
|
||||
@@ -95,7 +95,7 @@ print_core (struct obstack *oout, state *s)
|
||||
obstack_sgrow (oout, "[");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
||||
{
|
||||
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
||||
obstack_printf (oout, "%s%s", sep, symbols[k]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
obstack_sgrow (oout, "]");
|
||||
|
||||
+4
-1
@@ -45,7 +45,10 @@ typedef struct code_props {
|
||||
CODE_PROPS_SYMBOL_ACTION, CODE_PROPS_RULE_ACTION
|
||||
} kind;
|
||||
|
||||
/** \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE. */
|
||||
/**
|
||||
* \c NULL iff \c code_props::kind is \c CODE_PROPS_NONE.
|
||||
* Memory is allocated in an obstack freed elsewhere.
|
||||
*/
|
||||
char const *code;
|
||||
/** Undefined iff \c code_props::code is \c NULL. */
|
||||
location location;
|
||||
|
||||
+88
-87
@@ -46,6 +46,9 @@ YY_DECL;
|
||||
|
||||
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
||||
|
||||
static char *fetch_type_name (char *cp, char const **type_name,
|
||||
location dollar_loc);
|
||||
|
||||
static void handle_action_dollar (symbol_list *rule, char *cp,
|
||||
location dollar_loc);
|
||||
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
|
||||
@@ -95,11 +98,15 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
int braces_level = 0;
|
||||
|
||||
/* Whether a semicolon is probably needed.
|
||||
The heuristic is that a semicolon is not needed after '{', '}', ';',
|
||||
or a C preprocessor directive, and that whitespaces and comments
|
||||
do not affect this flag.
|
||||
Note that '{' does not need a semicolon because of '{}'.
|
||||
A semicolon may be needed before a cpp direcive, but don't bother. */
|
||||
|
||||
The heuristic is that a semicolon is not needed after '{', '}',
|
||||
';', or a C preprocessor directive, and that whitespaces and
|
||||
comments do not affect this flag. Note that '{' does not need a
|
||||
semicolon because of '{}'. A semicolon may be needed before a
|
||||
cpp directive, but don't bother.
|
||||
|
||||
While it is maintained in several start-conditions (factoring
|
||||
opportunities), it is meaningful only for SC_RULE_ACTION. */
|
||||
bool need_semicolon = false;
|
||||
|
||||
/* Whether in a C preprocessor directive. Don't use a start condition
|
||||
@@ -157,7 +164,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
}
|
||||
|
||||
|
||||
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{
|
||||
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
|
||||
{
|
||||
"'" {
|
||||
STRING_GROW;
|
||||
BEGIN SC_CHARACTER;
|
||||
@@ -176,42 +184,31 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
STRING_GROW;
|
||||
BEGIN SC_LINE_COMMENT;
|
||||
}
|
||||
[$@] {
|
||||
warn_at (*loc, _("stray '%s'"), yytext);
|
||||
obstack_escape (&obstack_for_string, yytext);
|
||||
need_semicolon = true;
|
||||
}
|
||||
[\[\]] {
|
||||
obstack_escape (&obstack_for_string, yytext);
|
||||
need_semicolon = true;
|
||||
}
|
||||
}
|
||||
|
||||
<SC_RULE_ACTION>
|
||||
{
|
||||
"$"("<"{tag}">")?{ref} {
|
||||
ref_tail_fields = 0;
|
||||
ref_tail_fields = NULL;
|
||||
handle_action_dollar (self->rule, yytext, *loc);
|
||||
if (ref_tail_fields) {
|
||||
if (ref_tail_fields)
|
||||
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
||||
}
|
||||
need_semicolon = true;
|
||||
}
|
||||
"@"{ref} {
|
||||
ref_tail_fields = 0;
|
||||
ref_tail_fields = NULL;
|
||||
handle_action_at (self->rule, yytext, *loc);
|
||||
if (ref_tail_fields) {
|
||||
if (ref_tail_fields)
|
||||
obstack_sgrow (&obstack_for_string, ref_tail_fields);
|
||||
}
|
||||
need_semicolon = true;
|
||||
}
|
||||
"$" {
|
||||
warn_at (*loc, _("stray '$'"));
|
||||
obstack_sgrow (&obstack_for_string, "$][");
|
||||
need_semicolon = true;
|
||||
}
|
||||
"@" {
|
||||
warn_at (*loc, _("stray '@'"));
|
||||
obstack_sgrow (&obstack_for_string, "@@");
|
||||
need_semicolon = true;
|
||||
}
|
||||
"[" {
|
||||
obstack_sgrow (&obstack_for_string, "@{");
|
||||
need_semicolon = true;
|
||||
}
|
||||
"]" {
|
||||
obstack_sgrow (&obstack_for_string, "@}");
|
||||
need_semicolon = true;
|
||||
}
|
||||
|
||||
@@ -263,8 +260,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
|
||||
<SC_SYMBOL_ACTION>
|
||||
{
|
||||
"$$" {
|
||||
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
|
||||
"$"("<"{tag}">")?"$" {
|
||||
const char *type_name = NULL;
|
||||
fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
|
||||
obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
self->is_value_used = true;
|
||||
}
|
||||
"@$" {
|
||||
@@ -274,30 +275,18 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------.
|
||||
| Escape M4 quoting characters in C code. |
|
||||
`-----------------------------------------*/
|
||||
|
||||
<*>
|
||||
{
|
||||
\$ obstack_sgrow (&obstack_for_string, "$][");
|
||||
\@ obstack_sgrow (&obstack_for_string, "@@");
|
||||
\[ obstack_sgrow (&obstack_for_string, "@{");
|
||||
\] obstack_sgrow (&obstack_for_string, "@}");
|
||||
/* Escape M4 quoting characters in C code. */
|
||||
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
|
||||
|
||||
/* By default, grow the string obstack with the input. */
|
||||
.|\n STRING_GROW;
|
||||
|
||||
/* End of processing. */
|
||||
<<EOF>> STRING_FINISH; return last_string;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------.
|
||||
| By default, grow the string obstack with the input. |
|
||||
`-----------------------------------------------------*/
|
||||
|
||||
<*>.|\n STRING_GROW;
|
||||
|
||||
/* End of processing. */
|
||||
<*><<EOF>> {
|
||||
STRING_FINISH;
|
||||
return last_string;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
static inline bool
|
||||
@@ -345,7 +334,7 @@ typedef struct
|
||||
not visible from current midrule. */
|
||||
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
|
||||
|
||||
static variant *variant_table = 0;
|
||||
static variant *variant_table = NULL;
|
||||
static unsigned variant_table_size = 0;
|
||||
static unsigned variant_count = 0;
|
||||
|
||||
@@ -367,7 +356,7 @@ static void
|
||||
variant_table_free (void)
|
||||
{
|
||||
free (variant_table);
|
||||
variant_table = 0;
|
||||
variant_table = NULL;
|
||||
variant_table_size = variant_count = 0;
|
||||
}
|
||||
|
||||
@@ -410,7 +399,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_at_spec(unsigned symbol_index)
|
||||
get_at_spec (unsigned symbol_index)
|
||||
{
|
||||
static char at_buf[20];
|
||||
if (symbol_index == 0)
|
||||
@@ -454,30 +443,30 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
|
||||
/* Create the explanation message. */
|
||||
obstack_init (&msg_buf);
|
||||
|
||||
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||
obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
||||
obstack_printf (&msg_buf, "[%s]", id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
|
||||
if (var->err & VARIANT_HIDDEN)
|
||||
{
|
||||
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||
obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (var->id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
||||
obstack_printf (&msg_buf, "[%s]", var->id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, var->id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
}
|
||||
|
||||
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
|
||||
obstack_printf (&msg_buf, _(" at %s"), at_spec);
|
||||
|
||||
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
||||
{
|
||||
const char *format =
|
||||
_(", cannot be accessed from mid-rule action at $%d");
|
||||
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
|
||||
obstack_printf (&msg_buf, format, midrule_rhs_index);
|
||||
}
|
||||
|
||||
obstack_1grow (&msg_buf, '\0');
|
||||
@@ -688,6 +677,31 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
int max_left_semantic_context = 0;
|
||||
|
||||
|
||||
/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
|
||||
beginning (i.e., after the opening "<", and return the pointer
|
||||
immediately after it. */
|
||||
|
||||
static
|
||||
char *
|
||||
fetch_type_name (char *cp, char const **type_name,
|
||||
location dollar_loc)
|
||||
{
|
||||
if (*cp == '<')
|
||||
{
|
||||
*type_name = ++cp;
|
||||
while (*cp != '>')
|
||||
++cp;
|
||||
|
||||
/* The '>' symbol will be later replaced by '\0'. Original
|
||||
'text' is needed for error messages. */
|
||||
++cp;
|
||||
if (untyped_var_seen)
|
||||
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
||||
tag_seen = true;
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
|
||||
| |
|
||||
@@ -701,7 +715,6 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
{
|
||||
char const *type_name = NULL;
|
||||
char *cp = text + 1;
|
||||
char *gt_ptr = 0;
|
||||
symbol_list *effective_rule;
|
||||
int effective_rule_length;
|
||||
int n;
|
||||
@@ -718,26 +731,14 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
}
|
||||
|
||||
/* Get the type name if explicit. */
|
||||
if (*cp == '<')
|
||||
{
|
||||
type_name = ++cp;
|
||||
while (*cp != '>')
|
||||
++cp;
|
||||
|
||||
/* The '>' symbol will be later replaced by '\0'. Original
|
||||
'text' is needed for error messages. */
|
||||
gt_ptr = cp;
|
||||
++cp;
|
||||
if (untyped_var_seen)
|
||||
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
||||
tag_seen = true;
|
||||
}
|
||||
cp = fetch_type_name (cp, &type_name, dollar_loc);
|
||||
|
||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
||||
|
||||
if (gt_ptr)
|
||||
*gt_ptr = '\0';
|
||||
/* End type_name. */
|
||||
if (type_name)
|
||||
cp[-1] = '\0';
|
||||
|
||||
switch (n)
|
||||
{
|
||||
@@ -764,11 +765,11 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
}
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
|
||||
obstack_fgrow1 (&obstack_for_string,
|
||||
"]b4_lhs_value([%s])[", type_name);
|
||||
obstack_sgrow (&obstack_for_string, "]b4_lhs_value(");
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
rule->action_props.is_value_used = true;
|
||||
break;
|
||||
|
||||
@@ -785,12 +786,12 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
cp, quote (effective_rule->content.sym->tag));
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
|
||||
obstack_fgrow3 (&obstack_for_string,
|
||||
"]b4_rhs_value(%d, %d, [%s])[",
|
||||
effective_rule_length, n, type_name);
|
||||
obstack_printf (&obstack_for_string,
|
||||
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
|
||||
obstack_quote (&obstack_for_string, type_name);
|
||||
obstack_sgrow (&obstack_for_string, ")[");
|
||||
if (n > 0)
|
||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||
true;
|
||||
@@ -826,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
||||
locations_flag = true;
|
||||
|
||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
||||
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
||||
switch (n)
|
||||
{
|
||||
case INVALID_REF:
|
||||
@@ -837,7 +838,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
||||
break;
|
||||
|
||||
default:
|
||||
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
||||
obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
||||
effective_rule_length, n);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@
|
||||
#include "reader.h"
|
||||
#include "uniqstr.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <c-ctype.h>
|
||||
#include <mbswidth.h>
|
||||
#include <quote.h>
|
||||
|
||||
@@ -560,7 +560,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
\\(.|\n) {
|
||||
char const *p = yytext + 1;
|
||||
/* Quote only if escaping won't make the character visible. */
|
||||
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
|
||||
if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
|
||||
p = quote (p);
|
||||
else
|
||||
p = quotearg_style_mem (escape_quoting_style, p, 1);
|
||||
|
||||
+20
-18
@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
|
||||
"@@" fputc ('@', yyout);
|
||||
"@{" fputc ('[', yyout);
|
||||
"@}" fputc (']', yyout);
|
||||
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */
|
||||
@\n /* Likewise. */
|
||||
"@`" continue; /* Used by b4_cat in ../data/bison.m4. */
|
||||
@\n continue;
|
||||
|
||||
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
|
||||
"@ofile@" QPUTS (outname);
|
||||
@@ -87,9 +87,9 @@ static void fail_for_invalid_at (char const *at);
|
||||
}
|
||||
|
||||
/* This pattern must not match more than the previous @ patterns. */
|
||||
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
||||
\n out_lineno++; ECHO;
|
||||
[^@\n]+ ECHO;
|
||||
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
||||
\n out_lineno++; ECHO;
|
||||
[^@\n]+ ECHO;
|
||||
|
||||
<INITIAL><<EOF>> {
|
||||
if (outname)
|
||||
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
<SC_AT_DIRECTIVE_ARGS>{
|
||||
[^@]+ { STRING_GROW; }
|
||||
<SC_AT_DIRECTIVE_ARGS>
|
||||
{
|
||||
[^@]+ STRING_GROW;
|
||||
|
||||
"@@" { obstack_1grow (&obstack_for_string, '@'); }
|
||||
"@{" { obstack_1grow (&obstack_for_string, '['); }
|
||||
"@}" { obstack_1grow (&obstack_for_string, ']'); }
|
||||
"@`" /* Empty. Useful for starting an argument
|
||||
that begins with whitespace. */
|
||||
@\n /* Empty. */
|
||||
"@@" obstack_1grow (&obstack_for_string, '@');
|
||||
"@{" obstack_1grow (&obstack_for_string, '[');
|
||||
"@}" obstack_1grow (&obstack_for_string, ']');
|
||||
"@`" continue; /* For starting an argument that begins with whitespace. */
|
||||
@\n continue;
|
||||
|
||||
@[,)] {
|
||||
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
|
||||
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
|
||||
}
|
||||
}
|
||||
|
||||
@.? { fail_for_invalid_at (yytext); }
|
||||
@.? fail_for_invalid_at (yytext);
|
||||
}
|
||||
|
||||
<SC_AT_DIRECTIVE_SKIP_WS>{
|
||||
[ \t\r\n]
|
||||
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
|
||||
<SC_AT_DIRECTIVE_SKIP_WS>
|
||||
{
|
||||
[ \t\r\n] continue;
|
||||
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
|
||||
}
|
||||
|
||||
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{
|
||||
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
|
||||
{
|
||||
<<EOF>> {
|
||||
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
|
||||
}
|
||||
|
||||
+10
-16
@@ -223,49 +223,43 @@ symbol_list_null (symbol_list *node)
|
||||
}
|
||||
|
||||
void
|
||||
symbol_list_destructor_set (symbol_list *node, char const *code, location loc)
|
||||
symbol_list_destructor_set (symbol_list *node, code_props const *destructor)
|
||||
{
|
||||
code_props destructor;
|
||||
code_props_symbol_action_init (&destructor, code, loc);
|
||||
code_props_translate_code (&destructor);
|
||||
switch (node->content_type)
|
||||
{
|
||||
case SYMLIST_SYMBOL:
|
||||
symbol_destructor_set (node->content.sym, &destructor);
|
||||
symbol_destructor_set (node->content.sym, destructor);
|
||||
break;
|
||||
case SYMLIST_TYPE:
|
||||
semantic_type_destructor_set (
|
||||
semantic_type_get (node->content.type_name), &destructor);
|
||||
semantic_type_get (node->content.type_name), destructor);
|
||||
break;
|
||||
case SYMLIST_DEFAULT_TAGGED:
|
||||
default_tagged_destructor_set (&destructor);
|
||||
default_tagged_destructor_set (destructor);
|
||||
break;
|
||||
case SYMLIST_DEFAULT_TAGLESS:
|
||||
default_tagless_destructor_set (&destructor);
|
||||
default_tagless_destructor_set (destructor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
symbol_list_printer_set (symbol_list *node, char const *code, location loc)
|
||||
symbol_list_printer_set (symbol_list *node, code_props const *printer)
|
||||
{
|
||||
code_props printer;
|
||||
code_props_symbol_action_init (&printer, code, loc);
|
||||
code_props_translate_code (&printer);
|
||||
switch (node->content_type)
|
||||
{
|
||||
case SYMLIST_SYMBOL:
|
||||
symbol_printer_set (node->content.sym, &printer);
|
||||
symbol_printer_set (node->content.sym, printer);
|
||||
break;
|
||||
case SYMLIST_TYPE:
|
||||
semantic_type_printer_set (
|
||||
semantic_type_get (node->content.type_name), &printer);
|
||||
semantic_type_get (node->content.type_name), printer);
|
||||
break;
|
||||
case SYMLIST_DEFAULT_TAGGED:
|
||||
default_tagged_printer_set (&printer);
|
||||
default_tagged_printer_set (printer);
|
||||
break;
|
||||
case SYMLIST_DEFAULT_TAGLESS:
|
||||
default_tagless_printer_set (&printer);
|
||||
default_tagless_printer_set (printer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -119,11 +119,11 @@ uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
|
||||
bool symbol_list_null (symbol_list *node);
|
||||
|
||||
/** Set the \c \%destructor for \c node as \c code at \c loc. */
|
||||
void symbol_list_destructor_set (symbol_list *node, char const *code,
|
||||
location loc);
|
||||
void symbol_list_destructor_set (symbol_list *node,
|
||||
code_props const *destructor);
|
||||
|
||||
/** Set the \c \%printer for \c node as \c code at \c loc. */
|
||||
void symbol_list_printer_set (symbol_list *node, char const *code,
|
||||
location loc);
|
||||
void symbol_list_printer_set (symbol_list *node,
|
||||
code_props const *printer);
|
||||
|
||||
#endif /* !SYMLIST_H_ */
|
||||
|
||||
+14
-7
@@ -60,23 +60,30 @@ struct symbol
|
||||
/** The location of its first occurrence. */
|
||||
location location;
|
||||
|
||||
/** Its \c \%type. */
|
||||
/** Its \c \%type.
|
||||
|
||||
Beware that this is the type_name as was entered by the user,
|
||||
including silly things such as "]" if she entered "%token <]> t".
|
||||
Therefore, when outputting type_name to M4, be sure to escape it
|
||||
into "@}". See quoted_output for instance. */
|
||||
uniqstr type_name;
|
||||
|
||||
/** Its \c \%type's location. */
|
||||
location type_location;
|
||||
|
||||
/** Any \c \%destructor declared specifically for this symbol.
|
||||
|
||||
Access this field only through <tt>symbol</tt>'s interface functions. For
|
||||
example, if <tt>symbol::destructor = NULL</tt>, a default \c \%destructor
|
||||
or a per-type \c \%destructor might be appropriate, and
|
||||
\c symbol_destructor_get will compute the correct one. */
|
||||
Access this field only through <tt>symbol</tt>'s interface
|
||||
functions. For example, if <tt>symbol::destructor = NULL</tt>, a
|
||||
default \c \%destructor or a per-type \c \%destructor might be
|
||||
appropriate, and \c symbol_destructor_get will compute the
|
||||
correct one. */
|
||||
code_props destructor;
|
||||
|
||||
/** Any \c \%printer declared specifically for this symbol.
|
||||
|
||||
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||
\sa symbol::destructor */
|
||||
Access this field only through <tt>symbol</tt>'s interface functions.
|
||||
\sa symbol::destructor */
|
||||
code_props printer;
|
||||
|
||||
symbol_number number;
|
||||
|
||||
+48
-44
@@ -38,11 +38,6 @@
|
||||
# include <stddef.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
|
||||
# if HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
||||
# include <unistd.h>
|
||||
# include <inttypes.h>
|
||||
|
||||
@@ -105,7 +100,6 @@ typedef size_t uintptr_t;
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# endif
|
||||
|
||||
# define FUNCTION_PRINT() fprintf (stderr, "%s: ", __func__)
|
||||
|
||||
/*------.
|
||||
| NLS. |
|
||||
@@ -160,36 +154,50 @@ typedef size_t uintptr_t;
|
||||
# define obstack_chunk_free free
|
||||
# include <obstack.h>
|
||||
|
||||
# define obstack_sgrow(Obs, Str) \
|
||||
# define obstack_sgrow(Obs, Str) \
|
||||
obstack_grow (Obs, Str, strlen (Str))
|
||||
|
||||
# define obstack_fgrow1(Obs, Format, Arg1) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
/* Output Str escaped for our postprocessing (i.e., escape M4 special
|
||||
characters).
|
||||
|
||||
# define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */
|
||||
|
||||
# define obstack_escape(Obs, Str) \
|
||||
do { \
|
||||
char const *p; \
|
||||
for (p = Str; *p; p++) \
|
||||
switch (*p) \
|
||||
{ \
|
||||
case '$': obstack_sgrow (Obs, "$]["); break; \
|
||||
case '@': obstack_sgrow (Obs, "@@" ); break; \
|
||||
case '[': obstack_sgrow (Obs, "@{" ); break; \
|
||||
case ']': obstack_sgrow (Obs, "@}" ); break; \
|
||||
default: obstack_1grow (Obs, *p ); break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped
|
||||
for our postprocessing (i.e., escape M4 special characters). If
|
||||
Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4
|
||||
programming easier (m4_ifval can be used).
|
||||
|
||||
For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */
|
||||
|
||||
# define obstack_quote(Obs, Str) \
|
||||
do { \
|
||||
char const* obstack_quote_p = Str; \
|
||||
if (obstack_quote_p && obstack_quote_p[0]) \
|
||||
{ \
|
||||
obstack_sgrow (Obs, "[["); \
|
||||
obstack_escape (Obs, obstack_quote_p); \
|
||||
obstack_sgrow (Obs, "]]"); \
|
||||
} \
|
||||
else \
|
||||
obstack_sgrow (Obs, "[]"); \
|
||||
} while (0)
|
||||
|
||||
# define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
# define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
@@ -205,25 +213,21 @@ do { \
|
||||
# define TAB_EXT ".tab"
|
||||
# endif
|
||||
|
||||
# ifndef DEFAULT_TMPDIR
|
||||
# define DEFAULT_TMPDIR "/tmp"
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
/*---------------------.
|
||||
| Free a linked list. |
|
||||
`---------------------*/
|
||||
|
||||
# define LIST_FREE(Type, List) \
|
||||
do { \
|
||||
Type *_node, *_next; \
|
||||
for (_node = List; _node; _node = _next) \
|
||||
{ \
|
||||
_next = _node->next; \
|
||||
free (_node); \
|
||||
} \
|
||||
} while (0)
|
||||
# define LIST_FREE(Type, List) \
|
||||
do { \
|
||||
Type *_node, *_next; \
|
||||
for (_node = List; _node; _node = _next) \
|
||||
{ \
|
||||
_next = _node->next; \
|
||||
free (_node); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*---------------------------------------------.
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ uniqstr uniqstr_vsprintf (char const *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
|
||||
/* Two uniqstr values have the same value iff they are the same. */
|
||||
#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2))
|
||||
#define UNIQSTR_EQ(USTR1, USTR2) (!!((USTR1) == (USTR2)))
|
||||
|
||||
/* Compare two uniqstr a la strcmp: negative for <, nul for =, and
|
||||
positive for >. Undefined order, relies on addresses. */
|
||||
|
||||
@@ -1230,6 +1230,142 @@ AT_CHECK_ACTION_LOCATIONS([[%destructor]])
|
||||
AT_CHECK_ACTION_LOCATIONS([[%printer]])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Qualified $$ in actions. ##
|
||||
## ------------------------- ##
|
||||
|
||||
# Check that we can used qualified $$ (v.g., $<type>$) not only in
|
||||
# rule actions, but also where $$ is valid: %printer and %destructor.
|
||||
#
|
||||
# FIXME: Not actually checking %desctructor, but it's the same code as
|
||||
# %printer...
|
||||
#
|
||||
# To do that, use a semantic value that has two fields (sem_type),
|
||||
# declare symbols to have only one of these types (INT, float), and
|
||||
# use $<type>$ to get the other one. Including for symbols that are
|
||||
# not typed (UNTYPED).
|
||||
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([[Qualified $$ in actions: $1]])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1"])
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]],
|
||||
[[%skeleton "$1"
|
||||
%defines // FIXME: Mandated by lalr1.cc in Bison 2.6.
|
||||
%locations // FIXME: Mandated by lalr1.cc in Bison 2.6.
|
||||
%debug
|
||||
%code requires
|
||||
{
|
||||
typedef struct sem_type
|
||||
{
|
||||
int ival;
|
||||
float fval;
|
||||
} sem_type;
|
||||
|
||||
# define YYSTYPE sem_type
|
||||
|
||||
]AT_SKEL_CC_IF([[
|
||||
# include <iostream>
|
||||
static void
|
||||
report (std::ostream& yyo, int ival, float fval)
|
||||
{
|
||||
yyo << "ival: " << ival << ", fval: " << fval;
|
||||
}
|
||||
]], [[
|
||||
# include <stdio.h>
|
||||
static void
|
||||
report (FILE* yyo, int ival, float fval)
|
||||
{
|
||||
fprintf (yyo, "ival: %d, fval: %1.1f", ival, fval);
|
||||
}
|
||||
]])[
|
||||
}
|
||||
|
||||
%code
|
||||
{
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
|
||||
%token UNTYPED
|
||||
%token <ival> INT
|
||||
%type <fval> float
|
||||
%printer { report (yyo, $$, $<fval>$); } <ival>;
|
||||
%printer { report (yyo, $<ival>$, $$ ); } <fval>;
|
||||
%printer { report (yyo, $<ival>$, $<fval>$); } <>;
|
||||
|
||||
]AT_SKEL_CC_IF([[
|
||||
/* The lalr1.cc skeleton, for backward compatibility, defines
|
||||
a constructor for position that initializes the filename. The
|
||||
glr.cc skeleton does not (and in fact cannot: location/position
|
||||
are stored in a union, from which objects with constructors are
|
||||
excluded in C++). */
|
||||
%initial-action {
|
||||
@$.initialize ();
|
||||
}
|
||||
]])[
|
||||
|
||||
%initial-action
|
||||
{
|
||||
$<ival>$ = 42;
|
||||
$<fval>$ = 4.2;
|
||||
}
|
||||
|
||||
%%
|
||||
float: UNTYPED INT
|
||||
{
|
||||
$$ = $<fval>1 + $<fval>2;
|
||||
$<ival>$ = $<ival>1 + $][2;
|
||||
};
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(AT_SKEL_CC_IF([[{yy::parser::token::UNTYPED,
|
||||
yy::parser::token::INT,
|
||||
EOF}]],
|
||||
[[{UNTYPED, INT, EOF}]]),
|
||||
[AT_VAL.ival = toknum * 10; AT_VAL.fval = toknum / 10.0;])[
|
||||
int
|
||||
main (void)
|
||||
{]AT_SKEL_CC_IF([[
|
||||
yy::parser p;
|
||||
p.set_debug_level(1);
|
||||
return p.parse ();]], [[
|
||||
yydebug = 1;
|
||||
return yyparse ();]])[
|
||||
}
|
||||
]])
|
||||
|
||||
AT_FULL_COMPILE([[input]])
|
||||
AT_PARSER_CHECK([./input], 0, [], [stderr])
|
||||
# Don't be too picky on the traces, GLR is not exactly the same. Keep
|
||||
# only the lines from the printer.
|
||||
#
|
||||
# Don't care about locations. FIXME: remove their removal when Bison
|
||||
# supports C++ without locations.
|
||||
AT_CHECK([[sed -ne 's/([-0-9.]*: /(/;/ival:/p' stderr]], 0,
|
||||
[[Reading a token: Next token is token UNTYPED (ival: 10, fval: 0.1)
|
||||
Shifting token UNTYPED (ival: 10, fval: 0.1)
|
||||
Reading a token: Next token is token INT (ival: 20, fval: 0.2)
|
||||
Shifting token INT (ival: 20, fval: 0.2)
|
||||
$][1 = token UNTYPED (ival: 10, fval: 0.1)
|
||||
$][2 = token INT (ival: 20, fval: 0.2)
|
||||
-> $$ = nterm float (ival: 30, fval: 0.3)
|
||||
Cleanup: popping nterm float (ival: 30, fval: 0.3)
|
||||
]])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_CLEANUP
|
||||
])
|
||||
|
||||
AT_TEST([yacc.c])
|
||||
AT_TEST([glr.c])
|
||||
AT_TEST([lalr1.cc])
|
||||
AT_TEST([glr.cc])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
## ----------------------------------------------- ##
|
||||
## Fix user actions without a trailing semicolon. ##
|
||||
## ----------------------------------------------- ##
|
||||
|
||||
+13
-18
@@ -29,16 +29,10 @@ CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
|
||||
# Is the compiler GCC?
|
||||
GCC='@GCC@'
|
||||
|
||||
# We want no optimization, as they uncover warnings (therefore,
|
||||
# failures) about uninitialized variables in the test suite. FIXME:
|
||||
# fix the warnings, not the flags.
|
||||
O0CFLAGS=`echo '@CFLAGS@' | sed 's/-O[0-9s] *//g'`
|
||||
O0CXXFLAGS=`echo '@CXXFLAGS@' | sed 's/-O[0-9s] *//g'`
|
||||
|
||||
# Sometimes a test group needs to ignore gcc warnings, so it locally
|
||||
# sets CFLAGS to this.
|
||||
NO_WERROR_CFLAGS="$O0CFLAGS @WARN_CFLAGS@ @WARN_CFLAGS_TEST@"
|
||||
NO_WERROR_CXXFLAGS="$O0CXXFLAGS @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@"
|
||||
NO_WERROR_CFLAGS='@CFLAGS@ @WARN_CFLAGS@ @WARN_CFLAGS_TEST@'
|
||||
NO_WERROR_CXXFLAGS='@CXXFLAGS@ @WARN_CXXFLAGS@ @WARN_CXXFLAGS_TEST@'
|
||||
|
||||
# But most of the time, we want -Werror.
|
||||
CFLAGS="$NO_WERROR_CFLAGS @WERROR_CFLAGS@"
|
||||
@@ -51,7 +45,6 @@ BISON_CXX_WORKS='@BISON_CXX_WORKS@'
|
||||
if "$at_arg_compile_c_with_cxx"; then
|
||||
CC_IS_CXX=1
|
||||
CC=$CXX
|
||||
O0CFLAGS=$O0CXXFLAGS
|
||||
NO_WERROR_CFLAGS=$NO_WERROR_CXXFLAGS
|
||||
CFLAGS=$CXXFLAGS
|
||||
else
|
||||
@@ -63,24 +56,26 @@ fi
|
||||
## Other. ##
|
||||
## ------- ##
|
||||
|
||||
# Are special link options needed?
|
||||
LDFLAGS='@LDFLAGS@'
|
||||
|
||||
# Are special libraries needed?
|
||||
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
|
||||
|
||||
# Empty if no javac was found
|
||||
CONF_JAVAC='@CONF_JAVAC@'
|
||||
|
||||
# Empty if no Java VM was found
|
||||
CONF_JAVA='@CONF_JAVA@'
|
||||
|
||||
# Empty if no xsltproc was found
|
||||
: ${XSLTPROC='@XSLTPROC@'}
|
||||
|
||||
# We need egrep.
|
||||
: ${EGREP='@EGREP@'}
|
||||
|
||||
# Use simple quotes (lib/quote.c).
|
||||
LC_CTYPE=C
|
||||
export LC_CTYPE
|
||||
|
||||
# Are special link options needed?
|
||||
LDFLAGS='@LDFLAGS@'
|
||||
|
||||
# Are special libraries needed?
|
||||
LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@"
|
||||
|
||||
# Empty if no xsltproc was found
|
||||
: ${XSLTPROC='@XSLTPROC@'}
|
||||
|
||||
: ${PERL='@PERL@'}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
abs_top_srcdir='@abs_top_srcdir@'
|
||||
abs_top_builddir='@abs_top_builddir@'
|
||||
: ${PERL=perl}
|
||||
: ${PERL='@PERL@'}
|
||||
|
||||
# Use the shipped files, not those installed.
|
||||
BISON_PKGDATADIR=$abs_top_srcdir/data
|
||||
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
# Checking the output filenames. -*- Autotest -*-
|
||||
# Checking the C++ Features. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation,
|
||||
# Inc.
|
||||
@@ -30,6 +30,7 @@ m4_define([AT_CHECK_DOXYGEN],
|
||||
[m4_fatal([invalid argument: $1])])
|
||||
AT_SETUP([Doxygen $1 Documentation])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
|
||||
AT_DATA([input.yy],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%locations
|
||||
@@ -38,10 +39,7 @@ AT_DATA([input.yy],
|
||||
%%
|
||||
exp:;
|
||||
%%
|
||||
yy::parser::error (const location& l, const std::string& m)
|
||||
{
|
||||
std::cerr << l << s << std::endl;
|
||||
}
|
||||
]AT_YYERROR_DEFINE[
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-o input.cc input.yy], 0)
|
||||
@@ -94,6 +92,7 @@ EXTRACT_STATIC = AT_DOXYGEN_PRIVATE
|
||||
AT_CHECK([doxygen --version || exit 77], 0, ignore)
|
||||
AT_CHECK([doxygen], 0, [], [ignore])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
AT_CLEANUP
|
||||
|
||||
m4_popdef([AT_DOXYGEN_PRIVATE])
|
||||
|
||||
+23
-6
@@ -288,16 +288,16 @@ static int power (int base, int exponent);
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
}
|
||||
|
||||
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
|
||||
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [[
|
||||
/* The lalr1.cc skeleton, for backward compatibility, defines
|
||||
a constructor for position that initializes the filename. The
|
||||
glr.cc skeleton does not (and in fact cannot: location/position
|
||||
are stored in a union, from which objects with constructors are
|
||||
excluded in C++. */
|
||||
excluded in C++). */
|
||||
%initial-action {
|
||||
@$.initialize ();
|
||||
}
|
||||
])])[
|
||||
]])])[
|
||||
|
||||
/* Bison Declarations */
|
||||
%token CALC_EOF 0 "end of input"
|
||||
@@ -386,11 +386,9 @@ AT_YYERROR_SEES_LOC_IF([
|
||||
fprintf (stderr, ": ");])
|
||||
fprintf (stderr, "%s\n", s);
|
||||
}])[
|
||||
|
||||
]AT_DEFINES_IF([],
|
||||
[AT_CALC_LEX
|
||||
AT_CALC_MAIN])[
|
||||
]])
|
||||
AT_CALC_MAIN])])
|
||||
|
||||
AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
|
||||
[[#include "calc.h]AT_SKEL_CC_IF([[h]])["
|
||||
@@ -500,6 +498,23 @@ AT_CHECK([cat stderr], 0, [expout])
|
||||
])
|
||||
|
||||
|
||||
# AT_CHECK_SPACES([FILE])
|
||||
# -----------------------
|
||||
# Make sure we did not introduce bad spaces. Checked here because all
|
||||
# the skeletons are (or should be) exercized here.
|
||||
m4_define([AT_CHECK_SPACES],
|
||||
[AT_CHECK([$PERL -ne '
|
||||
chomp;
|
||||
print "$.: {$_}\n"
|
||||
if (# No starting/ending empty lines.
|
||||
(eof || $. == 1) && /^\s*$/
|
||||
# No trailing space. FIXME: not ready for "maint".
|
||||
# || /\s$/
|
||||
)' $1
|
||||
])dnl
|
||||
])
|
||||
|
||||
|
||||
# AT_CHECK_CALC([BISON-OPTIONS])
|
||||
# ------------------------------
|
||||
# Start a testing chunk which compiles `calc' grammar with
|
||||
@@ -514,6 +529,8 @@ AT_BISON_OPTION_PUSHDEFS([$1])
|
||||
|
||||
AT_DATA_CALC_Y([$1])
|
||||
AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
|
||||
AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([cc], [c])])
|
||||
AT_DEFINES_IF([AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([hh], [h])])])
|
||||
|
||||
# Test the priorities.
|
||||
_AT_CHECK_CALC([$1],
|
||||
|
||||
+4
-1
@@ -35,7 +35,10 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1)
|
||||
dnl support is rapidly evolving, let's keep that information to be careful.
|
||||
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
|
||||
m4_pushdef([AT_LALR1_DIFF_CHECK],
|
||||
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||
[dnl We need diff -u, which is not portable.
|
||||
AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore])
|
||||
|
||||
AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
|
||||
AT_CHECK([[diff -u input-lalr.output input.output \
|
||||
| sed -n '/^@@/,$p' | sed 's/^ $//']],
|
||||
|
||||
+23
-6
@@ -126,8 +126,9 @@ AT_SETUP([Several parsers])
|
||||
|
||||
# AT_TEST([PREFIX], [DIRECTIVES])
|
||||
# -------------------------------
|
||||
# Generate and compile to *.o. Make sure there is no YY* nor yy* in
|
||||
# the header (but YYDEBUG and YYPARSE_PARAM).
|
||||
# Generate and compile to *.o. Make sure there is no (allowed) YY*
|
||||
# nor yy* identifiers in the header. Check that headers are
|
||||
# self-contained, and can be compiled by a C++ compiler.
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_BISON_OPTION_PUSHDEFS([%define api.prefix "$1_" $2])
|
||||
AT_DATA_GRAMMAR([$1.AT_SKEL_CC_IF([yy], [y])],
|
||||
@@ -161,20 +162,23 @@ exp:
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-d -o AT_SKEL_CC_IF([$1.cc $1.yy], [$1.c $1.y])])
|
||||
|
||||
# Check there is no 'yy' left.
|
||||
# C++ output relies on namespaces and still uses yy a lot.
|
||||
AT_SKEL_CC_IF([],
|
||||
[AT_CHECK([$EGREP yy $1.h], [1])])
|
||||
|
||||
# Ignore comments. Ignore YYPARSE_PARAM (obsolete) and
|
||||
# YYPUSH_MORE(_DEFINED)? (whose definition is constant).
|
||||
# Check there is not 'YY' left.
|
||||
# Ignore comments, YYPARSE_PARAM (obsolete), YYPUSH_MORE(_DEFINED)?
|
||||
# (constant definition), YY_\w+_INCLUDED (header guards).
|
||||
#
|
||||
# YYDEBUG (not renamed) can be read, but not changed.
|
||||
AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \
|
||||
-e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ |
|
||||
$EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?)|(defined|if) YYDEBUG']],
|
||||
$EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?|_[0-9A-Z_]+_INCLUDED)|(defined|if) YYDEBUG']],
|
||||
[1])
|
||||
AT_LANG_COMPILE([$1.o])
|
||||
|
||||
AT_LANG_COMPILE([$1.o])
|
||||
AT_CHECK([[echo "$1" >>expout]])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
@@ -239,6 +243,19 @@ AT_TEST([x8], [%define api.pure %define api.push-pull both])
|
||||
AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
||||
AT_CHECK([./parser], [0], [[expout]])
|
||||
|
||||
# Check that the headers are self-contained, and protected against
|
||||
# multiple inclusions. While at it, check they are sane for C++.
|
||||
for h in *.h *.hh
|
||||
do
|
||||
# No shell expansion with AT_DATA.
|
||||
cat >$h.cc <<EOF
|
||||
AT_DATA_SOURCE_PROLOGUE
|
||||
#include "$h"
|
||||
#include "$h"
|
||||
EOF
|
||||
AT_COMPILE_CXX([$h.o])
|
||||
done
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
+101
-4
@@ -1194,7 +1194,7 @@ AT_DATA([empty.y],
|
||||
start: '';
|
||||
start: '
|
||||
]])
|
||||
AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
|
||||
AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
|
||||
|
||||
AT_BISON_CHECK([empty.y], [1], [],
|
||||
[[empty.y:2.8-9: warning: empty character literal
|
||||
@@ -1209,7 +1209,7 @@ AT_DATA([two.y],
|
||||
start: 'ab';
|
||||
start: 'ab
|
||||
]])
|
||||
AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
|
||||
AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
|
||||
|
||||
AT_BISON_CHECK([two.y], [1], [],
|
||||
[[two.y:2.8-11: warning: extra characters in character literal
|
||||
@@ -1224,7 +1224,7 @@ AT_DATA([three.y],
|
||||
start: 'abc';
|
||||
start: 'abc
|
||||
]])
|
||||
AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
|
||||
AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
|
||||
|
||||
AT_BISON_CHECK([three.y], [1], [],
|
||||
[[three.y:2.8-12: warning: extra characters in character literal
|
||||
@@ -1253,7 +1253,7 @@ start: '\777' '\0' '\xfff' '\x0'
|
||||
# Beside we cannot even expect "echo '\0'" to output two characters
|
||||
# (well three with \n): at least Bash 3.2 converts the two-character
|
||||
# sequence "\0" into a single NUL character.
|
||||
AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|
||||
AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|
||||
|| exit 77]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [1], [],
|
||||
@@ -1369,3 +1369,100 @@ AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18])
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Stray $ or @. ##
|
||||
## -------------- ##
|
||||
|
||||
AT_SETUP([[Stray $ or @]])
|
||||
|
||||
# Give %printer and %destructor "<*> exp TOK" instead of "<*>" to
|
||||
# check that the warnings are reported once, not three times.
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]],
|
||||
[[%token TOK
|
||||
%destructor { $%; @%; } <*> exp TOK;
|
||||
%initial-action { $%; @%; };
|
||||
%printer { $%; @%; } <*> exp TOK;
|
||||
%%
|
||||
exp: TOK { $%; @%; $$ = $1; };
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input.y]], 0, [],
|
||||
[[input.y:10.19: warning: stray '$'
|
||||
input.y:10.23: warning: stray '@'
|
||||
input.y:11.19: warning: stray '$'
|
||||
input.y:11.23: warning: stray '@'
|
||||
input.y:12.19: warning: stray '$'
|
||||
input.y:12.23: warning: stray '@'
|
||||
input.y:14.19: warning: stray '$'
|
||||
input.y:14.23: warning: stray '@'
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Code injection. ##
|
||||
## ---------------- ##
|
||||
|
||||
|
||||
AT_SETUP([[Code injection]])
|
||||
|
||||
m4_pattern_allow([^m4_errprintn$])
|
||||
|
||||
# AT_TEST([MACRO])
|
||||
# ----------------
|
||||
# Try to have MACRO be run by bison.
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_DATA([[input.y]],
|
||||
[[%type <$1(DEAD %type)> exp
|
||||
%token <$1(DEAD %token)> a
|
||||
%initial-action
|
||||
{
|
||||
$$;
|
||||
$<$1(DEAD %initial-action)>$
|
||||
};
|
||||
%printer
|
||||
{
|
||||
$$
|
||||
$<$1(DEAD %printer)>$
|
||||
} <> <*>;
|
||||
%lex-param
|
||||
{
|
||||
$1(DEAD %lex-param)
|
||||
};
|
||||
%parse-param
|
||||
{
|
||||
$1(DEAD %parse-param)
|
||||
};
|
||||
%%
|
||||
exp:
|
||||
a a[last]
|
||||
{
|
||||
$$;
|
||||
$][1;
|
||||
$<$1(DEAD action 1)>$
|
||||
$<$1(DEAD action 2)>1
|
||||
$<$1(DEAD action 3)>last
|
||||
$<$1(DEAD action 4)>0
|
||||
;
|
||||
};
|
||||
]])
|
||||
|
||||
# FIXME: Provide a means to iterate over all the skeletons.
|
||||
AT_BISON_CHECK([[-d input.y]])
|
||||
AT_BISON_CHECK([[-d -S glr.c input.y]])
|
||||
AT_BISON_CHECK([[-d -S lalr1.cc input.y]])
|
||||
AT_BISON_CHECK([[-d -S glr.cc input.y]])
|
||||
AT_BISON_CHECK([[ -S lalr1.java input.y]])
|
||||
])
|
||||
|
||||
AT_TEST([m4_errprintn])
|
||||
AT_TEST([@:>@m4_errprintn])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
+4
-3
@@ -38,7 +38,7 @@ m4_define([m4_null_if],
|
||||
# Expect COUNT matches of the PERL-REGEXP in FILE. The file is
|
||||
# taken in "slurp" mode, i.e., one can match end-of-lines.
|
||||
m4_define([AT_MATCHES_CHECK],
|
||||
[AT_CHECK([perl -0777 -ne '
|
||||
[AT_CHECK([$PERL -0777 -ne '
|
||||
my $count = 0;
|
||||
s{$2}{ ++$count; "" }gem;
|
||||
printf "$count\n";' $1], [0], [$3
|
||||
@@ -333,7 +333,7 @@ static
|
||||
static size_t toknum = 0;
|
||||
int res;
|
||||
]AT_USE_LEX_ARGS[;
|
||||
assert (toknum < sizeof input);
|
||||
assert (toknum < sizeof input / sizeof input[0]);
|
||||
res = input[toknum++];
|
||||
]$2[;]AT_LOCATION_IF([[
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
|
||||
@@ -405,7 +405,8 @@ void
|
||||
public void yyerror (String s)
|
||||
{
|
||||
System.err.println (s);
|
||||
}]])])dnl
|
||||
}]])],
|
||||
[m4_fatal([$0: invalid language: ]AT_LANG)])dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
+87
-5
@@ -917,7 +917,6 @@ m4_define([AT_CHECK_DANCER],
|
||||
[AT_SETUP([Dancer $1])
|
||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||
_AT_DATA_DANCER_Y([$1])
|
||||
AT_BISON_CHECK([-o dancer.c dancer.y])
|
||||
AT_FULL_COMPILE([dancer])
|
||||
AT_PARSER_CHECK([./dancer], 1, [],
|
||||
[syntax error, unexpected ':'
|
||||
@@ -1002,7 +1001,6 @@ m4_define([AT_CHECK_EXPECT2],
|
||||
[AT_SETUP([Expecting two tokens $1])
|
||||
AT_BISON_OPTION_PUSHDEFS([$1])
|
||||
_AT_DATA_EXPECT2_Y([$1])
|
||||
AT_BISON_CHECK([-o expect2.c expect2.y])
|
||||
AT_FULL_COMPILE([expect2])
|
||||
AT_PARSER_CHECK([./expect2], 1, [],
|
||||
[syntax error, unexpected '+', expecting A or B
|
||||
@@ -1483,17 +1481,17 @@ AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]],
|
||||
|
||||
# Check number of default reductions in inconsistent states to be sure
|
||||
# syntax error is detected before unnecessary reductions are performed.
|
||||
AT_CHECK([[perl -0777 -ne 'print s/inconsistent default reduction//g;' \
|
||||
AT_CHECK([[$PERL -0777 -ne 'print s/inconsistent default reduction//g;' \
|
||||
< stdout.txt || exit 77]], [[0]], [[14]])
|
||||
|
||||
# Check number of default reductions in consistent states to be sure
|
||||
# it is performed before the syntax error is detected.
|
||||
AT_CHECK([[perl -0777 -ne 'print s/\bconsistent default reduction//g;' \
|
||||
AT_CHECK([[$PERL -0777 -ne 'print s/\bconsistent default reduction//g;' \
|
||||
< stdout.txt || exit 77]], [[0]], [[2]])
|
||||
|
||||
# Check number of reallocs to be sure reallocated memory isn't somehow
|
||||
# lost between LAC invocations.
|
||||
AT_CHECK([[perl -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
|
||||
AT_CHECK([[$PERL -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
|
||||
|| exit 77]], [[0]], [[3]])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
@@ -1585,3 +1583,87 @@ Stack now 0
|
||||
m4_popdef([AT_LAC_CHECK])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ---------------------- ##
|
||||
## Lex and parse params. ##
|
||||
## ---------------------- ##
|
||||
|
||||
# AT_TEST(SKELETON)
|
||||
# -----------------
|
||||
# Check that the identifier of the params is properly fetched
|
||||
# even when there are trailing blanks.
|
||||
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([[Lex and parse params: $1]])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%locations %skeleton $1])
|
||||
|
||||
## FIXME: Improve parsing of parse-param and use the generated
|
||||
## yyerror.
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%defines
|
||||
%locations
|
||||
%skeleton $1
|
||||
%union { int ival; }
|
||||
%parse-param { int x }
|
||||
// Spaces, tabs, and new lines.
|
||||
%parse-param { @&t@
|
||||
int y @&t@
|
||||
@&t@
|
||||
@&t@
|
||||
}
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
]AT_SKEL_CC_IF([], [[
|
||||
static
|
||||
void
|
||||
yyerror (int x, int y, const char *msg)
|
||||
{
|
||||
fprintf (stderr, "x: %d, y: %d, %s\n", x, y, msg);
|
||||
}]])[
|
||||
|
||||
]AT_YYLEX_DECLARE[
|
||||
%}
|
||||
|
||||
%%
|
||||
exp: 'a' { fprintf (stdout, "x: %d, y: %d\n", x, y); };
|
||||
%%
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
|
||||
]AT_SKEL_CC_IF(
|
||||
[AT_YYERROR_DEFINE
|
||||
|
||||
int
|
||||
yyparse (int x, int y)
|
||||
{
|
||||
yy::parser parser(x, y);
|
||||
return parser.parse ();
|
||||
}
|
||||
])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return !!yyparse(1, 2);
|
||||
}
|
||||
]])
|
||||
|
||||
AT_FULL_COMPILE([input])
|
||||
AT_CHECK([./input], 0, [[x: 1, y: 2
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_CLEANUP
|
||||
])
|
||||
|
||||
## FIXME: test Java, and iterate over skeletons.
|
||||
AT_TEST("yacc.c")
|
||||
AT_TEST("glr.c")
|
||||
AT_TEST("lalr1.cc")
|
||||
AT_TEST("glr.cc")
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
+1
-1
@@ -315,7 +315,7 @@ print '@output(@,@)', "\n";
|
||||
(print "garbage"x10, "\n") for (1..1000);
|
||||
print "${M4}_divert_pop(0)\n";
|
||||
]])
|
||||
AT_CHECK([[perl gen-skel.pl > skel.c || exit 77]])
|
||||
AT_CHECK([[$PERL gen-skel.pl > skel.c || exit 77]])
|
||||
|
||||
AT_DATA([[input.y]],
|
||||
[[%skeleton "./skel.c"
|
||||
|
||||
+94
-29
@@ -27,6 +27,11 @@ AT_BANNER([[User Actions.]])
|
||||
# errors.
|
||||
m4_define([AT_SYNCLINES_COMPILE],
|
||||
[AT_CHECK([$CC $CFLAGS $CPPFLAGS -c $1], [ignore], [], [stderr])
|
||||
|
||||
# Transform stderr into something like this:
|
||||
#
|
||||
# input.y:4: #error "4"
|
||||
#
|
||||
# In case GCC displays column information, strip it down.
|
||||
#
|
||||
# input.y:4:2: #error "4" or
|
||||
@@ -42,6 +47,11 @@ m4_define([AT_SYNCLINES_COMPILE],
|
||||
# =>
|
||||
# input.y:4: #error "8"
|
||||
#
|
||||
# The message may include a caret-error:
|
||||
#
|
||||
# input.y:1:2: error: #error "1"
|
||||
# #error "1"
|
||||
# ^
|
||||
#
|
||||
# And possibly distcc adds its bits.
|
||||
#
|
||||
@@ -54,19 +64,22 @@ m4_define([AT_SYNCLINES_COMPILE],
|
||||
# distcc[35882] (dcc_connect_by_name) ERROR: failed to look up host "chrisimac": Unknown host
|
||||
# distcc[35882] Warning: failed to distribute input.c to chrisimac/4, running locally instead
|
||||
|
||||
AT_CHECK([[sed -e '/^distcc\[[0-9]*\] /d' \
|
||||
-e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' \
|
||||
-e 's/^\([^:]*:[^:]*:\)[^@%:@]*\( @%:@error\)/\1\2/' \
|
||||
-e "/^[^:]*: In function '[^\']*':$/d" \
|
||||
stderr]],
|
||||
0, [stdout])
|
||||
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
|
||||
s/^distcc\[\d+\] .*\n//gm;
|
||||
s/^([^:]+:\d+)[.:][^:]+:(.+)$/$][1:$][2/gm;
|
||||
s/^([^:]+:\d+):[^#]*( #error)/$][1:$][2/gm;
|
||||
s/^[^:]*: In function '[^']+':\n//gm;
|
||||
s/^\ +#error.*\n\ *\^\n//gm;
|
||||
EOF
|
||||
]],
|
||||
0, [stdout])
|
||||
])
|
||||
|
||||
# AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
|
||||
# -----------------------------------------
|
||||
# AT_TEST(TITLE, INPUT, ERROR-MSG)
|
||||
# --------------------------------
|
||||
# Check that compiling the parser produced from INPUT cause GCC
|
||||
# to issue ERROR-MSG.
|
||||
m4_define([AT_TEST_SYNCLINE],
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([$1])
|
||||
AT_BISON_OPTION_PUSHDEFS
|
||||
# It seems impossible to find a generic scheme to check the location
|
||||
@@ -103,12 +116,12 @@ AT_CLEANUP
|
||||
])
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Prologue synch line. ##
|
||||
## --------------------- ##
|
||||
## ------------------- ##
|
||||
## Prologue syncline. ##
|
||||
## ------------------- ##
|
||||
|
||||
|
||||
AT_TEST_SYNCLINE([Prologue synch line],
|
||||
AT_TEST([Prologue syncline],
|
||||
[[%{
|
||||
#error "2"
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
@@ -122,11 +135,11 @@ exp: '0';
|
||||
])
|
||||
|
||||
|
||||
## ------------------- ##
|
||||
## %union synch line. ##
|
||||
## ------------------- ##
|
||||
## ----------------- ##
|
||||
## %union syncline. ##
|
||||
## ----------------- ##
|
||||
|
||||
AT_TEST_SYNCLINE([%union synch line],
|
||||
AT_TEST([%union syncline],
|
||||
[[%union {
|
||||
#error "2"
|
||||
char dummy;
|
||||
@@ -143,11 +156,11 @@ exp: '0';
|
||||
])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Postprologue synch line. ##
|
||||
## ------------------------- ##
|
||||
## ----------------------- ##
|
||||
## Postprologue syncline. ##
|
||||
## ----------------------- ##
|
||||
|
||||
AT_TEST_SYNCLINE([Postprologue synch line],
|
||||
AT_TEST([Postprologue syncline],
|
||||
[[%{
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
@@ -167,11 +180,11 @@ exp: '0';
|
||||
])
|
||||
|
||||
|
||||
## ------------------- ##
|
||||
## Action synch line. ##
|
||||
## ------------------- ##
|
||||
## ----------------- ##
|
||||
## Action syncline. ##
|
||||
## ----------------- ##
|
||||
|
||||
AT_TEST_SYNCLINE([Action synch line],
|
||||
AT_TEST([Action syncline],
|
||||
[[%{
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
@@ -186,11 +199,11 @@ exp:
|
||||
])
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Epilogue synch line. ##
|
||||
## --------------------- ##
|
||||
## ------------------- ##
|
||||
## Epilogue syncline. ##
|
||||
## ------------------- ##
|
||||
|
||||
AT_TEST_SYNCLINE([Epilogue synch line],
|
||||
AT_TEST([Epilogue syncline],
|
||||
[[%{
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
@@ -202,3 +215,55 @@ exp: '0';
|
||||
]],
|
||||
[input.y:8: #error "8"
|
||||
])
|
||||
|
||||
## -------------------- ##
|
||||
## %code top syncline. ##
|
||||
## -------------------- ##
|
||||
|
||||
AT_TEST([%code top syncline],
|
||||
[[%code top {
|
||||
#error "2"
|
||||
}
|
||||
%{
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
%}
|
||||
%%
|
||||
exp: '0';
|
||||
%%
|
||||
]],
|
||||
[input.y:2: #error "2"
|
||||
])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
## ----------- ##
|
||||
## %no-lines. ##
|
||||
## ----------- ##
|
||||
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([%no-lines])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%skeleton "$1" %defines])
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[%skeleton "$1" %defines
|
||||
%{
|
||||
]AT_YYERROR_DECLARE_EXTERN[
|
||||
]AT_YYLEX_DECLARE_EXTERN[
|
||||
%}
|
||||
%%
|
||||
exp: '0'
|
||||
])
|
||||
AT_BISON_CHECK([--no-lines -o input.AT_SKEL_CC_IF([cc], [c]) -d input.y])
|
||||
AT_CHECK([[grep '#line' ]AT_SKEL_CC_IF([*.cc *.hh], [*.c *.h])], 1)
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_CLEANUP
|
||||
])
|
||||
|
||||
AT_TEST([yacc.c])
|
||||
AT_TEST([glr.c])
|
||||
AT_TEST([lalr1.cc])
|
||||
AT_TEST([glr.cc])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
+37
-31
@@ -125,7 +125,7 @@ EOF
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
mv stdout $1
|
||||
])
|
||||
|
||||
@@ -214,7 +214,7 @@ main (void)
|
||||
EOF
|
||||
]])
|
||||
|
||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
mv stdout $1
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
])
|
||||
@@ -350,7 +350,7 @@ main (void)
|
||||
EOF
|
||||
]])
|
||||
|
||||
AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
AT_CHECK([$PERL -w ./gengram.pl $2 || exit 77], 0, [stdout])
|
||||
mv stdout $1
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
])
|
||||
@@ -412,38 +412,44 @@ yylex (void)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Return argv[1] as an int. */
|
||||
static int
|
||||
get_args (int argc, const char **argv)
|
||||
{
|
||||
int res;
|
||||
char *endp;
|
||||
assert (argc == 2);
|
||||
res = strtol (argv[1], &endp, 10);
|
||||
assert (argv[1] != endp);
|
||||
assert (0 <= res);
|
||||
assert (res <= INT_MAX);
|
||||
assert (errno != ERANGE);
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
char *endp;
|
||||
YYSTYPE yylval_init;
|
||||
assert (argc == 2);
|
||||
yylval_init = strtol (argv[1], &endp, 10);
|
||||
assert (argv[1] != endp);
|
||||
assert (0 <= yylval_init);
|
||||
assert (yylval_init <= INT_MAX);
|
||||
assert (errno != ERANGE);
|
||||
yydebug = 1;
|
||||
{
|
||||
int count;
|
||||
int status;
|
||||
]m4_bmatch([$2], [%push-],
|
||||
[[ yypstate *ps = yypstate_new ();
|
||||
]])[ for (count = 0; count < 2; ++count)
|
||||
{
|
||||
int new_status;
|
||||
yylval = yylval_init;
|
||||
]m4_bmatch([$2], [%push-],
|
||||
[[ new_status = yypull_parse (ps);
|
||||
]],
|
||||
[[ new_status = yyparse ();
|
||||
]])[ assert (0 <= count || new_status == status);
|
||||
YYSTYPE yylval_init = get_args (argc, argv);
|
||||
int status;
|
||||
int count;
|
||||
]m4_bmatch([$2], [api.push-pull both],
|
||||
[[ yypstate *ps = yypstate_new ();
|
||||
]])[ yydebug = 1;
|
||||
for (count = 0; count < 2; ++count)
|
||||
{
|
||||
int new_status;
|
||||
yylval = yylval_init;
|
||||
new_status = ]m4_bmatch([$2], [api.push-pull both],
|
||||
[[yypull_parse (ps)]],
|
||||
[[yyparse ()]])[;
|
||||
if (count == 0)
|
||||
status = new_status;
|
||||
}
|
||||
]m4_bmatch([$2], [%push-],
|
||||
[[ yypstate_delete (ps);
|
||||
]])[ return status;
|
||||
}
|
||||
else
|
||||
assert (new_status == status);
|
||||
}]m4_bmatch([$2], [api.push-pull both],[[
|
||||
yypstate_delete (ps);]])[
|
||||
return status;
|
||||
}
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS([$2])
|
||||
|
||||
Reference in New Issue
Block a user