[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bison-2.7 and MacOS 10.13
From: |
David Barto |
Subject: |
Re: bison-2.7 and MacOS 10.13 |
Date: |
Sat, 8 Sep 2018 10:57:40 -0700 |
Yes, thanks. I’ve not undertaken the change yet as we have a GA in a week.
We were passing 3 args, so the same rules apply and it does make it easier to
use.
David
> On Sep 8, 2018, at 12:28 AM, Akim Demaille <address@hidden> wrote:
>
>
>
>> Le 7 sept. 2018 à 14:29, David Barto <address@hidden> a écrit :
>>
>> Our code is very very old and doesn’t support the newer non - YYPARSE
>> defined version of bison.
>
> I guess you mean YYPARSE_PARAM here?
>
> It should not be too hard to migrate.
>
>
> Previously, suppose you wanted to pass some struct named
> parser_control. You needed to define the type, and define the macro
> YYPARSE_PARAM:
>
>> %{
>> struct parser_control
>> {
>> int nastiness;
>> int randomness;
>> };
>>
>> #define YYPARSE_PARAM pcontrol
>> %}
>
> In your grammar actions, you had to cast to use the parse param
> something like:
>
>> exp: "number"
>> {
>> $$ = $1 + ((struct parser_control *) pcontrol)->randomness;
>> }
>
> and call your parser this way:
>
>> {
>> struct parser_control foo;
>> ... /* Store proper data in foo. */
>> res = yyparse ((void *) &foo);
>> ...
>> }
>
> To migrate to newer versions of Bison (perfectly valid with 2.7!):
>
>> %{
>> struct parser_control
>> {
>> int nastiness;
>> int randomness;
>> };
>> %}
>> %parse-param {parser_control* pcontrol}
>
> In your actions:
>
>> exp: "number"
>> {
>> $$ = $1 + pcontrol->randomness;
>> }
>
> and call your parser this way:
>
>> {
>> struct parser_control foo;
>> ... /* Store proper data in foo. */
>> res = yyparse (&foo);
>> ...
>> }
>
> No more casts, not more limitations to a single param.
>
> Does this help?
>
David Barto
address@hidden
Sometimes, my best code does nothing. Most of the rest of it has bugs.