Merge remote-tracking branch 'origin/maint'

* origin/maint:
  tests: do not output m4 set up.
  tests: use the generic yyerror function.
  tests: use assert instead of plain abort.
  tests: improve the generic yylex implementation.
  tests: generalize the compilation macros.
  tests: fix confusion between api.prefix and name-prefix.
  maint: gitignores.
  yacc: work around the ylwrap limitation.

Conflicts:
	NEWS
	tests/local.at
This commit is contained in:
Akim Demaille
2012-06-26 16:43:22 +02:00
16 changed files with 269 additions and 232 deletions

112
NEWS
View File

@@ -113,19 +113,33 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?] * Noteworthy changes in release ?.? (????-??-??) [?]
** Future changes: ** Future changes
The next major release will drop support for generating parsers in K&R C, The next major release of Bison will drop support for the following
and remove the definitions of yystype and yyltype (removal announced since deprecated features. Please report disagreements to bug-bison@gnu.org.
Bison 1.875). YYPARSE_PARAM and YYLEX_PARAM, which were deprecated in
favor of %parse-param and %lex-param (introduced in Bison 1.875 too), will
no longer be supported.
** The generated header is included (yacc.c) *** K&C parsers
Support for generating parsers in K&R C will be removed. Parsers
generated for C supprt ISO C90, and are tested with ISO C99 and ISO C11
compilers.
*** Deprecated features
The definitions of yystype and yyltype will be removed, as announced since
Bison 1.875. Use YYSTYPE and YYLTYPE only.
YYPARSE_PARAM and YYLEX_PARAM, which were deprecated in favor of
%parse-param and %lex-param (introduced in Bison 1.875), will no longer be
supported.
*** The generated header will be included (yacc.c)
Instead of duplicating the content of the generated header (definition of Instead of duplicating the content of the generated header (definition of
YYSTYPE, yyltype etc.), the generated parser now includes it, as was YYSTYPE, yyparse declaration etc.), the generated parser will include it,
already the case for GLR or C++ parsers. as is already the case for GLR or C++ parsers. This change is deferred
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
it.
** Headers (yacc.c, glr.c, glr.cc) ** Headers (yacc.c, glr.c, glr.cc)
@@ -191,10 +205,10 @@ GNU Bison NEWS
The header files such as "parser.hh", "location.hh", etc. used a constant The header files such as "parser.hh", "location.hh", etc. used a constant
name for preprocessor guards, for instance: name for preprocessor guards, for instance:
#ifndef BISON_LOCATION_HH #ifndef BISON_LOCATION_HH
# define BISON_LOCATION_HH # define BISON_LOCATION_HH
... ...
#endif // !BISON_LOCATION_HH #endif // !BISON_LOCATION_HH
The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
case characters are converted to upper case, and series of case characters are converted to upper case, and series of
@@ -202,10 +216,10 @@ GNU Bison NEWS
With "bison -o lang++/parser.cc", "location.hh" would now include: With "bison -o lang++/parser.cc", "location.hh" would now include:
#ifndef YY_LANG_LOCATION_HH #ifndef YY_LANG_LOCATION_HH
# define YY_LANG_LOCATION_HH # define YY_LANG_LOCATION_HH
... ...
#endif // !YY_LANG_LOCATION_HH #endif // !YY_LANG_LOCATION_HH
*** C++ locations: *** C++ locations:
@@ -436,33 +450,33 @@ GNU Bison NEWS
to use it. If, for instance, your location structure has "first" to use it. If, for instance, your location structure has "first"
and "last" members, instead of and "last" members, instead of
# define YYLLOC_DEFAULT(Current, Rhs, N) \ # define YYLLOC_DEFAULT(Current, Rhs, N) \
do \ do \
if (N) \ if (N) \
{ \ { \
(Current).first = (Rhs)[1].location.first; \ (Current).first = (Rhs)[1].location.first; \
(Current).last = (Rhs)[N].location.last; \ (Current).last = (Rhs)[N].location.last; \
} \ } \
else \ else \
{ \ { \
(Current).first = (Current).last = (Rhs)[0].location.last; \ (Current).first = (Current).last = (Rhs)[0].location.last; \
} \ } \
while (false) while (false)
use: use:
# define YYLLOC_DEFAULT(Current, Rhs, N) \ # define YYLLOC_DEFAULT(Current, Rhs, N) \
do \ do \
if (N) \ if (N) \
{ \ { \
(Current).first = YYRHSLOC (Rhs, 1).first; \ (Current).first = YYRHSLOC (Rhs, 1).first; \
(Current).last = YYRHSLOC (Rhs, N).last; \ (Current).last = YYRHSLOC (Rhs, N).last; \
} \ } \
else \ else \
{ \ { \
(Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \ (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
} \ } \
while (false) while (false)
** YYLLOC_DEFAULT in C++: ** YYLLOC_DEFAULT in C++:
@@ -1462,9 +1476,9 @@ GNU Bison NEWS
** Incorrect "Token not used" ** Incorrect "Token not used"
On a grammar such as On a grammar such as
%token useless useful %token useless useful
%% %%
exp: '0' %prec useful; exp: '0' %prec useful;
where a token was used to set the precedence of the last rule, where a token was used to set the precedence of the last rule,
bison reported both "useful" and "useless" as useless tokens. bison reported both "useful" and "useless" as useless tokens.
@@ -1483,9 +1497,9 @@ GNU Bison NEWS
the user symbol is used in the reports, the graphs, and the verbose the user symbol is used in the reports, the graphs, and the verbose
error messages instead of "$end", which remains being the default. error messages instead of "$end", which remains being the default.
For instance For instance
%token MYEOF 0 %token MYEOF 0
or or
%token MYEOF 0 "end of file" %token MYEOF 0 "end of file"
** Semantic parser ** Semantic parser
This old option, which has been broken for ages, is removed. This old option, which has been broken for ages, is removed.
@@ -1521,9 +1535,9 @@ GNU Bison NEWS
Previous versions don't complain when there is a type clash on Previous versions don't complain when there is a type clash on
the default action if the rule has a mid-rule action, such as in: the default action if the rule has a mid-rule action, such as in:
%type <foo> bar %type <foo> bar
%% %%
bar: '0' {} '0'; bar: '0' {} '0';
This is fixed. This is fixed.

4
build-aux/snippet/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
/_Noreturn.h
/arg-nonnull.h
/c++defs.h
/warn-on-use.h

View File

@@ -229,6 +229,8 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
# b4_declare_yyparse_push_ # b4_declare_yyparse_push_
# ------------------------ # ------------------------
# Declaration of yyparse (and dependencies) when using the push parser
# (including in pull mode).
m4_define([b4_declare_yyparse_push_], m4_define([b4_declare_yyparse_push_],
[[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; [[typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
enum { YYPUSH_MORE = 4 }; enum { YYPUSH_MORE = 4 };
@@ -274,12 +276,14 @@ m4_define([b4_declare_yyparse],
# Declaration that might either go into the header (if --defines) # Declaration that might either go into the header (if --defines)
# or open coded in the parser body. # or open coded in the parser body.
m4_define([b4_shared_declarations], m4_define([b4_shared_declarations],
[b4_declare_yydebug[ [b4_cpp_guard_open([b4_spec_defines_file])[
]b4_declare_yydebug[
]b4_percent_code_get([[requires]])[ ]b4_percent_code_get([[requires]])[
]b4_token_enums_defines(b4_tokens)[ ]b4_token_enums_defines(b4_tokens)[
]b4_declare_yylstype[ ]b4_declare_yylstype[
]b4_declare_yyparse[ ]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[]dnl ]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
]) ])
## -------------- ## ## -------------- ##
@@ -338,8 +342,9 @@ m4_if(b4_prefix, [yy], [],
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], /* In a future release of Bison, this section will be replaced
[b4_shared_declarations])[ by #include "@basename(]b4_spec_defines_file[@)". */
]b4_shared_declarations[
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
]b4_user_post_prologue ]b4_user_post_prologue
@@ -1997,9 +2002,7 @@ b4_defines_if(
[@output(b4_spec_defines_file@)@ [@output(b4_spec_defines_file@)@
b4_copyright([Bison interface for Yacc-like parsers in C])[ b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[ ]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]])dnl b4_defines_if ]])dnl b4_defines_if
m4_divert_pop(0) m4_divert_pop(0)
m4_popdef([b4_copyright_years]) m4_popdef([b4_copyright_years])

3
lib/glthread/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/lock.c
/lock.h
/threadlib.c

View File

@@ -1009,4 +1009,3 @@ default_tagless_code_props_set (code_props_type kind, code_props const *code)
} }
default_tagless_code_props[kind] = *code; default_tagless_code_props[kind] = *code;
} }

View File

@@ -174,11 +174,12 @@ AT_CLEANUP
## Printers and Destructors. ## ## Printers and Destructors. ##
## -------------------------- ## ## -------------------------- ##
# _AT_CHECK_PRINTER_AND_DESTRUCTOR($1, $2, $3, $4, BISON-DIRECTIVE, UNION-FLAG) # _AT_CHECK_PRINTER_AND_DESTRUCTOR($1, $2, $3, $4,
# ----------------------------------------------------------------------------- # BISON-DIRECTIVE, UNION-FLAG)
# -------------------------------------------------------------
m4_define([_AT_CHECK_PRINTER_AND_DESTRUCTOR], m4_define([_AT_CHECK_PRINTER_AND_DESTRUCTOR],
[# Make sure complex $n work. [# Make sure complex $n work.
m4_if([$1$2$3], $[1]$[2]$[3], [], m4_if([$1$2$3$4], $[1]$[2]$[3]$[4], [],
[m4_fatal([$0: Invalid arguments: $@])])dnl [m4_fatal([$0: Invalid arguments: $@])])dnl
# Be sure to pass all the %directives to this macro to have correct # Be sure to pass all the %directives to this macro to have correct
@@ -193,13 +194,16 @@ AT_DATA_GRAMMAR([[input.y]],
#define YYINITDEPTH 10 #define YYINITDEPTH 10
#define YYMAXDEPTH 10 #define YYMAXDEPTH 10
]AT_LALR1_CC_IF( #define RANGE(Location) ]AT_LALR1_CC_IF([(Location).begin.line, (Location).end.line],
[#define RANGE(Location) (Location).begin.line, (Location).end.line], [(Location).first_line, (Location).last_line])[
[#define RANGE(Location) (Location).first_line, (Location).last_line])
[}
$5] /* Display the symbol type Symbol. */
m4_ifval([$6], [%union #define V(Symbol, Value, Location, Sep) \
fprintf (stderr, #Symbol " (%d@%d-%d)" Sep, Value, RANGE(Location))
}
$5
]m4_ifval([$6], [%union
{ {
int ival; int ival;
}]) }])
@@ -221,28 +225,28 @@ AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
input line thing 'x' 'y' input line thing 'x' 'y'
%destructor %destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input input
%destructor %destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line line
%destructor %destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing thing
%destructor %destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x' 'x'
%destructor %destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y' 'y'
%token END 0 %token END 0
%destructor %destructor
{ printf ("Freeing token END (%d@%d-%d)\n", $$, RANGE (@$)); } { fprintf (stderr, "Freeing token END (%d@%d-%d)\n", $$, RANGE (@$)); }
END END
%% %%
@@ -257,14 +261,15 @@ input:
/* Nothing. */ /* Nothing. */
{ {
$$ = 0; $$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$)); V(input, $$, @$, ": /* Nothing */\n");
} }
| line input /* Right recursive to load the stack so that popping at | line input /* Right recursive to load the stack so that popping at
END can be exercised. */ END can be exercised. */
{ {
$$ = 2; $$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n", V(input, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2)); V(line, $1, @1, " ");
V(input, $2, @2, "\n");
} }
; ;
@@ -272,28 +277,36 @@ line:
thing thing thing ';' thing thing thing ';'
{ {
$$ = $1; $$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n", V(line, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), V(thing, $1, @1, " ");
$3, RANGE (@3), $4, RANGE (@4)); V(thing, $2, @2, " ");
V(thing, $3, @3, " ");
V(;, $4, @4, "\n");
} }
| '(' thing thing ')' | '(' thing thing ')'
{ {
$$ = $1; $$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n", V(line, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), V('(', $1, @1, " ");
$3, RANGE (@3), $4, RANGE (@4)); V(thing, $2, @2, " ");
V(thing, $3, @3, " ");
V(')', $4, @4, "\n");
} }
| '(' thing ')' | '(' thing ')'
{ {
$$ = $1; $$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n", V(line, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3)); V('(', $1, @1, " ");
V(thing, $2, @2, " ");
V(')', $3, @3, "\n");
} }
| '(' error ')' | '(' error ')'
{ {
$$ = -1; $$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n", V(line, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3)); V('(', $1, @1, " ");
fprintf (stderr, "error (@%d-%d) ", RANGE(@2));
V(')', $3, @3, "\n");
} }
; ;
@@ -301,14 +314,16 @@ thing:
'x' 'x'
{ {
$$ = $1; $$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n", V(thing, $$, @$, ": ");
$$, RANGE (@$), $1, RANGE (@1)); V('x', $1, @1, "\n");
} }
; ;
%% %%
/* Alias to ARGV[1]. */ /* Alias to ARGV[1]. */
const char *source = YY_NULL; const char *source = YY_NULL;
]AT_YYERROR_DEFINE[
static static
]AT_YYLEX_PROTOTYPE[ ]AT_YYLEX_PROTOTYPE[
{ {
@@ -316,33 +331,18 @@ static
int c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++; int c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++;
/* As in BASIC, line numbers go from 10 to 10. */ /* As in BASIC, line numbers go from 10 to 10. */
]AT_LALR1_CC_IF( ]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = 10 * c;
[ AT_LOC.begin.line = AT_LOC.begin.column = 10 * c; ]AT_LOC_LAST_LINE[ = ]AT_LOC_LAST_COLUMN[ = ]AT_LOC_FIRST_LINE[ + 9;
AT_LOC.end.line = AT_LOC.end.column = AT_LOC.begin.line + 9; assert (0 <= c && c <= strlen (source));
],
[ AT_LOC.first_line = AT_LOC.first_column = 10 * c;
AT_LOC.last_line = AT_LOC.last_column = AT_LOC.first_line + 9;
])[
if (! (0 <= c && c <= strlen (source)))
abort ();
if (source[c]) if (source[c])
printf ("sending: '%c'", source[c]); fprintf (stderr, "sending: '%c'", source[c]);
else else
printf ("sending: END"); fprintf (stderr, "sending: END");
printf (" (%d@%d-%d)\n", c, RANGE (]AT_LOC[)); fprintf (stderr, " (%d@%d-%d)\n", c, RANGE (]AT_LOC[));
return source[c]; return source[c];
} }
]AT_LALR1_CC_IF( ]AT_LALR1_CC_IF(
[/* A C++ error reporting function. */ [static bool yydebug;
void
yy::parser::error (const location& l, const std::string& m)
{
printf ("%d-%d: %s\n", RANGE (l), m.c_str());
}
static bool yydebug;
int int
yyparse () yyparse ()
{ {
@@ -350,12 +350,7 @@ yyparse ()
parser.set_debug_level (yydebug); parser.set_debug_level (yydebug);
return parser.parse (); return parser.parse ();
} }
], ])[
[static void
yyerror (const char *msg)
{
printf ("%d-%d: %s\n", RANGE (yylloc), msg);
}])[
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
@@ -367,9 +362,9 @@ main (int argc, const char *argv[])
status = yyparse (); status = yyparse ();
switch (status) switch (status)
{ {
case 0: printf ("Successful parse.\n"); break; case 0: fprintf (stderr, "Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break; case 1: fprintf (stderr, "Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break; default: fprintf (stderr, "Parsing FAILED (status %d).\n", status); break;
} }
return status; return status;
} }
@@ -383,7 +378,7 @@ AT_FULL_COMPILE([input])
# I.e., epsilon-reductions, as in "(x)" which ends by reducing # I.e., epsilon-reductions, as in "(x)" which ends by reducing
# an empty "line" nterm. # an empty "line" nterm.
# FIXME: This location is not satisfying. Depend on the lookahead? # FIXME: This location is not satisfying. Depend on the lookahead?
AT_PARSER_CHECK([./input '(x)'], 0, AT_PARSER_CHECK([./input '(x)'], 0, [],
[[sending: '(' (0@0-9) [[sending: '(' (0@0-9)
sending: 'x' (1@10-19) sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19) thing (1@10-19): 'x' (1@10-19)
@@ -402,10 +397,10 @@ Successful parse.
# --------------------------------- # ---------------------------------
# '(y)' is an error, but can be recovered from. But what's the location # '(y)' is an error, but can be recovered from. But what's the location
# of the error itself ('y'), and of the resulting reduction ('(error)'). # of the error itself ('y'), and of the resulting reduction ('(error)').
AT_PARSER_CHECK([./input '(y)'], 0, AT_PARSER_CHECK([./input '(y)'], 0, [],
[[sending: '(' (0@0-9) [[sending: '(' (0@0-9)
sending: 'y' (1@10-19) sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x' 10.10-19.18: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19) Freeing token 'y' (1@10-19)
sending: ')' (2@20-29) sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29) line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
@@ -432,14 +427,14 @@ Successful parse.
# '(', 'x', ')', # '(', 'x', ')',
# '(', 'x', ')', # '(', 'x', ')',
# 'y' # 'y'
AT_PARSER_CHECK([./input '(xxxxx)(x)(x)y'], 1, AT_PARSER_CHECK([./input '(xxxxx)(x)(x)y'], 1, [],
[[sending: '(' (0@0-9) [[sending: '(' (0@0-9)
sending: 'x' (1@10-19) sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19) thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29) sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29) thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39) sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')' 30.30-39.38: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29) Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19) Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39) Freeing token 'x' (3@30-39)
@@ -464,7 +459,7 @@ input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129) input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129) input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129) input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting END 130.130-139.138: syntax error, unexpected 'y', expecting END
Freeing nterm input (2@0-129) Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139) Freeing token 'y' (13@130-139)
Parsing FAILED. Parsing FAILED.
@@ -480,7 +475,7 @@ Parsing FAILED.
# '(', 'x', ')', # '(', 'x', ')',
# '(', 'x', ')', # '(', 'x', ')',
# 'x' # 'x'
AT_PARSER_CHECK([./input '(x)(x)x'], 1, AT_PARSER_CHECK([./input '(x)(x)x'], 1, [],
[[sending: '(' (0@0-9) [[sending: '(' (0@0-9)
sending: 'x' (1@10-19) sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19) thing (1@10-19): 'x' (1@10-19)
@@ -494,7 +489,7 @@ line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
sending: 'x' (6@60-69) sending: 'x' (6@60-69)
thing (6@60-69): 'x' (6@60-69) thing (6@60-69): 'x' (6@60-69)
sending: END (7@70-79) sending: END (7@70-79)
70-79: syntax error, unexpected END, expecting 'x' 70.70-79.78: syntax error, unexpected END, expecting 'x'
Freeing nterm thing (6@60-69) Freeing nterm thing (6@60-69)
Freeing nterm line (3@30-59) Freeing nterm line (3@30-59)
Freeing nterm line (0@0-29) Freeing nterm line (0@0-29)
@@ -508,7 +503,7 @@ Parsing FAILED.
# Upon stack overflow, all symbols on the stack should be destroyed. # Upon stack overflow, all symbols on the stack should be destroyed.
# Only check for yacc.c. # Only check for yacc.c.
AT_YACC_IF([ AT_YACC_IF([
AT_PARSER_CHECK([./input '(x)(x)(x)(x)(x)(x)(x)'], 2, AT_PARSER_CHECK([./input '(x)(x)(x)(x)(x)(x)(x)'], 2, [],
[[sending: '(' (0@0-9) [[sending: '(' (0@0-9)
sending: 'x' (1@10-19) sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19) thing (1@10-19): 'x' (1@10-19)
@@ -543,7 +538,7 @@ sending: '(' (18@180-189)
sending: 'x' (19@190-199) sending: 'x' (19@190-199)
thing (19@190-199): 'x' (19@190-199) thing (19@190-199): 'x' (19@190-199)
sending: ')' (20@200-209) sending: ')' (20@200-209)
200-209: memory exhausted 200.200-209.208: memory exhausted
Freeing nterm thing (19@190-199) Freeing nterm thing (19@190-199)
Freeing nterm line (15@150-179) Freeing nterm line (15@150-179)
Freeing nterm line (12@120-149) Freeing nterm line (12@120-149)
@@ -1202,7 +1197,7 @@ AT_DATA_GRAMMAR([[input.y]],
%debug %debug
]$1[ { ]$1[ {
printf ("%d\n", @$.first_line); fprintf (stderr, "%d\n", @$.first_line);
} ]m4_if($1, [%initial-action], [], [[start]])[ } ]m4_if($1, [%initial-action], [], [[start]])[
%% %%

View File

@@ -45,7 +45,7 @@ m4_define([_AT_DATA_CALC_Y],
[m4_fatal([$0: Invalid arguments: $@])])dnl [m4_fatal([$0: Invalid arguments: $@])])dnl
m4_pushdef([AT_CALC_MAIN], m4_pushdef([AT_CALC_MAIN],
[#include <stdlib.h> /* abort */ [#include <assert.h>
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#else #else
@@ -98,10 +98,8 @@ main (int argc, const char **argv)
status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[); status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[);
if (fclose (input)) if (fclose (input))
perror ("fclose"); perror ("fclose");
if (global_result != result) assert (global_result == result);
abort (); assert (global_count == count);
if (global_count != count)
abort ();
return status; return status;
} }
]]) ]])

View File

@@ -56,6 +56,7 @@ AT_DATA_GRAMMAR([input.y],
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
#define YYERROR_VERBOSE 1 #define YYERROR_VERBOSE 1
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
@@ -66,8 +67,7 @@ static int
yylex (void) yylex (void)
{ {
static size_t toknum; static size_t toknum;
if (! (toknum <= strlen (input))) assert (toknum <= strlen (input));
abort ();
return input[toknum++]; return input[toknum++];
} }

View File

@@ -122,12 +122,12 @@ declarator : ID
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <assert.h>
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
if (argc != 2) assert (argc == 2);
abort ();
if (!freopen (argv[1], "r", stdin)) if (!freopen (argv[1], "r", stdin))
return 3; return 3;
return yyparse (); return yyparse ();
@@ -152,8 +152,7 @@ main (int argc, char **argv)
while (1) while (1)
{ {
if (feof (stdin)) assert (!feof (stdin));
abort ();
c = getchar (); c = getchar ();
switch (c) switch (c)
{ {
@@ -182,8 +181,7 @@ main (int argc, char **argv)
{ {
buffer[i++] = c; buffer[i++] = c;
colNum += 1; colNum += 1;
if (i == sizeof buffer - 1) assert (i != sizeof buffer - 1);
abort ();
c = getchar (); c = getchar ();
} }
while (isalnum (c) || c == '_'); while (isalnum (c) || c == '_');

View File

@@ -32,6 +32,7 @@ AT_DATA_GRAMMAR([glr-regr1.y],
%{ %{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#define YYSTYPE int #define YYSTYPE int
static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1); static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
@@ -80,8 +81,7 @@ yylex (void)
for (;;) for (;;)
{ {
int ch; int ch;
if (feof (stdin)) assert (!feof (stdin));
abort ();
ch = getchar (); ch = getchar ();
if (ch == EOF) if (ch == EOF)
return 0; return 0;
@@ -128,6 +128,7 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
%} %}
@@ -177,8 +178,7 @@ yylex (void)
{ {
char buf[50]; char buf[50];
char *s; char *s;
if (feof (stdin)) assert (!feof (stdin));
abort ();
switch (fscanf (input, " %1[a-z,]", buf)) switch (fscanf (input, " %1[a-z,]", buf))
{ {
case 1: case 1:
@@ -190,8 +190,7 @@ yylex (void)
} }
if (fscanf (input, "%49s", buf) != 1) if (fscanf (input, "%49s", buf) != 1)
return 0; return 0;
if (sizeof buf - 1 <= strlen (buf)) assert (strlen (buf) < sizeof buf - 1);
abort ();
s = (char *) malloc (strlen (buf) + 1); s = (char *) malloc (strlen (buf) + 1);
strcpy (s, buf); strcpy (s, buf);
yylval = s; yylval = s;
@@ -242,6 +241,7 @@ AT_DATA_GRAMMAR([glr-regr3.y],
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <assert.h>
static int MergeRule (int x0, int x1); static int MergeRule (int x0, int x1);
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
@@ -302,8 +302,7 @@ int T[] = { T1, T2, T3, T4 };
int yylex (void) int yylex (void)
{ {
char inp[3]; char inp[3];
if (feof (stdin)) assert (!feof (stdin));
abort ();
if (fscanf (input, "%2s", inp) == EOF) if (fscanf (input, "%2s", inp) == EOF)
return 0; return 0;
switch (inp[0]) switch (inp[0])
@@ -935,6 +934,7 @@ AT_DATA_GRAMMAR([glr-regr12.y],
%{ %{
# include <stdlib.h> # include <stdlib.h>
# include <assert.h>
static int merge (YYSTYPE, YYSTYPE); static int merge (YYSTYPE, YYSTYPE);
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
@@ -1003,8 +1003,7 @@ yylex (void)
{ {
static int const input[] = { PARENT_RHS_AFTER, 0 }; static int const input[] = { PARENT_RHS_AFTER, 0 };
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input / sizeof *input)) assert (toknum < sizeof input / sizeof *input);
abort ();
if (input[toknum] == PARENT_RHS_AFTER) if (input[toknum] == PARENT_RHS_AFTER)
parent_rhs_after_value = 1; parent_rhs_after_value = 1;
return input[toknum++]; return input[toknum++];
@@ -1064,6 +1063,7 @@ AT_DATA_GRAMMAR([glr-regr13.y],
%{ %{
#include <stdio.h> #include <stdio.h>
#include <assert.h>
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
static void print_lookahead (char const *); static void print_lookahead (char const *);
@@ -1122,8 +1122,7 @@ yylex (void)
{ {
static char const input[] = "ab"; static char const input[] = "ab";
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input)) assert (toknum < sizeof input);
abort ();
yylloc.first_line = yylloc.last_line = 1; yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1; yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = input[toknum] + 'A' - 'a'; yylval.value = input[toknum] + 'A' - 'a';
@@ -1212,6 +1211,7 @@ AT_DATA_GRAMMAR([glr-regr14.y],
%{ %{
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h>
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
static void print_lookahead (char const *); static void print_lookahead (char const *);
@@ -1328,8 +1328,7 @@ yylex (void)
{ {
static char const input[] = "abcdddd"; static char const input[] = "abcdddd";
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input)) assert (toknum < sizeof input);
abort ();
yylloc.first_line = yylloc.last_line = 1; yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = toknum + 1; yylloc.first_column = yylloc.last_column = toknum + 1;
yylval.value = input[toknum] + 'A' - 'a'; yylval.value = input[toknum] + 'A' - 'a';
@@ -1492,6 +1491,7 @@ AT_DATA_GRAMMAR([glr-regr16.y],
%{ %{
# include <stdlib.h> # include <stdlib.h>
# include <assert.h>
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
static int lookahead_value = 0; static int lookahead_value = 0;
@@ -1512,8 +1512,7 @@ yylex (void)
{ {
static char const input[] = "ab"; static char const input[] = "ab";
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input)) assert (toknum < sizeof input);
abort ();
if (input[toknum] == 'b') if (input[toknum] == 'b')
lookahead_value = 1; lookahead_value = 1;
return input[toknum++]; return input[toknum++];
@@ -1551,7 +1550,8 @@ AT_CLEANUP
AT_SETUP([Uninitialized location when reporting ambiguity]) AT_SETUP([Uninitialized location when reporting ambiguity])
AT_BISON_OPTION_PUSHDEFS AT_BISON_OPTION_PUSHDEFS([%glr-parser %locations %define api.pure])
AT_DATA_GRAMMAR([glr-regr17.y], AT_DATA_GRAMMAR([glr-regr17.y],
[[ [[
%glr-parser %glr-parser
@@ -1562,8 +1562,8 @@ AT_DATA_GRAMMAR([glr-regr17.y],
%union { int dummy; } %union { int dummy; }
%{ %{
static void yyerror (YYLTYPE *, char const *); ]AT_YYERROR_DECLARE[
static int yylex (YYSTYPE *, YYLTYPE *); ]AT_YYLEX_DECLARE[
%} %}
%initial-action { %initial-action {
@@ -1593,21 +1593,15 @@ empty1: ;
empty2: ; empty2: ;
%% %%
# include <assert.h>
static void ]AT_YYERROR_DEFINE[
yyerror (YYLTYPE *locp, char const *msg)
{
fprintf (stderr, "%d.%d-%d.%d: %s.\n", locp->first_line,
locp->first_column, locp->last_line, locp->last_column, msg);
}
static int static int
yylex (YYSTYPE *lvalp, YYLTYPE *llocp) yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{ {
static char const input[] = "ab"; static char const input[] = "ab";
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input)) assert (toknum < sizeof input);
abort ();
lvalp->dummy = 0; lvalp->dummy = 0;
llocp->first_line = llocp->last_line = 2; llocp->first_line = llocp->last_line = 2;
llocp->first_column = toknum + 1; llocp->first_column = toknum + 1;
@@ -1629,7 +1623,7 @@ AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [],
AT_COMPILE([glr-regr17]) AT_COMPILE([glr-regr17])
AT_PARSER_CHECK([[./glr-regr17]], 0, [], AT_PARSER_CHECK([[./glr-regr17]], 0, [],
[1.1-2.3: syntax is ambiguous. [1.1-2.2: syntax is ambiguous
]) ])
AT_CLEANUP AT_CLEANUP

View File

@@ -111,8 +111,8 @@ main (void)
# Link and execute, just to make sure everything is fine (and in # Link and execute, just to make sure everything is fine (and in
# particular, that MY_LLOC is indeed defined somewhere). # particular, that MY_LLOC is indeed defined somewhere).
AT_COMPILE([caller.o], [-c caller.c]) AT_COMPILE([caller.o])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_COMPILE([caller], [caller.o input.o]) AT_COMPILE([caller], [caller.o input.o])
AT_PARSER_CHECK([./caller]) AT_PARSER_CHECK([./caller])

View File

@@ -533,6 +533,7 @@ char apostrophe = '\'';
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
%} %}
/* %{ and %} can be here too. */ /* %{ and %} can be here too. */
@@ -600,8 +601,7 @@ yylex (void)
#output "; /* " #output "; /* "
*/ */
static size_t toknum; static size_t toknum;
if (! (toknum < sizeof input)) assert (toknum < sizeof input);
abort ();
yylval = value_as_yystype (input[toknum]); yylval = value_as_yystype (input[toknum]);
return input[toknum++]; return input[toknum++];
} }
@@ -624,8 +624,8 @@ main (void)
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y]) AT_BISON_CHECK([-d -v -o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_COMPILE([main.o], [-c main.c]) AT_COMPILE([main.o])
AT_COMPILE([input], [input.o main.o]) AT_COMPILE([input], [input.o main.o])
AT_PARSER_CHECK([./input], 0, AT_PARSER_CHECK([./input], 0,
[[[@<:@], [[[@<:@],
@@ -745,7 +745,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
AT_BISON_CHECK([-o input.c input.y]) AT_BISON_CHECK([-o input.c input.y])
# Make sure we don't export silly token identifiers with periods or dashes. # Make sure we don't export silly token identifiers with periods or dashes.
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
# Periods are genuine letters, they can start identifiers. # Periods are genuine letters, they can start identifiers.

View File

@@ -90,7 +90,8 @@ m4_popdef([AT_LOC_LAST_COLUMN])])
# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS]) # AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
# ----------------------------------------- # -----------------------------------------
m4_define([AT_BISON_OPTION_PUSHDEFS], m4_define([AT_BISON_OPTION_PUSHDEFS],
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])]) [m4_divert_text([KILL],
[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])])
# _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS]) # _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS])
@@ -137,16 +138,16 @@ m4_pushdef([AT_PURE_AND_LOC_IF],
m4_pushdef([AT_GLR_OR_PARAM_IF], m4_pushdef([AT_GLR_OR_PARAM_IF],
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])]) [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX], m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"],
[m4_bregexp([$3], [%name-prefix "\([^""]*\)"], [\1])],
[yy])])
m4_pushdef([AT_API_PREFIX],
[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"], [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
[yy])]) [yy])])
m4_pushdef([AT_TOKEN_PREFIX], m4_pushdef([AT_TOKEN_PREFIX],
[m4_bmatch([$3], [%define api.tokens.prefix ".*"], [m4_bmatch([$3], [%define api.tokens.prefix ".*"],
[m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])]) [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
m4_pushdef([AT_API_prefix],
[m4_bmatch([$3], [%define api\.prefix ".*"],
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
[yy])])
# yyerror receives the location if %location & %pure & (%glr or %parse-param). # yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF], m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
@@ -165,19 +166,27 @@ m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1], [AT_PURE_IF([$1],
[AT_SKEL_CC_IF([$1], [$2])])]) [AT_SKEL_CC_IF([$1], [$2])])])
m4_pushdef([AT_YYSTYPE],
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]],
[[YYSTYPE]])])
m4_pushdef([AT_YYLTYPE],
[AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::location_type]],
[[YYLTYPE]])])
AT_PURE_LEX_IF( AT_PURE_LEX_IF(
[m4_pushdef([AT_LOC], [(*llocp)]) [m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)]) m4_pushdef([AT_VAL], [(*lvalp)])
m4_pushdef([AT_YYLEX_FORMALS], m4_pushdef([AT_YYLEX_FORMALS],
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])]) [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])])
m4_pushdef([AT_YYLEX_ARGS], m4_pushdef([AT_YYLEX_ARGS],
[lvalp[]AT_LOCATION_IF([, llocp])]) [lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS], m4_pushdef([AT_USE_LEX_ARGS],
[(void) lvalp;AT_LOCATION_IF([(void) llocp])]) [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
m4_pushdef([AT_YYLEX_PRE_FORMALS], m4_pushdef([AT_YYLEX_PRE_FORMALS],
[AT_YYLEX_FORMALS, ]) [AT_YYLEX_FORMALS, ])
m4_pushdef([AT_YYLEX_PRE_ARGS], m4_pushdef([AT_YYLEX_PRE_ARGS],
[AT_YYLEX_ARGS, ]) [AT_YYLEX_ARGS, ])
], ],
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]]) [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]]) m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
@@ -204,17 +213,20 @@ AT_GLR_IF([AT_KEYWORDS([glr])])
# AT_BISON_OPTION_POPDEFS # AT_BISON_OPTION_POPDEFS
# ----------------------- # -----------------------
m4_define([AT_BISON_OPTION_POPDEFS], m4_define([AT_BISON_OPTION_POPDEFS],
[m4_divert_text([KILL],
[m4_popdef([AT_YYLEX_PRE_ARGS]) [m4_popdef([AT_YYLEX_PRE_ARGS])
m4_popdef([AT_YYLEX_PRE_FORMALS]) m4_popdef([AT_YYLEX_PRE_FORMALS])
m4_popdef([AT_USE_LEX_ARGS]) m4_popdef([AT_USE_LEX_ARGS])
m4_popdef([AT_YYLEX_ARGS]) m4_popdef([AT_YYLEX_ARGS])
m4_popdef([AT_YYLEX_FORMALS]) m4_popdef([AT_YYLEX_FORMALS])
m4_popdef([AT_YYLTYPE])
m4_popdef([AT_YYSTYPE])
m4_popdef([AT_VAL]) m4_popdef([AT_VAL])
m4_popdef([AT_LOC]) m4_popdef([AT_LOC])
m4_popdef([AT_PURE_LEX_IF]) m4_popdef([AT_PURE_LEX_IF])
m4_popdef([AT_YYERROR_SEES_LOC_IF]) m4_popdef([AT_YYERROR_SEES_LOC_IF])
m4_popdef([AT_YYERROR_ARG_LOC_IF]) m4_popdef([AT_YYERROR_ARG_LOC_IF])
m4_popdef([AT_API_PREFIX]) m4_popdef([AT_API_prefix])
m4_popdef([AT_NAME_PREFIX]) m4_popdef([AT_NAME_PREFIX])
m4_popdef([AT_GLR_OR_PARAM_IF]) m4_popdef([AT_GLR_OR_PARAM_IF])
m4_popdef([AT_PURE_AND_LOC_IF]) m4_popdef([AT_PURE_AND_LOC_IF])
@@ -230,7 +242,7 @@ m4_popdef([AT_SKEL_JAVA_IF])
m4_popdef([AT_GLR_CC_IF]) m4_popdef([AT_GLR_CC_IF])
m4_popdef([AT_LALR1_CC_IF]) m4_popdef([AT_LALR1_CC_IF])
m4_popdef([AT_DEFINES_IF]) m4_popdef([AT_DEFINES_IF])
AT_LOC_POPDEF AT_LOC_POPDEF])dnl
])# AT_BISON_OPTION_POPDEFS ])# AT_BISON_OPTION_POPDEFS
@@ -287,7 +299,7 @@ $2])
# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION]) # AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
# --------------------------------------- # ---------------------------------------
m4_define([AT_YYLEX_PROTOTYPE], m4_define([AT_YYLEX_PROTOTYPE],
[int AT_API_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl [int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
]) ])
m4_define([AT_YYLEX_DECLARE_EXTERN], m4_define([AT_YYLEX_DECLARE_EXTERN],
@@ -299,19 +311,19 @@ m4_define([AT_YYLEX_DECLARE],
]) ])
m4_define([AT_YYLEX_DEFINE], m4_define([AT_YYLEX_DEFINE],
[[#include <stdlib.h> /* abort */ [[#include <assert.h>
static static
]AT_YYLEX_PROTOTYPE[ ]AT_YYLEX_PROTOTYPE[
{ {
static char const input[] = "$1"; static char const input[] = "$1";
static size_t toknum = 0; static size_t toknum = 0;
int res; int res;
if (! (toknum < sizeof input)) ]AT_USE_LEX_ARGS[;
abort (); assert (toknum < sizeof input);
res = input[toknum++]; res = input[toknum++];
]$2;[]AT_LOCATION_IF([[ ]$2[;]AT_LOCATION_IF([[
]AT_API_PREFIX[lloc.first_line = ]AT_API_PREFIX[lloc.last_line = 1; ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
]AT_API_PREFIX[lloc.first_column = ]AT_API_PREFIX[lloc.last_column = toknum;]])[ ]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
return res; return res;
}]dnl }]dnl
]) ])
@@ -329,7 +341,7 @@ m4_define([AT_YYERROR_FORMALS],
m4_define([AT_YYERROR_PROTOTYPE], m4_define([AT_YYERROR_PROTOTYPE],
[m4_case(AT_LANG, [m4_case(AT_LANG,
[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl [c], [[void ]AT_NAME_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
]) ])
m4_define([AT_YYERROR_DECLARE_EXTERN], m4_define([AT_YYERROR_DECLARE_EXTERN],
@@ -540,21 +552,37 @@ m4_define([AT_QUELL_VALGRIND],
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]) # AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
# ---------------------------------------- # ----------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.', # Compile SOURCES into OUTPUT.
# assume that we are linking too; this is a hack. #
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c" appended.
m4_define([AT_COMPILE], m4_define([AT_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])], [AT_CHECK(m4_join([ ],
[$CC $CFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])]) 0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc]) # AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
# -------------------------------------------- # ---------------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.', # Compile SOURCES into OUTPUT. If the C++ compiler does not work,
# assume that we are linking too; this is a hack. # ignore the test.
# If the C++ compiler does not work, ignore the test. #
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".cc" appended.
m4_define([AT_COMPILE_CXX], m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++) [AT_KEYWORDS(c++)
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore) AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])], AT_CHECK(m4_join([ ],
[$CXX $CXXFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])]) 0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES) # AT_JAVA_COMPILE(SOURCES)
@@ -569,6 +597,11 @@ AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
# AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c] # AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]
# -------------------------------------------- # --------------------------------------------
# Compile SOURCES into OUTPUT. Skip if compiler does not work.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c"/".cc" appended.
m4_define([AT_LANG_COMPILE], m4_define([AT_LANG_COMPILE],
[m4_case(AT_LANG, [m4_case(AT_LANG,
[c], [AT_COMPILE([$1], [$2])], [c], [AT_COMPILE([$1], [$2])],

View File

@@ -162,10 +162,8 @@ int main (int argc, const char **argv)
} }
status = yyparse (); status = yyparse ();
fclose (input); fclose (input);
if (global_result != result) assert (global_result == result);
abort (); assert (global_count == count);
if (global_count != count)
abort ();
return status; return status;
} }
]]) ]])

View File

@@ -41,7 +41,7 @@ program: 'x';
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y]) AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_COMPILE([input.o], [-DYYDEBUG -c input.c]) AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
AT_CLEANUP AT_CLEANUP
@@ -71,7 +71,7 @@ program: { $$ = ""; };
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y]) AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_CLEANUP AT_CLEANUP
@@ -111,7 +111,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-y -o input.c input.y]) AT_BISON_CHECK([-y -o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_CLEANUP AT_CLEANUP
@@ -156,7 +156,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y]) AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_CLEANUP AT_CLEANUP
@@ -527,7 +527,7 @@ exp:
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y]) AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c]) AT_COMPILE([input.o])
AT_CLEANUP AT_CLEANUP
@@ -901,6 +901,7 @@ yyparse ()
} }
]) ])
#include <assert.h>
static int static int
yylex (AT_LALR1_CC_IF([int *lval], [void])) yylex (AT_LALR1_CC_IF([int *lval], [void]))
[{ [{
@@ -910,8 +911,7 @@ yylex (AT_LALR1_CC_IF([int *lval], [void]))
}; };
static size_t toknum; static size_t toknum;
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[ ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
if (! (toknum < sizeof tokens / sizeof *tokens)) assert (toknum < sizeof tokens / sizeof *tokens);
abort ();
return tokens[toknum++]; return tokens[toknum++];
}] }]
@@ -986,6 +986,7 @@ yyparse ()
} }
])[ ])[
#include <assert.h>
static int static int
yylex (]AT_LALR1_CC_IF([int *lval], [void])[) yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
{ {
@@ -995,8 +996,7 @@ yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
}; };
static size_t toknum; static size_t toknum;
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[ ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
if (! (toknum < sizeof tokens / sizeof *tokens)) assert (toknum < sizeof tokens / sizeof *tokens);
abort ();
return tokens[toknum++]; return tokens[toknum++];
} }

