line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MarpaX::Languages::ECMAScript::AST::Impl; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Implementation of Marpa's interface |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
209
|
use Marpa::R2 2.080000; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use MarpaX::Languages::ECMAScript::AST::Exceptions qw/:all/; |
10
|
|
|
|
|
|
|
use MarpaX::Languages::ECMAScript::AST::Impl::Logger; |
11
|
|
|
|
|
|
|
use MarpaX::Languages::ECMAScript::AST::Impl::Singleton; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.020'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $MARPA_TRACE_FILE_HANDLE; |
16
|
|
|
|
|
|
|
our $MARPA_TRACE_BUFFER; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub BEGIN { |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
## We do not want Marpa to pollute STDERR |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
## Autovivify a new file handle |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
open($MARPA_TRACE_FILE_HANDLE, '>', \$MARPA_TRACE_BUFFER); |
25
|
|
|
|
|
|
|
if (! defined($MARPA_TRACE_FILE_HANDLE)) { |
26
|
|
|
|
|
|
|
InternalError(error => "Cannot create temporary file handle to tie Marpa logging, $!\n"); |
27
|
|
|
|
|
|
|
} else { |
28
|
|
|
|
|
|
|
if (! tie ${$MARPA_TRACE_FILE_HANDLE}, 'MarpaX::Languages::ECMAScript::AST::Impl::Logger') { |
29
|
|
|
|
|
|
|
InternalError(error => "Cannot tie $MARPA_TRACE_FILE_HANDLE, $!\n"); |
30
|
|
|
|
|
|
|
if (! close($MARPA_TRACE_FILE_HANDLE)) { |
31
|
|
|
|
|
|
|
InternalError(error => "Cannot close temporary file handle, $!\n"); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
$MARPA_TRACE_FILE_HANDLE = undef; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $singleton = MarpaX::Languages::ECMAScript::AST::Impl::Singleton->instance(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
|
|
|
|
|
|
my ($class, $grammarOptionsHashp, $recceOptionsHashp) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $self->{grammar} = $singleton->G($grammarOptionsHashp); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if (defined($recceOptionsHashp)) { |
47
|
|
|
|
|
|
|
$recceOptionsHashp->{grammar} = $self->{grammar}; |
48
|
|
|
|
|
|
|
} else { |
49
|
|
|
|
|
|
|
$recceOptionsHashp = {grammar => $self->{grammar}}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
$recceOptionsHashp->{trace_terminals} = $ENV{MARPA_TRACE_TERMINALS} || $ENV{MARPA_TRACE} || 0; |
52
|
|
|
|
|
|
|
$recceOptionsHashp->{trace_values} = $ENV{MARPA_TRACE_VALUES} || $ENV{MARPA_TRACE} || 0; |
53
|
|
|
|
|
|
|
$recceOptionsHashp->{trace_file_handle} = $MARPA_TRACE_FILE_HANDLE; |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
# Save recceOptionsHashp for further use |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
$self->{_recceOptionsHashp} = $recceOptionsHashp; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
bless($self, $class); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub make_R { |
66
|
|
|
|
|
|
|
$_[0]->{recce} = Marpa::R2::Scanless::R->new($_[0]->{_recceOptionsHashp}); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub destroy_R { |
71
|
|
|
|
|
|
|
$_[0]->{recce} = undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub value { |
76
|
|
|
|
|
|
|
return $_[0]->{recce}->value(@_[1..$#_]); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub read { |
81
|
|
|
|
|
|
|
return $_[0]->{recce}->read(@_[1..$#_]); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub resume { |
86
|
|
|
|
|
|
|
return $_[0]->{recce}->resume(@_[1..$#_]); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub last_completed { |
91
|
|
|
|
|
|
|
return $_[0]->{recce}->last_completed(@_[1..$#_]); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub last_completed_range { |
96
|
|
|
|
|
|
|
return $_[0]->{recce}->last_completed_range(@_[1..$#_]); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub range_to_string { |
101
|
|
|
|
|
|
|
return $_[0]->{recce}->range_to_string(@_[1..$#_]); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub event { |
106
|
|
|
|
|
|
|
return $_[0]->{recce}->event(@_[1..$#_]); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub events { |
111
|
|
|
|
|
|
|
return $_[0]->{recce}->events(); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub pause_lexeme { |
116
|
|
|
|
|
|
|
return $_[0]->{recce}->pause_lexeme(@_[1..$#_]); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub pause_span { |
121
|
|
|
|
|
|
|
return $_[0]->{recce}->pause_span(@_[1..$#_]); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub literal { |
126
|
|
|
|
|
|
|
return $_[0]->{recce}->literal(@_[1..$#_]); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub line_column { |
131
|
|
|
|
|
|
|
return $_[0]->{recce}->line_column(@_[1..$#_]); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub substring { |
136
|
|
|
|
|
|
|
return $_[0]->{recce}->substring(@_[1..$#_]); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub lexeme_read { |
141
|
|
|
|
|
|
|
return $_[0]->{recce}->lexeme_read(@_[1..$#_]); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub current_g1_location { |
146
|
|
|
|
|
|
|
return $_[0]->{recce}->current_g1_location(@_[1..$#_]); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub g1_location_to_span { |
151
|
|
|
|
|
|
|
return $_[0]->{recce}->g1_location_to_span(@_[1..$#_]); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub terminals_expected { |
156
|
|
|
|
|
|
|
return $_[0]->{recce}->terminals_expected(@_[1..$#_]); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub show_progress { |
161
|
|
|
|
|
|
|
return $_[0]->{recce}->show_progress(@_[1..$#_]); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub progress { |
166
|
|
|
|
|
|
|
return $_[0]->{recce}->progress(@_[1..$#_]); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub grammar { |
171
|
|
|
|
|
|
|
return $_[0]->{grammar}; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub G { |
176
|
|
|
|
|
|
|
return $_[0]->grammar; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub recce { |
181
|
|
|
|
|
|
|
return $_[0]->{recce}; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub R { |
186
|
|
|
|
|
|
|
return $_[0]->recce; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub rule_ids { |
191
|
|
|
|
|
|
|
return $_[0]->{grammar}->rule_ids(@_[1..$#_]); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub rule_expand { |
196
|
|
|
|
|
|
|
return $_[0]->{grammar}->rule_expand(@_[1..$#_]); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub symbol_name { |
201
|
|
|
|
|
|
|
return $_[0]->{grammar}->symbol_name(@_[1..$#_]); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
__END__ |