Eyapp/Treeregexp.pm

filter: Statementstmt 89.7% 561 / 625 Branchbran 64.0% 146 / 228 Conditioncond 45.7% 16 / 35 MC/DCmcdc 28.5% 6 / 21 Subroutinesub 84.0% 105 / 125 Podpod 0.0% 0 / 19 totaltotal 79.2% 834 / 1053 CC 180 SCAR 25.5
CC
180
Cov
81%
__ANON__
156.0
_Lexer
29.6
new
19.6
CRAP 12.9
« Eyapp/Node.pm ↑ Summary Eyapp/_TreeregexpSupport.pm »
1 ########################################################################################
2 #
3 # This file was generated using Parse::Eyapp version 1.21.
4 #
5 # Copyright © 2006, 2007, 2008, 2009, 2010, 2011, 2012 Casiano Rodriguez-Leon.
6 # Copyright © 2017 William N. Braswell, Jr.
7 # All Rights Reserved.
8 #
9 # Parse::Yapp is Copyright © 1998, 1999, 2000, 2001, Francois Desarmenien.
10 # Parse::Yapp is Copyright © 2017 William N. Braswell, Jr.
11 # All Rights Reserved.
12 #
13 # Don't edit this file, use source file 'lib/Parse/Eyapp/Treeregexp.yp' instead.
14 #
15 # ANY CHANGE MADE HERE WILL BE LOST !
16 #
17 ########################################################################################
18 package Parse::Eyapp::Treeregparser;
19 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 36 push @Parse::Eyapp::Treeregparser::ISA, 'Parse::Eyapp::Driver';
22  
23  
24  
25  
26 36 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=12.0
27 # This strange way to load the modules is to guarantee compatibility when
28 # using several standalone and non-standalone Eyapp parsers
29  
30 40 ▶ require Parse::Eyapp::Driver unless Parse::Eyapp::Driver->can('YYParse');
Branch: 1 branch
BranchTrueFalseTotal
unless "Parse::Eyapp::Driver"->can("YYParse") 0 40 40
31 38 ▶ require Parse::Eyapp::Node unless Parse::Eyapp::Node->can('hnew');
Branch: 1 branch
BranchTrueFalseTotal
unless "Parse::Eyapp::Node"->can("hnew") 0 40 40
32 }
33
34  
35 0 ▶sub unexpendedInput { defined($_) ? substr($_, (defined(pos $_) ? pos $_ : 0)) : '' }
Subroutine unexpendedInput: not called CC=3 SCAR=12.7
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 2 2 4
defined pos $_ ? : 0 2 2
36  
37  
38 38 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 36 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 36 our $VERSION = $Parse::Eyapp::Driver::VERSION;
42  
43 36 my $debug = 0; # comment
44 36 $Data::Dumper::Indent = 1;
45  
46 # %times: Hash indexed in the variables: stores the number of
47 # appearances in the treereg formula
48 36 my %times = ();
49 36 my ($tokenbegin, $tokenend);
50 36 my $filename; # Name of the input file
51  
52 { # closure for $numstar: support code for * treeregexes
53  
54 36 my $numstar = -1; # Number of stars in treereg formula
55  
56 3 ▶ sub new_star {
Subroutine new_star: called CC=1 SCAR=0.0
57 3 $numstar++;
58 3 return "W_$numstar";
59 }
60  
61 54 ▶ sub reset_times {
Subroutine reset_times: called CC=1 SCAR=0.0
62 54 %times = ();
63 54 $numstar = -1; # New formula
64 }
65 }
66  
67 # treereg: IDENT '(' childlist ')' ('and' CODE)?
68 36 ▶sub new_ident_inner {
Subroutine new_ident_inner: called CC=2 SCAR=6.9
69 90 my ($id, $line) = @{$_[1]};
70 90 my ($semantic) = $_[5]->children;
71 90 my $node = $_[3];
72  
73 90 $times{$id}++;
74  
75 90 $node->{id} = $id;
76 90 $node->{line} = $line;
77 90 ▶ $node->{semantic} = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 10 80 90
78 90 return (bless $node, 'Parse::Eyapp::Treeregexp::IDENT_INNER');
79 }
80  
81 # treereg: REGEXP (':' IDENT)? '(' childlist ')' ('and' CODE)?
82 11 ▶sub new_regexp_inner {
Subroutine new_regexp_inner: called CC=3 SCAR=11.0
83 11 my $node = $_[4];
84 11 my $line = $_[1][1];
85  
86 11 my $id;
87  
88 # $W and @W are default variables for REGEXPs
89 11 ▶ if ( $_[2]->children) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[2]->children) { } 4 7 11
90 4 $id = $_[2]->child(0)->{attr}[0];
91 }
92 else {
93 7 $id = 'W';
94 }
95 11 $times{$id}++;
96  
97 11 $node->{id} = $id;
98 11 $node->{line} = $line;
99 11 $node->{regexp} = $_[1][0];
100 11 $node->{options} = $_[1][2];
101  
102 11 my ($semantic) = $_[6]->children;
103 11 ▶ $node->{semantic} = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 11 11
104 11 return bless $node, 'Parse::Eyapp::Treeregexp::REGEXP_INNER';
105 }
106  
107 # treereg: SCALAR '(' childlist ')' ('and' CODE)?
108 2 ▶sub new_scalar_inner {
Subroutine new_scalar_inner: called CC=4 SCAR=14.0
109 2 my $node = $_[3];
110 2 my ($var, $line) = @{$_[1]};
111 2 $var =~ s/\$//;
112  
113 2 $times{$var}++;
114 2 ▶ _SyntaxError('Repeated scalar in treereg', $_[1][1]) if $times{$var} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $times{$var} > 1 0 2 2
115 2 ▶ _SyntaxError(q{Can't use $W to identify an scalar treeregexp}, $_[1][1]) if $var eq 'W';
Branch: 1 branch
BranchTrueFalseTotal
if $var eq "W" 0 2 2
116  
117 2 $node->{id} = $var;
118 2 $node->{line} = $line;
119 2 my ($semantic) = $_[5]->children;
120 2 ▶ $node->{semantic} = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 2 2
121 2 return (bless $node, 'Parse::Eyapp::Treeregexp::SCALAR_INNER');
122 }
123  
124 # treereg: : '.' '(' childlist ')' ('and' CODE)?
125 1 ▶sub new_dot_inner {
Subroutine new_dot_inner: called CC=2 SCAR=6.9
126 1 my $node = $_[3];
127 1 my $line = $_[1][1];
128 1 my $var = 'W';
129  
130 1 $times{$var}++;
131  
132 1 $node->{id} = $var;
133 1 $node->{line} = $line;
134 1 my ($semantic) = $_[5]->children;
135 1 ▶ $node->{semantic} = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 1 1
136  
137 1 return (bless $node, 'Parse::Eyapp::Treeregexp::SCALAR_INNER');
138 }
139  
140 # treereg: IDENT ('and' CODE)?
141 26 ▶sub new_ident_terminal {
Subroutine new_ident_terminal: called CC=2 SCAR=6.9
142 26 my $id = $_[1][0];
143 26 $times{$id}++;
144
145 26 my ($semantic) = $_[2]->children;
146 26 ▶ $semantic = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 5 21 26
147
148 return (
149 26 bless { children => [], attr => $id, semantic => $semantic }, 'Parse::Eyapp::Treeregexp::IDENT_TERMINAL'
150 );
151 }
152  
153 # treereg: REGEXP (':' IDENT)? ('and' CODE)?
154 1 ▶sub new_regexp_terminal {
Subroutine new_regexp_terminal: called CC=3 SCAR=11.4
155 # $regexp and @regexp are default variables for REGEXPs
156 1 my $id;
157 1 ▶ if ($_[2]->children) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[2]->children) { } 0 1 1
158 0 $id = {$_[2]->child(0)}->{attr}[0];
159 }
160 else {
161 1 $id = 'W';
162 }
163 1 $times{$id}++;
164  
165 1 my ($semantic) = $_[3]->children;
166 1 ▶ $semantic = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 1 1
167  
168 1 return bless {
169 children => [],
170 regexp => $_[1][0],
171 options => $_[1][2],
172 attr => $id,
173 semantic => $semantic
174 }, 'Parse::Eyapp::Treeregexp::REGEXP_TERMINAL'
175 }
176  
177 # treereg: SCALAR ('and' CODE)?
178 58 ▶sub new_scalar_terminal {
Subroutine new_scalar_terminal: called CC=4 SCAR=14.0
179 58 my $var = $_[1][0];
180 58 $var =~ s/\$//;
181 58 $times{$var}++;
182 58 ▶ _SyntaxError('Repeated scalar in treereg', $_[1][1]) if $times{$var} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $times{$var} > 1 0 58 58
183 58 ▶ _SyntaxError(q{Can't use $W to identify an scalar treeregexp}, $_[1][1]) if $var eq 'W';
Branch: 1 branch
BranchTrueFalseTotal
if $var eq "W" 1 57 58
184  
185 57 my ($semantic) = $_[2]->children;
186 57 ▶ $semantic = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 57 57
187  
188 57 return bless {
189 children => [],
190 attr => $var,
191 semantic => $semantic
192 }, 'Parse::Eyapp::Treeregexp::SCALAR_TERMINAL';
193 }
194  
195 # treereg: '.' ('and' CODE)?
196 25 ▶sub new_dot_terminal {
Subroutine new_dot_terminal: called CC=2 SCAR=7.0
197 # $W and @W are implicit variables for dots "."
198 25 $times{'W'}++;
199  
200 25 my ($semantic) = $_[2]->children;
201 25 ▶ $semantic = $semantic? $semantic->{attr} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$semantic ? : 0 25 25
202  
203 25 return bless {
204 children => [],
205 attr => 'W',
206 semantic => $semantic
207 }, 'Parse::Eyapp::Treeregexp::SCALAR_TERMINAL';
208 }
209  
210 # treereg: ARRAY
211 38 ▶sub new_array_terminal {
Subroutine new_array_terminal: called CC=3 SCAR=11.0
212 38 my $var = $_[1][0];
213 38 $var =~ s/\@//;
214  
215 38 $times{$var} += 2; # awful trick so that fill_declarations works
216 38 ▶ _SyntaxError( 'Repeated array in treereg', $_[1][1]) if $times{$var} > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $times{$var} > 2 1 37 38
217 37 ▶ _SyntaxError("Can't use $var to identify an array treeregexp", $_[1][1]) if $var =~ /^W(_\d+)?$/;
Branch: 1 branch
BranchTrueFalseTotal
if $var =~ /^W(_\d+)?$/ 1 36 37
218  
219 36 return bless {
220 children => [],
221 attr => $var,
222 }, 'Parse::Eyapp::Treeregexp::ARRAY_TERMINAL';
223 }
224  
225 # treereg: '*'
226 3 ▶sub new_array_star {
Subroutine new_array_star: called CC=1 SCAR=0.0
227 # $wathever_#number and @wathever_#number are reserved for "*"
228 3 my $var = new_star();
229 3 $times{$var} += 2;
230  
231 3 return bless {
232 children => [],
233 attr => $var,
234 }, 'Parse::Eyapp::Treeregexp::ARRAY_TERMINAL';
235 }
236  
237  
238 # Default lexical analyzer
239 0 ▶our $LEX = sub {
Subroutine __ANON__: not called CC=12 SCAR=50.5
240 0 my $self = shift;
241 0 my $pos;
242  
243 0 for (${$self->input}) {
244
245  
246 0 ▶ m{\G(\s+)}gc and $self->tokenline($1 =~ tr{\n}{});
Branch: 1 branch
BranchTrueFalseTotal
/\G(\s+)/cg and $self->tokenline($1 =~ tr/\n//) 0 0 0
247  
248 0 ▶ m{\G(and|\=\>|\(|\;|\,|\*|\.|\:|\)|\=)}gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(and|\=\>|\(|\;|\,|\*|\.|\:|\)|\=)/cg and return $1, $1 0 0 0
249  
250 0 ▶ /\G(REGEXP)/gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(REGEXP)/cg and return $1, $1 0 0 0
251 0 ▶ /\G(ARRAY)/gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(ARRAY)/cg and return $1, $1 0 0 0
252 0 ▶ /\G(IDENT)/gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(IDENT)/cg and return $1, $1 0 0 0
253 0 ▶ /\G(SCALAR)/gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(SCALAR)/cg and return $1, $1 0 0 0
254 0 ▶ /\G(CODE)/gc and return ($1, $1);
Branch: 1 branch
BranchTrueFalseTotal
/\G(CODE)/cg and return $1, $1 0 0 0
255  
256  
257 0 ▶ return ('', undef) if ($_ eq '') || (defined(pos($_)) && (pos($_) >= length($_)));
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "" or defined pos $_ and pos $_ >= length $_ 0 0 0
Condition0%0/6
$_ eq "" or defined pos $_ and pos $_ >= length $_
l!l&&r!l&&!r
000
defined pos $_ and pos $_ >= length $_
!ll&&!rl&&r
000
MC/DC0%0/3
$_ eq "" or defined pos $_ and pos $_ >= length $_
$_ eq "" defined pos $_ pos $_ >= length $_
Truth table0%0/4
A or B and C
A= $_ eq ""B= defined pos $_C= pos $_ >= length $_
ABCresult
1XX1
0111
00X0
0100
258 0 /\G\s*(\S+)/;
259 0 my $near = substr($1,0,10);
260  
261 0 return($near, $near);
262  
263 # die( "Error inside the lexical analyzer near '". $near
264 # ."'. Line: ".$self->line()
265 # .". File: '".$self->YYFilename()."'. No match found.\n");
266 }
267 }
268 36 ;
269  
270  
271 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
272  
273 36 my $warnmessage =<< "EOFWARN";
274 Warning!: Did you changed the \@Parse::Eyapp::Treeregparser::ISA variable inside the header section of the eyapp program?
275 EOFWARN
276  
277 30 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
278 30 my($class)=shift;
279 30 ▶ ref($class) and $class=ref($class);
Branch: 1 branch
BranchTrueFalseTotal
ref $class and $class = ref $class 0 30 30
280  
281 30 ▶ warn $warnmessage unless __PACKAGE__->isa('Parse::Eyapp::Driver');
Branch: 1 branch
BranchTrueFalseTotal
unless __PACKAGE__->isa("Parse::Eyapp::Driver") 0 30 30
282 my($self)=$class->SUPER::new(
283 yyversion => '1.21',
284 yyGRAMMAR =>
285 [#[productionNameAndLabel => lhs, [ rhs], bypass]]
286 [ '_SUPERSTART' => '$start', [ 'treeregexplist', '$end' ], 0 ],
287 [ '_STAR_LIST' => 'STAR-1', [ 'STAR-1', 'treeregexp' ], 0 ],
288 [ '_STAR_LIST' => 'STAR-1', [ ], 0 ],
289 [ 'treeregexplist_3' => 'treeregexplist', [ 'STAR-1' ], 0 ],
290 [ '_PAREN' => 'PAREN-2', [ '=>', 'CODE' ], 0 ],
291 [ '_OPTIONAL' => 'OPTIONAL-3', [ 'PAREN-2' ], 0 ],
292 [ '_OPTIONAL' => 'OPTIONAL-3', [ ], 0 ],
293 [ '_PLUS_LIST' => 'PLUS-4', [ 'PLUS-4', 'IDENT' ], 0 ],
294 [ '_PLUS_LIST' => 'PLUS-4', [ 'IDENT' ], 0 ],
295 [ 'treeregexp_9' => 'treeregexp', [ 'IDENT', ':', 'treereg', 'OPTIONAL-3' ], 0 ],
296 [ 'treeregexp_10' => 'treeregexp', [ 'CODE' ], 0 ],
297 [ 'treeregexp_11' => 'treeregexp', [ 'IDENT', '=', 'PLUS-4', ';' ], 0 ],
298 [ 'treeregexp_12' => 'treeregexp', [ 'REGEXP' ], 0 ],
299 [ '_PAREN' => 'PAREN-5', [ 'and', 'CODE' ], 0 ],
300 [ '_OPTIONAL' => 'OPTIONAL-6', [ 'PAREN-5' ], 0 ],
301 [ '_OPTIONAL' => 'OPTIONAL-6', [ ], 0 ],
302 [ '_PAREN' => 'PAREN-7', [ ':', 'IDENT' ], 0 ],
303 [ '_OPTIONAL' => 'OPTIONAL-8', [ 'PAREN-7' ], 0 ],
304 [ '_OPTIONAL' => 'OPTIONAL-8', [ ], 0 ],
305 [ '_PAREN' => 'PAREN-9', [ 'and', 'CODE' ], 0 ],
306 [ '_OPTIONAL' => 'OPTIONAL-10', [ 'PAREN-9' ], 0 ],
307 [ '_OPTIONAL' => 'OPTIONAL-10', [ ], 0 ],
308 [ '_PAREN' => 'PAREN-11', [ 'and', 'CODE' ], 0 ],
309 [ '_OPTIONAL' => 'OPTIONAL-12', [ 'PAREN-11' ], 0 ],
310 [ '_OPTIONAL' => 'OPTIONAL-12', [ ], 0 ],
311 [ '_PAREN' => 'PAREN-13', [ 'and', 'CODE' ], 0 ],
312 [ '_OPTIONAL' => 'OPTIONAL-14', [ 'PAREN-13' ], 0 ],
313 [ '_OPTIONAL' => 'OPTIONAL-14', [ ], 0 ],
314 [ '_PAREN' => 'PAREN-15', [ 'and', 'CODE' ], 0 ],
315 [ '_OPTIONAL' => 'OPTIONAL-16', [ 'PAREN-15' ], 0 ],
316 [ '_OPTIONAL' => 'OPTIONAL-16', [ ], 0 ],
317 [ '_PAREN' => 'PAREN-17', [ ':', 'IDENT' ], 0 ],
318 [ '_OPTIONAL' => 'OPTIONAL-18', [ 'PAREN-17' ], 0 ],
319 [ '_OPTIONAL' => 'OPTIONAL-18', [ ], 0 ],
320 [ '_PAREN' => 'PAREN-19', [ 'and', 'CODE' ], 0 ],
321 [ '_OPTIONAL' => 'OPTIONAL-20', [ 'PAREN-19' ], 0 ],
322 [ '_OPTIONAL' => 'OPTIONAL-20', [ ], 0 ],
323 [ '_PAREN' => 'PAREN-21', [ 'and', 'CODE' ], 0 ],
324 [ '_OPTIONAL' => 'OPTIONAL-22', [ 'PAREN-21' ], 0 ],
325 [ '_OPTIONAL' => 'OPTIONAL-22', [ ], 0 ],
326 [ '_PAREN' => 'PAREN-23', [ 'and', 'CODE' ], 0 ],
327 [ '_OPTIONAL' => 'OPTIONAL-24', [ 'PAREN-23' ], 0 ],
328 [ '_OPTIONAL' => 'OPTIONAL-24', [ ], 0 ],
329 [ 'treereg_43' => 'treereg', [ 'IDENT', '(', 'childlist', ')', 'OPTIONAL-6' ], 0 ],
330 [ 'treereg_44' => 'treereg', [ 'REGEXP', 'OPTIONAL-8', '(', 'childlist', ')', 'OPTIONAL-10' ], 0 ],
331 [ 'treereg_45' => 'treereg', [ 'SCALAR', '(', 'childlist', ')', 'OPTIONAL-12' ], 0 ],
332 [ 'treereg_46' => 'treereg', [ '.', '(', 'childlist', ')', 'OPTIONAL-14' ], 0 ],
333 [ 'treereg_47' => 'treereg', [ 'IDENT', 'OPTIONAL-16' ], 0 ],
334 [ 'treereg_48' => 'treereg', [ 'REGEXP', 'OPTIONAL-18', 'OPTIONAL-20' ], 0 ],
335 [ 'treereg_49' => 'treereg', [ 'SCALAR', 'OPTIONAL-22' ], 0 ],
336 [ 'treereg_50' => 'treereg', [ '.', 'OPTIONAL-24' ], 0 ],
337 [ 'treereg_51' => 'treereg', [ 'ARRAY' ], 0 ],
338 [ 'treereg_52' => 'treereg', [ '*' ], 0 ],
339 [ '_STAR_LIST' => 'STAR-25', [ 'STAR-25', ',', 'treereg' ], 0 ],
340 [ '_STAR_LIST' => 'STAR-25', [ 'treereg' ], 0 ],
341 [ '_STAR_LIST' => 'STAR-26', [ 'STAR-25' ], 0 ],
342 [ '_STAR_LIST' => 'STAR-26', [ ], 0 ],
343 [ 'childlist_57' => 'childlist', [ 'STAR-26' ], 0 ],
344 ],
345 yyLABELS =>
346 {
347 '_SUPERSTART' => 0,
348 '_STAR_LIST' => 1,
349 '_STAR_LIST' => 2,
350 'treeregexplist_3' => 3,
351 '_PAREN' => 4,
352 '_OPTIONAL' => 5,
353 '_OPTIONAL' => 6,
354 '_PLUS_LIST' => 7,
355 '_PLUS_LIST' => 8,
356 'treeregexp_9' => 9,
357 'treeregexp_10' => 10,
358 'treeregexp_11' => 11,
359 'treeregexp_12' => 12,
360 '_PAREN' => 13,
361 '_OPTIONAL' => 14,
362 '_OPTIONAL' => 15,
363 '_PAREN' => 16,
364 '_OPTIONAL' => 17,
365 '_OPTIONAL' => 18,
366 '_PAREN' => 19,
367 '_OPTIONAL' => 20,
368 '_OPTIONAL' => 21,
369 '_PAREN' => 22,
370 '_OPTIONAL' => 23,
371 '_OPTIONAL' => 24,
372 '_PAREN' => 25,
373 '_OPTIONAL' => 26,
374 '_OPTIONAL' => 27,
375 '_PAREN' => 28,
376 '_OPTIONAL' => 29,
377 '_OPTIONAL' => 30,
378 '_PAREN' => 31,
379 '_OPTIONAL' => 32,
380 '_OPTIONAL' => 33,
381 '_PAREN' => 34,
382 '_OPTIONAL' => 35,
383 '_OPTIONAL' => 36,
384 '_PAREN' => 37,
385 '_OPTIONAL' => 38,
386 '_OPTIONAL' => 39,
387 '_PAREN' => 40,
388 '_OPTIONAL' => 41,
389 '_OPTIONAL' => 42,
390 'treereg_43' => 43,
391 'treereg_44' => 44,
392 'treereg_45' => 45,
393 'treereg_46' => 46,
394 'treereg_47' => 47,
395 'treereg_48' => 48,
396 'treereg_49' => 49,
397 'treereg_50' => 50,
398 'treereg_51' => 51,
399 'treereg_52' => 52,
400 '_STAR_LIST' => 53,
401 '_STAR_LIST' => 54,
402 '_STAR_LIST' => 55,
403 '_STAR_LIST' => 56,
404 'childlist_57' => 57,
405 },
406 yyTERMS =>
407 { '' => { ISSEMANTIC => 0 },
408 '(' => { ISSEMANTIC => 0 },
409 ')' => { ISSEMANTIC => 0 },
410 '*' => { ISSEMANTIC => 0 },
411 ',' => { ISSEMANTIC => 0 },
412 '.' => { ISSEMANTIC => 0 },
413 ':' => { ISSEMANTIC => 0 },
414 ';' => { ISSEMANTIC => 0 },
415 '=' => { ISSEMANTIC => 0 },
416 '=>' => { ISSEMANTIC => 0 },
417 'and' => { ISSEMANTIC => 0 },
418 ARRAY => { ISSEMANTIC => 1 },
419 CODE => { ISSEMANTIC => 1 },
420 IDENT => { ISSEMANTIC => 1 },
421 REGEXP => { ISSEMANTIC => 1 },
422 SCALAR => { ISSEMANTIC => 1 },
423 error => { ISSEMANTIC => 0 },
424 },
425 yyFILENAME => 'lib/Parse/Eyapp/Treeregexp.yp',
426 yystates =>
427 [
428 {#State 0
429 DEFAULT => -2,
430 GOTOS => {
431 'treeregexplist' => 2,
432 'STAR-1' => 1
433 }
434 },
435 {#State 1
436 ACTIONS => {
437 'REGEXP' => 5,
438 'IDENT' => 6,
439 '' => -3,
440 'CODE' => 3
441 },
442 GOTOS => {
443 'treeregexp' => 4
444 }
445 },
446 {#State 2
447 ACTIONS => {
448 '' => 7
449 }
450 },
451 {#State 3
452 DEFAULT => -10
453 },
454 {#State 4
455 DEFAULT => -1
456 },
457 {#State 5
458 DEFAULT => -12
459 },
460 {#State 6
461 ACTIONS => {
462 "=" => 9,
463 ":" => 8
464 }
465 },
466 {#State 7
467 DEFAULT => 0
468 },
469 {#State 8
470 ACTIONS => {
471 "." => 16,
472 'REGEXP' => 11,
473 "*" => 13,
474 'ARRAY' => 14,
475 'IDENT' => 12,
476 'SCALAR' => 10
477 },
478 GOTOS => {
479 'treereg' => 15
480 }
481 },
482 {#State 9
483 ACTIONS => {
484 'IDENT' => 18
485 },
486 GOTOS => {
487 'PLUS-4' => 17
488 }
489 },
490 {#State 10
491 ACTIONS => {
492 'CODE' => -39,
493 ")" => -39,
494 "=>" => -39,
495 'IDENT' => -39,
496 '' => -39,
497 "(" => 21,
498 "," => -39,
499 "and" => 19,
500 'REGEXP' => -39
501 },
502 GOTOS => {
503 'PAREN-21' => 22,
504 'OPTIONAL-22' => 20
505 }
506 },
507 {#State 11
508 ACTIONS => {
509 '' => -33,
510 "(" => -18,
511 "," => -33,
512 'REGEXP' => -33,
513 "and" => -33,
514 'CODE' => -33,
515 ":" => 25,
516 "=>" => -33,
517 'IDENT' => -33,
518 ")" => -33
519 },
520 GOTOS => {
521 'OPTIONAL-8' => 24,
522 'PAREN-17' => 23,
523 'PAREN-7' => 27,
524 'OPTIONAL-18' => 26
525 }
526 },
527 {#State 12
528 ACTIONS => {
529 "and" => 29,
530 'REGEXP' => -30,
531 "(" => 28,
532 '' => -30,
533 "," => -30,
534 ")" => -30,
535 "=>" => -30,
536 'IDENT' => -30,
537 'CODE' => -30
538 },
539 GOTOS => {
540 'PAREN-15' => 30,
541 'OPTIONAL-16' => 31
542 }
543 },
544 {#State 13
545 DEFAULT => -52
546 },
547 {#State 14
548 DEFAULT => -51
549 },
550 {#State 15
551 ACTIONS => {
552 'REGEXP' => -6,
553 "=>" => 33,
554 'IDENT' => -6,
555 'CODE' => -6,
556 '' => -6
557 },
558 GOTOS => {
559 'PAREN-2' => 34,
560 'OPTIONAL-3' => 32
561 }
562 },
563 {#State 16
564 ACTIONS => {
565 'CODE' => -42,
566 ")" => -42,
567 "=>" => -42,
568 'IDENT' => -42,
569 '' => -42,
570 "(" => 38,
571 "," => -42,
572 "and" => 35,
573 'REGEXP' => -42
574 },
575 GOTOS => {
576 'OPTIONAL-24' => 37,
577 'PAREN-23' => 36
578 }
579 },
580 {#State 17
581 ACTIONS => {
582 'IDENT' => 39,
583 ";" => 40
584 }
585 },
586 {#State 18
587 DEFAULT => -8
588 },
589 {#State 19
590 ACTIONS => {
591 'CODE' => 41
592 }
593 },
594 {#State 20
595 DEFAULT => -49
596 },
597 {#State 21
598 ACTIONS => {
599 'ARRAY' => 14,
600 'IDENT' => 12,
601 'SCALAR' => 10,
602 ")" => -56,
603 "." => 16,
604 'REGEXP' => 11,
605 "*" => 13
606 },
607 GOTOS => {
608 'STAR-25' => 43,
609 'childlist' => 44,
610 'STAR-26' => 42,
611 'treereg' => 45
612 }
613 },
614 {#State 22
615 DEFAULT => -38
616 },
617 {#State 23
618 DEFAULT => -32
619 },
620 {#State 24
621 ACTIONS => {
622 "(" => 46
623 }
624 },
625 {#State 25
626 ACTIONS => {
627 'IDENT' => 47
628 }
629 },
630 {#State 26
631 ACTIONS => {
632 '' => -36,
633 "," => -36,
634 'REGEXP' => -36,
635 "and" => 50,
636 'CODE' => -36,
637 "=>" => -36,
638 'IDENT' => -36,
639 ")" => -36
640 },
641 GOTOS => {
642 'PAREN-19' => 48,
643 'OPTIONAL-20' => 49
644 }
645 },
646 {#State 27
647 DEFAULT => -17
648 },
649 {#State 28
650 ACTIONS => {
651 'REGEXP' => 11,
652 "*" => 13,
653 ")" => -56,
654 'SCALAR' => 10,
655 'IDENT' => 12,
656 'ARRAY' => 14,
657 "." => 16
658 },
659 GOTOS => {
660 'childlist' => 51,
661 'STAR-25' => 43,
662 'STAR-26' => 42,
663 'treereg' => 45
664 }
665 },
666 {#State 29
667 ACTIONS => {
668 'CODE' => 52
669 }
670 },
671 {#State 30
672 DEFAULT => -29
673 },
674 {#State 31
675 DEFAULT => -47
676 },
677 {#State 32
678 DEFAULT => -9
679 },
680 {#State 33
681 ACTIONS => {
682 'CODE' => 53
683 }
684 },
685 {#State 34
686 DEFAULT => -5
687 },
688 {#State 35
689 ACTIONS => {
690 'CODE' => 54
691 }
692 },
693 {#State 36
694 DEFAULT => -41
695 },
696 {#State 37
697 DEFAULT => -50
698 },
699 {#State 38
700 ACTIONS => {
701 'ARRAY' => 14,
702 'IDENT' => 12,
703 'SCALAR' => 10,
704 ")" => -56,
705 "." => 16,
706 "*" => 13,
707 'REGEXP' => 11
708 },
709 GOTOS => {
710 'treereg' => 45,
711 'STAR-26' => 42,
712 'childlist' => 55,
713 'STAR-25' => 43
714 }
715 },
716 {#State 39
717 DEFAULT => -7
718 },
719 {#State 40
720 DEFAULT => -11
721 },
722 {#State 41
723 DEFAULT => -37
724 },
725 {#State 42
726 DEFAULT => -57
727 },
728 {#State 43
729 ACTIONS => {
730 "," => 56,
731 ")" => -55
732 }
733 },
734 {#State 44
735 ACTIONS => {
736 ")" => 57
737 }
738 },
739 {#State 45
740 DEFAULT => -54
741 },
742 {#State 46
743 ACTIONS => {
744 "." => 16,
745 'IDENT' => 12,
746 'ARRAY' => 14,
747 'SCALAR' => 10,
748 ")" => -56,
749 'REGEXP' => 11,
750 "*" => 13
751 },
752 GOTOS => {
753 'treereg' => 45,
754 'STAR-26' => 42,
755 'STAR-25' => 43,
756 'childlist' => 58
757 }
758 },
759 {#State 47
760 ACTIONS => {
761 "=>" => -31,
762 'IDENT' => -31,
763 ")" => -31,
764 'CODE' => -31,
765 'REGEXP' => -31,
766 "and" => -31,
767 "(" => -16,
768 '' => -31,
769 "," => -31
770 }
771 },
772 {#State 48
773 DEFAULT => -35
774 },
775 {#State 49
776 DEFAULT => -48
777 },
778 {#State 50
779 ACTIONS => {
780 'CODE' => 59
781 }
782 },
783 {#State 51
784 ACTIONS => {
785 ")" => 60
786 }
787 },
788 {#State 52
789 DEFAULT => -28
790 },
791 {#State 53
792 DEFAULT => -4
793 },
794 {#State 54
795 DEFAULT => -40
796 },
797 {#State 55
798 ACTIONS => {
799 ")" => 61
800 }
801 },
802 {#State 56
803 ACTIONS => {
804 'REGEXP' => 11,
805 'ARRAY' => 14,
806 "*" => 13,
807 'IDENT' => 12,
808 'SCALAR' => 10,
809 "." => 16
810 },
811 GOTOS => {
812 'treereg' => 62
813 }
814 },
815 {#State 57
816 ACTIONS => {
817 'REGEXP' => -24,
818 "and" => 65,
819 '' => -24,
820 "," => -24,
821 "=>" => -24,
822 'IDENT' => -24,
823 ")" => -24,
824 'CODE' => -24
825 },
826 GOTOS => {
827 'PAREN-11' => 64,
828 'OPTIONAL-12' => 63
829 }
830 },
831 {#State 58
832 ACTIONS => {
833 ")" => 66
834 }
835 },
836 {#State 59
837 DEFAULT => -34
838 },
839 {#State 60
840 ACTIONS => {
841 'REGEXP' => -15,
842 "and" => 67,
843 '' => -15,
844 "," => -15,
845 "=>" => -15,
846 'IDENT' => -15,
847 ")" => -15,
848 'CODE' => -15
849 },
850 GOTOS => {
851 'PAREN-5' => 68,
852 'OPTIONAL-6' => 69
853 }
854 },
855 {#State 61
856 ACTIONS => {
857 '' => -27,
858 "," => -27,
859 'REGEXP' => -27,
860 "and" => 72,
861 'CODE' => -27,
862 "=>" => -27,
863 'IDENT' => -27,
864 ")" => -27
865 },
866 GOTOS => {
867 'PAREN-13' => 70,
868 'OPTIONAL-14' => 71
869 }
870 },
871 {#State 62
872 DEFAULT => -53
873 },
874 {#State 63
875 DEFAULT => -45
876 },
877 {#State 64
878 DEFAULT => -23
879 },
880 {#State 65
881 ACTIONS => {
882 'CODE' => 73
883 }
884 },
885 {#State 66
886 ACTIONS => {
887 'CODE' => -21,
888 ")" => -21,
889 'IDENT' => -21,
890 "=>" => -21,
891 "," => -21,
892 '' => -21,
893 "and" => 76,
894 'REGEXP' => -21
895 },
896 GOTOS => {
897 'OPTIONAL-10' => 75,
898 'PAREN-9' => 74
899 }
900 },
901 {#State 67
902 ACTIONS => {
903 'CODE' => 77
904 }
905 },
906 {#State 68
907 DEFAULT => -14
908 },
909 {#State 69
910 DEFAULT => -43
911 },
912 {#State 70
913 DEFAULT => -26
914 },
915 {#State 71
916 DEFAULT => -46
917 },
918 {#State 72
919 ACTIONS => {
920 'CODE' => 78
921 }
922 },
923 {#State 73
924 DEFAULT => -22
925 },
926 {#State 74
927 DEFAULT => -20
928 },
929 {#State 75
930 DEFAULT => -44
931 },
932 {#State 76
933 ACTIONS => {
934 'CODE' => 79
935 }
936 },
937 {#State 77
938 DEFAULT => -13
939 },
940 {#State 78
941 DEFAULT => -25
942 },
943 {#State 79
944 DEFAULT => -19
945 }
946 ],
947 yyrules =>
948 [
949 [#Rule _SUPERSTART
950 '$start', 2, undef
951 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
952 ],
953 [#Rule _STAR_LIST
954 'STAR-1', 2,
955 68 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_TX1X2 }
Subroutine __ANON__: called CC=1 SCAR=0.0
956 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
957 ],
958 [#Rule _STAR_LIST
959 'STAR-1', 0,
960 30 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
961 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
962 ],
963 [#Rule treeregexplist_3
964 'treeregexplist', 1,
965 27 ▶sub { $_[1]->{children} }
Subroutine __ANON__: called CC=1 SCAR=0.0
966 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
967 ],
968 [#Rule _PAREN
969 'PAREN-2', 2,
970 50 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: called CC=1 SCAR=0.0
971 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
972 ],
973 [#Rule _OPTIONAL
974 'OPTIONAL-3', 1,
975 50 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
976 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
977 ],
978 [#Rule _OPTIONAL
979 'OPTIONAL-3', 0,
980 4 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
981 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
982 ],
983 [#Rule _PLUS_LIST
984 'PLUS-4', 2,
985 6 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_TX1X2 }
Subroutine __ANON__: called CC=1 SCAR=0.0
986 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
987 ],
988 [#Rule _PLUS_LIST
989 'PLUS-4', 1,
990 4 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
991 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
992 ],
993 [#Rule treeregexp_9
994 'treeregexp', 4,
995 54 ▶sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
996 54 my $name = $_[1][0];
997 54 my $tree = $_[3];
998 54 my ($action) = $_[4]->children;
999 my $self = bless {
1000 name => $name,
1001 times => [ %times ],
1002 54 children => [$tree, $action->{attr} ]
1003 }, 'Parse::Eyapp::Treeregexp::TREEREGEXP';
1004 54 reset_times();
1005 54 ▶ print Dumper($self) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 54 54
1006 54 $self;
1007 }
1008 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1009 ],
1010 [#Rule treeregexp_10
1011 'treeregexp', 1,
1012 10 ▶sub { bless $_[1], 'Parse::Eyapp::Treeregexp::GLOBALCODE'; }
Subroutine __ANON__: called CC=1 SCAR=0.0
1013 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1014 ],
1015 [#Rule treeregexp_11
1016 'treeregexp', 4,
1017 4 ▶sub { bless { name => $_[1], members => $_[3] }, 'Parse::Eyapp::Treeregexp::FAMILY'; }
Subroutine __ANON__: called CC=1 SCAR=0.0
1018 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1019 ],
1020 [#Rule treeregexp_12
1021 'treeregexp', 1,
1022 0 ▶sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1023 0 _SyntaxError("Expected an Identifier for the treeregexp", $tokenend);
1024 }
1025 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1026 ],
1027 [#Rule _PAREN
1028 'PAREN-5', 2,
1029 10 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: called CC=1 SCAR=0.0
1030 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1031 ],
1032 [#Rule _OPTIONAL
1033 'OPTIONAL-6', 1,
1034 10 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
1035 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1036 ],
1037 [#Rule _OPTIONAL
1038 'OPTIONAL-6', 0,
1039 80 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1040 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1041 ],
1042 [#Rule _PAREN
1043 'PAREN-7', 2,
1044 4 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: called CC=1 SCAR=0.0
1045 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1046 ],
1047 [#Rule _OPTIONAL
1048 'OPTIONAL-8', 1,
1049 4 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
1050 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1051 ],
1052 [#Rule _OPTIONAL
1053 'OPTIONAL-8', 0,
1054 8 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1055 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1056 ],
1057 [#Rule _PAREN
1058 'PAREN-9', 2,
1059 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1060 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1061 ],
1062 [#Rule _OPTIONAL
1063 'OPTIONAL-10', 1,
1064 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1065 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1066 ],
1067 [#Rule _OPTIONAL
1068 'OPTIONAL-10', 0,
1069 11 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1070 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1071 ],
1072 [#Rule _PAREN
1073 'PAREN-11', 2,
1074 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1075 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1076 ],
1077 [#Rule _OPTIONAL
1078 'OPTIONAL-12', 1,
1079 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1080 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1081 ],
1082 [#Rule _OPTIONAL
1083 'OPTIONAL-12', 0,
1084 2 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1085 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1086 ],
1087 [#Rule _PAREN
1088 'PAREN-13', 2,
1089 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1090 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1091 ],
1092 [#Rule _OPTIONAL
1093 'OPTIONAL-14', 1,
1094 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1095 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1096 ],
1097 [#Rule _OPTIONAL
1098 'OPTIONAL-14', 0,
1099 1 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1100 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1101 ],
1102 [#Rule _PAREN
1103 'PAREN-15', 2,
1104 5 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: called CC=1 SCAR=0.0
1105 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1106 ],
1107 [#Rule _OPTIONAL
1108 'OPTIONAL-16', 1,
1109 5 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
1110 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1111 ],
1112 [#Rule _OPTIONAL
1113 'OPTIONAL-16', 0,
1114 21 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1115 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1116 ],
1117 [#Rule _PAREN
1118 'PAREN-17', 2,
1119 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1120 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1121 ],
1122 [#Rule _OPTIONAL
1123 'OPTIONAL-18', 1,
1124 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1125 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1126 ],
1127 [#Rule _OPTIONAL
1128 'OPTIONAL-18', 0,
1129 1 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1130 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1131 ],
1132 [#Rule _PAREN
1133 'PAREN-19', 2,
1134 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1135 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1136 ],
1137 [#Rule _OPTIONAL
1138 'OPTIONAL-20', 1,
1139 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1140 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1141 ],
1142 [#Rule _OPTIONAL
1143 'OPTIONAL-20', 0,
1144 1 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1145 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1146 ],
1147 [#Rule _PAREN
1148 'PAREN-21', 2,
1149 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1150 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1151 ],
1152 [#Rule _OPTIONAL
1153 'OPTIONAL-22', 1,
1154 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1155 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1156 ],
1157 [#Rule _OPTIONAL
1158 'OPTIONAL-22', 0,
1159 58 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1160 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1161 ],
1162 [#Rule _PAREN
1163 'PAREN-23', 2,
1164 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforParenthesis}
Subroutine __ANON__: not called CC=1 SCAR=6.9
1165 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1166 ],
1167 [#Rule _OPTIONAL
1168 'OPTIONAL-24', 1,
1169 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1170 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1171 ],
1172 [#Rule _OPTIONAL
1173 'OPTIONAL-24', 0,
1174 25 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: called CC=1 SCAR=0.0
1175 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1176 ],
1177 [#Rule treereg_43
1178 'treereg', 5,
1179 90 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1180 90 goto &new_ident_inner;
1181 }
1182 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1183 ],
1184 [#Rule treereg_44
1185 'treereg', 6,
1186 11 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1187 11 goto &new_regexp_inner;
1188 }
1189 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1190 ],
1191 [#Rule treereg_45
1192 'treereg', 5,
1193 2 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1194 2 goto &new_scalar_inner;
1195 }
1196 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1197 ],
1198 [#Rule treereg_46
1199 'treereg', 5,
1200 1 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1201 1 goto &new_dot_inner;
1202 }
1203 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1204 ],
1205 [#Rule treereg_47
1206 'treereg', 2,
1207 26 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1208 26 goto &new_ident_terminal;
1209 }
1210 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1211 ],
1212 [#Rule treereg_48
1213 'treereg', 3,
1214 1 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1215 1 goto &new_regexp_terminal;
1216 }
1217 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1218 ],
1219 [#Rule treereg_49
1220 'treereg', 2,
1221 58 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1222 58 goto &new_scalar_terminal;
1223 }
1224 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1225 ],
1226 [#Rule treereg_50
1227 'treereg', 2,
1228 25 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1229 25 goto &new_dot_terminal;
1230 }
1231 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1232 ],
1233 [#Rule treereg_51
1234 'treereg', 1,
1235 38 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1236 38 goto &new_array_terminal;
1237 }
1238 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1239 ],
1240 [#Rule treereg_52
1241 'treereg', 1,
1242 3 ▶sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1243 3 goto &new_array_star;
1244 }
1245 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1246 ],
1247 [#Rule _STAR_LIST
1248 'STAR-25', 3,
1249 88 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_TX1X2 }
Subroutine __ANON__: called CC=1 SCAR=0.0
1250 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1251 ],
1252 [#Rule _STAR_LIST
1253 'STAR-25', 1,
1254 110 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_single }
Subroutine __ANON__: called CC=1 SCAR=0.0
1255 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1256 ],
1257 [#Rule _STAR_LIST
1258 'STAR-26', 1,
1259 104 ▶sub { { $_[1] } # optimize
Subroutine __ANON__: called CC=1 SCAR=0.0
1260 }
1261 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1262 ],
1263 [#Rule _STAR_LIST
1264 'STAR-26', 0,
1265 0 ▶sub { goto &Parse::Eyapp::Driver::YYActionforT_empty }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1266 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1267 ],
1268 [#Rule childlist_57
1269 'childlist', 1,
1270 104 ▶sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
1271 104 my @list = $_[1]->children();
1272 104 my @New = ();
1273 104 my ($r, $b);
1274 104 my $numarrays = 0;
1275  
1276 # Merge array prefixes with its successors
1277 104 local $_;
1278 104 ▶ while (@list) {
Branch: 1 branch
BranchTrueFalseTotal
if (@list) 174 104 278
1279 174 $_ = shift @list;
1280 174 ▶ if ($_->isa('Parse::Eyapp::Treeregexp::ARRAY_TERMINAL')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa("Parse::Eyapp::Treeregexp::ARRAY_TERMINAL")) 35 139 174
1281 35 $numarrays++;
1282 35 $r = shift @list;
1283 35 ▶ if (defined($r)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r) 16 19 35
1284 16 ▶ croak "Error. Two consecutive lists are not allowed!" if $r->isa('Parse::Eyapp::Treeregexp::ARRAY_TERMINAL');
Branch: 1 branch
BranchTrueFalseTotal
if $r->isa("Parse::Eyapp::Treeregexp::ARRAY_TERMINAL") 0 16 16
1285 16 $r->{arrayprefix} = $_->{attr};
1286 16 $_ = $r;
1287 }
1288 }
1289 174 push @New, $_;
1290 }
1291 104 $_[1]->{numarrays} = $numarrays;
1292 104 $_[1]->{children} = \@New;
1293 104 $_[1];
1294 }
1295 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1296 30 ]
1297 ],
1298 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
1299 yybypass => 0,
1300 yybuildingtree => 0,
1301 yyprefix => '',
1302 yyaccessors => {
1303 },
1304 yyconflicthandlers => {}
1305 ,
1306 yystateconflict => { },
1307 @_,
1308 );
1309 30 bless($self,$class);
1310  
1311 30 $self->make_node_classes('TERMINAL', '_OPTIONAL', '_STAR_LIST', '_PLUS_LIST',
1312 '_SUPERSTART',
1313 '_STAR_LIST',
1314 '_STAR_LIST',
1315 'treeregexplist_3',
1316 '_PAREN',
1317 '_OPTIONAL',
1318 '_OPTIONAL',
1319 '_PLUS_LIST',
1320 '_PLUS_LIST',
1321 'treeregexp_9',
1322 'treeregexp_10',
1323 'treeregexp_11',
1324 'treeregexp_12',
1325 '_PAREN',
1326 '_OPTIONAL',
1327 '_OPTIONAL',
1328 '_PAREN',
1329 '_OPTIONAL',
1330 '_OPTIONAL',
1331 '_PAREN',
1332 '_OPTIONAL',
1333 '_OPTIONAL',
1334 '_PAREN',
1335 '_OPTIONAL',
1336 '_OPTIONAL',
1337 '_PAREN',
1338 '_OPTIONAL',
1339 '_OPTIONAL',
1340 '_PAREN',
1341 '_OPTIONAL',
1342 '_OPTIONAL',
1343 '_PAREN',
1344 '_OPTIONAL',
1345 '_OPTIONAL',
1346 '_PAREN',
1347 '_OPTIONAL',
1348 '_OPTIONAL',
1349 '_PAREN',
1350 '_OPTIONAL',
1351 '_OPTIONAL',
1352 '_PAREN',
1353 '_OPTIONAL',
1354 '_OPTIONAL',
1355 'treereg_43',
1356 'treereg_44',
1357 'treereg_45',
1358 'treereg_46',
1359 'treereg_47',
1360 'treereg_48',
1361 'treereg_49',
1362 'treereg_50',
1363 'treereg_51',
1364 'treereg_52',
1365 '_STAR_LIST',
1366 '_STAR_LIST',
1367 '_STAR_LIST',
1368 '_STAR_LIST',
1369 'childlist_57', );
1370 30 $self;
1371 }
1372  
1373  
1374  
1375 36 my $input;
1376  
1377 885 ▶sub _Lexer {
Subroutine _Lexer: called CC=24 SCAR=33.9
1378  
1379 885 ▶ return('', undef) unless defined($input);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input 0 885 885
1380  
1381 #Skip blanks
1382 $input=~m{\G((?:
1383 \s+ # any white space char
1384 | \#[^\n]* # Perl like comments
1385 | /\*.*?\*/ # C like comments
1386 )+)}xsgc
1387 885 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ m[\G((?: \s+ # any white space char | \#[^\n]* # Perl like comments | /\*.*?\*/ # C like comments )+)]cgsx and do { my($blanks) = $1; pos $input >= length $input and return "", undef; $tokenend += $blanks =~ tr/\n// } 424 461 885
1388 424 my($blanks)=$1;
1389  
1390 #Maybe At EOF
1391 424 ▶ pos($input) >= length($input)
Branch: 1 branch
BranchTrueFalseTotal
pos $input >= length $input and return "", undef 27 397 424
1392 and return('', undef);
1393 397 $tokenend += $blanks =~ tr/\n//;
1394 };
1395
1396 858 $tokenbegin = $tokenend;
1397  
1398 858 ▶ $input=~/\G(and)/gc
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(and)/cg and return $1, [$1, $tokenbegin] 15 843 858
1399 and return($1, [$1, $tokenbegin]);
1400  
1401 $input=~/\G([A-Za-z_][A-Za-z0-9_]*)/gc
1402 843 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G([A-Za-z_][A-Za-z0-9_]*)/cg and do { return "IDENT", [$1, $tokenbegin] } 198 645 843
1403 198 return('IDENT', [$1, $tokenbegin]);
1404 };
1405  
1406 $input=~/\G(\$[A-Za-z_][A-Za-z0-9_]*)/gc
1407 645 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(\$[A-Za-z_][A-Za-z0-9_]*)/cg and do { return "SCALAR", [$1, $tokenbegin] } 60 585 645
1408 60 return('SCALAR', [$1, $tokenbegin]);
1409 };
1410  
1411 $input=~/\G(\@[A-Za-z_][A-Za-z0-9_]*)/gc
1412 585 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(\@[A-Za-z_][A-Za-z0-9_]*)/cg and do { return "ARRAY", [$1, $tokenbegin] } 38 547 585
1413 38 return('ARRAY', [$1, $tokenbegin]);
1414 };
1415 $input=~m{\G/(
1416 (?:[^/\\]| # no escape or slash
1417 \\\\| # escaped escape
1418 \\/| # escaped slash
1419 \\ # escape
1420 )+?
1421 )
1422 /([Begiomxsc]*)}xgc
1423 547 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ m(\G/( (?:[^/\\]| # no escape or slash \\\\| # escaped escape \\/| # escaped slash \\ # escape )+? ) /([Begiomxsc]*))cgx and do { my $string = $1; my $options = $2 ? $2 : ""; $tokenend += $string =~ tr/\n//; $string =~ s/((?:[a-zA-Z_][a-zA-Z_0-9]*::)*(?:[a-zA-Z_][a-zA-Z_0-9]*))/\\b$1\\b/g unless $options =~ s/B//; $options .= 'x' unless $options =~ /x/ or $options =~ s/X//; return "REGEXP", [$string, $tokenbegin, $options] } 13 534 547
1424 # $x=~ s/((?:[a-zA_Z_]\w*::)*(?:[a-zA_Z_]\w*))/\\b$1\\b/g
1425 13 my $string = $1;
1426 13 ▶ my $options = $2? $2 : '';
Branch: 1 branch
BranchTrueFalseTotal
$2 ? : 1 12 13
1427 13 $tokenend += $string =~ tr/\n//;
1428  
1429 # Default behavior: Each perl identifier is surrounded by \b boundaries
1430 # Use "B" option to negate this behavior
1431 13 ▶ $string =~ s/((?:[a-zA-Z_][a-zA-Z_0-9]*::)*(?:[a-zA-Z_][a-zA-Z_0-9]*))/\\b$1\\b/g
Branch: 1 branch
BranchTrueFalseTotal
unless $options =~ s/B// 13 0 13
1432 unless $options =~ s{B}{};
1433  
1434 # Default behavior: make "x" default option
1435 # Use X option to negate this behavior
1436 13 ▶ $options .= "x" unless ($options =~ m{x} or $options =~ s{X}{});
Branch: 1 branch
BranchTrueFalseTotal
unless $options =~ /x/ or $options =~ s/X// 13 0 13
Condition33%1/3
$options =~ /x/ or $options =~ s/X//
l!l&&r!l&&!r
0013
MC/DC0%0/2
$options =~ /x/ or $options =~ s/X//
$options =~ /x/ $options =~ s/X//
Truth table33%1/3
A or B
A= $options =~ /x/B= $options =~ s/X//
ABresult
1X1
011
000
1437  
1438 13 return('REGEXP', [$string, $tokenbegin, $options]);
1439 };
1440 $input=~/\G%\{/gc
1441 534 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G%\{/cg and do { my $code; $input =~ /\G(.*?)%}/cgs or _SyntaxError("Unmatched %{", $tokenbegin); $code = $1; $tokenend += $code =~ tr/\n//; return "Parse::Eyapp::Treeregexp::GLOBALCODE", [$code, $tokenbegin] } 0 534 534
1442 0 my($code);
1443  
1444 0 ▶ $input=~/\G(.*?)%}/sgc
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(.*?)%}/cgs or _SyntaxError("Unmatched %{", $tokenbegin) 0 0 0
1445 or _SyntaxError( "Unmatched %{", $tokenbegin);
1446  
1447 0 $code=$1;
1448 0 $tokenend+= $code=~tr/\n//;
1449 0 return('Parse::Eyapp::Treeregexp::GLOBALCODE', [$code, $tokenbegin]);
1450 };
1451  
1452 $input=~/\G\{/gc
1453 534 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G\{/cg and do { my($level, $from, $code); $from = pos $input; $level = 1; while ($input =~ /([{}])/cg) { substr($input, pos($input) - 1, 1) eq "\\" and next; $level += $1 eq "{" ? 1 : -1 or last; } ; $level and _SyntaxError("Not closed open curly bracket { at $tokenbegin"); $code = substr($input, $from, pos($input) - $from - 1); $tokenend += $code =~ tr/\n//; return "CODE", [$code, $tokenbegin] } 75 459 534
1454 75 my($level,$from,$code);
1455  
1456 75 $from=pos($input);
1457  
1458 75 $level=1;
1459 75 ▶ while($input=~/([{}])/gc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /([{}])/cg) 287 0 287
1460 287 ▶ substr($input,pos($input)-1,1) eq '\\' #Quoted
Branch: 1 branch
BranchTrueFalseTotal
substr($input, pos($input) - 1, 1) eq "\\" and next 0 287 287
1461 and next;
1462 287 ▶ $level += ($1 eq '{' ? 1 : -1)
Branch: 2 branches
BranchTrueFalseTotal
$level += $1 eq "{" ? 1 : -1 or last 212 75 287
$1 eq '{' ? : 106 181 287
1463 or last;
1464 }
1465 $level
1466 75 ▶ and _SyntaxError("Not closed open curly bracket { at $tokenbegin");
Branch: 1 branch
BranchTrueFalseTotal
$level and _SyntaxError("Not closed open curly bracket { at $tokenbegin") 0 75 75
1467 75 $code = substr($input,$from,pos($input)-$from-1);
1468 75 $tokenend+= $code=~tr/\n//;
1469 75 return('CODE', [$code, $tokenbegin]);
1470 };
1471  
1472 459 ▶ $input=~/\G(=>)/gc
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(=>)/cg and return $1, $1 50 409 459
1473 and return($1, $1);
1474  
1475 #Always return something
1476 $input=~/\G(.)/sg
1477 409 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$input =~ /\G(.)/gs and do { $1 eq "\n" and ++$tokenend; return $1, [$1, $tokenbegin] } 409 0 409
1478 409 ▶ $1 eq "\n" and ++$tokenend;
Branch: 1 branch
BranchTrueFalseTotal
$1 eq "\n" and ++$tokenend 0 409 409
1479 409 return ($1, [$1, $tokenbegin]);
1480 };
1481 #At EOF
1482 0 return('', undef);
1483 }
1484  
1485 0 ▶sub _Error {
Subroutine _Error: not called CC=3 SCAR=24.8
1486 0 my($value)=$_[0]->YYCurval;
1487  
1488 0 ▶ die "Syntax Error at end of file\n" unless (defined($value) and ref($value) eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and ref $value eq "ARRAY" 0 0 0
Condition0%0/3
defined $value and ref $value eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and ref $value eq "ARRAY"
defined $value ref $value eq "ARRAY"
Truth table0%0/3
A and B
A= defined $valueB= ref $value eq "ARRAY"
ABresult
0X0
100
111
1489 0 my($what)= "input: '$$value[0]'";
1490  
1491 0 _SyntaxError("Unexpected $what",$$value[1]);
1492 }
1493  
1494 3 ▶sub _SyntaxError {
Subroutine _SyntaxError: called CC=2 SCAR=7.1
1495 3 my($message,$lineno)=@_;
1496  
1497 3 ▶ $message= "Error in file $filename: $message, at ".
Branch: 1 branch
BranchTrueFalseTotal
$lineno < 0 ? : 0 3 3
1498 ($lineno < 0 ? "eof" : "line $lineno").
1499 ".\n";
1500  
1501 3 die $message;
1502 }
1503  
1504 ####################################################################
1505 # Purpose : Treeregexp compiler bottom end. Code generation.
1506  
1507 package Parse::Eyapp::Treeregexp;
1508 36 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1509 36 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
1510 36 ▶use Parse::Eyapp::Base qw(compute_lines slurp_file valid_keys invalid_keys write_file);
Subroutine BEGIN: called CC=1 SCAR=0.0
1511  
1512 my %index; # Index of each ocurrence of a variable
1513 36 my $prefix; # Assume each AST node name /class is prefixed by $prefix
1514 36 my $severity = 0; # 0 = Don't check arity. 1 = Check arity. 2 = Check and give a warning 3 = ... croak
1515 36 my $allowlinenumbers = 1; # Enable/Disable line number directives
1516 #my $warninfo = "Line numbers in error messages are relative to the line where new is called.\n";
1517 36 my %methods; # $method{$treeclass} = [ array of YATW objects or transformations ]
1518 36 my $ouputlinepattern = '##line NUM FILE # line in code by treeregexp';
1519  
1520 209 ▶sub compute_var_name {
Subroutine compute_var_name: called CC=2 SCAR=6.9
Pod undocumented
1521 209 my $var = shift;
1522  
1523 209 my $nodename;
1524 209 ▶ if ($times{$var} > 1) { # node is array
Branch: 1 branch
BranchTrueFalseTotal
if ($times{$var} > 1) { } 40 169 209
1525 40 $nodename = $index{$var}++;
1526 40 $nodename = '$'."$var\[$nodename]";
1527 }
1528 else {
1529 169 $nodename = '$'.$var;
1530 }
1531 209 return $nodename;
1532 }
1533  
1534 ####################################################################
1535 # Usage :
1536 # my $transform = Parse::Eyapp::Treeregexp->new( STRING => q{
1537 # zero_times: TIMES(NUM($x), ., .) and { $x->{attr} == 0 } => { $_[0] = $NUM }
1538 # times_zero: TIMES(., ., NUM($x)) and { $x->{attr} == 0 } => { $_[0] = $NUM }
1539 # },
1540 # PACKAGE => 'Transformations',
1541 # OUTPUTFILE => 'main.pm',
1542 # SEVERITY => 0,
1543 # NUMBERS => 0,
1544 # ) ;
1545 # Returns : A Parse::Eyapp::Treeregexp object
1546 # Throws : croak if STRING and INFILE are defined or if no input is provided
1547 # also if the PACKAGE isrg does not contain a valid identifier
1548 # Parameters :
1549 36 my %_Trnew = (
1550 PACKAGE => 'STRING', # The package where the module will reside
1551 PREFIX => 'STRING', # prefix for all the node classes
1552 OUTPUTFILE => 'STRING', # If specified the package will be dumped to such file
1553 SYNTAX => 'BOOL', # Check perl actions syntax after generating the package
1554 SEVERITY => 'INT', # Controls the level of checking matching the number of childrens
1555 PERL5LIB => 'ARRAY', # Search path
1556 INFILE => 'STRING', # Input file containing the grammar
1557 STRING => 'STRING', # Input string containing the grammar. Incompatible with INFILE
1558 NUMBERS => 'BOOL', # Generate (or not) #line directives
1559 FIRSTLINE => 'INT', # Use it only with STRING. The linenumber where the string
1560 # containing the grammar begins
1561 );
1562 36 my $validkeys = valid_keys(%_Trnew);
1563  
1564 31 ▶sub new {
Subroutine new: called CC=16 SCAR=29.8
Pod undocumented
1565 31 my $class = shift;
1566 31 ▶ croak "Error in new_package: Use named arguments" if (@_ %2);
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 31 31
1567 31 my %arg = @_;
1568  
1569 31 ▶ if (defined($a = invalid_keys(\%_Trnew, \%arg))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($a = invalid_keys(\%_Trnew, \%arg))) 1 30 31
1570 1 croak( "Parse::Eyapp::Treeregexp::new Error!: unknown argument $a. "
1571 ."Valid arguments are: $validkeys")
1572 }
1573 30 my $checksyntax = 1;
1574 30 ▶ $checksyntax = $arg{SYNTAX} if exists($arg{SYNTAX});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"SYNTAX"} 0 30 30
1575  
1576 30 my ($packagename, $outputfile) = ($arg{PACKAGE}, $arg{OUTPUTFILE});
1577  
1578 # file scope variables
1579 30 $filename = $arg{INFILE};
1580
1581 30 ▶ my $perl5lib = $arg{PERL5LIB} || [];
Condition50%1/2
$arg{'PERL5LIB'} || []
l!l
030
MC/DC0%0/1
$arg{'PERL5LIB'} || []
$arg{'PERL5LIB'}
Truth table50%1/2
A
A= $arg{'PERL5LIB'}
Aresult
11
00
1582  
1583 #package scope variables
1584 30 $severity = $arg{SEVERITY};
1585 30 ▶ $prefix = $arg{PREFIX} || '';
Condition100%2/2
$arg{'PREFIX'} || ''
l!l
228
MC/DC100%1/1
$arg{'PREFIX'} || ''
$arg{'PREFIX'}
Truth table100%2/2
A
A= $arg{'PREFIX'}
Aresult
11
00
1586 30 ▶ $allowlinenumbers = defined($arg{NUMBERS})?$arg{NUMBERS}:1 ;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{'NUMBERS'} ? : 2 28 30
1587  
1588 30 my $input_from_file = 0;
1589 30 $tokenbegin = $tokenend = 1;
1590  
1591 30 $input = $arg{STRING};
1592 30 ▶ if (defined($filename)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $filename) { } 0 30 30
elsif (defined $input) { } 30 0 30
1593 0 $input_from_file = 1;
1594 0 ▶ croak "STRING and INFILE parameters are mutually exclusive " if defined($input);
Branch: 1 branch
BranchTrueFalseTotal
if defined $input 0 0 0
1595 0 $input = slurp_file($filename, 'trg');
1596 }
1597 elsif (defined($input)) { # input from string
1598 30 my ($callerpackagename);
1599 30 ($callerpackagename, $filename, $tokenend) = caller;
1600  
1601 30 ▶ $packagename = $callerpackagename
Branch: 1 branch
BranchTrueFalseTotal
unless defined $packagename and $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/ 28 2 30
Condition66%2/3
defined $packagename and $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/
!ll&&!rl&&r
2802
MC/DC50%1/2
defined $packagename and $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/
defined $packagename $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/
Truth table66%2/3
A and B
A= defined $packagenameB= $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/
ABresult
0X0
100
111
1602 unless defined($packagename) # Perl identifier regexp
1603 and $packagename =~ /(?:[A-Za-z_][A-Za-z0-9_]*::)*[A-Za-z_][A-Za-z0-9_]*/;
1604  
1605 }
1606 else {
1607 0 croak "Undefined input.";
1608 }
1609 30 ▶ ($packagename) = $filename =~ m{(^[a-zA-Z_]\w*)} if !defined($packagename);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $packagename 0 30 30
1610 30 ▶ $tokenend = $arg{FIRSTLINE} if exists($arg{FIRSTLINE}) and $arg{FIRSTLINE} =~ m{^\s*\d+};
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"FIRSTLINE"} and $arg{"FIRSTLINE"} =~ /^\s*\d+/ 8 22 30
Condition66%2/3
exists $arg{"FIRSTLINE"} and $arg{"FIRSTLINE"} =~ /^\s*\d+/
!ll&&!rl&&r
2208
MC/DC50%1/2
exists $arg{"FIRSTLINE"} and $arg{"FIRSTLINE"} =~ /^\s*\d+/
exists $arg{"FIRSTLINE"} $arg{"FIRSTLINE"} =~ /^\s*\d+/
Truth table66%2/3
A and B
A= exists $arg{"FIRSTLINE"}B= $arg{"FIRSTLINE"} =~ /^\s*\d+/
ABresult
0X0
100
111
1611 30 $tokenbegin = $tokenend;
1612 30 ▶ croak "Bad formed package name"
Branch: 1 branch
BranchTrueFalseTotal
unless $packagename =~ /^(?:[A-Za-z_][A-Za-z0-9_]*::)* # Perl identifier: prefix (?:[A-Za-z_][A-Za-z0-9_]*)$/x 0 30 30
1613 unless $packagename =~ m{^(?:[A-Za-z_][A-Za-z0-9_]*::)* # Perl identifier: prefix
1614 (?:[A-Za-z_][A-Za-z0-9_]*)$}x;
1615  
1616  
1617 #my ($basename) = $packagename =~ m{([a-zA-Z]\w*$)};
1618 #$outputfile = "$basename.pm" unless defined($outputfile);
1619  
1620 30 my $object = bless {
1621 'INPUT_FROM_FILE' => $input_from_file,
1622 'PACKAGENAME' => $packagename,
1623 'OUTPUTFILE' => $outputfile,
1624 'CHECKSYNTAX' => $checksyntax,
1625 'PERL5LIB' => $perl5lib,
1626 }, $class;
1627 30 return $object;
1628 }
1629  
1630 620 ▶sub has_array_prefix {
Subroutine has_array_prefix: called CC=1 SCAR=0.0
Pod undocumented
1631 620 my $self = shift;
1632  
1633 return defined($self->{arrayprefix})
1634 620 }
1635  
1636 { # closure with $formula $declarations and $text
1637  
1638 36 my $formula;
1639 my $declarations;
1640 36 my $text = '';
1641  
1642 229 ▶ sub _generate_treereg_code {
Subroutine _generate_treereg_code: called CC=7 SCAR=19.5
1643 229 my $treereg = shift; # the node
1644 229 my $father = shift;
1645 229 my $source = shift; # Perl code describing how access this node
1646 229 my $order = shift; # my index in the array of children
1647  
1648 229 ▶ my $name = ref($treereg) || $treereg;
Condition33%1/3
ref $treereg || $treereg
l!l&&r!l&&!r
22900
MC/DC0%0/2
ref $treereg || $treereg
ref $treereg $treereg
Truth table33%1/3
A || B
A= ref $treeregB= $treereg
ABresult
1X1
011
000
1649 229 my $aux;
1650 my $nodename;
1651 229 my $is_array = has_array_prefix($treereg);
1652  
1653 229 ($nodename, $aux) = $treereg->translate($father, $source, $order);
1654 229 $formula .= $aux;
1655 229 ▶ return if (ref($treereg) =~ m{TERMINAL$} or $is_array);
Branch: 1 branch
BranchTrueFalseTotal
if ref($treereg) =~ /TERMINAL$/ or $is_array 133 96 229
Condition100%3/3
ref($treereg) =~ /TERMINAL$/ or $is_array
l!l&&r!l&&!r
126796
MC/DC100%2/2
ref($treereg) =~ /TERMINAL$/ or $is_array
ref($treereg) =~ /TERMINAL$/ $is_array
Truth table100%3/3
A or B
A= ref($treereg) =~ /TERMINAL$/B= $is_array
ABresult
1X1
011
000
1656  
1657 # $j : index of the child in the treeregexp formula not counting arrays
1658 96 my $j = 0;
1659 96 for (@{$treereg->{children}}) {
1660  
1661 # Saving $is_array has to be done before the call to
1662 #_generate_treereg_code, since
1663 # we delete the array_prefix entry after processing node $_
1664 # (See sub translate_array_prefix)
1665 162 $is_array = has_array_prefix($_);
1666 162 _generate_treereg_code($_, $nodename, "$nodename->child($j+\$child_index)", $j);
1667 162 ▶ $j++ unless $is_array;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_array 146 16 162
1668 }
1669 96 ▶ if (my $pat = $treereg->{semantic}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pat = $treereg->{"semantic"}) 10 86 96
1670 10 my $pattern = process_pattern($pat, $filename);
1671 10 $formula .= $pattern;
1672 }
1673 }
1674  
1675 67 ▶ sub generate_treereg_code {
Subroutine generate_treereg_code: called CC=1 SCAR=0.0
Pod undocumented
1676 67 my $treereg = shift;
1677  
1678 67 $formula = '';
1679 67 _generate_treereg_code($treereg, '', '$_[$child_index]', undef);
1680 }
1681
1682 # Parameters:
1683 # $checksyntax: controls whether or not to check Perl code for syntax errors
1684 30 ▶ sub generate {
Subroutine generate: called CC=15 SCAR=28.3
Pod undocumented
1685 30 my $self = shift;
1686 30 ▶ croak "Error at ".__PACKAGE__."::generate. Expected a ".__PACKAGE__." object."
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa(__PACKAGE__) 0 30 30
1687 unless $self->isa(__PACKAGE__);
1688 30 ▶ my $checksyntax = $self->{'CHECKSYNTAX'} || 1;
Condition50%1/2
$self->{'CHECKSYNTAX'} || 1
l!l
300
MC/DC0%0/1
$self->{'CHECKSYNTAX'} || 1
$self->{'CHECKSYNTAX'}
Truth table50%1/2
A
A= $self->{'CHECKSYNTAX'}
Aresult
11
00
1689 my ($input_from_file, $packagename, $outputfile)
1690 30 = @$self{'INPUT_FROM_FILE', 'PACKAGENAME', 'OUTPUTFILE',};
1691  
1692 30 my $parser = Parse::Eyapp::Treeregparser->new();
1693 30 my $t = $parser->YYParse( yylex => \&Parse::Eyapp::Treeregparser::_Lexer,
1694 yyerror => \&Parse::Eyapp::Treeregparser::_Error,
1695 yybuildingtree => 1);
1696  
1697 # Traverse the tree generating the pattern-action subroutine
1698 27 my ($names, @names, %family); # Names of the generated subroutines
1699 27 my @Transformations = @$t;
1700 27 for my $transform (@Transformations) {
1701 $transform->isa('Parse::Eyapp::Treeregexp::GLOBALCODE')
1702 63 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$transform->isa("Parse::Eyapp::Treeregexp::GLOBALCODE") and do { $text .= $transform->translate; next } 9 54 63
1703 9 $text .= $transform->translate();
1704 9 next; # iteration done
1705 };
1706  
1707 $transform->isa('Parse::Eyapp::Treeregexp::FAMILY')
1708 54 ▶ and do {
Branch: 1 branch
BranchTrueFalseTotal
$transform->isa("Parse::Eyapp::Treeregexp::FAMILY") and do { () = ($transform->{"name"}[0], @{$transform->{"members"}{"children"};}); push @{$family{$name};}, @members; next } 3 51 54
1709 3 my ($name, @members) = ($transform->{name}[0], @{$transform->{members}{children}});
1710 3 push @{$family{$name}}, @members;
1711 3 next;
1712 };
1713 51 my ($treereg, $action) = @{$transform->{children}};
1714  
1715 51 %times = @{$transform->{times}}; # global scope visible. Weakness
1716 51 %index = ();
1717 51 &fill_declarations(\$declarations);
1718  
1719 51 my $name = $transform->{name};
1720  
1721 51 ▶ $action ||= ""; # To Do
Condition100%2/2
$action ||= ""
l!l
474
MC/DC100%1/1
$action ||= ""
$action
Truth table100%2/2
A
A= $action
Aresult
11
00
1722 51 $names .= "$name ";
1723 51 generate_treereg_code($treereg);
1724 51 my @classes = $treereg->classes;
1725 51 push @{$methods{$_}}, $name for @classes;
1726  
1727 51 $text .= fill_translation_sub($name, \$declarations, \$formula, $action, $filename);
1728 } # for my $transform ...
1729  
1730 27 $text = fill_translation_package($filename, $packagename, \$text, $names, \%family);
1731  
1732 27 ▶ if ($input_from_file or defined($outputfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input_from_file or defined $outputfile) { } 0 27 27
Condition33%1/3
$input_from_file or defined $outputfile
l!l&&r!l&&!r
0027
MC/DC0%0/2
$input_from_file or defined $outputfile
$input_from_file defined $outputfile
Truth table33%1/3
A or B
A= $input_from_fileB= defined $outputfile
ABresult
1X1
011
000
1733 0 ▶ compute_lines(\$text, $outputfile, $ouputlinepattern) if $self->{NUMBERS};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"NUMBERS"} 0 0 0
1734 0 write_file($outputfile, \$text);
1735 0 ▶ if ($self->{CHECKSYNTAX}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"CHECKSYNTAX"}) 0 0 0
1736 0 push @INC, @{$self->{PERL5LIB}};
1737 0 require $outputfile;
1738 }
1739 }
1740 else {
1741 27 ▶ print $text if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 27 27
1742 27 ▶ if ($self->{CHECKSYNTAX}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"CHECKSYNTAX"}) 27 0 27
1743 27 push @INC, @{$self->{PERL5LIB}};
1744 0 ▶ croak $@ unless eval $text;
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine delete_code: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=6 SCAR=18.4
Subroutine delete_b: called CC=4 SCAR=14.2
Subroutine delete_b_in_abc: called CC=3 SCAR=11.2
Subroutine moveinvariant: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=5 SCAR=16.5
Branch: 22 branches
BranchTrueFalseTotal
unless eval $text 0 27 27
unless ref($CODE = $_[$child_index]) eq "CODE" 521 170 691
unless ref($B = $_[$child_index]) eq "B" 90 47 137
unless ref($ABC = $_[$child_index]) eq "ABC" 12 21 33
unless until_first_match($ABC, 0, $a, \@a) 24 24 48
unless defined($x = $_[$child_index]) 53 10 63
unless until_first_match($x, 0, $a, \@a) 0 6 6
unless ref($WHILE = $_[$child_index]) eq "WHILE" 0 6 6
unless ref($VAR = $WHILE->child(0 + $child_index)) eq "VAR" 0 2 2
unless defined($b = $VAR->child(0 + $child_index)) 0 2 2
unless ref($BLOCK = $WHILE->child(1 + $child_index)) eq "BLOCK" 1 0 1
unless until_first_match($BLOCK, 0, $a, \@a) 33 2 35
unless ref($ASSIGN = $_[$child_index]) eq "ASSIGN" 0 2 2
unless defined($x = $ASSIGN->child(0 + $child_index)) 0 2 2
unless ref($NUM = $ASSIGN->child(1 + $child_index)) eq "NUM" 0 2 2
unless defined($e = $NUM->child(0 + $child_index)) 49 5 54
unless ref($W = $_[$child_index]) =~ /\bTIMES\b|\bPLUS\b|\bDIV\b|\bMINUS\b/xi 52 3 55
unless defined($n = $W->child(0 + $child_index)) 1 2 3
unless defined($m = $W->child(1 + $child_index)) 0 2 2
unless ref($TIMES = $_[$child_index]) eq "TIMES" 2 0 2
unless ref($NUM = $TIMES->child(0 + $child_index)) eq "NUM" 0 0 0
unless defined($x = $NUM->child(0 + $child_index)) 0 0 0
1745 }
1746 }
1747  
1748 27 undef %times;
1749 27 undef %index;
1750 27 undef $tokenbegin;
1751 27 undef $tokenend;
1752 27 undef $prefix;
1753 27 undef $input;
1754 27 undef $declarations;
1755 27 undef $text;
1756 27 undef $filename;
1757 27 return 1;
1758 }
1759  
1760 16 ▶ sub translate_array_prefix {
Subroutine translate_array_prefix: called CC=1 SCAR=0.0
Pod undocumented
1761 16 my ($self, $father, $order) = @_;
1762  
1763 16 my $localformula = $formula;
1764
1765 16 my $arrname = $self->{arrayprefix};
1766 16 delete($self->{arrayprefix});
1767 16 generate_treereg_code($self);
1768 16 my $aux = fill_translation_array_sub($self, $arrname, $order, \$formula, $father);
1769
1770 16 $formula = $localformula;
1771  
1772 16 return $aux;
1773 }
1774  
1775 } # closure with $formula $declarations and $text
1776  
1777 36 ▶sub make_references_to_subs {
Subroutine make_references_to_subs: called CC=1 SCAR=0.0
Pod undocumented
1778 30 $_[0] =~ s/\b([a-z_A-Z]\w*)\b/$1 => \\\&$1,/g;
1779 }
1780  
1781 3 ▶sub unique {
Subroutine unique: called CC=1 SCAR=0.0
Pod undocumented
1782 3 my %saw = ();
1783 3 my @out = grep(!$saw{$_}++, @_);
1784 3 return @out;
1785 }
1786  
1787 # Checks that all the transformation rules in the list have been defined
1788 3 ▶sub check_existence {
Subroutine check_existence: called CC=3 SCAR=11.1
Pod undocumented
1789 3 my $familyname = shift;
1790 3 my $names = shift;
1791 3 my $line = shift;
1792  
1793 3 for (@_) {
1794 8 ▶ croak "Error! treereg rule '$_' not defined (family '$familyname' at line $line)."
Branch: 1 branch
BranchTrueFalseTotal
unless $names =~ /\b$_\b/ 0 8 8
1795 unless $names =~ m/\b$_\b/;
1796 }
1797 }
1798  
1799 229 ▶sub translate {
Subroutine translate: called CC=2 SCAR=6.9
Pod undocumented
1800 229 my ($self, $father, $order, $translation) = @_;
1801  
1802 229 ▶ $translation = translate_array_prefix($self, $father, $order) if has_array_prefix($self);
Branch: 1 branch
BranchTrueFalseTotal
if has_array_prefix($self) 16 213 229
1803 229 return $translation;
1804 }
1805  
1806 ######### Fill subroutines ##########
1807  
1808 73 ▶sub linenumber {
Subroutine linenumber: called CC=2 SCAR=6.9
Pod undocumented
1809 73 my ($linenumber, $filename) = @_;
1810  
1811 73 ▶ return "#line $linenumber \"$filename\"" if $allowlinenumbers;
Branch: 1 branch
BranchTrueFalseTotal
if $allowlinenumbers 59 14 73
1812 14 return '';
1813 }
1814  
1815 ####################################################################
1816 # Usage : fill_translation_array_sub($self, $arrname, $order, \$formula, $father);
1817 # Purpose : translation of array atoms in treeregexps like ABC(@a, B, @c)
1818 # Returns : the text containing the sub handler and the loop
1819 # Parameters : $name: gives the name to the array and to the sub handler
1820 # $order: index of the array formula as child
1821 # $formula: declarations
1822 # $father: the father node of the array tree pattern
1823  
1824 16 ▶sub fill_translation_array_sub {
Subroutine fill_translation_array_sub: called CC=2 SCAR=7.0
Pod undocumented
1825 16 my ($self, $name, $order, $formula, $father, $line) = @_;
1826
1827 16 chomp($$formula);
1828 16 my $sname = '$'.$name; # var referencing the sub
1829 16 my $aname = '@'.$name; # the array that will hold the nodes
1830 16 ▶ $line = '' unless defined($line);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 16 0 16
1831  
1832 16 return <<"END_TRANSLATION_STAR_SUB";
1833 my $sname = sub {
1834 my \$child_index = 0;
1835 $$formula
1836 $line
1837 return 1;
1838 }; # end anonymous sub $sname
1839  
1840 return 0 unless until_first_match(
1841 $father, $order, $sname, \\$aname);
1842 \$child_index += 1+$aname;
1843 END_TRANSLATION_STAR_SUB
1844 } # sub fill_translation_array_sub
1845  
1846 14 ▶sub process_pattern {
Subroutine process_pattern: called CC=2 SCAR=7.1
Pod undocumented
1847 14 my ($pat, $filename) = @_;
1848
1849 14 my $linenodirective = linenumber($pat->[1], $filename);
1850 14 my ($pattern);
1851 14 ▶ if (defined($pat)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pat) { } 14 0 14
1852 14 $pattern =<<"ENDOFPATTERN";
1853 return 0 unless do
1854 $linenodirective
1855 {$pat->[0]};
1856 ENDOFPATTERN
1857 }
1858 else {
1859 0 $pattern = '';
1860 #chomp($formula);
1861 }
1862 14 return $pattern;
1863 }
1864  
1865 51 ▶sub process_action {
Subroutine process_action: called CC=2 SCAR=6.9
Pod undocumented
1866 51 my ($action, $filename) = @_;
1867  
1868 51 my ($actiontext);
1869  
1870 51 ▶ if ($action) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action) { } 47 4 51
1871 47 my $line_directive = linenumber($action->[1], $filename);
1872 47 $actiontext = "$line_directive\n".
1873 " { $action->[0]}";
1874 }
1875 else {
1876 4 $actiontext = " 1;"
1877 }
1878 51 return $actiontext;
1879 }
1880  
1881 51 ▶sub fill_translation_sub {
Subroutine fill_translation_sub: called CC=2 SCAR=7.0
Pod undocumented
1882 51 my ($name, $declarations, $formula, $action, $filename, $line) = @_;
1883 51 my ($actiontext);
1884  
1885 51 ▶ $line = '' unless defined($line);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 51 0 51
1886 51 $actiontext = process_action($action, $filename);
1887  
1888 51 return <<"END_TREEREG_TRANSLATIONS";
1889  
1890 sub $name {
1891 my \$$name = \$_[3]; # reference to the YATW pattern object
1892 $$declarations
1893 {
1894 my \$child_index = 0;
1895  
1896 $$formula
1897 } # end block of child_index
1898 $actiontext
1899  
1900 } # end of $name
1901 $line
1902 END_TREEREG_TRANSLATIONS
1903 } # end sub fill_translation_sub
1904  
1905 51 ▶sub fill_declarations {
Subroutine fill_declarations: called CC=3 SCAR=11.0
Pod undocumented
1906 51 my $declarations = shift;
1907  
1908 51 $$declarations = '';
1909 51 for (keys(%times)) {
1910 209 ▶ $$declarations .= " my \$$_;\n", next if ($times{$_} == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $times{$_} == 1 154 55 209
1911 55 $$declarations .= " my \@$_;\n"
1912 }
1913 }
1914  
1915 27 ▶sub fill_translation_package {
Subroutine fill_translation_package: called CC=2 SCAR=6.9
Pod undocumented
1916 27 my ($filename, $packagename, $code, $names, $family) = @_;
1917 27 my $familiesdecl = '';
1918  
1919 27 for (keys %$family) {
1920 3 my $t;
1921 3 my @members = map { $t = $_->{attr}; $t->[0] } @{$family->{$_}};
1922 3 @members = unique(@members);
1923 3 my $line = $family->{$_}[0]{attr}[1];
1924 3 check_existence($_, $names, $line, @members);
1925 3 $t = "@members";
1926 3 &make_references_to_subs($t);
1927 3 my $line_directive = linenumber($line, $filename);
1928 3 $familiesdecl .= "$line_directive\n".
1929 "our \@$_ = Parse::Eyapp::YATW->buildpatterns($t);\n"; # TODO lines, etc.
1930 }
1931  
1932 27 my $scalar_names;
1933 27 ($scalar_names = $names) =~ s/\b([a-z_A-Z]\w*)\b/our \$$1,/g;;
1934 27 &make_references_to_subs($names);
1935 27 $familiesdecl .= "our \@all = ( $scalar_names) = Parse::Eyapp::YATW->buildpatterns($names);\n";
1936  
1937 27 return <<"END_PACKAGE_TRANSLATIONS";
1938 package $packagename;
1939  
1940 # This module has been generated using Parse::Eyapp::Treereg
1941 # from file $filename. Don't modify it.
1942 # Change $filename instead.
1943 # Copyright © 2006, 2007, 2008, 2009, 2010, 2011, 2012 Casiano Rodriguez-Leon.
1944 # Copyright © 2017 William N. Braswell, Jr.
1945 # All Rights Reserved.
1946 #
1947 # Parse::Yapp is Copyright © 1998, 1999, 2000, 2001, Francois Desarmenien.
1948 # Parse::Yapp is Copyright © 2017 William N. Braswell, Jr.
1949 # All Rights Reserved.
1950 # You may use it and distribute it under the terms of either
1951 # the GNU General Public License or the Artistic License,
1952 # as specified in the Perl README file.
1953  
1954 use strict;
1955 use warnings;
1956 use Carp;
1957 use Parse::Eyapp::_TreeregexpSupport qw(until_first_match checknumchildren);
1958  
1959 $familiesdecl
1960 $$code
1961 1;
1962  
1963 END_PACKAGE_TRANSLATIONS
1964 } # end of sub fill_translation_package
1965  
1966 ######## TERMINAL classes #########
1967 107 ▶sub code_translation {
Subroutine code_translation: called CC=2 SCAR=6.9
Pod undocumented
1968 107 my $self = shift;
1969  
1970 107 my $pat = $self->{semantic};
1971 107 ▶ return process_pattern($pat, $filename) if $pat;
Branch: 1 branch
BranchTrueFalseTotal
if $pat 4 103 107
1972 103 return '';
1973 }
1974  
1975 ######## Parse::Eyapp::Treeregexp::REGEXP_TERMINAL #########
1976  
1977 1 ▶sub Parse::Eyapp::Treeregexp::REGEXP_TERMINAL::translate {
Subroutine translate: called CC=1 SCAR=0.0
1978 1 my ($self, $father, $source, $order) = @_;
1979  
1980 # nodename is the variable associated with the tree node i.e.
1981 # for a node NUM it may be $NUM[0] or similar
1982 1 my ($nodename, $aux);
1983 1 $nodename = '$'.$self->{attr};
1984
1985 1 my ($regexp, $options) = ($self->{regexp}, $self->{options});
1986 1 $aux = translate($self, $father, $order,
1987 " return 0 unless ref($nodename = $source) =~ m{$regexp}$options;\n");
1988 1 $aux .= code_translation($self);
1989 1 return ($nodename, $aux);
1990 }
1991  
1992 12 ▶sub Parse::Eyapp::Treeregexp::REGEXP_TERMINAL::classes {
Subroutine classes: called CC=1 SCAR=0.0
1993 12 my $treereg = shift;
1994  
1995 12 my $regexp = $treereg->{regexp};
1996  
1997 # what if option "B" is used?
1998 12 my @classes;
1999 12 @classes = $regexp =~ m/\\b|((?:[a-zA-Z_][a-zA-Z_0-9]*::)*(?:[a-zA-Z_][a-zA-Z_0-9]*))/g;
2000 12 return grep {defined($_) } @classes;
2001 }
2002  
2003 ######## Parse::Eyapp::Treeregexp::SCALAR_TERMINAL #########
2004  
2005 73 ▶sub Parse::Eyapp::Treeregexp::SCALAR_TERMINAL::translate {
Subroutine translate: called CC=1 SCAR=0.0
2006 73 my ($self, $father, $source, $order) = @_;
2007  
2008 73 my ($nodename, $aux);
2009  
2010 # Warning! not needed for scalars but for Ws (see alias)
2011 73 $nodename = Parse::Eyapp::Treeregexp::compute_var_name($self->{attr});
2012 73 $aux = translate($self, $father, $order,
2013 " return 0 unless defined($nodename = $source);\n");
2014  
2015 73 $aux .= code_translation($self);
2016 73 return ($nodename, $aux);
2017 }
2018  
2019 3 ▶sub Parse::Eyapp::Treeregexp::SCALAR_TERMINAL::classes {
Subroutine classes: called CC=1 SCAR=0.0
2020 3 my $self = shift;
2021  
2022 3 return ('*');
2023 }
2024  
2025 ######## Parse::Eyapp::Treeregexp::IDENT_TERMINAL #########
2026 33 ▶sub Parse::Eyapp::Treeregexp::IDENT_TERMINAL::translate {
Subroutine translate: called CC=1 SCAR=0.0
2027 33 my ($self, $father, $source, $order) = @_;
2028  
2029 33 my ($nodename, $aux);
2030 33 my $name = $self->{attr};
2031 33 $nodename = Parse::Eyapp::Treeregexp::compute_var_name($self->{attr});
2032 33 $aux = translate($self, $father, $order,
2033 " return 0 unless ref($nodename = $source) eq '$prefix$name';\n");
2034 33 $aux .= code_translation($self);
2035 33 return ($nodename, $aux);
2036 }
2037  
2038 8 ▶sub Parse::Eyapp::Treeregexp::IDENT_TERMINAL::classes {
Subroutine classes: called CC=1 SCAR=0.0
2039 8 my $treereg = shift;
2040  
2041 8 my @classes = ($treereg->{attr});
2042 8 return @classes;
2043 }
2044  
2045 ######## Parse::Eyapp::Treeregexp::ARRAY_TERMINAL #########
2046 19 ▶sub Parse::Eyapp::Treeregexp::ARRAY_TERMINAL::translate {
Subroutine translate: called CC=1 SCAR=0.0
2047 19 my ($self, $father, $source, $order) = @_;
2048  
2049 19 my ($nodename, $aux);
2050 19 my $id = $self->{attr};
2051 19 $nodename = '@'.$id;
2052 19 $aux = translate($self, $father, $order,
2053 " $nodename = ($father->children);\n".
2054 " $nodename = $nodename\[\$child_index+$order..\$#$id];\n"
2055 );
2056 19 return ($nodename, $aux);
2057 }
2058  
2059 0 ▶sub Parse::Eyapp::Treeregexp::ARRAY_TERMINAL::classes {
Subroutine classes: not called CC=1 SCAR=6.9
2060 0 croak "Fatal error: Parse::Eyapp::Treeregexp::ARRAY_TERMINAL::classes called from the root of a tree";
2061 }
2062  
2063 ############### INNER classes ###############
2064 103 ▶sub generate_check_numchildren {
Subroutine generate_check_numchildren: called CC=2 SCAR=6.9
Pod undocumented
2065 103 my ($self, $nodename, $severity) = @_;
2066  
2067 103 ▶ return '' unless $severity;
Branch: 1 branch
BranchTrueFalseTotal
unless $severity 99 4 103
2068  
2069 4 my $name = $self->{id};
2070 4 my $numexpected = @{$self->{children}};
2071 4 my $line = $self->{line};
2072  
2073 4 my $warning = " return 0 unless checknumchildren($nodename, $numexpected, $line, ".
2074 "'$filename', $self->{numarrays}, $severity);\n";
2075 4 return $warning;
2076 }
2077  
2078 ############### Parse::Eyapp::Treeregexp::REGEXP_INNER ###############
2079  
2080 11 ▶sub Parse::Eyapp::Treeregexp::REGEXP_INNER::translate {
Subroutine translate: called CC=1 SCAR=0.0
2081 11 my ($self, $father, $source, $order) = @_;
2082  
2083 11 my ($nodename, $aux);
2084  
2085 11 my $name = $self->{id};
2086 11 $nodename = Parse::Eyapp::Treeregexp::compute_var_name($name);
2087  
2088 11 my $warning = generate_check_numchildren($self, $nodename, $severity);
2089  
2090 11 my ($regexp, $options) = ($self->{regexp}, $self->{options});
2091  
2092 # TODO #line goes here
2093 11 my $template = " return 0 unless ref($nodename = $source) =~ m{$regexp}$options;\n"
2094 . $warning;
2095 11 $aux = translate($self, $father, $order, $template);
2096 11 return ($nodename, $aux);
2097 }
2098  
2099 36 *Parse::Eyapp::Treeregexp::REGEXP_INNER::classes = \&Parse::Eyapp::Treeregexp::REGEXP_TERMINAL::classes;
2100
2101 ############### Parse::Eyapp::Treeregexp::IDENT_INNER ###############
2102  
2103 89 ▶sub Parse::Eyapp::Treeregexp::IDENT_INNER::translate {
Subroutine translate: called CC=1 SCAR=0.0
2104 89 my ($self, $father, $source, $order) = @_;
2105  
2106 89 my ($nodename, $aux);
2107  
2108 89 my $name = $self->{id};
2109 89 $nodename = Parse::Eyapp::Treeregexp::compute_var_name($name);
2110  
2111 89 my $warning = generate_check_numchildren($self, $nodename, $severity);
2112  
2113 89 my $template = " return 0 unless (ref($nodename = $source) eq '$prefix$name');\n"
2114 . $warning;
2115 89 $aux = translate($self, $father, $order, $template);
2116 89 return ($nodename, $aux);
2117 }
2118  
2119 28 ▶sub Parse::Eyapp::Treeregexp::IDENT_INNER::classes {
Subroutine classes: called CC=1 SCAR=0.0
2120 28 my $treereg = shift;
2121  
2122 28 my @classes = ( $treereg->{id} );
2123 28 return @classes;
2124 }
2125  
2126 ############### Parse::Eyapp::Treeregexp::SCALAR_INNER ###############
2127  
2128 3 ▶sub Parse::Eyapp::Treeregexp::SCALAR_INNER::translate {
Subroutine translate: called CC=1 SCAR=0.0
2129 3 my ($self, $father, $source, $order) = @_;
2130  
2131 3 my ($nodename, $aux);
2132  
2133 3 my $name = $self->{id};
2134  
2135 # Warning! not needed for scalars but for Ws
2136 3 $nodename = Parse::Eyapp::Treeregexp::compute_var_name($name);
2137  
2138 3 my $warning = generate_check_numchildren($self, $nodename, $severity);
2139  
2140 3 my $template = " return 0 unless defined($nodename = $source);\n"
2141 . $warning;
2142 3 $aux = translate($self, $father, $order, $template);
2143 3 return ($nodename, $aux);
2144 }
2145  
2146 36 *Parse::Eyapp::Treeregexp::SCALAR_INNER::classes = \&Parse::Eyapp::Treeregexp::SCALAR_TERMINAL::classes;
2147  
2148 ########## Parse::Eyapp::Treeregexp::GLOBALCODE #############
2149  
2150 9 ▶sub Parse::Eyapp::Treeregexp::GLOBALCODE::translate {
Subroutine translate: called CC=1 SCAR=0.0
2151 9 my $transform = shift;
2152  
2153 9 my $line_directive = linenumber($transform->[1], $filename);
2154 9 return "$line_directive\n".
2155 "$transform->[0]\n";
2156 };
2157  
2158  
2159  
2160 =for None
2161  
2162 =cut
2163  
2164  
2165 ################ @@@@@@@@@ End of User Code @@@@@@@@@ ###################
2166  
2167  
2168  
2169 36 1;
« Eyapp/Node.pm ↑ Summary Eyapp/_TreeregexpSupport.pm »