View File

@@ -56,6 +56,7 @@ print <<EOF;
%{ %{
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#define MAX $max #define MAX $max
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
]AT_YYERROR_DECLARE[ ]AT_YYERROR_DECLARE[
@@ -77,8 +78,8 @@ for my $size (1 .. $max)
print <<EOF; print <<EOF;
%% %%
input: input:
exp { if (\@S|@1 != 0) abort (); \$\$ = \@S|@1; } exp { assert (\@S|@1 == 0); \$\$ = \@S|@1; }
| input exp { if (\@S|@2 != \@S|@1 + 1) abort (); \$\$ = \@S|@2; } | input exp { assert (\@S|@2 == \@S|@1 + 1); \$\$ = \@S|@2; }
; ;
exp: exp:
@@ -192,6 +193,7 @@ print
print <<\EOF; print <<\EOF;
%% %%
#include <assert.h>
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
static int static int
yylex (void) yylex (void)
@@ -199,8 +201,7 @@ yylex (void)
static int counter = 1; static int counter = 1;
if (counter <= MAX) if (counter <= MAX)
return counter++; return counter++;
if (counter++ != MAX + 1) assert (counter++ == MAX + 1);
abort ();
return 0; return 0;
} }
@@ -328,8 +329,7 @@ yylex (void)
static int counter = 1; static int counter = 1;
if (counter > MAX) if (counter > MAX)
{ {
if (counter++ != MAX + 1) assert (counter++ == MAX + 1);
abort ();
return 0; return 0;
} }
if (return_token) if (return_token)
@@ -401,11 +401,11 @@ AT_DATA([input.y],
exp: WAIT_FOR_EOF exp | ; exp: WAIT_FOR_EOF exp | ;
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
#include <assert.h>
static int static int
yylex (void) yylex (void)
{ {
if (yylval < 0) assert (0 <= yylval);
abort ();
if (yylval--) if (yylval--)
return WAIT_FOR_EOF; return WAIT_FOR_EOF;
else else
@@ -417,13 +417,12 @@ main (int argc, const char **argv)
{ {
char *endp; char *endp;
YYSTYPE yylval_init; YYSTYPE yylval_init;
if (argc != 2) assert (argc == 2);
abort ();
yylval_init = strtol (argv[1], &endp, 10); yylval_init = strtol (argv[1], &endp, 10);
if (! (argv[1] != endp assert (argv[1] != endp);
&& 0 <= yylval_init && yylval_init <= INT_MAX assert (0 <= yylval_init);
&& errno != ERANGE)) assert (yylval_init <= INT_MAX);
abort (); assert (errno != ERANGE);
yydebug = 1; yydebug = 1;
{ {
int count; int count;
@@ -438,8 +437,7 @@ main (int argc, const char **argv)
[[ new_status = yypull_parse (ps); [[ new_status = yypull_parse (ps);
]], ]],
[[ new_status = yyparse (); [[ new_status = yyparse ();
]])[ if (count > 0 && new_status != status) ]])[ assert (0 <= count || new_status == status);
abort ();
status = new_status; status = new_status;
} }
]m4_bmatch([$2], [%push-], ]m4_bmatch([$2], [%push-],