> Le 17 juin 2018 à 16:33, Rici Lake <ricil...@gmail.com> 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