[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison/flex compatibility revisited
From: |
Bruce Lilly |
Subject: |
Bison/flex compatibility revisited |
Date: |
Mon, 24 Feb 2003 00:02:48 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 |
Hi,
The current beta versions of flex have an %option header that
generates a header file with various things defined, including
start conditions. Flex also has a reentrant option, which is
implemented by referring to data held in a structure which the
caller passes to yylex.
If that header is used bith a bison-generated parser (e.g. to
get the start condition definitions) there can be some
interaction between macros defined in the header and names
used internally in bison. IIRC that happened in bison 1.75b
with "yyout", and it's in bison 1.875 with "yylineno". It's
probably best to avoid local variables beginning with yy...
A patch for bison 1.875 is attached.
*** data/glr.c.orig Thu Dec 26 03:27:09 2002
--- data/glr.c Sun Feb 23 23:48:17 2003
***************
*** 1100,1108 ****
yy_reduce_print (size_t yyk, yyRuleNum yyrule)
{
int yyi;
! unsigned int yylineno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %u), ",
! yyk, yyrule - 1, yylineno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
--- 1100,1108 ----
yy_reduce_print (size_t yyk, yyRuleNum yyrule)
{
int yyi;
! unsigned int lineno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %u), ",
! yyk, yyrule - 1, lineno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
*** data/yacc.c.orig Sat Dec 28 03:36:02 2002
--- data/yacc.c Sun Feb 23 23:48:24 2003
***************
*** 575,583 ****
[[int yyrule], [yyrule]])[
{
int yyi;
! unsigned int yylineno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
! yyrule - 1, yylineno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
--- 575,583 ----
[[int yyrule], [yyrule]])[
{
int yyi;
! unsigned int lineno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
! yyrule - 1, lineno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
- Bison/flex compatibility revisited,
Bruce Lilly <=
- Re: Bison/flex compatibility revisited, Paul Eggert, 2003/02/25
- Re: Bison/flex compatibility revisited, Bruce Lilly, 2003/02/25
- Re: Bison/flex compatibility revisited, Paul Eggert, 2003/02/25
- Re: Bison/flex compatibility revisited, John, 2003/02/25
- Re: Bison/flex compatibility revisited, Bruce Lilly, 2003/02/26
- Re: Bison/flex compatibility revisited, Bruce Lilly, 2003/02/26
- Re: Bison/flex compatibility revisited, John, 2003/02/26
- Re: Bison/flex compatibility revisited, Bruce Lilly, 2003/02/26
- Re: Bison/flex compatibility revisited, John, 2003/02/26
- Re: Bison/flex compatibility revisited, Bruce Lilly, 2003/02/26