line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
23
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
our $VERSION = 0.02; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Lox::Stmt; |
6
|
|
|
|
|
|
|
sub new { |
7
|
2
|
|
|
2
|
0
|
5
|
my ($class, $args) = @_; |
8
|
2
|
|
|
|
|
9
|
return bless { %$args }, $class; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Lox::Stmt::Break; |
12
|
1
|
|
|
1
|
|
5
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub accept { |
15
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
16
|
0
|
|
|
|
|
0
|
return $visitor->visit_break_stmt($self); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Lox::Stmt::Block; |
20
|
1
|
|
|
1
|
|
74
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
21
|
0
|
|
|
0
|
|
0
|
sub statements { $_[0]->{statements} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub accept { |
24
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
25
|
0
|
|
|
|
|
0
|
return $visitor->visit_block_stmt($self); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Lox::Stmt::Class; |
29
|
1
|
|
|
1
|
|
93
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
30
|
0
|
|
|
0
|
|
0
|
sub name { $_[0]->{name} } |
31
|
0
|
|
|
0
|
|
0
|
sub methods { $_[0]->{methods} } |
32
|
0
|
|
|
0
|
|
0
|
sub superclass { $_[0]->{superclass} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub accept { |
35
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
36
|
0
|
|
|
|
|
0
|
return $visitor->visit_class_stmt($self); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package Lox::Stmt::Expression; |
40
|
1
|
|
|
1
|
|
140
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
41
|
0
|
|
|
0
|
|
0
|
sub expression { $_[0]->{expression} } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub accept { |
44
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
45
|
0
|
|
|
|
|
0
|
return $visitor->visit_expression_stmt($self); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Lox::Stmt::Function; |
49
|
1
|
|
|
1
|
|
101
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
50
|
0
|
|
|
0
|
|
0
|
sub name { $_[0]->{name} } |
51
|
0
|
|
|
0
|
|
0
|
sub params { $_[0]->{params} } |
52
|
0
|
|
|
0
|
|
0
|
sub body { $_[0]->{body} } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub accept { |
55
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
56
|
0
|
|
|
|
|
0
|
return $visitor->visit_function_stmt($self); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package Lox::Stmt::If; |
60
|
1
|
|
|
1
|
|
124
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
61
|
0
|
|
|
0
|
|
0
|
sub condition { $_[0]->{condition} } |
62
|
0
|
|
|
0
|
|
0
|
sub then_branch { $_[0]->{then_branch} } |
63
|
0
|
|
|
0
|
|
0
|
sub else_branch { $_[0]->{else_branch} } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub accept { |
66
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
67
|
0
|
|
|
|
|
0
|
return $visitor->visit_if_stmt($self); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
package Lox::Stmt::Print; |
71
|
1
|
|
|
1
|
|
234
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
72
|
2
|
|
|
2
|
|
8
|
sub expression { $_[0]->{expression} } |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub accept { |
75
|
2
|
|
|
2
|
|
4
|
my ($self, $visitor) = @_; |
76
|
2
|
|
|
|
|
6
|
return $visitor->visit_print_stmt($self); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
package Lox::Stmt::Return; |
80
|
1
|
|
|
1
|
|
126
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
81
|
0
|
|
|
0
|
|
0
|
sub keyword { $_[0]->{keyword} } |
82
|
0
|
|
|
0
|
|
0
|
sub value { $_[0]->{value} } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub accept { |
85
|
0
|
|
|
0
|
|
0
|
my ($self, $visitor) = @_; |
86
|
0
|
|
|
|
|
0
|
return $visitor->visit_return_stmt($self); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package Lox::Stmt::Var; |
90
|
1
|
|
|
1
|
|
119
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
91
|
3
|
|
|
3
|
|
13
|
sub name { $_[0]->{name} } |
92
|
3
|
|
|
3
|
|
13
|
sub initializer { $_[0]->{initializer} } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub accept { |
95
|
2
|
|
|
2
|
|
4
|
my ($self, $visitor) = @_; |
96
|
2
|
|
|
|
|
7
|
return $visitor->visit_var_stmt($self); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package Lox::Stmt::While; |
100
|
1
|
|
|
1
|
|
97
|
use parent -norequire, 'Lox::Stmt'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
101
|
0
|
|
|
0
|
|
|
sub condition { $_[0]->{condition} } |
102
|
0
|
|
|
0
|
|
|
sub body { $_[0]->{body} } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub accept { |
105
|
0
|
|
|
0
|
|
|
my ($self, $visitor) = @_; |
106
|
0
|
|
|
|
|
|
return $visitor->visit_while_stmt($self); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |