[Top][All Lists]

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

Re: proposed namespace cleanup for bison.simple

From: Pascal Bart
Subject: Re: proposed namespace cleanup for bison.simple
Date: Fri, 30 Nov 2001 10:27:10 +0100


> Bison's bison.simple file unnecessarily infringes on the user name
> space in several places.  It uses several local variables whose names
> do not begin with YY or yy, which can collide with user-defined
> macros.  It uses a couple of macros and functions that begin with _YY
> or __yy, which can collide with system names.  (Part of the problem is
> due to patches I've contributed over the years without fully
> understanding the name space issues -- sorry!)

There're no problem :), I think that's a good idea, locals variables which
collides with user's variables generate warnings and this is very
With future C++ parser this problem will be resolve (I believe, we will
use namespace).

> Conversely, in some cases bison.simple does not include system headers
> or contain declarations even when it needs to in order to conform to
> the C standard, e.g. to declare fprintf, malloca, or alloca.  This can
> cause incorrect code to be generated on some systems.

Well, bison parser has to be portable, and any systems are very strange,
so we cann't be sure system headers exist on system and they have correct
declarations, (could we generate parser, which could work with 'configure'
script substitutions ? =) I trust you about protability. But I've never
that any declarations are not C standard :(.

> Here is a proposed patch that attempts to clarify the system header
> situation in the documentation, and to clean up the name definitions
> in bison.simple.  Historically the trickiest header to include is
> <string.h>, so the patch below removes all uses of the builtin string
> functions to avoid any problems there.

That's ok for me, thank you.

> 2001-11-29  Paul Eggert  <address@hidden>
> Name space cleanup in generated parser.
> * doc/bison.texinfo (Bison Parser): Discuss system headers
> and their effect on the user name space.
> * src/bison.simple:
> YYSTACK_BYTES, YYSTACK_RELOCATE): Do not define unless necessary,
> i.e. unless ! defined (yyoverflow) || defined (YYERROR_VERBOSE).
> (YYSIZE_T): New macro.  Use it instead of size_t, to avoid infringing
> on user names when possible.
> (YYSTACK_USE_ALLOCA): Do not define; just use any existing defn.
> Simplify test for whather <alloca.h> exists.
> (<stdlib.h>): Include if we will use malloc, and if standard C or C++.
> (<stdio.h>): Include if YYDEBUG.
> (yymemcpy): Renamed from __yy_memcpy.  Do not define unless
> ! defined (yyoverflow) && ! defined (yymemcpy).
> (yymemcpy, yyparse): Rename local variables as needed so that
> they all begin with 'yy'.
> (yystrlen, yystpcpy): New functions.
> All uses changed.
> (yyparse): size_t -> YYSIZE_T.  Use yystrlen and yystpcpy
> instead of relying on string.h functions.  Use YYSTACK_ALLOC
> and YYSTACK_FREE instead of malloc and free.

Pascal Bart (address@hidden)

reply via email to

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