bison-patches
[Top][All Lists]
Advanced

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

Re: C99 in Bison


From: Akim Demaille
Subject: Re: C99 in Bison
Date: Wed, 26 Aug 2009 15:46:47 +0200


Le 20 août 09 à 20:20, Joel E. Denny a écrit :

A couple of years ago, Paul Eggert recommended we wait a couple of years at least to start requiring users to have C99 compilers in order to build
Bison:

 http://lists.gnu.org/archive/html/bison-patches/2007-05/msg00012.html

How about now?

I have no opinion about this. What are the others doing? Say coreutils for instance :)

 I'd love to be able to do things like:

 void
 foo (int *array, size n)
 {
   int array2[n]; // variable-length array
   for (int i = 0; i < n; ++i) // mixed declarations and code
     {
// Single-line comments, which are so tempting that we've already
       // begun using them.  Oops.
     }
 }

If this is ok, we should probably add a configure.ac check for C99.

And what about C99 for building Bison-generated parsers?

I doubt we can do that.  For a start we could move to C90 in yacc.c :)

#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
    void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif

If I read correctly our parse-gram.c, we have two errors:

# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{


and

static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yytoken)
{

All the other functions are KnR compliant too. Maybe we should poll the audience, say via NEWS.



reply via email to

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