mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 09:43:03 +00:00
%name-prefix is broken.
* src/files.c (spec_name_prefix): Initialize to NULL, not to "yy". Adjust all dependencies. * tests/headers.at (export YYLTYPE): Strengthen this test: use %name-prefix. Renaming yylval but not yylloc is not consistent. Now we do. * src/bison.simple: Prefix yylloc if used. * doc/bison.texinfo (Decl Summary): Document that.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
|||||||
|
2001-12-29 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
%name-prefix is broken.
|
||||||
|
|
||||||
|
* src/files.c (spec_name_prefix): Initialize to NULL, not to "yy".
|
||||||
|
Adjust all dependencies.
|
||||||
|
* tests/headers.at (export YYLTYPE): Strengthen this test: use
|
||||||
|
%name-prefix.
|
||||||
|
|
||||||
|
Renaming yylval but not yylloc is not consistent. Now we do.
|
||||||
|
|
||||||
|
* src/bison.simple: Prefix yylloc if used.
|
||||||
|
* doc/bison.texinfo (Decl Summary): Document that.
|
||||||
|
|
||||||
|
|
||||||
2001-12-29 Akim Demaille <akim@epita.fr>
|
2001-12-29 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* doc/bison.texinfo: Promote `%long-directive' over
|
* doc/bison.texinfo: Promote `%long-directive' over
|
||||||
|
|||||||
@@ -3289,10 +3289,10 @@ accurate parse error messages.
|
|||||||
Rename the external symbols used in the parser so that they start with
|
Rename the external symbols used in the parser so that they start with
|
||||||
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
|
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
|
||||||
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
|
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
|
||||||
@code{yylval}, @code{yychar} and @code{yydebug}. For example, if you
|
@code{yylval}, @code{yychar}, @code{yydebug}, and possible
|
||||||
use @samp{%name-prefix="c_"}, the names become @code{c_parse},
|
@code{yylloc}. For example, if you use @samp{%name-prefix="c_"}, the
|
||||||
@code{c_lex}, and so on. @xref{Multiple Parsers, ,Multiple Parsers in
|
names become @code{c_parse}, @code{c_lex}, and so on. @xref{Multiple
|
||||||
the Same Program}.
|
Parsers, ,Multiple Parsers in the Same Program}.
|
||||||
|
|
||||||
@item %no-parser
|
@item %no-parser
|
||||||
Do not include any C code in the parser file; generate tables only. The
|
Do not include any C code in the parser file; generate tables only. The
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* Using locations. */
|
/* Using locations. */
|
||||||
#define YYLSP_NEEDED %%locations-flag
|
#define YYLSP_NEEDED %%locations-flag
|
||||||
|
|
||||||
/* If name_prefix is specify substitute the variables and functions
|
/* If NAME_PREFIX is specified substitute the variables and functions
|
||||||
names. */
|
names. */
|
||||||
#define yyparse %%prefix##parse
|
#define yyparse %%prefix##parse
|
||||||
#define yylex %%prefix##lex
|
#define yylex %%prefix##lex
|
||||||
@@ -49,6 +49,10 @@
|
|||||||
#define yychar %%prefix##char
|
#define yychar %%prefix##char
|
||||||
#define yydebug %%prefix##debug
|
#define yydebug %%prefix##debug
|
||||||
#define yynerrs %%prefix##nerrs
|
#define yynerrs %%prefix##nerrs
|
||||||
|
#if YYLSP_NEEDED
|
||||||
|
# define yylloc %%prefix##lloc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Copy the user declarations. */
|
/* Copy the user declarations. */
|
||||||
%%prologue
|
%%prologue
|
||||||
|
|||||||
@@ -32,9 +32,16 @@ struct obstack action_obstack;
|
|||||||
struct obstack attrs_obstack;
|
struct obstack attrs_obstack;
|
||||||
struct obstack output_obstack;
|
struct obstack output_obstack;
|
||||||
|
|
||||||
|
/* Initializing some values below (such SPEC_NAME_PREFIX to `yy') is
|
||||||
|
tempting, but don't do that: for the time being our handling of the
|
||||||
|
%directive vs --option leaves precedence to the options by deciding
|
||||||
|
that if a %directive sets a variable which is really set (i.e., not
|
||||||
|
NULL), then the %directive is ignored. As a result, %name-prefix,
|
||||||
|
for instance, will not be honored. */
|
||||||
|
|
||||||
char *spec_outfile = NULL; /* for -o. */
|
char *spec_outfile = NULL; /* for -o. */
|
||||||
char *spec_file_prefix = NULL; /* for -b. */
|
char *spec_file_prefix = NULL; /* for -b. */
|
||||||
const char *spec_name_prefix = "yy"; /* for -p. */
|
const char *spec_name_prefix = NULL; /* for -p. */
|
||||||
char *spec_verbose_file = NULL; /* for --verbose. */
|
char *spec_verbose_file = NULL; /* for --verbose. */
|
||||||
char *spec_graph_file = NULL; /* for -g. */
|
char *spec_graph_file = NULL; /* for -g. */
|
||||||
char *spec_defines_file = NULL; /* for --defines. */
|
char *spec_defines_file = NULL; /* for --defines. */
|
||||||
|
|||||||
@@ -1075,7 +1075,8 @@ output_master_parser (void)
|
|||||||
|
|
||||||
#define MUSCLE_INSERT_PREFIX(Key, Value) \
|
#define MUSCLE_INSERT_PREFIX(Key, Value) \
|
||||||
{ \
|
{ \
|
||||||
obstack_fgrow2 (&muscle_obstack, "%s%s", spec_name_prefix, Value); \
|
obstack_fgrow2 (&muscle_obstack, "%s%s", \
|
||||||
|
spec_name_prefix ? spec_name_prefix : "yy", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
}
|
}
|
||||||
@@ -1091,7 +1092,7 @@ prepare (void)
|
|||||||
MUSCLE_INSERT_INT ("final", final_state);
|
MUSCLE_INSERT_INT ("final", final_state);
|
||||||
MUSCLE_INSERT_INT ("maxtok", max_user_token_number);
|
MUSCLE_INSERT_INT ("maxtok", max_user_token_number);
|
||||||
MUSCLE_INSERT_INT ("error-verbose", error_verbose);
|
MUSCLE_INSERT_INT ("error-verbose", error_verbose);
|
||||||
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix);
|
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");
|
||||||
|
|
||||||
MUSCLE_INSERT_INT ("nnts", nvars);
|
MUSCLE_INSERT_INT ("nnts", nvars);
|
||||||
MUSCLE_INSERT_INT ("nrules", nrules);
|
MUSCLE_INSERT_INT ("nrules", nrules);
|
||||||
@@ -1127,7 +1128,7 @@ yystype;\n\
|
|||||||
|
|
||||||
if (!pure_parser)
|
if (!pure_parser)
|
||||||
fprintf (out, "\nextern YYSTYPE %slval;\n",
|
fprintf (out, "\nextern YYSTYPE %slval;\n",
|
||||||
spec_name_prefix);
|
spec_name_prefix ? spec_name_prefix : "yy");
|
||||||
|
|
||||||
if (locations_flag)
|
if (locations_flag)
|
||||||
{
|
{
|
||||||
@@ -1145,7 +1146,7 @@ typedef struct yyltype\n\
|
|||||||
#endif\n");
|
#endif\n");
|
||||||
if (!pure_parser)
|
if (!pure_parser)
|
||||||
fprintf (out, "\nextern YYLTYPE %slloc;\n",
|
fprintf (out, "\nextern YYLTYPE %slloc;\n",
|
||||||
spec_name_prefix);
|
spec_name_prefix ? spec_name_prefix : "yy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (semantic_parser)
|
if (semantic_parser)
|
||||||
|
|||||||
@@ -82,18 +82,20 @@ AT_SETUP([export YYLTYPE])
|
|||||||
|
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[%locations
|
[%locations
|
||||||
|
|
||||||
|
%name-prefix="my_"
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
yylex (void)
|
my_lex (void)
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yyerror (const char *msg)
|
my_error (const char *msg)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s\n", msg);
|
fprintf (stderr, "%s\n", msg);
|
||||||
}
|
}
|
||||||
@@ -105,22 +107,22 @@ exp:;
|
|||||||
|
|
||||||
AT_CHECK([bison --defines input.y -o input.c])
|
AT_CHECK([bison --defines input.y -o input.c])
|
||||||
|
|
||||||
# YYLTYPE should be defined, and YYLLOC declared.
|
# YYLTYPE should be defined, and MY_LLOC declared.
|
||||||
AT_DATA([caller.c],
|
AT_DATA([caller.c],
|
||||||
[[#include "input.h"
|
[[#include "input.h"
|
||||||
YYLTYPE *yyllocp = &yylloc;
|
YYLTYPE *my_llocp = &my_lloc;
|
||||||
|
|
||||||
int yyparse (void);
|
int my_parse (void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
return yyparse ();
|
return my_parse ();
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
|
|
||||||
# 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 YYLLOC is indeed defined somewhere).
|
# particular, that MY_LLOC is indeed defined somewhere).
|
||||||
AT_CHECK([$CC $CFLAGS $CPPFLAGS caller.c input.c -o caller], 0, [], [ignore])
|
AT_CHECK([$CC $CFLAGS $CPPFLAGS caller.c input.c -o caller], 0, [], [ignore])
|
||||||
AT_CHECK([caller])
|
AT_CHECK([caller])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user