-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugDynamicResolution2.eyp
80 lines (57 loc) · 1.36 KB
/
DebugDynamicResolution2.eyp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
%{
=head1 SYNOPSIS
See http://search.cpan.org/perldoc?Parse::Eyapp::debuggingtut
This file solves the conflict in Debug.eyp using dynamic
conflict resolution techniques
(see section 'SOLVING CONFLICTS WITH THE POSTPONED CONFLICT STRATEGY' in
http://search.cpan.org/perldoc?Parse::Eyapp::debuggingtut)
Be sure C<DebugTail.pm> is reachable
compile it with
eyapp -b '' DebugDynamicResolution.eyp
Execute the generated modulino with:
./DebugDynamicResolution.pm -t
Try input "D;D;D; S;S;S".
=head1 See also
Debug.eyp Debug1.eyp Debug2.eyp DebugLookForward.eyp
=cut
our $VERSION = '0.01';
use base q{DebugTail};
%}
%token D S
%tree bypass
%%
p:
%name PROG
ds ';' ss
| %name SS
ss
;
ds:
%name MORE_Ds
D hacktables ';' ds
| %name LAST_D
D hacktables
;
ss:
%name SS
S ';' ss
| %name S
S
;
hacktables:
/* empty. This action solves the conflict using dynamic precedence */
{
my $self = shift;
if (${$self->input()} =~ m{^\s*;\s*S}) {
$self->YYSetReduce(';', 'LAST_D' )
}
else {
$self->YYSetShift(';')
}
undef; # skip this node in the AST
}
;
%%
__PACKAGE__->lexer( \&DebugTail::lex);
my $prompt = 'Provide a statement like "D;D; S;S" and press <CR><CTRL-D>: ';
__PACKAGE__->main($prompt) unless caller;