help-bison
[Top][All Lists]
Advanced

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

Re: %prefix with C++ namespaces


From: Joel E. Denny
Subject: Re: %prefix with C++ namespaces
Date: Tue, 2 Oct 2007 01:07:24 -0400 (EDT)

On Mon, 1 Oct 2007, Sebastian Pipping wrote:

> Joel E. Denny wrote:
> > Well, if we document how the splitting is done, then I figure they can't
> > complain too much.  I certainly don't want to see Bison parse complex C++
> > constructs.  Let the C++ compiler catch those errors.
> 
> Wouldn't it be both easy and powerful to solve that namespace thing
> using "%define"s?
> 
> 
> What I have in mind is one %define each for begin and end of the
> namespace, something like this:
> 
>   %define "namespace_intro" "namespace Gnu { namespace Bison {"
>   %define "namespace_outro" "} }"
> 
> The default would be set to
> 
>   %define "namespace_intro" "namespace <prefix> {"
>   %define "namespace_outro" "}"

I see this as more work for the user.

> If that's possible that would
> * take namespace parsing off Bison's shoulders and

When I spoke of Bison parsing complex C++ constructs, I was responding to 
this:

On Sun, 30 Sep 2007, Akim Demaille wrote:

> it's just that if we start looking at
> what it contains, someday someone might complain that we generated
> invalid C++ code instead of rejecting invalid prefixes.

I think Akim was worried that I might try to report syntactically invalid 
namespace references.  For example, "ns1::%bogus$::ns2".  Leave that to 
the compiler.  We can document that Bison just splits on "::" blindly, and 
that should be straightforward to implement.  For syntactically valid 
namespace references minus any leading "::", I believe this approach will 
always work.

On Mon, 1 Oct 2007, Sebastian Pipping wrote:

> * be flexible at the same time.

Do you have some use cases in mind that we can't handle with the approach 
we've been discussing?




reply via email to

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