[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in Bison-2.1 (and previous)?
From: |
Steve Murphy |
Subject: |
Re: Bug in Bison-2.1 (and previous)? |
Date: |
Fri, 14 Apr 2006 12:32:33 -0600 |
On Fri, 2006-04-14 at 10:02 -0600, Joel E. Denny wrote:
Joel--
Many, many, many thanks. Yes, you are right, the parse-param works, if
I test the same file I process! (blush).
And, moving my decls down below the union got rid of the need for
the duplicate declarations, and parse-param puts the proper arg in the
calls to yyerror. Miracles happen daily!
Been using this stuff for maybe over 20 years, and I learn something new
even still...!
murf
> On Thu, 13 Apr 2006, Steve Murphy wrote:
>
> > Trouble is, that I need this to be a pure parser, and I need yyerror to
> > bump a count of the number of syntax errors. So I desparately need that
> > middle argument to pass in a pointer to a struct (or whatever), so I
> > increment the error count. I can't do it as a global!
>
> Maybe you want:
>
> %parse-param { struct YourStruct *struct_ptr_var }
>
> > So, I tried playing with %parse-param, but it seems to be a boolean; if
> > it's set, I get three args to yyerror; but it doesn't matter what it's
> > set to. If I change it, I get the same results. Its value isn't used.
>
> It works fine for me in 2.1.
>
> > In my mind, specifying '%locations' should be sufficient to add the
> > &yylloc arg to the yyerror call (along with whatever else it does), and
> > the %pure-parser should alone add the struct_ptr_var to the call.
>
> I agree, but backward compatibility is the problem here. We're discussing
> ways to clean this up.
>
> > unless bison is intelligent enough to extract the "my_struct_ptr" from
> > the parse-param value...
>
> It is, but there's a limitation. See the documentation.
>
> > It seems that YYLTYPE and YYSTYPE are not defined at point where the
> > %{ stuff is included; so I had to insert these definitions myself; Seems
> > to me that if user defined function prototypes are to be declared in
> > these, that the structs & etc that they would naturally use, should be
> > defined before these are possibly used!
>
> All %{ ... %} before the %union are together called the pre-prologue.
> All %{ ... %} after the %union are together called the post-prologue.
> Bison writes the pre-prologue before those definitions, and it writes the
> post-prologue after them.
>
> Joel
>