help-bison
[Top][All Lists]
Advanced

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

Re: interesting push parser use case


From: Bob Rossi
Subject: Re: interesting push parser use case
Date: Wed, 20 Feb 2008 10:54:49 -0500
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

On Sun, Sep 09, 2007 at 11:03:13AM +0200, address@hidden wrote:
> > On Sat, 8 Sep 2007, Bob Rossi wrote:
> >> The second issue is slightly more fuzzy. Essentially, after each token I
> >> give to the parser, it would probably be useful to know if it just
> >> finished a particular rule, and if so, which rule.
> >
> > Could you use %parse-param to pass a pointer to a variable to be set by
> > the semantic action of that rule?
> >
> 
> Yes.  Personally, I think this would be overkill in most situations, but
> if it's useful to you I don't see any problem with it.  I do recommend
> using a pointer to an object of a `struct' or `class' type, so you could
> use the object passed as a parameter to `yyparse' (and `yylex') for other
> purposes, too.
> 
> I would also wrap the code for setting it in #ifdef WHATEVER ... #endif,
> so that it's conditionally compiled.  This way, you could build the
> program without the overhead of this feature, if you don't always need it.

Hi Laruence,

Sorry for the extremely long delay. I'm trying out your suggestion now.
Whenver I put a struct in the parse param like so,
  %parse-param { struct gdbmi_pdata *gdbmi_pdata }
I get a compiler warning, 
../../../../cgdb/lib/gdbmi/src/gdbmi_grammar.h:127: warning: ‘struct
gdbmi_pdata’ declared inside parameter list

Do you know how to avoid that? It seems like the header file generated
has the struct in the parameter list but the definition is not in global
scope.

The more I think about it, this might have been introduced with the push
parser, since we put the declarations in the .h file now.

Does anyone have any suggestions on how to fix this? One obvious
solution would be to have a section in the bison grammar file that would
go into the header file, to allow the definition or prototype of certain
types.

Bob Rossi





reply via email to

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