mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
Merge remote-tracking branch 'origin/maint'
* origin/maint: tests: use the generalized default yylex. tests: AT_YYERROR_DEFINE: prepare for list of ints. skeletons: no longer define YYLSP_NEEDED. c++: do not export YYTOKEN_TABLE and YYERROR_VERBOSE. Conflicts: data/c.m4 data/glr.cc data/lalr1.cc doc/bison.texi tests/regression.at
This commit is contained in:
31
NEWS
31
NEWS
@@ -124,14 +124,16 @@ GNU Bison NEWS
|
||||
generated for C supprt ISO C90, and are tested with ISO C99 and ISO C11
|
||||
compilers.
|
||||
|
||||
*** Deprecated features
|
||||
*** Features deprecated since Bison 1.875
|
||||
|
||||
The definitions of yystype and yyltype will be removed, as announced since
|
||||
Bison 1.875. Use YYSTYPE and YYLTYPE only.
|
||||
The definitions of yystype and yyltype will be removed; use YYSTYPE and
|
||||
YYLTYPE.
|
||||
|
||||
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.
|
||||
YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
|
||||
%lex-param, will no longer be supported.
|
||||
|
||||
Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
|
||||
%error-verbose.
|
||||
|
||||
*** The generated header will be included (yacc.c)
|
||||
|
||||
@@ -141,9 +143,9 @@ GNU Bison NEWS
|
||||
because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
|
||||
it.
|
||||
|
||||
** Headers (yacc.c, glr.c, glr.cc)
|
||||
** Headers
|
||||
|
||||
*** Guards
|
||||
*** Guards (yacc.c, glr.c, glr.cc)
|
||||
|
||||
The generated headers are now guarded, as is already the case for C++
|
||||
parsers (lalr1.cc). For intance, with --defines=foo.h:
|
||||
@@ -153,7 +155,7 @@ GNU Bison NEWS
|
||||
...
|
||||
#endif /* !YY_FOO_H */
|
||||
|
||||
*** New declarations
|
||||
*** New declarations (yacc.c, glr.c)
|
||||
|
||||
The generated header now declares yydebug and yyparse. Both honor
|
||||
--name-prefix=bar_, and yield
|
||||
@@ -168,6 +170,17 @@ GNU Bison NEWS
|
||||
in order to facilitate the inclusion of several parser headers inside a
|
||||
single compilation unit.
|
||||
|
||||
*** Exported symbols in C++
|
||||
|
||||
The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
|
||||
header, are removed, as they prevent the possibility of including several
|
||||
generated headers from a single compilation unit.
|
||||
|
||||
*** YYLSP_NEEDED
|
||||
|
||||
For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
|
||||
longer defined.
|
||||
|
||||
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
|
||||
|
||||
** Future changes:
|
||||
|
||||
6
TODO
6
TODO
@@ -126,12 +126,6 @@ The code bw glr.c and yacc.c is really alike, we can certainly factor
|
||||
some parts.
|
||||
|
||||
|
||||
* Yacc.c: CPP Macros
|
||||
|
||||
Do some people use YYPURE, YYLSP_NEEDED like we do in the test suite?
|
||||
They should not: it is not documented. But if they need to, let's
|
||||
find something clean (not like YYLSP_NEEDED...).
|
||||
|
||||
* Report
|
||||
|
||||
** Figures
|
||||
|
||||
@@ -317,9 +317,9 @@ m4_define([b4_define_flag_if],
|
||||
|
||||
# _b4_define_flag_if($1, $2, FLAG)
|
||||
# --------------------------------
|
||||
# This macro works around the impossibility to define macros
|
||||
# inside macros, because issuing `[$1]' is not possible in M4 :(.
|
||||
# This sucks hard, GNU M4 should really provide M5 like $$1.
|
||||
# Work around the impossibility to define macros inside macros,
|
||||
# because issuing `[$1]' is not possible in M4. GNU M4 should provide
|
||||
# $$1 a la M5/TeX.
|
||||
m4_define([_b4_define_flag_if],
|
||||
[m4_if([$1$2], $[1]$[2], [],
|
||||
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
||||
@@ -333,8 +333,12 @@ m4_define([b4_$3_if],
|
||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
||||
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
||||
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
||||
|
||||
# yytoken_table is needed to support verbose errors.
|
||||
b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])
|
||||
|
||||
|
||||
## --------- ##
|
||||
## Symbols. ##
|
||||
|
||||
@@ -100,9 +100,6 @@ m4_define([b4_identification],
|
||||
|
||||
/* Pull parsers. */
|
||||
#define YYPULL ]b4_pull_flag])[
|
||||
|
||||
/* Using locations. */
|
||||
#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
|
||||
]])
|
||||
|
||||
|
||||
|
||||
@@ -223,11 +223,6 @@ b4_percent_code_get([[top]])[
|
||||
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||
#endif
|
||||
|
||||
/* Enabling the token table. */
|
||||
#ifndef YYTOKEN_TABLE
|
||||
# define YYTOKEN_TABLE ]b4_token_table[
|
||||
#endif
|
||||
|
||||
/* Default (constant) value used for initialization for null
|
||||
right-hand sides. Unlike the standard yacc.c template,
|
||||
here we set the default value of $$ to a zeroed-out value.
|
||||
@@ -362,7 +357,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
#if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||
static const char *const yytname[] =
|
||||
|
||||
@@ -236,9 +236,6 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
]b4_percent_define_ifdef([[location_type]], [],
|
||||
[[#include "location.hh"]])[
|
||||
|
||||
/* Using locations. */
|
||||
#define YYLSP_NEEDED ]b4_locations_if([1], [0])[
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
||||
|
||||
@@ -167,19 +167,6 @@ b4_namespace_close])[
|
||||
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
||||
#endif
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
#ifdef YYERROR_VERBOSE
|
||||
# undef YYERROR_VERBOSE
|
||||
# define YYERROR_VERBOSE 1
|
||||
#else
|
||||
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||
#endif
|
||||
|
||||
/* Enabling the token table. */
|
||||
#ifndef YYTOKEN_TABLE
|
||||
# define YYTOKEN_TABLE ]b4_token_table[
|
||||
#endif
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
/// A Bison parser.
|
||||
@@ -244,18 +231,16 @@ b4_namespace_close])[
|
||||
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
||||
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
||||
|
||||
/* Tables. */
|
||||
]b4_parser_tables_declare[
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif]b4_error_verbose_if([
|
||||
// Tables.
|
||||
]b4_parser_tables_declare[]b4_error_verbose_if([
|
||||
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
static std::string yytnamerr_ (const char *n);])[
|
||||
|
||||
#if YYDEBUG
|
||||
]b4_token_table_if([], [[#if YYDEBUG]])[
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
]b4_token_table_if([[#if YYDEBUG]])[
|
||||
]b4_integral_parser_table_declare([rline], [b4_rline],
|
||||
[YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
|
||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||
@@ -263,10 +248,10 @@ b4_namespace_close])[
|
||||
/// Print the state stack on the debug stream.
|
||||
virtual void yystack_print_ ();
|
||||
|
||||
/* Debugging. */
|
||||
// Debugging.
|
||||
int yydebug_;
|
||||
std::ostream* yycdebug_;
|
||||
#endif
|
||||
#endif // YYDEBUG
|
||||
|
||||
/// Convert a scanner token number \a t to a symbol number.
|
||||
static inline token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t);
|
||||
@@ -654,7 +639,7 @@ b4_percent_code_get[]dnl
|
||||
{
|
||||
yydebug_ = l;
|
||||
}
|
||||
#endif
|
||||
#endif // YYDEBUG
|
||||
|
||||
inline ]b4_parser_class_name[::state_type
|
||||
]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yylhs)
|
||||
@@ -1099,7 +1084,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
||||
|
||||
]b4_parser_tables_define[
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
]b4_token_table_if([], [[#if YYDEBUG]])[
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||
const char*
|
||||
@@ -1107,9 +1092,8 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
||||
{
|
||||
]b4_tname[
|
||||
};
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
]b4_token_table_if([[#if YYDEBUG]])[
|
||||
]b4_integral_parser_table_define([rline], [b4_rline])[
|
||||
|
||||
// Print the state stack on the debug stream.
|
||||
|
||||
@@ -337,11 +337,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
|
||||
#endif
|
||||
|
||||
/* Enabling the token table. */
|
||||
#ifndef YYTOKEN_TABLE
|
||||
# define YYTOKEN_TABLE ]b4_token_table[
|
||||
#endif
|
||||
|
||||
/* In a future release of Bison, this section will be replaced
|
||||
by #include "@basename(]b4_spec_defines_file[@)". */
|
||||
]b4_shared_declarations[
|
||||
@@ -594,7 +589,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
||||
[YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
|
||||
#endif
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
#if YYDEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||
static const char *const yytname[] =
|
||||
|
||||
@@ -142,7 +142,6 @@ escaped_output (FILE *out, char const *string)
|
||||
static void
|
||||
prepare_symbols (void)
|
||||
{
|
||||
MUSCLE_INSERT_BOOL ("token_table", token_table_flag);
|
||||
MUSCLE_INSERT_INT ("tokens_number", ntokens);
|
||||
MUSCLE_INSERT_INT ("nterms_number", nvars);
|
||||
MUSCLE_INSERT_INT ("symbols_number", nsyms);
|
||||
@@ -682,6 +681,7 @@ prepare (void)
|
||||
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||
MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen);
|
||||
MUSCLE_INSERT_BOOL ("token_table_flag", token_table_flag);
|
||||
MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag);
|
||||
MUSCLE_INSERT_BOOL ("yacc_flag", yacc_flag);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ exp: { putchar ('0'); }
|
||||
;
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(123456789)[
|
||||
]AT_YYLEX_DEFINE(["123456789"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -116,7 +116,7 @@ sum_of_the_five_previous_values:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([])[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ sum: { printf ("%d\n", $0.val + $-1.val + $-2.val); } ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE()[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -636,7 +636,7 @@ start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([abcd], [[yylval = res]])[
|
||||
]AT_YYLEX_DEFINE(["abcd"], [[yylval = res]])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -748,7 +748,7 @@ start:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([abcdef])[
|
||||
]AT_YYLEX_DEFINE(["abcdef"])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -966,7 +966,7 @@ start:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([abd], [yylval = res])[
|
||||
]AT_YYLEX_DEFINE(["abd"], [yylval = res])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1066,7 +1066,7 @@ start: { USE($$); } ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([])[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1121,7 +1121,7 @@ start:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([])[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1381,7 +1381,7 @@ accept: /*empty*/ {
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([a])[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1417,7 +1417,7 @@ AT_DATA_GRAMMAR([input.y],
|
||||
# include <assert.h>
|
||||
|
||||
]AT_YYERROR_DECLARE[
|
||||
static int yylex (YYSTYPE *yylval);
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
%%
|
||||
input:
|
||||
@@ -1432,15 +1432,7 @@ exp:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
static int
|
||||
yylex (YYSTYPE *yylval)
|
||||
{
|
||||
static char const input[] = "bcd";
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
*yylval = (toknum + 1) * 10;
|
||||
return input[toknum++];
|
||||
}
|
||||
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (toknum + 1) * 10])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
||||
@@ -485,7 +485,7 @@ reduce-nonassoc: %prec 'a';
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([aaa])[
|
||||
]AT_YYLEX_DEFINE(["aaa"])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
||||
@@ -383,7 +383,7 @@ B: 'a' { $$ = make_value ("B", "'a'"); } ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([a])[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -466,7 +466,7 @@ start:
|
||||
;
|
||||
|
||||
%%
|
||||
]AT_YYLEX_DEFINE(a)[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
]AT_YYERROR_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
@@ -519,7 +519,7 @@ start: 'a' | 'a' ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(a)[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -834,7 +834,7 @@ start:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE()[
|
||||
]AT_YYLEX_DEFINE[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -889,7 +889,7 @@ start:
|
||||
%%
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([a])[
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -998,16 +998,9 @@ merge (YYSTYPE s1, YYSTYPE s2)
|
||||
}
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
static int
|
||||
yylex (void)
|
||||
{
|
||||
static int const input[] = { PARENT_RHS_AFTER, 0 };
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input / sizeof *input);
|
||||
if (input[toknum] == PARENT_RHS_AFTER)
|
||||
parent_rhs_after_value = 1;
|
||||
return input[toknum++];
|
||||
}
|
||||
]AT_YYLEX_DEFINE([{ PARENT_RHS_AFTER, 0 }],
|
||||
[if (res == PARENT_RHS_AFTER)
|
||||
parent_rhs_after_value = 1;])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -1117,17 +1110,8 @@ change_lookahead:
|
||||
%%
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
static int
|
||||
yylex (void)
|
||||
{
|
||||
static char const input[] = "ab";
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = toknum + 1;
|
||||
yylval.value = input[toknum] + 'A' - 'a';
|
||||
return input[toknum++];
|
||||
}
|
||||
]AT_YYLEX_DEFINE(["ab"],
|
||||
[yylval.value = res + 'A' - 'a'])[
|
||||
|
||||
static void
|
||||
print_lookahead (char const *reduction)
|
||||
@@ -1449,7 +1433,7 @@ ambiguity2: ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE()[
|
||||
]AT_YYLEX_DEFINE[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -1507,16 +1491,9 @@ alt2: ;
|
||||
%%
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
static int
|
||||
yylex (void)
|
||||
{
|
||||
static char const input[] = "ab";
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
if (input[toknum] == 'b')
|
||||
lookahead_value = 1;
|
||||
return input[toknum++];
|
||||
}
|
||||
]AT_YYLEX_DEFINE(["ab"],
|
||||
[if (res == 'b')
|
||||
lookahead_value = 1])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -1663,7 +1640,7 @@ sym3: %merge<merge> { $$ = 0; } ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE()[
|
||||
]AT_YYLEX_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1709,7 +1686,7 @@ start:
|
||||
b: 'b';
|
||||
d: /* nada. */;
|
||||
%%
|
||||
]AT_YYLEX_DEFINE([abc])[
|
||||
]AT_YYLEX_DEFINE(["abc"])[
|
||||
]AT_YYERROR_DEFINE[
|
||||
int
|
||||
main (void)
|
||||
|
||||
@@ -296,8 +296,11 @@ $2])
|
||||
# AT_YYLEX_PROTOTYPE
|
||||
# AT_YYLEX_DECLARE_EXTERN
|
||||
# AT_YYLEX_DECLARE
|
||||
# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
|
||||
# ---------------------------------------
|
||||
# AT_YYLEX_DEFINE([INPUT], [ACTION])
|
||||
# ----------------------------------
|
||||
# INPUT can be empty, or in double quotes, or a list (in braces).
|
||||
# ACTION may compute yylval for instance, using "res" as token type,
|
||||
# and "toknum" as the number of calls to yylex (starting at 0).
|
||||
m4_define([AT_YYLEX_PROTOTYPE],
|
||||
[int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
|
||||
])
|
||||
@@ -315,7 +318,9 @@ m4_define([AT_YYLEX_DEFINE],
|
||||
static
|
||||
]AT_YYLEX_PROTOTYPE[
|
||||
{
|
||||
static char const input[] = "$1";
|
||||
]m4_bmatch([$1], [^\(".*"\)?$],
|
||||
[[static char const input[] = ]m4_default([$1], [""])],
|
||||
[[static int const input[] = ]$1])[;
|
||||
static size_t toknum = 0;
|
||||
int res;
|
||||
]AT_USE_LEX_ARGS[;
|
||||
|
||||
@@ -101,7 +101,7 @@ start: ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]m4_if([$1], [[both]], [AT_YYLEX_DEFINE([])])[
|
||||
]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
|
||||
@@ -463,15 +463,7 @@ AT_DATA_GRAMMAR([input.y],
|
||||
exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
static int called;
|
||||
if (called++)
|
||||
abort ();
|
||||
return SPECIAL;
|
||||
}
|
||||
]AT_YYLEX_DEFINE([{ SPECIAL }])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -837,13 +829,11 @@ AT_CLEANUP
|
||||
# so that possible bound checking compilers could check all the skeletons.
|
||||
m4_define([_AT_DATA_DANCER_Y],
|
||||
[AT_DATA_GRAMMAR([dancer.y],
|
||||
[%{
|
||||
static int yylex (AT_LALR1_CC_IF([int *], [void]));
|
||||
AT_LALR1_CC_IF([#include <cstdlib>],
|
||||
[#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
]AT_YYERROR_DECLARE[])
|
||||
%}
|
||||
[[%code provides
|
||||
{
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
$1
|
||||
%token ARROW INVALID NUMBER STRING DATA
|
||||
%defines
|
||||
@@ -888,7 +878,8 @@ member: STRING
|
||||
| INVALID
|
||||
;
|
||||
%%
|
||||
AT_YYERROR_DEFINE[
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([":"])[
|
||||
]AT_LALR1_CC_IF(
|
||||
[int
|
||||
yyparse ()
|
||||
@@ -899,28 +890,14 @@ yyparse ()
|
||||
#endif
|
||||
return parser.parse ();
|
||||
}
|
||||
])
|
||||
|
||||
#include <assert.h>
|
||||
static int
|
||||
yylex (AT_LALR1_CC_IF([int *lval], [void]))
|
||||
[{
|
||||
static int const tokens[] =
|
||||
{
|
||||
':', -1
|
||||
};
|
||||
static size_t toknum;
|
||||
]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
|
||||
assert (toknum < sizeof tokens / sizeof *tokens);
|
||||
return tokens[toknum++];
|
||||
}]
|
||||
])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return yyparse ();
|
||||
}
|
||||
])
|
||||
]])
|
||||
])# _AT_DATA_DANCER_Y
|
||||
|
||||
|
||||
@@ -1062,13 +1039,8 @@ start:
|
||||
%printer { fprintf (yyoutput, "PRINTER"); } 'a';
|
||||
|
||||
%%
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
static int
|
||||
yylex (void)
|
||||
{
|
||||
return 'a';
|
||||
}
|
||||
]AT_YYLEX_DEFINE(["a"])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -1201,13 +1173,7 @@ sr_conflict:
|
||||
%%
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
static int const input[] = { 1, 2, 3, 0 };
|
||||
static int const *inputp = input;
|
||||
return *inputp++;
|
||||
}
|
||||
]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -1304,7 +1270,7 @@ syntax_error:
|
||||
/* Induce two syntax error messages (which requires full error
|
||||
recovery by shifting 3 tokens) in order to detect any loss of the
|
||||
reallocated buffer. */
|
||||
]AT_YYLEX_DEFINE([abc])[
|
||||
]AT_YYLEX_DEFINE(["abc"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1412,7 +1378,7 @@ syntax_error2:
|
||||
]AT_YYERROR_DEFINE[
|
||||
/* Induce two syntax error messages (which requires full error
|
||||
recovery by shifting 3 tokens). */
|
||||
]AT_YYLEX_DEFINE([abc])[
|
||||
]AT_YYLEX_DEFINE(["abc"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -1562,7 +1528,7 @@ A: /*empty*/ | 'a' ;
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE([$1])[
|
||||
]AT_YYLEX_DEFINE(["$1"])[
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user