bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison CVS test case failures for C++ parser


From: Akim Demaille
Subject: Re: Bison CVS test case failures for C++ parser
Date: Thu, 19 Jan 2006 13:49:58 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

>>> "Paul" == Paul Eggert <address@hidden> writes:

 > "make maintainer-check" fails with Bison CVS due to the use of some
 > uninitialized objects in the C++ parser.  Can a C++ expert please look
 > into this?  Here is a log:

Here is the fix.  There is a difference between glr and lalr skeletons
wrt the initial token: it seems that glr really pushes one, $end.  In
the glr case it was not initialized properly.

Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.1412
diff -u -r1.1412 ChangeLog
--- ChangeLog   19 Jan 2006 06:48:52 -0000      1.1412
+++ ChangeLog   19 Jan 2006 12:45:46 -0000
@@ -1,3 +1,8 @@
+2006-01-19  Akim Demaille  <address@hidden>
+
+       * tests/calc.at (_AT_DATA_CALC_Y): Initialize the whole initial
+       location, not just parts of it.
+
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.86
diff -u -r1.86 calc.at
--- tests/calc.at       3 Jan 2006 09:06:22 -0000       1.86
+++ tests/calc.at       19 Jan 2006 12:45:46 -0000
@@ -99,7 +99,7 @@
    are stored in a union, from which objects with constructors are
    excluded in C++. */
 %initial-action {
-  @$.begin.filename = @$.end.filename = 0;
+  @$.initialize (0);
 }
 ])[
 

The initial $end looks weird on traces:

/tmp % bison end.y -o end.cc && make end && ./end               nostromo 13:47
g++     end.cc   -o end
Starting parse
Entering state 0
Reading a token: Next token is token '0' (1.0: )
Shifting token '0' (1.0: )
Entering state 1
Reducing stack 0 by rule 1 (line 20):
   $1 = token '0' (1.0: )
-> $$ = nterm input (1.0: )
Entering state 2
Reading a token: Next token is token $end (1.1: )
Shifting token $end (1.1: )
Entering state 3
Cleanup: popping token $end (1.1: )             <=============
Cleanup: popping nterm input (1.0: )
Cleanup: popping token $end (1.0: )             <=============


/* Infix notation calculator--calc */
%skeleton "glr.cc" %defines %locations %pure-parser %debug
%define "global_tokens_and_yystype"
%{
#ifndef YYLTYPE
# define YYLTYPE yy::location
#endif

#define YYSTYPE int

static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
%}

%initial-action {
  @$.initialize (0);
}


%%
input: '0'
%%
/* A C++ error reporting function.  */
void
yy::parser::error (const location& l, const std::string& m)
{
  std::cerr << l << ": " << m << std::endl;
}

static int
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{
  static const char *input = "0";
  int res = *input++;

  llocp->step ();
  llocp->columns (1);

  /* Return end-of-file.  */
  if (res == 0)
    return EOF;

  /* Return single chars. */
  return res;
}

int
main (int argc, const char **argv)
{
  yy::parser parser;
  parser.set_debug_level (!!YYDEBUG);
  return parser.parse ();
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]