bug-bison
[Top][All Lists]
Advanced

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

Re: Bison C++ mid-rule value lost with variants


From: Akim Demaille
Subject: Re: Bison C++ mid-rule value lost with variants
Date: Thu, 29 Nov 2018 06:59:54 +0100


> Le 17 juin 2018 à 16:33, Rici Lake <address@hidden> a écrit :
> 
> Although unrelated to this proposal, I would also favour allowing
> 
> %%
> <type> nonterminal: rhs
> 
> as an alternative to
> 
> %type <type> nonterminal
> %%
> nonterminal: rhs

FTR, the more I contemplate this idea, the more I like it.

Unfortunately we hit again the classical S/R conflict of the
naive YACC grammar: in a grammar such as

%%
<int>
exp
: "number"
| exp "+" exp                 { $$ = $1 + $3; }
| exp "*" exp                 { $$ = $1 * $3; }
| "(" exp ")"                 { $$ = $2; }
| "[" <int> { $$ = 42; } "]"  { $$ = $2; }
;

a single lookahead will not suffice for the parser to know,
when it's reading the rhs of a rule, whether the <tag> coming
is that of a midrule action so we stay in the right hand rule of
the rule, or the tag of the lhs of the next rule.

GLR would of course solve the problem.  But I'm not eager to
sit Bison on top of GLR right now (we use LAC for instance,
not implemented in glr.c).


reply via email to

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