help-bison
[Top][All Lists]
Advanced

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

%merge confusion


From: Jot Dot
Subject: %merge confusion
Date: Thu, 24 Dec 2020 20:28:35 -0700 (MST)

I'm using %glr-parser and ran into a snag with the %merge feature.

I figure I must be misinterpreting something along the way.
I think I've done what the docs say:
https://www.gnu.org/software/bison/manual/html_node/Merging-GLR-Parses.html

Everything compiles fine except one bison generated line in the parser code.

Assuming I have something simple like the following:
%token <some_type> IDENTIFIER
%type <some_type> subrule expr
...
subrule:
    IDENTIFIER  { $$ = $1; } %merge <stmtMerge>
    | expr      { $$ = $1; } %merge <stmtMerge>
    ;

The Issue:

Bison is generating the following 'yyuserMerge' code (near the bottom of this 
message).
Look at the case statement in the procedure.

it generates:
  case 1: yy0->some_type = stmtMerge (*yy0, *yy1); break; // Assigning to a 
type?
          ^^^^^^^^^^^^^^ Here

Instead of something like:
case 1: *yy0 = stmtMerge (*yy0, *yy1); break; // This *might* make sense. Looks 
better anyways :)
        ^^^^ Here


What is actually happening does not make sense to me.
'some-type' is treated as a variable name. Its a type.
The subrule has a type. It is not a variable.
Considering YYSTYPE is the 'semantic_type', it also does not make
sense to have this 'semantic_type' as a field inside itself.
I'm confused. Not sure where to look for a solution.

This is the resultant code generated by bison:

static void
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
{
  YYUSE (yy0);
  YYUSE (yy1);

  switch (yyn)
    {
  case 1: yy0->gen::index_t = stmtMerge (*yy0, *yy1); break; // My only compile 
error :(

      default: break;
    }
}

where: gen::index_t is the 'some_type' for the rule I used.
The %merge is in that rule.

Ok, now feeling awkward / foolish / dumb ...
Can anyone tell me what I am doing wrong?
This is my last issue that I see to make my project compile.

Thanks for any help / guidance anyone can give.



reply via email to

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