%{ =head1 SYNOPSIS See section 'SOLVING CONFLICTS WITH THE POSTPONED CONFLICT STRATEGY' in http://search.cpan.org/perldoc?Parse::Eyapp::debuggingtut This example illustrates how to dynamically change the behavior of the parser for a shift-reduce conflict Be sure C is reachable compile it with eyapp -b '' DynamicallyChangingTheParser.eyp execute the generated modulino with the option C<-t>: ./DynamicallyChangingTheParser.pm -t =head1 See also Debug.eyp Debug1.eyp Debug2.eyp and DebugLookForward.eyp =cut our $VERSION = '0.01'; %} %token D S %lexer { m{\G(\s+)}gc and $self->tokenline($1 =~ tr{\n}{}); return ($1,$1) if m{\G(.)}gc; } %tree bypass # Expect just 1 shift-reduce conflict %expect 1 %conflict ISLAST { my $self = shift; if (${$self->input()} =~ m{(?=\G\s*;\s*S)}) { $self->YYSetReduce(';', 'D1' ) } else { $self->YYSetShift(';') } } %% p: %name PROG block + ; block: %name BLOCK_DS '{' ds ';' ss '}' | %name BLOCK_S '{' ss '}' ; ds: %name D2 D %PREC ISLAST ';' ds | %name D1 D %PREC ISLAST ; ss: %name S2 S ';' ss | %name S1 S ; %% my $prompt = 'Provide a statement like "{D; S} {D; D; S}" and press : '; __PACKAGE__->main($prompt) unless caller;