%{
=head1 SYNOPSIS
See the grammar in file C<confusing.eyp> first.
This example illustrates how to solve the conflict using
the postponed conflict resolution technique.
Compile the grammar with:
eyapp -b '' confusingsolveddynamic.eyp
and execute it with:
./confusingsolveddynamic.pm -t
=head1 SEE ALSO
=over 2
=item * The grammar in file C<confusing.eyp>
=item * http://www.cs.man.ac.uk/~pjj/cs2121/ho/node19.html
=cut
use base q{DebugTail};
%}
%semantic token 'c' 'd' 'f' 'x' 'y'
%expect-rr 1
%conflict DORF {
my $self = shift;
if (${$self->input()} =~ m{^.*?d}) {
$self->YYSetReduce('c', 'XY:D' );
}
else {
$self->YYSetReduce('c', 'XY:F' );
}
}
%tree
%%
A:
%name Bcd
B 'c' 'd'
| %name Ecf
E 'c' 'f'
;
B: %name XY:D
'x' 'y' %PREC DORF
;
E: %name XY:F
'x' 'y' %PREC DORF
;
%%
__PACKAGE__->lexer( \&DebugTail::lex);
unless (caller) {
my $prompt = 'Try "x y c d" or "x y c f" and press <CR><CTRL-D>: ';
__PACKAGE__->main($prompt)
}