[Top][All Lists]

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

Re: beta testing

From: Hans Aberg
Subject: Re: beta testing
Date: Wed, 21 Feb 2001 14:31:19 +0100

At 13:43 +0100 2001/02/21, Magnus Fromreide wrote:
>My view on the C++ support have long been that it would be nice to be able
>to generate a parser that is wrapped up in an anonymous namespace. From
>that is it then simple to wrap it in a class (given a pure parser) or just
>add accessor functions. Right now the reason that kills this is the
>include of <stdio.h> from bison.simple, otherwise
>namespace {
>#include "y.tab.c"
>works, but native support would be better.

One reason for wrapping stuff within a namespace is to make the names local
to that namespace. However, this does not work with the macro names that
the Bison parser uses. So for there to be much of a point using namespaces,
one would have to replace
  #define identifier  257
  #define implies     258
  const int identifier = 257;
  const int implies = 258;
in the .tab.cc file, and
  extern int identifier;
  extern int implies;

Then, when wrapped up in the parser namespace, these names become truly
local, and will not clash with other names.

-- One other solution would be to make these names static to the parser
class, they would become local to that class.

The namespace solution is better though, because the names are then
globally exported and can be used without a .tab.h header if one so would
want, as one can write
  namespace my_parser {
    extern int identifier;
    extern int implies;
  // Use the names here.
in whatever file that needs to use them.

-- Perhaps not for the token names, but the parser can then export more
quantities. (I came across a few that are now not in the .tab.h file.)

  Hans Aberg

reply via email to

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