[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in Bison-2.1 (and previous)?
From: |
Joel E. Denny |
Subject: |
Re: Bug in Bison-2.1 (and previous)? |
Date: |
Thu, 13 Apr 2006 12:14:06 -0400 (EDT) |
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