File Coverage

blib/lib/Parse/RecDescent.pm
Criterion Covered Total %
statement 3914 4698 83.3
branch 1141 2478 46.0
condition 398 1004 39.6
subroutine 244 245 99.5
pod 0 8 0.0
total 5697 8433 67.5


line stmt bran cond sub pod time code
1             # GENERATE RECURSIVE DESCENT PARSER OBJECTS FROM A GRAMMAR
2              
3 13     13   111166 use 5.006;
  13         42  
4 13     13   119 use strict;
  13         25  
  13         526  
5              
6             package Parse::RecDescent;
7              
8 13     13   13626 use Text::Balanced qw ( extract_codeblock extract_bracketed extract_quotelike extract_delimited );
  13         279464  
  13         1456  
9              
10 13     13   157 use vars qw ( $skip );
  13         34  
  13         129276  
11              
12             *defskip = \ '\s*'; # DEFAULT SEPARATOR IS OPTIONAL WHITESPACE
13             $skip = '\s*'; # UNIVERSAL SEPARATOR IS OPTIONAL WHITESPACE
14             my $MAXREP = 100_000_000; # REPETITIONS MATCH AT MOST 100,000,000 TIMES
15              
16              
17             #ifndef RUNTIME
18             sub import # IMPLEMENT PRECOMPILER BEHAVIOUR UNDER:
19             # perl -MParse::RecDescent - [runtimeclassname]
20             {
21 1     1   93 local *_die = sub { print @_, "\n"; exit };
  1     14   4  
  14         174  
22              
23 14         122 my ($package, $file, $line) = caller;
24              
25 14 50 33     9375 if ($file eq '-' && $line == 0)
26             {
27 1 0 0     2 _die("Usage: perl -MLocalTest - ")
28             unless @ARGV >= 2 and $ARGV <= 3;
29              
30 1         122 my ($sourcefile, $class, $runtime_class) = @ARGV;
31              
32 1         10 local *IN;
33 1 0       2 open IN, $sourcefile
34             or _die(qq{Can't open grammar file "$sourcefile"});
35 1         103 local $/; #
36 1         7 my $grammar = ;
37 1         2 close IN;
38              
39 1         50 Parse::RecDescent->Precompile({ -runtime_class => $runtime_class },
40             $grammar, $class, $sourcefile);
41 1         6 exit;
42             }
43             }
44              
45             sub Save
46             {
47 1     1 0 1 my $self = shift;
48 1         55 my %opt;
49 1 0       6 if ('HASH' eq ref $_[0]) {
50 1         2 %opt = (%opt, %{$_[0]});
  1         61  
51 1         6 shift;
52             }
53 1         2 my ($class) = @_;
54 1         48 $self->{saving} = 1;
55 1         17 $self->Precompile(undef,$class);
56 1         4 $self->{saving} = 0;
57             }
58              
59             sub PrecompiledRuntime
60             {
61 1     1 0 129 my ($self, $class) = @_;
62 1         8 my $opt = {
63             -standalone => 1,
64             -runtime_class => $class,
65             };
66 1         2 $self->Precompile($opt, '', $class);
67             }
68              
69             sub Precompile
70             {
71 10     10 0 54303 my $self = shift;
72 10         56 my %opt = ( -standalone => 0,
73             );
74 10 50       64 if ('HASH' eq ref $_[0]) {
75 10         79 %opt = (%opt, %{$_[0]});
  10         51  
76 10         29 shift;
77             }
78 10         76 my ($grammar, $class, $sourcefile) = @_;
79              
80 10 50       83 $class =~ /^(\w+::)*\w+$/ or croak("Bad class name: $class");
81              
82 10         23 my $modulefile = $class;
83 10         84 $modulefile =~ s/.*:://;
84 10         25 $modulefile .= ".pm";
85              
86 10         105 my $code = '';
87              
88 10         96 local *OUT;
89 10 50       1106 open OUT, ">", $modulefile
90             or croak("Can't write to new module file '$modulefile'");
91              
92 10         249 print OUT "#\n",
93             "# This parser was generated with\n",
94             "# Parse::RecDescent version $Parse::RecDescent::VERSION\n",
95             "#\n\n";
96              
97 10 50 33     121 print STDERR "precompiling grammar from file '$sourcefile'\n",
98             "to class $class in module file '$modulefile'\n"
99             if $grammar && $sourcefile;
100              
101 10 50       31 if ($grammar) {
102 10 50 33     142 $self = Parse::RecDescent->new($grammar, # $grammar
103             1, # $compiling
104             $class # $namespace
105             )
106             || croak("Can't compile bad grammar")
107             if $grammar;
108              
109             # Do not allow &DESTROY to remove the precompiled namespace
110 10         90 delete $self->{_not_precompiled};
111              
112 10         32 foreach ( keys %{$self->{rules}} ) {
  10         193  
113 565         908 $self->{rules}{$_}{changed} = 1;
114             }
115              
116 10         85 $code = $self->_code();
117             }
118              
119             # If a name for the runtime package was not provided,
120             # generate one based on the module output name and the generated
121             # code
122 10 50       68 if (not defined($opt{-runtime_class})) {
123 10 100       100 if ($opt{-standalone}) {
124 9         32 my $basename = $class . '::_Runtime';
125              
126 9         17 my $name = $basename;
127              
128 9         2050 for (my $i = 0; $code =~ /$basename/; ++$i) {
129 1         5 $name = sprintf("%s%06d", $basename, $i);
130             }
131              
132 9         48 $opt{-runtime_class} = $name;
133             } else {
134 2         63 my $package = ref $self;
135 2 50       10 local $::RD_HINT = defined $::RD_HINT ? $::RD_HINT : 1;
136 2         10 _hint(<
137             The precompiled grammar did not specify the -runtime_class
138             option. The resulting parser will "use $package". Future changes to
139             $package may cause $class to stop working.
140              
141             Consider building a -standalone parser, or providing the
142             -runtime_class option as described in Parse::RecDescent's POD.
143              
144             Use \$::RD_HINT = 0 to disable this message.
145             EOWARNING
146 2         61 $opt{-runtime_class} = $package;
147             }
148             }
149              
150 10         26303 $code =~ s/Parse::RecDescent/$opt{-runtime_class}/gs;
151              
152             # Make the resulting pre-compiled parser stand-alone by including
153             # the contents of Parse::RecDescent as -runtime_class in the
154             # resulting precompiled parser.
155 10 100       62 if ($opt{-standalone}) {
156 9         150 local *IN;
157 9 50       1009 open IN, '<', $Parse::RecDescent::_FILENAME
158             or croak("Can't open $Parse::RecDescent::_FILENAME for standalone pre-compilation: $!\n");
159 9         24 my $exclude = 0;
160 9         118 print OUT "{\n";
161 9         235 while () {
162 28225 100       50605 if ($_ =~ /^\s*#\s*ifndef\s+RUNTIME\s*$/) {
163 9         111 ++$exclude;
164             }
165 28225 100       37401 if ($exclude) {
166 1545 100       4579 if ($_ =~ /^\s*#\s*endif\s$/) {
167 9         111 --$exclude;
168             }
169             } else {
170 26681 100       46106 if ($_ =~ m/^__END__/) {
171 9         33 last;
172             }
173              
174 26673         33614 s/Parse::RecDescent/$opt{-runtime_class}/gs;
175 26673         69947 print OUT $_;
176             }
177             }
178 9         164 close IN;
179 9         176 print OUT "}\n";
180             }
181              
182 10 50       47 if ($grammar) {
183 10         40 print OUT "package $class;\n";
184             }
185              
186 10 100       101 if (not $opt{-standalone}) {
187 2         11 print OUT "use $opt{-runtime_class};\n";
188             }
189              
190 10 50       34 if ($grammar) {
191 10         93 print OUT "{ my \$ERRORS;\n\n";
192              
193 10         29044 print OUT $code;
194              
195 10         48 print OUT "}\npackage $class; sub new { ";
196 10         99 print OUT "my ";
197              
198 10         126 $code = $self->_dump([$self], [qw(self)]);
199 10         233231 $code =~ s/Parse::RecDescent/$opt{-runtime_class}/gs;
200              
201 10         23130 print OUT $code;
202              
203 10         58 print OUT "}";
204             }
205              
206 10 50       722 close OUT
207             or croak("Can't write to new module file '$modulefile'");
208             }
209             #endif
210              
211             package Parse::RecDescent::LineCounter;
212              
213              
214             sub TIESCALAR # ($classname, \$text, $thisparser, $prevflag)
215             {
216 575 100   575   14609 bless {
217             text => $_[1],
218             parser => $_[2],
219             prev => $_[3]?1:0,
220             }, $_[0];
221             }
222              
223             sub FETCH
224             {
225 616     616   905 my $parser = $_[0]->{parser};
226 616         823 my $cache = $parser->{linecounter_cache};
227 616         1161 my $from = $parser->{fulltextlen}-length(${$_[0]->{text}})-$_[0]->{prev}
228 616         781 ;
229              
230 616 100       1502 unless (exists $cache->{$from})
231             {
232             $parser->{lastlinenum} = $parser->{offsetlinenum}
233 292         801 - Parse::RecDescent::_linecount(substr($parser->{fulltext},$from))
234             + 1;
235 292         776 $cache->{$from} = $parser->{lastlinenum};
236             }
237 616         9795 return $cache->{$from};
238             }
239              
240             sub STORE
241             {
242 1     1   48 my $parser = $_[0]->{parser};
243 1         4 $parser->{offsetlinenum} -= $parser->{lastlinenum} - $_[1];
244 1         3 return undef;
245             }
246              
247             sub resync # ($linecounter)
248             {
249 1     1   48 my $self = tied($_[0]);
250 1 0       6 die "Tried to alter something other than a LineCounter\n"
251             unless $self =~ /Parse::RecDescent::LineCounter/;
252              
253 1         2 my $parser = $self->{parser};
254             my $apparently = $parser->{offsetlinenum}
255 1         49 - Parse::RecDescent::_linecount(${$self->{text}})
  1         6  
256             + 1;
257              
258 1         2 $parser->{offsetlinenum} += $parser->{lastlinenum} - $apparently;
259 1         47 return 1;
260             }
261              
262             package Parse::RecDescent::ColCounter;
263              
264             sub TIESCALAR # ($classname, \$text, $thisparser, $prevflag)
265             {
266 239 100   239   6187 bless {
267             text => $_[1],
268             parser => $_[2],
269             prev => $_[3]?1:0,
270             }, $_[0];
271             }
272              
273             sub FETCH
274             {
275 616     616   926 my $parser = $_[0]->{parser};
276 616         814 my $missing = $parser->{fulltextlen}-length(${$_[0]->{text}})-$_[0]->{prev}+1;
  616         1188  
277 616         2107 substr($parser->{fulltext},0,$missing) =~ m/^(.*)\Z/m;
278 616         15038 return length($1);
279             }
280              
281             sub STORE
282             {
283 1     1   6 die "Can't set column number via \$thiscolumn\n";
284             }
285              
286              
287             package Parse::RecDescent::OffsetCounter;
288              
289             sub TIESCALAR # ($classname, \$text, $thisparser, $prev)
290             {
291 239 100   239   6233 bless {
292             text => $_[1],
293             parser => $_[2],
294             prev => $_[3]?-1:0,
295             }, $_[0];
296             }
297              
298             sub FETCH
299             {
300 444     444   749 my $parser = $_[0]->{parser};
301 444         601 return $parser->{fulltextlen}-length(${$_[0]->{text}})+$_[0]->{prev};
  444         6296  
302             }
303              
304             sub STORE
305             {
306 1     1   61 die "Can't set current offset via \$thisoffset or \$prevoffset\n";
307             }
308              
309              
310              
311             package Parse::RecDescent::Rule;
312              
313             sub new ($$$$$)
314             {
315 663   33 663   1716 my $class = ref($_[0]) || $_[0];
316 663         815 my $name = $_[1];
317 663         822 my $owner = $_[2];
318 663         875 my $line = $_[3];
319 663         805 my $replace = $_[4];
320              
321 663 100       1728 if (defined $owner->{"rules"}{$name})
322             {
323 5         16 my $self = $owner->{"rules"}{$name};
324 5 50 66     19 if ($replace && !$self->{"changed"})
325             {
326 1         94 $self->reset;
327             }
328 5         19 return $self;
329             }
330             else
331             {
332 659         6111 return $owner->{"rules"}{$name} =
333             bless
334             {
335             "name" => $name,
336             "prods" => [],
337             "calls" => [],
338             "changed" => 0,
339             "line" => $line,
340             "impcount" => 0,
341             "opcount" => 0,
342             "vars" => "",
343             }, $class;
344             }
345             }
346              
347             sub reset($)
348             {
349 1     1   81 @{$_[0]->{"prods"}} = ();
  1         6  
350 1         3 @{$_[0]->{"calls"}} = ();
  1         93  
351 1         6 $_[0]->{"changed"} = 0;
352 1         2 $_[0]->{"impcount"} = 0;
353 1         76 $_[0]->{"opcount"} = 0;
354 1         5 $_[0]->{"vars"} = "";
355             }
356              
357       1     sub DESTROY {}
358              
359             sub hasleftmost($$)
360             {
361 2624     2624   3125 my ($self, $ref) = @_;
362              
363 2624         2760 my $prod;
364 2624         2555 foreach $prod ( @{$self->{"prods"}} )
  2624         4517  
365             {
366 5825 100       9733 return 1 if $prod->hasleftmost($ref);
367             }
368              
369 1389         4022 return 0;
370             }
371              
372             sub leftmostsubrules($)
373             {
374 2220     2220   2565 my $self = shift;
375 2220         2702 my @subrules = ();
376              
377 2220         1994 my $prod;
378 2220         2219 foreach $prod ( @{$self->{"prods"}} )
  2220         4079  
379             {
380 4994         8020 push @subrules, $prod->leftmostsubrule();
381             }
382              
383 2220         4562 return @subrules;
384             }
385              
386             sub expected($)
387             {
388 699     699   1040 my $self = shift;
389 699         1105 my @expected = ();
390              
391 699         882 my $prod;
392 699         809 foreach $prod ( @{$self->{"prods"}} )
  699         1786  
393             {
394 1297         2586 my $next = $prod->expected();
395 1297 100 100     3989 unless (! $next or _contains($next,@expected) )
396             {
397 1217         2613 push @expected, $next;
398             }
399             }
400              
401 699         5906 return join ', or ', @expected;
402             }
403              
404             sub _contains($@)
405             {
406 3955     3955   4689 my $target = shift;
407 3955         3702 my $item;
408 3955 100       5994 foreach $item ( @_ ) { return 1 if $target eq $item; }
  10134         19987  
409 3402         9906 return 0;
410             }
411              
412             sub addcall($$)
413             {
414 1348     1348   1844 my ( $self, $subrule ) = @_;
415 1348 100       1440 unless ( _contains($subrule, @{$self->{"calls"}}) )
  1348         2863  
416             {
417 1035         1152 push @{$self->{"calls"}}, $subrule;
  1035         3113  
418             }
419             }
420              
421             sub addprod($$)
422             {
423 1253     1253   1633 my ( $self, $prod ) = @_;
424 1253         1380 push @{$self->{"prods"}}, $prod;
  1253         2585  
425 1253         1964 $self->{"changed"} = 1;
426 1253         1575 $self->{"impcount"} = 0;
427 1253         1503 $self->{"opcount"} = 0;
428 1253         1231 $prod->{"number"} = $#{$self->{"prods"}};
  1253         2664  
429 1253         3628 return $prod;
430             }
431              
432             sub addvar
433             {
434 2     2   10 my ( $self, $var, $parser ) = @_;
435 2 50       8 if ($var =~ /\A\s*local\s+([%@\$]\w+)/)
436             {
437 1         62 $parser->{localvars} .= " $1";
438 1         5 $self->{"vars"} .= "$var;\n" }
439             else
440 2         7 { $self->{"vars"} .= "my $var;\n" }
441 2         61 $self->{"changed"} = 1;
442 2         10 return 1;
443             }
444              
445             sub addautoscore
446             {
447 1     1   2 my ( $self, $code ) = @_;
448 1         62 $self->{"autoscore"} = $code;
449 1         5 $self->{"changed"} = 1;
450 1         2 return 1;
451             }
452              
453             sub nextoperator($)
454             {
455 1     1   58 my $self = shift;
456 1         6 my $prodcount = scalar @{$self->{"prods"}};
  1         2  
457 1         59 my $opcount = ++$self->{"opcount"};
458 1         5 return "_operator_${opcount}_of_production_${prodcount}_of_rule_$self->{name}";
459             }
460              
461             sub nextimplicit($)
462             {
463 38     38   58 my $self = shift;
464 38         145 my $prodcount = scalar @{$self->{"prods"}};
  38         84  
465 38         67 my $impcount = ++$self->{"impcount"};
466 38         249 return "_alternation_${impcount}_of_production_${prodcount}_of_rule_$self->{name}";
467             }
468              
469              
470             sub code
471             {
472 662     662   994 my ($self, $namespace, $parser, $check) = @_;
473              
474 662 50       35046 eval 'undef &' . $namespace . '::' . $self->{"name"} unless $parser->{saving};
475              
476             my $code =
477             '
478             # ARGS ARE: ($parser, $text; $repeating, $_noactions, \@args, $_itempos)
479             sub ' . $namespace . '::' . $self->{"name"} . '
480             {
481             my $thisparser = $_[0];
482             use vars q{$tracelevel};
483             local $tracelevel = ($tracelevel||0)+1;
484             $ERRORS = 0;
485             my $thisrule = $thisparser->{"rules"}{"' . $self->{"name"} . '"};
486              
487             Parse::RecDescent::_trace(q{Trying rule: [' . $self->{"name"} . ']},
488             Parse::RecDescent::_tracefirst($_[1]),
489             q{' . $self->{"name"} . '},
490             $tracelevel)
491             if defined $::RD_TRACE;
492              
493             ' . ($parser->{deferrable}
494             ? 'my $def_at = @{$thisparser->{deferred}};'
495             : '') .
496             '
497             my $err_at = @{$thisparser->{errors}};
498              
499             my $score;
500             my $score_return;
501             my $_tok;
502             my $return = undef;
503             my $_matched=0;
504             my $commit=0;
505             my @item = ();
506             my %item = ();
507             my $repeating = $_[2];
508             my $_noactions = $_[3];
509             my @arg = defined $_[4] ? @{ &{$_[4]} } : ();
510             my $_itempos = $_[5];
511             my %arg = ($#arg & 01) ? @arg : (@arg, undef);
512             my $text;
513             my $lastsep;
514             my $current_match;
515             my $expectation = new Parse::RecDescent::Expectation(q{' . $self->expected() . '});
516             $expectation->at($_[1]);
517             '. ($parser->{_check}{thisoffset}?'
518             my $thisoffset;
519             tie $thisoffset, q{Parse::RecDescent::OffsetCounter}, \$text, $thisparser;
520             ':'') . ($parser->{_check}{prevoffset}?'
521             my $prevoffset;
522             tie $prevoffset, q{Parse::RecDescent::OffsetCounter}, \$text, $thisparser, 1;
523             ':'') . ($parser->{_check}{thiscolumn}?'
524             my $thiscolumn;
525             tie $thiscolumn, q{Parse::RecDescent::ColCounter}, \$text, $thisparser;
526             ':'') . ($parser->{_check}{prevcolumn}?'
527             my $prevcolumn;
528             tie $prevcolumn, q{Parse::RecDescent::ColCounter}, \$text, $thisparser, 1;
529             ':'') . ($parser->{_check}{prevline}?'
530             my $prevline;
531             tie $prevline, q{Parse::RecDescent::LineCounter}, \$text, $thisparser, 1;
532             ':'') . '
533             my $thisline;
534             tie $thisline, q{Parse::RecDescent::LineCounter}, \$text, $thisparser;
535              
536 662 50       4486 '. $self->{vars} .'
    100          
    100          
    100          
    100          
    100          
537             ';
538              
539 662         896 my $prod;
540 662         727 foreach $prod ( @{$self->{"prods"}} )
  662         1292  
541             {
542 1258 50       2404 $prod->addscore($self->{autoscore},0,0) if $self->{autoscore};
543 1258 50       2448 next unless $prod->checkleftmost();
544 1258         2815 $code .= $prod->code($namespace,$self,$parser);
545              
546             $code .= $parser->{deferrable}
547 1258 50       3281 ? ' splice
548             @{$thisparser->{deferred}}, $def_at unless $_matched;
549             '
550             : '';
551             }
552              
553             $code .=
554             '
555             unless ( $_matched || defined($score) )
556             {
557             ' .($parser->{deferrable}
558             ? ' splice @{$thisparser->{deferred}}, $def_at;
559             '
560             : '') . '
561              
562             $_[1] = $text; # NOT SURE THIS IS NEEDED
563             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' rule>>},
564             Parse::RecDescent::_tracefirst($_[1]),
565             q{' . $self->{"name"} .'},
566             $tracelevel)
567             if defined $::RD_TRACE;
568             return undef;
569             }
570             if (!defined($return) && defined($score))
571             {
572             Parse::RecDescent::_trace(q{>>Accepted scored production<<}, "",
573             q{' . $self->{"name"} .'},
574             $tracelevel)
575             if defined $::RD_TRACE;
576             $return = $score_return;
577             }
578             splice @{$thisparser->{errors}}, $err_at;
579             $return = $item[$#item] unless defined $return;
580             if (defined $::RD_TRACE)
581             {
582             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' rule<< (return value: [} .
583             $return . q{])}, "",
584             q{' . $self->{"name"} .'},
585             $tracelevel);
586             Parse::RecDescent::_trace(q{(consumed: [} .
587             Parse::RecDescent::_tracemax(substr($_[1],0,-length($text))) . q{])},
588             Parse::RecDescent::_tracefirst($text),
589 662 50       1926 , q{' . $self->{"name"} .'},
590             $tracelevel)
591             }
592             $_[1] = $text;
593             return $return;
594             }
595             ';
596              
597 662         9111 return $code;
598             }
599              
600             my @left;
601             sub isleftrec($$)
602             {
603 662     662   853 my ($self, $rules) = @_;
604 662         1174 my $root = $self->{"name"};
605 662         1302 @left = $self->leftmostsubrules();
606 662         799 my $next;
607 662         877 foreach $next ( @left )
608             {
609 1748 100       3972 next unless defined $rules->{$next}; # SKIP NON-EXISTENT RULES
610 1559 50       2539 return 1 if $next eq $root;
611 1559         1385 my $child;
612 1559         3174 foreach $child ( $rules->{$next}->leftmostsubrules() )
613             {
614 1334 100       2228 push(@left, $child)
615             if ! _contains($child, @left) ;
616             }
617             }
618 662         1465 return 0;
619             }
620              
621             package Parse::RecDescent::Production;
622              
623             sub describe ($;$)
624             {
625 2515 100   2515   3072 return join ' ', map { $_->describe($_[1]) or () } @{$_[0]->{items}};
  4645         10623  
  2515         4991  
626             }
627              
628             sub new ($$;$$)
629             {
630 1253     1253   1931 my ($self, $line, $uncommit, $error) = @_;
631 1253   33     4004 my $class = ref($self) || $self;
632              
633 1253         9873 bless
634             {
635             "items" => [],
636             "uncommit" => $uncommit,
637             "error" => $error,
638             "line" => $line,
639             strcount => 0,
640             patcount => 0,
641             dircount => 0,
642             actcount => 0,
643             }, $class;
644             }
645              
646             sub expected ($)
647             {
648 1297     1297   1352 my $itemcount = scalar @{$_[0]->{"items"}};
  1297         2691  
649 1297 50       4283 return ($itemcount) ? $_[0]->{"items"}[0]->describe(1) : '';
650             }
651              
652             sub hasleftmost ($$)
653             {
654 5825     5825   7029 my ($self, $ref) = @_;
655 5825 50       5314 return ${$self->{"items"}}[0] eq $ref if scalar @{$self->{"items"}};
  5825         31639  
  5825         12572  
656 1         8 return 0;
657             }
658              
659             sub isempty($)
660             {
661 1258     1258   1342 my $self = shift;
662 1258         1229 return 0 == @{$self->{"items"}};
  1258         4875  
663             }
664              
665             sub leftmostsubrule($)
666             {
667 4994     4994   5309 my $self = shift;
668              
669 4994 50       4863 if ( $#{$self->{"items"}} >= 0 )
  4994         11305  
670             {
671 4994         9961 my $subrule = $self->{"items"}[0]->issubrule();
672 4994 100       11269 return $subrule if defined $subrule;
673             }
674              
675 3065         4917 return ();
676             }
677              
678             sub checkleftmost($)
679             {
680 1258     1258   1433 my @items = @{$_[0]->{"items"}};
  1258         3036  
681 1258 50 100     9501 if (@items==1 && ref($items[0]) =~ /\AParse::RecDescent::Error/
    100 66        
    50 100        
      100        
      33        
      33        
682             && $items[0]->{commitonly} )
683             {
684 1         3 Parse::RecDescent::_warn(2,"Lone in production treated
685             as ");
686 1         75 Parse::RecDescent::_hint("A production consisting of a single
687             conditional directive would
688             normally succeed (with the value zero) if the
689             rule is not 'commited' when it is
690             tried. Since you almost certainly wanted
691             ' ' Parse::RecDescent
692             supplied it for you.");
693 1         11 push @{$_[0]->{items}},
  1         2  
694             Parse::RecDescent::UncondReject->new(0,0,'');
695             }
696             elsif (@items==1 && ($items[0]->describe||"") =~ /
697             {
698             # Do nothing
699             }
700             elsif (@items &&
701             ( ref($items[0]) =~ /\AParse::RecDescent::UncondReject/
702             || ($items[0]->describe||"") =~ /
703             ))
704             {
705 1         65 Parse::RecDescent::_warn(1,"Optimizing away production: [". $_[0]->describe ."]");
706 1 0       5 my $what = $items[0]->describe =~ /
    0          
707             ? "a (which acts like an unconditional during parsing)"
708             : $items[0]->describe =~ /
709             ? "an (which acts like an unconditional during parsing)"
710             : "an unconditional ";
711 1 0       2 my $caveat = $items[0]->describe =~ /
712             ? " after the specified variable was set up"
713             : "";
714 1 0       63 my $advice = @items > 1
715             ? "However, there were also other (useless) items after the leading "
716             . $items[0]->describe
717             . ", so you may have been expecting some other behaviour."
718             : "You can safely ignore this message.";
719 1         6 Parse::RecDescent::_hint("The production starts with $what. That means that the
720             production can never successfully match, so it was
721             optimized out of the final parser$caveat. $advice");
722 1         3 return 0;
723             }
724 1258         3442 return 1;
725             }
726              
727             sub changesskip($)
728             {
729 1258     1258   1193 my $item;
730 1258         1335 foreach $item (@{$_[0]->{"items"}})
  1258         2627  
731             {
732 2314 100       7637 if (ref($item) =~ /Parse::RecDescent::(Action|Directive)/)
733             {
734 99 100       412 return 1 if $item->{code} =~ /\$skip\s*=/;
735             }
736             }
737 1255         4293 return 0;
738             }
739              
740             sub adddirective
741             {
742 138     138   329 my ( $self, $whichop, $line, $name ) = @_;
743 138         429 push @{$self->{op}},
744             { type=>$whichop, line=>$line, name=>$name,
745 138         154 offset=> scalar(@{$self->{items}}) };
  138         815  
746             }
747              
748             sub addscore
749             {
750 1     1   3 my ( $self, $code, $lookahead, $line ) = @_;
751             $self->additem(Parse::RecDescent::Directive->new(
752             "local \$^W;
753             my \$thisscore = do { $code } + 0;
754             if (!defined(\$score) || \$thisscore>\$score)
755             { \$score=\$thisscore; \$score_return=\$item[-1]; }
756             undef;", $lookahead, $line,"") )
757 1 0       96 unless $self->{items}[-1]->describe =~ /
758 1         5 return 1;
759             }
760              
761             sub check_pending
762             {
763 1187     1187   1611 my ( $self, $line ) = @_;
764 1187 100       2623 if ($self->{op})
765             {
766 138         186 while (my $next = pop @{$self->{op}})
  138         415  
767             {
768 1         3 Parse::RecDescent::_error("Incomplete <$next->{type}op:...>.", $line);
769 1         140 Parse::RecDescent::_hint(
770             "The current production ended without completing the
771             <$next->{type}op:...> directive that started near line
772             $next->{line}. Did you forget the closing '>'?");
773             }
774             }
775 1187         3449 return 1;
776             }
777              
778             sub enddirective
779             {
780 138     138   308 my ( $self, $line, $minrep, $maxrep ) = @_;
781 138 50       335 unless ($self->{op})
782             {
783 1         3 Parse::RecDescent::_error("Unmatched > found.", $line);
784 1         60 Parse::RecDescent::_hint(
785             "A '>' angle bracket was encountered, which typically
786             indicates the end of a directive. However no suitable
787             preceding directive was encountered. Typically this
788             indicates either a extra '>' in the grammar, or a
789             problem inside the previous directive.");
790 1         9 return;
791             }
792 138         152 my $op = pop @{$self->{op}};
  138         381  
793 138         198 my $span = @{$self->{items}} - $op->{offset};
  138         294  
794 138 50       803 if ($op->{type} =~ /left|right/)
795             {
796 138 50       271 if ($span != 3)
797             {
798 1         2 Parse::RecDescent::_error(
799             "Incorrect <$op->{type}op:...> specification:
800             expected 3 args, but found $span instead", $line);
801 1         60 Parse::RecDescent::_hint(
802             "The <$op->{type}op:...> directive requires a
803             sequence of exactly three elements. For example:
804             <$op->{type}op:leftarg /op/ rightarg>");
805             }
806             else
807             {
808 138         295 push @{$self->{items}},
809             Parse::RecDescent::Operator->new(
810 138         171 $op->{type}, $minrep, $maxrep, splice(@{$self->{"items"}}, -3));
  138         589  
811 138         429 $self->{items}[-1]->sethashname($self);
812 138         549 $self->{items}[-1]{name} = $op->{name};
813             }
814             }
815             }
816              
817             sub prevwasreturn
818             {
819 1     1   79 my ( $self, $line ) = @_;
820 1 0       5 unless (@{$self->{items}})
  1         3  
821             {
822 1         56 Parse::RecDescent::_error(
823             "Incorrect specification:
824             expected item missing", $line);
825 1         6 Parse::RecDescent::_hint(
826             "The directive requires a
827             sequence of at least one item. For example:
828             ");
829 1         2 return;
830             }
831 1         53 push @{$self->{items}},
  1         6  
832             Parse::RecDescent::Result->new();
833             }
834              
835             sub additem
836             {
837 2591     2591   3509 my ( $self, $item ) = @_;
838 2591         4642 $item->sethashname($self);
839 2591         2783 push @{$self->{"items"}}, $item;
  2591         5232  
840 2591         9678 return $item;
841             }
842              
843             sub _duplicate_itempos
844             {
845 12     12   24 my ($src) = @_;
846 12         23 my $dst = {};
847              
848 12         89 foreach (keys %$src)
849             {
850 34         37 %{$dst->{$_}} = %{$src->{$_}};
  34         103  
  34         148  
851             }
852 12         207 $dst;
853             }
854              
855             sub _update_itempos
856             {
857 178     178   284 my ($dst, $src, $typekeys, $poskeys) = @_;
858              
859 178 50       690 my @typekeys = 'ARRAY' eq ref $typekeys ?
860             @$typekeys :
861             keys %$src;
862              
863 178         396 foreach my $k (keys %$src)
864             {
865 532 50       927 if ('ARRAY' eq ref $poskeys)
866             {
867 532         590 @{$dst->{$k}}{@$poskeys} = @{$src->{$k}}{@$poskeys};
  532         5165  
  532         900  
868             }
869             else
870             {
871 1         63 %{$dst->{$k}} = %{$src->{$k}};
  1         5  
  1         3  
872             }
873             }
874             }
875              
876             sub preitempos
877             {
878             return q
879 113     113   295 {
880             push @itempos, {'offset' => {'from'=>$thisoffset, 'to'=>undef},
881             'line' => {'from'=>$thisline, 'to'=>undef},
882             'column' => {'from'=>$thiscolumn, 'to'=>undef} };
883             }
884             }
885              
886             sub incitempos
887             {
888             return q
889 58     58   299 {
890             $itempos[$#itempos]{'offset'}{'from'} += length($lastsep);
891             $itempos[$#itempos]{'line'}{'from'} = $thisline;
892             $itempos[$#itempos]{'column'}{'from'} = $thiscolumn;
893             }
894             }
895              
896             sub unincitempos
897             {
898             # the next incitempos will properly set these two fields, but
899             # {'offset'}{'from'} needs to be decreased by length($lastsep)
900             # $itempos[$#itempos]{'line'}{'from'}
901             # $itempos[$#itempos]{'column'}{'from'}
902             return q
903 58     58   289 {
904             $itempos[$#itempos]{'offset'}{'from'} -= length($lastsep) if defined $lastsep;
905             }
906             }
907              
908             sub postitempos
909             {
910             return q
911 113     113   329 {
912             $itempos[$#itempos]{'offset'}{'to'} = $prevoffset;
913             $itempos[$#itempos]{'line'}{'to'} = $prevline;
914             $itempos[$#itempos]{'column'}{'to'} = $prevcolumn;
915             }
916             }
917              
918             sub code($$$$)
919             {
920 1258     1258   2019 my ($self,$namespace,$rule,$parser) = @_;
921             my $code =
922             '
923             while (!$_matched'
924             . (defined $self->{"uncommit"} ? '' : ' && !$commit')
925             . ')
926             {
927             ' .
928             ($self->changesskip()
929             ? 'local $skip = defined($skip) ? $skip : $Parse::RecDescent::skip;'
930             : '') .'
931             Parse::RecDescent::_trace(q{Trying production: ['
932             . $self->describe . ']},
933             Parse::RecDescent::_tracefirst($_[1]),
934             q{' . $rule ->{name}. '},
935             $tracelevel)
936             if defined $::RD_TRACE;
937             my $thisprod = $thisrule->{"prods"}[' . $self->{"number"} . '];
938             ' . (defined $self->{"error"} ? '' : '$text = $_[1];' ) . '
939             my $_savetext;
940             @item = (q{' . $rule->{"name"} . '});
941 1258 100       4234 %item = (__RULE__ => q{' . $rule->{"name"} . '});
    100          
    100          
942             my $repcount = 0;
943              
944             ';
945             $code .=
946             ' my @itempos = ({});
947 1258 100       3492 ' if $parser->{_check}{itempos};
948              
949 1258         1404 my $item;
950             my $i;
951              
952 1258         1788 for ($i = 0; $i < @{$self->{"items"}}; $i++)
  3580         8789  
953             {
954 2323         2267 $item = ${$self->{items}}[$i];
  2323         3622  
955              
956 2323 100       4849 $code .= preitempos() if $parser->{_check}{itempos};
957              
958 2323         5238 $code .= $item->code($namespace,$rule,$parser->{_check});
959              
960 2323 100       7518 $code .= postitempos() if $parser->{_check}{itempos};
961              
962             }
963              
964 1258 50 33     6257 if ($parser->{_AUTOACTION} && defined($item) && !$item->isa("Parse::RecDescent::Action"))
    100 33        
      66        
      66        
965             {
966 1         6 $code .= $parser->{_AUTOACTION}->code($namespace,$rule);
967 1 0       2 Parse::RecDescent::_warn(1,"Autogenerating action in rule
968             \"$rule->{name}\":
969             $parser->{_AUTOACTION}{code}")
970             and
971             Parse::RecDescent::_hint("The \$::RD_AUTOACTION was defined,
972             so any production not ending in an
973             explicit action has the specified
974             \"auto-action\" automatically
975             appended.");
976             }
977             elsif ($parser->{_AUTOTREE} && defined($item) && !$item->isa("Parse::RecDescent::Action"))
978             {
979 28 100 100     212 if ($i==1 && $item->isterminal)
980             {
981 7         24 $code .= $parser->{_AUTOTREE}{TERMINAL}->code($namespace,$rule);
982             }
983             else
984             {
985 22         51 $code .= $parser->{_AUTOTREE}{NODE}->code($namespace,$rule);
986             }
987 28 50       186 Parse::RecDescent::_warn(1,"Autogenerating tree-building action in rule
988             \"$rule->{name}\"")
989             and
990             Parse::RecDescent::_hint("The directive was specified,
991             so any production not ending
992             in an explicit action has
993             some parse-tree building code
994             automatically appended.");
995             }
996              
997             $code .=
998             '
999             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' production: ['
1000             . $self->describe . ']<<},
1001             Parse::RecDescent::_tracefirst($text),
1002             q{' . $rule->{name} . '},
1003             $tracelevel)
1004             if defined $::RD_TRACE;
1005              
1006 1258 100       2226 ' . ( $parser->{_check}{itempos} ? '
1007             if ( defined($_itempos) )
1008             {
1009             Parse::RecDescent::Production::_update_itempos($_itempos, $itempos[ 1], undef, [qw(from)]);
1010             Parse::RecDescent::Production::_update_itempos($_itempos, $itempos[-1], undef, [qw(to)]);
1011             }
1012             ' : '' ) . '
1013              
1014             $_matched = 1;
1015             last;
1016             }
1017              
1018             ';
1019 1258         6725 return $code;
1020             }
1021              
1022             1;
1023              
1024             package Parse::RecDescent::Action;
1025              
1026 177     177   1543 sub describe { undef }
1027              
1028 85     85   404 sub sethashname { $_[0]->{hashname} = '__ACTION' . ++$_[1]->{actcount} .'__'; }
1029              
1030             sub new
1031             {
1032 92   33 92   266 my $class = ref($_[0]) || $_[0];
1033 92         504 bless
1034             {
1035             "code" => $_[1],
1036             "lookahead" => $_[2],
1037             "line" => $_[3],
1038             }, $class;
1039             }
1040              
1041 5     5   14 sub issubrule { undef }
1042 1     1   3 sub isterminal { 0 }
1043              
1044             sub code($$$$)
1045             {
1046 113     113   258 my ($self, $namespace, $rule) = @_;
1047              
1048             '
1049             Parse::RecDescent::_trace(q{Trying action},
1050             Parse::RecDescent::_tracefirst($text),
1051             q{' . $rule->{name} . '},
1052             $tracelevel)
1053             if defined $::RD_TRACE;
1054             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) .'
1055              
1056             $_tok = ($_noactions) ? 0 : do ' . $self->{"code"} . ';
1057             ' . ($self->{"lookahead"}<0?'if':'unless') . ' (defined $_tok)
1058             {
1059             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' action>> (return value: [undef])})
1060             if defined $::RD_TRACE;
1061             last;
1062             }
1063             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' action<< (return value: [}
1064             . $_tok . q{])},
1065             Parse::RecDescent::_tracefirst($text))
1066             if defined $::RD_TRACE;
1067             push @item, $_tok;
1068             ' . ($self->{line}>=0 ? '$item{'. $self->{hashname} .'}=$_tok;' : '' ) .'
1069 113 50       676 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    100          
    50          
1070             '
1071             }
1072              
1073              
1074             1;
1075              
1076             package Parse::RecDescent::Directive;
1077              
1078 17     17   87 sub sethashname { $_[0]->{hashname} = '__DIRECTIVE' . ++$_[1]->{dircount} . '__'; }
1079              
1080 20     20   88 sub issubrule { undef }
1081 1     1   6 sub isterminal { 0 }
1082 80 100   80   404 sub describe { $_[1] ? '' : $_[0]->{name} }
1083              
1084             sub new ($$$$$)
1085             {
1086 24   33 24   169 my $class = ref($_[0]) || $_[0];
1087 24         174 bless
1088             {
1089             "code" => $_[1],
1090             "lookahead" => $_[2],
1091             "line" => $_[3],
1092             "name" => $_[4],
1093             }, $class;
1094             }
1095              
1096             sub code($$$$)
1097             {
1098 24     24   48 my ($self, $namespace, $rule) = @_;
1099              
1100             '
1101             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) .'
1102              
1103             Parse::RecDescent::_trace(q{Trying directive: ['
1104             . $self->describe . ']},
1105             Parse::RecDescent::_tracefirst($text),
1106             q{' . $rule->{name} . '},
1107             $tracelevel)
1108             if defined $::RD_TRACE; ' .'
1109             $_tok = do { ' . $self->{"code"} . ' };
1110             if (defined($_tok))
1111             {
1112             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' directive<< (return value: [}
1113             . $_tok . q{])},
1114             Parse::RecDescent::_tracefirst($text))
1115             if defined $::RD_TRACE;
1116             }
1117             else
1118             {
1119             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' directive>>},
1120             Parse::RecDescent::_tracefirst($text))
1121             if defined $::RD_TRACE;
1122             }
1123             ' . ($self->{"lookahead"} ? '$text = $_savetext and ' : '' ) .'
1124             last '
1125             . ($self->{"lookahead"}<0?'if':'unless') . ' defined $_tok;
1126             push @item, $item{'.$self->{hashname}.'}=$_tok;
1127 24 50       176 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    50          
    50          
1128             '
1129             }
1130              
1131             1;
1132              
1133             package Parse::RecDescent::UncondReject;
1134              
1135 2     2   10 sub issubrule { undef }
1136 1     1   2 sub isterminal { 0 }
1137 9 100   9   126 sub describe { $_[1] ? '' : $_[0]->{name} }
1138 3     3   22 sub sethashname { $_[0]->{hashname} = '__DIRECTIVE' . ++$_[1]->{dircount} . '__'; }
1139              
1140             sub new ($$$;$)
1141             {
1142 3   33 3   27 my $class = ref($_[0]) || $_[0];
1143 3         82 bless
1144             {
1145             "lookahead" => $_[1],
1146             "line" => $_[2],
1147             "name" => $_[3],
1148             }, $class;
1149             }
1150              
1151             # MARK, YOU MAY WANT TO OPTIMIZE THIS.
1152              
1153              
1154             sub code($$$$)
1155             {
1156 3     3   10 my ($self, $namespace, $rule) = @_;
1157              
1158             '
1159             Parse::RecDescent::_trace(q{>>Rejecting production<< (found '
1160             . $self->describe . ')},
1161             Parse::RecDescent::_tracefirst($text),
1162             q{' . $rule->{name} . '},
1163             $tracelevel)
1164             if defined $::RD_TRACE;
1165             undef $return;
1166             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) .'
1167              
1168             $_tok = undef;
1169             ' . ($self->{"lookahead"} ? '$text = $_savetext and ' : '' ) .'
1170             last '
1171 3 50       9 . ($self->{"lookahead"}<0?'if':'unless') . ' defined $_tok;
    50          
    50          
1172             '
1173             }
1174              
1175             1;
1176              
1177             package Parse::RecDescent::Error;
1178              
1179 8     8   65 sub issubrule { undef }
1180 1     1   6 sub isterminal { 0 }
1181 43 50   43   306 sub describe { $_[1] ? '' : $_[0]->{commitonly} ? '' : '' }
    100          
1182 8     8   93 sub sethashname { $_[0]->{hashname} = '__DIRECTIVE' . ++$_[1]->{dircount} . '__'; }
1183              
1184             sub new ($$$$$)
1185             {
1186 8   33 8   33 my $class = ref($_[0]) || $_[0];
1187 8         61 bless
1188             {
1189             "msg" => $_[1],
1190             "lookahead" => $_[2],
1191             "commitonly" => $_[3],
1192             "line" => $_[4],
1193             }, $class;
1194             }
1195              
1196             sub code($$$$)
1197             {
1198 8     8   71 my ($self, $namespace, $rule) = @_;
1199              
1200 8         20 my $action = '';
1201              
1202 8 50       24 if ($self->{"msg"}) # ERROR MESSAGE SUPPLIED
1203             {
1204             #WAS: $action .= "Parse::RecDescent::_error(qq{$self->{msg}}" . ',$thisline);';
1205 1         66 $action .= 'push @{$thisparser->{errors}}, [qq{'.$self->{msg}.'},$thisline];';
1206              
1207             }
1208             else # GENERATE ERROR MESSAGE DURING PARSE
1209             {
1210 8         20 $action .= '
1211             my $rule = $item[0];
1212             $rule =~ s/_/ /g;
1213             #WAS: Parse::RecDescent::_error("Invalid $rule: " . $expectation->message() ,$thisline);
1214             push @{$thisparser->{errors}}, ["Invalid $rule: " . $expectation->message() ,$thisline];
1215             ';
1216             }
1217              
1218             my $dir =
1219             new Parse::RecDescent::Directive('if (' .
1220             ($self->{"commitonly"} ? '$commit' : '1') .
1221             ") { do {$action} unless ".' $_noactions; undef } else {0}',
1222 8 50       44 $self->{"lookahead"},0,$self->describe);
1223 8         92 $dir->{hashname} = $self->{hashname};
1224 8         31 return $dir->code($namespace, $rule, 0);
1225             }
1226              
1227             1;
1228              
1229             package Parse::RecDescent::Token;
1230              
1231 209     209   1647 sub sethashname { $_[0]->{hashname} = '__PATTERN' . ++$_[1]->{patcount} . '__'; }
1232              
1233 442     442   643 sub issubrule { undef }
1234 144     144   916 sub isterminal { 1 }
1235 827     827   4612 sub describe ($) { shift->{'description'}}
1236              
1237              
1238             # ARGS ARE: $self, $pattern, $left_delim, $modifiers, $lookahead, $linenum
1239             sub new ($$$$$$)
1240             {
1241 209   33 209   637 my $class = ref($_[0]) || $_[0];
1242 209         418 my $pattern = $_[1];
1243 209         340 my $pat = $_[1];
1244 209         348 my $ldel = $_[2];
1245 209         255 my $rdel = $ldel;
1246 209         297 $rdel =~ tr/{[(/;
1247              
1248 209         370 my $mod = $_[3];
1249              
1250 209         220 my $desc;
1251              
1252 209 50       426 if ($ldel eq '/') { $desc = "$ldel$pattern$rdel$mod" }
  209         576  
1253 1         7 else { $desc = "m$ldel$pattern$rdel$mod" }
1254 209         572 $desc =~ s/\\/\\\\/g;
1255 209         386 $desc =~ s/\$$/\\\$/g;
1256 209         374 $desc =~ s/}/\\}/g;
1257 209         299 $desc =~ s/{/\\{/g;
1258              
1259 209 50 66 16   15224 if (!eval "no strict;
  16     13   78  
  16     8   36  
  16     8   758  
  15     6   76  
  15     6   34  
  15     7   719  
  13     6   61  
  13     3   27  
  9     3   467  
  13     3   54  
  16     2   35  
  11         464  
  9         38  
  9         13  
  14         335  
  8         26  
  8         22  
  13         324  
  12         37  
  12         29  
  12         259  
  7         96  
  3         5  
  12         191  
  5         30  
  5         11  
  5         199  
  5         19  
  5         7  
  5         143  
  12         59  
  12         18  
  10         5783  
  11         53  
  11         21  
  11         4745  
1260             local \$SIG{__WARN__} = sub {0};
1261             '' =~ m$ldel$pattern$rdel$mod" and $@)
1262             {
1263 1         6 Parse::RecDescent::_warn(3, "Token pattern \"m$ldel$pattern$rdel$mod\"
1264             may not be a valid regular expression",
1265             $_[5]);
1266 1         2 $@ =~ s/ at \(eval.*/./;
1267 1         81 Parse::RecDescent::_hint($@);
1268             }
1269              
1270             # QUIETLY PREVENT (WELL-INTENTIONED) CALAMITY
1271 209         442 $mod =~ s/[gc]//g;
1272 209         343 $pattern =~ s/(\A|[^\\])\\G/$1/g;
1273              
1274 209         1885 bless
1275             {
1276             "pattern" => $pattern,
1277             "ldelim" => $ldel,
1278             "rdelim" => $rdel,
1279             "mod" => $mod,
1280             "lookahead" => $_[4],
1281             "line" => $_[5],
1282             "description" => $desc,
1283             }, $class;
1284             }
1285              
1286              
1287             sub code($$$$$)
1288             {
1289 209     210   329 my ($self, $namespace, $rule, $check) = @_;
1290 209         381 my $ldel = $self->{"ldelim"};
1291 209         366 my $rdel = $self->{"rdelim"};
1292 209         335 my $sdel = $ldel;
1293 209         367 my $mod = $self->{"mod"};
1294              
1295 209         548 $sdel =~ s/[[{(<]/{}/;
1296              
1297             my $code = '
1298             Parse::RecDescent::_trace(q{Trying terminal: [' . $self->describe
1299             . ']}, Parse::RecDescent::_tracefirst($text),
1300             q{' . $rule->{name} . '},
1301             $tracelevel)
1302             if defined $::RD_TRACE;
1303             undef $lastsep;
1304             $expectation->is(q{' . ($rule->hasleftmost($self) ? ''
1305             : $self->describe ) . '})->at($text);
1306             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) . '
1307              
1308             ' . ($self->{"lookahead"}<0?'if':'unless')
1309             . ' ($text =~ s/\A($skip)/$lastsep=$1 and ""/e and '
1310             . ($check->{itempos}? 'do {'.Parse::RecDescent::Production::incitempos().' 1} and ' : '')
1311             . ' $text =~ m' . $ldel . '\A(?:' . $self->{"pattern"} . ')' . $rdel . $mod . ')
1312             {
1313             '.($self->{"lookahead"} ? '$text = $_savetext;' : '$text = $lastsep . $text if defined $lastsep;') .
1314             ($check->{itempos} ? Parse::RecDescent::Production::unincitempos() : '') . '
1315             $expectation->failed();
1316             Parse::RecDescent::_trace(q{<>},
1317             Parse::RecDescent::_tracefirst($text))
1318             if defined $::RD_TRACE;
1319              
1320             last;
1321             }
1322             $current_match = substr($text, $-[0], $+[0] - $-[0]);
1323             substr($text,0,length($current_match),q{});
1324             Parse::RecDescent::_trace(q{>>Matched terminal<< (return value: [}
1325             . $current_match . q{])},
1326             Parse::RecDescent::_tracefirst($text))
1327             if defined $::RD_TRACE;
1328             push @item, $item{'.$self->{hashname}.'}=$current_match;
1329 209 100       486 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    50          
    100          
    50          
    100          
    50          
1330             ';
1331              
1332 209         802 return $code;
1333             }
1334              
1335             1;
1336              
1337             package Parse::RecDescent::Literal;
1338              
1339 919     920   2965 sub sethashname { $_[0]->{hashname} = '__STRING' . ++$_[1]->{strcount} . '__'; }
1340              
1341 2586     2587   3129 sub issubrule { undef }
1342 0     1   0 sub isterminal { 1 }
1343 4583     4584   22998 sub describe ($) { shift->{'description'} }
1344              
1345             sub new ($$$$)
1346             {
1347 919   33 920   2335 my $class = ref($_[0]) || $_[0];
1348              
1349 919         1183 my $pattern = $_[1];
1350              
1351 919         993 my $desc = $pattern;
1352 919         1155 $desc=~s/\\/\\\\/g;
1353 919         1106 $desc=~s/}/\\}/g;
1354 919         1039 $desc=~s/{/\\{/g;
1355              
1356 919         5120 bless
1357             {
1358             "pattern" => $pattern,
1359             "lookahead" => $_[2],
1360             "line" => $_[3],
1361             "description" => "'$desc'",
1362             }, $class;
1363             }
1364              
1365              
1366             sub code($$$$)
1367             {
1368 923     924   1332 my ($self, $namespace, $rule, $check) = @_;
1369              
1370             my $code = '
1371             Parse::RecDescent::_trace(q{Trying terminal: [' . $self->describe
1372             . ']},
1373             Parse::RecDescent::_tracefirst($text),
1374             q{' . $rule->{name} . '},
1375             $tracelevel)
1376             if defined $::RD_TRACE;
1377             undef $lastsep;
1378             $expectation->is(q{' . ($rule->hasleftmost($self) ? ''
1379             : $self->describe ) . '})->at($text);
1380             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) . '
1381              
1382             ' . ($self->{"lookahead"}<0?'if':'unless')
1383             . ' ($text =~ s/\A($skip)/$lastsep=$1 and ""/e and '
1384             . ($check->{itempos}? 'do {'.Parse::RecDescent::Production::incitempos().' 1} and ' : '')
1385             . ' $text =~ m/\A' . quotemeta($self->{"pattern"}) . '/)
1386             {
1387             '.($self->{"lookahead"} ? '$text = $_savetext;' : '$text = $lastsep . $text if defined $lastsep;').'
1388             '. ($check->{itempos} ? Parse::RecDescent::Production::unincitempos() : '') . '
1389             $expectation->failed();
1390             Parse::RecDescent::_trace(qq{<>},
1391             Parse::RecDescent::_tracefirst($text))
1392             if defined $::RD_TRACE;
1393             last;
1394             }
1395             $current_match = substr($text, $-[0], $+[0] - $-[0]);
1396             substr($text,0,length($current_match),q{});
1397             Parse::RecDescent::_trace(q{>>Matched terminal<< (return value: [}
1398             . $current_match . q{])},
1399             Parse::RecDescent::_tracefirst($text))
1400             if defined $::RD_TRACE;
1401             push @item, $item{'.$self->{hashname}.'}=$current_match;
1402 923 100       1551 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    50          
    100          
    50          
    100          
    50          
1403             ';
1404              
1405 923         2540 return $code;
1406             }
1407              
1408             1;
1409              
1410             package Parse::RecDescent::InterpLit;
1411              
1412 5     6   19 sub sethashname { $_[0]->{hashname} = '__STRING' . ++$_[1]->{strcount} . '__'; }
1413              
1414 6     7   8 sub issubrule { undef }
1415 0     1   0 sub isterminal { 1 }
1416 27     28   139 sub describe ($) { shift->{'description'} }
1417              
1418             sub new ($$$$)
1419             {
1420 5   33 6   18 my $class = ref($_[0]) || $_[0];
1421              
1422 5         9 my $pattern = $_[1];
1423 5         10 $pattern =~ s#/#\\/#g;
1424              
1425 5         9 my $desc = $pattern;
1426 5         9 $desc=~s/\\/\\\\/g;
1427 5         9 $desc=~s/}/\\}/g;
1428 5         5 $desc=~s/{/\\{/g;
1429              
1430 5         31 bless
1431             {
1432             "pattern" => $pattern,
1433             "lookahead" => $_[2],
1434             "line" => $_[3],
1435             "description" => "'$desc'",
1436             }, $class;
1437             }
1438              
1439             sub code($$$$)
1440             {
1441 5     6   38 my ($self, $namespace, $rule, $check) = @_;
1442              
1443             my $code = '
1444             Parse::RecDescent::_trace(q{Trying terminal: [' . $self->describe
1445             . ']},
1446             Parse::RecDescent::_tracefirst($text),
1447             q{' . $rule->{name} . '},
1448             $tracelevel)
1449             if defined $::RD_TRACE;
1450             undef $lastsep;
1451             $expectation->is(q{' . ($rule->hasleftmost($self) ? ''
1452             : $self->describe ) . '})->at($text);
1453             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) . '
1454              
1455             ' . ($self->{"lookahead"}<0?'if':'unless')
1456             . ' ($text =~ s/\A($skip)/$lastsep=$1 and ""/e and '
1457             . ($check->{itempos}? 'do {'.Parse::RecDescent::Production::incitempos().' 1} and ' : '')
1458             . ' do { $_tok = "' . $self->{"pattern"} . '"; 1 } and
1459             substr($text,0,length($_tok)) eq $_tok and
1460             do { substr($text,0,length($_tok)) = ""; 1; }
1461             )
1462             {
1463             '.($self->{"lookahead"} ? '$text = $_savetext;' : '$text = $lastsep . $text if defined $lastsep;').'
1464             '. ($check->{itempos} ? Parse::RecDescent::Production::unincitempos() : '') . '
1465             $expectation->failed();
1466             Parse::RecDescent::_trace(q{<>},
1467             Parse::RecDescent::_tracefirst($text))
1468             if defined $::RD_TRACE;
1469             last;
1470             }
1471             Parse::RecDescent::_trace(q{>>Matched terminal<< (return value: [}
1472             . $_tok . q{])},
1473             Parse::RecDescent::_tracefirst($text))
1474             if defined $::RD_TRACE;
1475             push @item, $item{'.$self->{hashname}.'}=$_tok;
1476 5 100       11 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    50          
    100          
    50          
    100          
    50          
1477             ';
1478              
1479 5         14 return $code;
1480             }
1481              
1482             1;
1483              
1484             package Parse::RecDescent::Subrule;
1485              
1486 1592     1593   2734 sub issubrule ($) { return $_[0]->{"subrule"} }
1487 9     10   25 sub isterminal { 0 }
1488       1021     sub sethashname {}
1489              
1490             sub describe ($)
1491             {
1492 3381   33 3382   9219 my $desc = $_[0]->{"implicit"} || $_[0]->{"subrule"};
1493 3381 100       7139 $desc = "" if $_[0]->{"matchrule"};
1494 3381         16519 return $desc;
1495             }
1496              
1497             sub callsyntax($$)
1498             {
1499 1020 100   1021   1964 if ($_[0]->{"matchrule"})
1500             {
1501 2         20 return "&{'$_[1]'.qq{$_[0]->{subrule}}}";
1502             }
1503             else
1504             {
1505 1018         6501 return $_[1].$_[0]->{"subrule"};
1506             }
1507             }
1508              
1509             sub new ($$$$;$$$)
1510             {
1511 1020   33 1021   2565 my $class = ref($_[0]) || $_[0];
1512 1020   50     9272 bless
      100        
1513             {
1514             "subrule" => $_[1],
1515             "lookahead" => $_[2],
1516             "line" => $_[3],
1517             "implicit" => $_[4] || undef,
1518             "matchrule" => $_[5],
1519             "argcode" => $_[6] || undef,
1520             }, $class;
1521             }
1522              
1523              
1524             sub code($$$$)
1525             {
1526 1020     1021   1501 my ($self, $namespace, $rule, $check) = @_;
1527              
1528             '
1529             Parse::RecDescent::_trace(q{Trying subrule: [' . $self->{"subrule"} . ']},
1530             Parse::RecDescent::_tracefirst($text),
1531             q{' . $rule->{"name"} . '},
1532             $tracelevel)
1533             if defined $::RD_TRACE;
1534             if (1) { no strict qw{refs};
1535             $expectation->is(' . ($rule->hasleftmost($self) ? 'q{}'
1536             # WAS : 'qq{'.$self->describe.'}' ) . ')->at($text);
1537             : 'q{'.$self->describe.'}' ) . ')->at($text);
1538             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' )
1539             . ($self->{"lookahead"}<0?'if':'unless')
1540             . ' (defined ($_tok = '
1541             . $self->callsyntax($namespace.'::')
1542             . '($thisparser,$text,$repeating,'
1543             . ($self->{"lookahead"}?'1':'$_noactions')
1544             . ($self->{argcode} ? ",sub { return $self->{argcode} }"
1545             : ',sub { \\@arg }')
1546             . ($check->{"itempos"}?',$itempos[$#itempos]':',undef')
1547             . ')))
1548             {
1549             '.($self->{"lookahead"} ? '$text = $_savetext;' : '').'
1550             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' subrule: ['
1551             . $self->{subrule} . ']>>},
1552             Parse::RecDescent::_tracefirst($text),
1553             q{' . $rule->{"name"} .'},
1554             $tracelevel)
1555             if defined $::RD_TRACE;
1556             $expectation->failed();
1557             last;
1558             }
1559             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' subrule: ['
1560             . $self->{subrule} . ']<< (return value: [}
1561             . $_tok . q{]},
1562              
1563             Parse::RecDescent::_tracefirst($text),
1564             q{' . $rule->{"name"} .'},
1565             $tracelevel)
1566             if defined $::RD_TRACE;
1567             $item{q{' . $self->{subrule} . '}} = $_tok;
1568             push @item, $_tok;
1569 1020 100       2898 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    100          
    100          
    100          
    100          
    100          
    100          
    100          
1570             }
1571             '
1572             }
1573              
1574             package Parse::RecDescent::Repetition;
1575              
1576 149     150   290 sub issubrule ($) { return $_[0]->{"subrule"} }
1577 3     4   10 sub isterminal { 0 }
1578       330     sub sethashname { }
1579              
1580             sub describe ($)
1581             {
1582 1777   66 1778   4743 my $desc = $_[0]->{"expected"} || $_[0]->{"subrule"};
1583 1777 50       3245 $desc = "" if $_[0]->{"matchrule"};
1584 1777         7012 return $desc;
1585             }
1586              
1587             sub callsyntax($$)
1588             {
1589 329 50   330   613 if ($_[0]->{matchrule})
1590 0         0 { return "sub { goto &{''.qq{$_[1]$_[0]->{subrule}}} }"; }
1591             else
1592 329         2220 { return "\\&$_[1]$_[0]->{subrule}"; }
1593             }
1594              
1595             sub new ($$$$$$$$$$)
1596             {
1597 329     330   835 my ($self, $subrule, $repspec, $min, $max, $lookahead, $line, $parser, $matchrule, $argcode) = @_;
1598 329   33     1054 my $class = ref($self) || $self;
1599 329 50       667 ($max, $min) = ( $min, $max) if ($max<$min);
1600              
1601 329         342 my $desc;
1602 329 100       745 if ($subrule=~/\A_alternation_\d+_of_production_\d+_of_rule/)
1603 37         135 { $desc = $parser->{"rules"}{$subrule}->expected }
1604              
1605 329 50       554 if ($lookahead)
1606             {
1607 0 0       0 if ($min>0)
1608             {
1609 0         0 return new Parse::RecDescent::Subrule($subrule,$lookahead,$line,$desc,$matchrule,$argcode);
1610             }
1611             else
1612             {
1613 0         0 Parse::RecDescent::_error("Not symbol (\"!\") before
1614             \"$subrule\" doesn't make
1615             sense.",$line);
1616 0         0 Parse::RecDescent::_hint("Lookahead for negated optional
1617             repetitions (such as
1618             \"!$subrule($repspec)\" can never
1619             succeed, since optional items always
1620             match (zero times at worst).
1621             Did you mean a single \"!$subrule\",
1622             instead?");
1623             }
1624             }
1625             bless
1626             {
1627 329   50     3373 "subrule" => $subrule,
1628             "repspec" => $repspec,
1629             "min" => $min,
1630             "max" => $max,
1631             "lookahead" => $lookahead,
1632             "line" => $line,
1633             "expected" => $desc,
1634             "argcode" => $argcode || undef,
1635             "matchrule" => $matchrule,
1636             }, $class;
1637             }
1638              
1639             sub code($$$$)
1640             {
1641 329     330   469 my ($self, $namespace, $rule, $check) = @_;
1642              
1643             my ($subrule, $repspec, $min, $max, $lookahead) =
1644 329         421 @{$self}{ qw{subrule repspec min max lookahead} };
  329         1178  
1645              
1646             '
1647             Parse::RecDescent::_trace(q{Trying repeated subrule: [' . $self->describe . ']},
1648             Parse::RecDescent::_tracefirst($text),
1649             q{' . $rule->{"name"} . '},
1650             $tracelevel)
1651             if defined $::RD_TRACE;
1652             $expectation->is(' . ($rule->hasleftmost($self) ? 'q{}'
1653             # WAS : 'qq{'.$self->describe.'}' ) . ')->at($text);
1654             : 'q{'.$self->describe.'}' ) . ')->at($text);
1655             ' . ($self->{"lookahead"} ? '$_savetext = $text;' : '' ) .'
1656             unless (defined ($_tok = $thisparser->_parserepeat($text, '
1657             . $self->callsyntax($namespace.'::')
1658             . ', ' . $min . ', ' . $max . ', '
1659             . ($self->{"lookahead"}?'1':'$_noactions')
1660             . ',$expectation,'
1661             . ($self->{argcode} ? "sub { return $self->{argcode} }"
1662             : 'sub { \\@arg }')
1663             . ($check->{"itempos"}?',$itempos[$#itempos]':',undef')
1664             . ')))
1665             {
1666             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' repeated subrule: ['
1667             . $self->describe . ']>>},
1668             Parse::RecDescent::_tracefirst($text),
1669             q{' . $rule->{"name"} .'},
1670             $tracelevel)
1671             if defined $::RD_TRACE;
1672             last;
1673             }
1674             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' repeated subrule: ['
1675             . $self->{subrule} . ']<< (}
1676             . @$_tok . q{ times)},
1677              
1678             Parse::RecDescent::_tracefirst($text),
1679             q{' . $rule->{"name"} .'},
1680             $tracelevel)
1681             if defined $::RD_TRACE;
1682             $item{q{' . "$self->{subrule}($self->{repspec})" . '}} = $_tok;
1683             push @item, $_tok;
1684 329 100       604 ' . ($self->{"lookahead"} ? '$text = $_savetext;' : '' ) .'
    50          
    50          
    50          
    100          
    50          
1685              
1686             '
1687             }
1688              
1689             package Parse::RecDescent::Result;
1690              
1691 0     1   0 sub issubrule { 0 }
1692 0     1   0 sub isterminal { 0 }
1693 0     1   0 sub describe { '' }
1694              
1695             sub new
1696             {
1697 0     1   0 my ($class, $pos) = @_;
1698              
1699 0         0 bless {}, $class;
1700             }
1701              
1702             sub code($$$$)
1703             {
1704 0     1   0 my ($self, $namespace, $rule) = @_;
1705              
1706 0         0 '
1707             $return = $item[-1];
1708             ';
1709             }
1710              
1711             package Parse::RecDescent::Operator;
1712              
1713             my @opertype = ( " non-optional", "n optional" );
1714              
1715 188     189   263 sub issubrule { 0 }
1716 0     1   0 sub isterminal { 0 }
1717              
1718 1084     1085   5603 sub describe { $_[0]->{"expected"} }
1719 137     138   579 sub sethashname { $_[0]->{hashname} = '__DIRECTIVE' . ++$_[1]->{dircount} . '__'; }
1720              
1721              
1722             sub new
1723             {
1724 137     138   252 my ($class, $type, $minrep, $maxrep, $leftarg, $op, $rightarg) = @_;
1725              
1726 137         496 bless
1727             {
1728             "type" => "${type}op",
1729             "leftarg" => $leftarg,
1730             "op" => $op,
1731             "min" => $minrep,
1732             "max" => $maxrep,
1733             "rightarg" => $rightarg,
1734             "expected" => "<${type}op: ".$leftarg->describe." ".$op->describe." ".$rightarg->describe.">",
1735             }, $class;
1736             }
1737              
1738             sub code($$$$)
1739             {
1740 137     138   211 my ($self, $namespace, $rule, $check) = @_;
1741              
1742 137         380 my @codeargs = @_[1..$#_];
1743              
1744             my ($leftarg, $op, $rightarg) =
1745 137         230 @{$self}{ qw{leftarg op rightarg} };
  137         408  
1746              
1747             my $code = '
1748             Parse::RecDescent::_trace(q{Trying operator: [' . $self->describe . ']},
1749             Parse::RecDescent::_tracefirst($text),
1750 137 100       245 q{' . $rule->{"name"} . '},
1751             $tracelevel)
1752             if defined $::RD_TRACE;
1753             $expectation->is(' . ($rule->hasleftmost($self) ? 'q{}'
1754             # WAS : 'qq{'.$self->describe.'}' ) . ')->at($text);
1755             : 'q{'.$self->describe.'}' ) . ')->at($text);
1756              
1757             $_tok = undef;
1758             OPLOOP: while (1)
1759             {
1760             $repcount = 0;
1761             my @item;
1762             my %item;
1763             ';
1764              
1765             $code .= '
1766             my $_itempos = $itempos[-1];
1767             my $itemposfirst;
1768 137 100       351 ' if $check->{itempos};
1769              
1770 137 100       365 if ($self->{type} eq "leftop" )
1771             {
1772 133         309 $code .= '
1773             # MATCH LEFTARG
1774             ' . $leftarg->code(@codeargs) . '
1775              
1776             ';
1777              
1778             $code .= '
1779             if (defined($_itempos) and !defined($itemposfirst))
1780             {
1781             $itemposfirst = Parse::RecDescent::Production::_duplicate_itempos($_itempos);
1782             }
1783 133 100       377 ' if $check->{itempos};
1784              
1785             $code .= '
1786             $repcount++;
1787              
1788             my $savetext = $text;
1789             my $backtrack;
1790              
1791             # MATCH (OP RIGHTARG)(s)
1792             while ($repcount < ' . $self->{max} . ')
1793             {
1794             $backtrack = 0;
1795             ' . $op->code(@codeargs) . '
1796             ' . ($op->isterminal() ? 'pop @item;' : '$backtrack=1;' ) . '
1797             ' . (ref($op) eq 'Parse::RecDescent::Token'
1798 133 50 66     481 ? 'if (defined $1) {push @item, $item{'.($self->{name}||$self->{hashname}).'}=$1; $backtrack=1;}'
    50          
1799             : "" ) . '
1800             ' . $rightarg->code(@codeargs) . '
1801             $savetext = $text;
1802             $repcount++;
1803             }
1804             $text = $savetext;
1805             pop @item if $backtrack;
1806              
1807             ';
1808             }
1809             else
1810             {
1811             $code .= '
1812             my $savetext = $text;
1813             my $backtrack;
1814             # MATCH (LEFTARG OP)(s)
1815 4         14 while ($repcount < ' . $self->{max} . ')
1816             {
1817             $backtrack = 0;
1818             ' . $leftarg->code(@codeargs) . '
1819             ';
1820             $code .= '
1821             if (defined($_itempos) and !defined($itemposfirst))
1822             {
1823             $itemposfirst = Parse::RecDescent::Production::_duplicate_itempos($_itempos);
1824             }
1825 4 50       22 ' if $check->{itempos};
1826              
1827             $code .= '
1828             $repcount++;
1829             $backtrack = 1;
1830             ' . $op->code(@codeargs) . '
1831             $savetext = $text;
1832             ' . ($op->isterminal() ? 'pop @item;' : "" ) . '
1833 4 50 33     11 ' . (ref($op) eq 'Parse::RecDescent::Token' ? 'do { push @item, $item{'.($self->{name}||$self->{hashname}).'}=$1; } if defined $1;' : "" ) . '
    50          
1834             }
1835             $text = $savetext;
1836             pop @item if $backtrack;
1837              
1838             # MATCH RIGHTARG
1839             ' . $rightarg->code(@codeargs) . '
1840             $repcount++;
1841             ';
1842             }
1843              
1844 137 100       496 $code .= 'unless (@item) { undef $_tok; last }' unless $self->{min}==0;
1845              
1846 137         172 $code .= '
1847             $_tok = [ @item ];
1848             ';
1849              
1850              
1851             $code .= '
1852             if (defined $itemposfirst)
1853             {
1854             Parse::RecDescent::Production::_update_itempos(
1855             $_itempos, $itemposfirst, undef, [qw(from)]);
1856             }
1857 137 100       282 ' if $check->{itempos};
1858              
1859 137         170 $code .= '
1860             last;
1861             } # end of OPLOOP
1862             ';
1863              
1864             $code .= '
1865             unless ($repcount>='.$self->{min}.')
1866             {
1867             Parse::RecDescent::_trace(q{<<'.Parse::RecDescent::_matchtracemessage($self,1).' operator: ['
1868             . $self->describe
1869             . ']>>},
1870             Parse::RecDescent::_tracefirst($text),
1871             q{' . $rule->{"name"} .'},
1872             $tracelevel)
1873             if defined $::RD_TRACE;
1874             $expectation->failed();
1875             last;
1876             }
1877             Parse::RecDescent::_trace(q{>>'.Parse::RecDescent::_matchtracemessage($self).' operator: ['
1878             . $self->describe
1879             . ']<< (return value: [}
1880             . qq{@{$_tok||[]}} . q{]},
1881             Parse::RecDescent::_tracefirst($text),
1882             q{' . $rule->{"name"} .'},
1883             $tracelevel)
1884             if defined $::RD_TRACE;
1885              
1886 137   66     376 push @item, $item{'.($self->{name}||$self->{hashname}).'}=$_tok||[];
1887             ';
1888              
1889 137         933 return $code;
1890             }
1891              
1892              
1893             package Parse::RecDescent::Expectation;
1894              
1895             sub new ($)
1896             {
1897 455     456   12245 bless {
1898             "failed" => 0,
1899             "expected" => "",
1900             "unexpected" => "",
1901             "lastexpected" => "",
1902             "lastunexpected" => "",
1903             "defexpected" => $_[1],
1904             };
1905             }
1906              
1907             sub is ($$)
1908             {
1909 840     841   1338 $_[0]->{lastexpected} = $_[1]; return $_[0];
  840         2007  
1910             }
1911              
1912             sub at ($$)
1913             {
1914 1410     1411   2229 $_[0]->{lastunexpected} = $_[1]; return $_[0];
  1410         28142  
1915             }
1916              
1917             sub failed ($)
1918             {
1919 219 100   220   4788 return unless $_[0]->{lastexpected};
1920 15 50       55 $_[0]->{expected} = $_[0]->{lastexpected} unless $_[0]->{failed};
1921 15 50       80 $_[0]->{unexpected} = $_[0]->{lastunexpected} unless $_[0]->{failed};
1922 15         300 $_[0]->{failed} = 1;
1923             }
1924              
1925             sub message ($)
1926             {
1927 0     1   0 my ($self) = @_;
1928 0 0       0 $self->{expected} = $self->{defexpected} unless $self->{expected};
1929 0         0 $self->{expected} =~ s/_/ /g;
1930 0 0 0     0 if (!$self->{unexpected} || $self->{unexpected} =~ /\A\s*\Z/s)
1931             {
1932 0         0 return "Was expecting $self->{expected}";
1933             }
1934             else
1935             {
1936 0         0 $self->{unexpected} =~ /\s*(.*)/;
1937 0         0 return "Was expecting $self->{expected} but found \"$1\" instead";
1938             }
1939             }
1940              
1941             1;
1942              
1943             package Parse::RecDescent;
1944              
1945 13     13   190 use Carp;
  13         27  
  13         1027  
1946 13     13   121 use vars qw ( $AUTOLOAD $VERSION $_FILENAME);
  13         51  
  13         5189  
1947              
1948             my $ERRORS = 0;
1949              
1950             our $VERSION = '1.967013';
1951             $VERSION = eval $VERSION;
1952             $_FILENAME=__FILE__;
1953              
1954             # BUILDING A PARSER
1955              
1956             my $nextnamespace = "namespace000001";
1957              
1958             sub _nextnamespace()
1959             {
1960 16     17   75 return "Parse::RecDescent::" . $nextnamespace++;
1961             }
1962              
1963             # ARGS ARE: $class, $grammar, $compiling, $namespace
1964             sub new ($$$$)
1965             {
1966 25   33 26 0 1180 my $class = ref($_[0]) || $_[0];
1967 25         57 local $Parse::RecDescent::compiling = $_[2];
1968 25 100       128 my $name_space_name = defined $_[3]
1969             ? "Parse::RecDescent::".$_[3]
1970             : _nextnamespace();
1971 25         237 my $self =
1972             {
1973             "rules" => {},
1974             "namespace" => $name_space_name,
1975             "startcode" => '',
1976             "localvars" => '',
1977             "_AUTOACTION" => undef,
1978             "_AUTOTREE" => undef,
1979              
1980             # Precompiled parsers used to set _precompiled, but that
1981             # wasn't present in some versions of Parse::RecDescent used to
1982             # build precompiled parsers. Instead, set a new
1983             # _not_precompiled flag, which is remove from future
1984             # Precompiled parsers at build time.
1985             "_not_precompiled" => 1,
1986             };
1987              
1988              
1989 25 50       80 if ($::RD_AUTOACTION) {
1990 0         0 my $sourcecode = $::RD_AUTOACTION;
1991 0 0       0 $sourcecode = "{ $sourcecode }"
1992             unless $sourcecode =~ /\A\s*\{.*\}\s*\Z/;
1993             $self->{_check}{itempos} =
1994 0         0 $sourcecode =~ /\@itempos\b|\$itempos\s*\[/;
1995             $self->{_AUTOACTION}
1996 0         0 = new Parse::RecDescent::Action($sourcecode,0,-1)
1997             }
1998              
1999 25         59 bless $self, $class;
2000 25         119 return $self->Replace($_[1])
2001             }
2002              
2003             sub Compile($$$$) {
2004 0     1 0 0 die "Compilation of Parse::RecDescent grammars not yet implemented\n";
2005             }
2006              
2007             sub DESTROY {
2008 23     24   6110 my ($self) = @_;
2009 23         109 my $namespace = $self->{namespace};
2010 23         325 $namespace =~ s/Parse::RecDescent:://;
2011 23 100       12054 if ($self->{_not_precompiled}) {
2012             # BEGIN WORKAROUND
2013             # Perl has a bug that creates a circular reference between
2014             # @ISA and that variable's stash:
2015             # https://rt.perl.org/rt3/Ticket/Display.html?id=92708
2016             # Emptying the array before deleting the stash seems to
2017             # prevent the leak. Once the ticket above has been resolved,
2018             # these two lines can be removed.
2019 13     13   137 no strict 'refs';
  13         32  
  13         132417  
2020 13         26 @{$self->{namespace} . '::ISA'} = ();
  13         174  
2021             # END WORKAROUND
2022              
2023             # Some grammars may contain circular references between rules,
2024             # such as:
2025             # a: 'ID' | b
2026             # b: '(' a ')'
2027             # Unless these references are broken, the subs stay around on
2028             # stash deletion below. Iterate through the stash entries and
2029             # for each defined code reference, set it to reference sub {}
2030             # instead.
2031             {
2032 13         35 local $^W; # avoid 'sub redefined' warnings.
  13         55  
2033 13     1   50 my $blank_sub = sub {};
2034 13         26 while (my ($name, $glob) = each %{"Parse::RecDescent::$namespace\::"}) {
  155         666  
2035 142 100       511 *$glob = $blank_sub if defined &$glob;
2036             }
2037             }
2038              
2039             # Delete the namespace's stash
2040 13         1667 delete $Parse::RecDescent::{$namespace.'::'};
2041             }
2042             }
2043              
2044             # BUILDING A GRAMMAR....
2045              
2046             # ARGS ARE: $self, $grammar, $isimplicit, $isleftop
2047             sub Replace ($$)
2048             {
2049             # set $replace = 1 for _generate
2050 25     26 0 80 splice(@_, 2, 0, 1);
2051              
2052 25         105 return _generate(@_);
2053             }
2054              
2055             # ARGS ARE: $self, $grammar, $isimplicit, $isleftop
2056             sub Extend ($$)
2057             {
2058             # set $replace = 0 for _generate
2059 4     5 0 203 splice(@_, 2, 0, 0);
2060              
2061 4         14 return _generate(@_);
2062             }
2063              
2064             sub _no_rule ($$;$)
2065             {
2066 0     1   0 _error("Ruleless $_[0] at start of grammar.",$_[1]);
2067 0 0       0 my $desc = $_[2] ? "\"$_[2]\"" : "";
2068 0         0 _hint("You need to define a rule for the $_[0] $desc
2069             to be part of.");
2070             }
2071              
2072             my $NEGLOOKAHEAD = '\G(\s*\.\.\.\!)';
2073             my $POSLOOKAHEAD = '\G(\s*\.\.\.)';
2074             my $RULE = '\G\s*(\w+)[ \t]*:';
2075             my $PROD = '\G\s*([|])';
2076             my $TOKEN = q{\G\s*/((\\\\/|\\\\\\\\|[^/])*)/([cgimsox]*)};
2077             my $MTOKEN = q{\G\s*(m\s*[^\w\s])};
2078             my $LITERAL = q{\G\s*'((\\\\['\\\\]|[^'])*)'};
2079             my $INTERPLIT = q{\G\s*"((\\\\["\\\\]|[^"])*)"};
2080             my $SUBRULE = '\G\s*(\w+)';
2081             my $MATCHRULE = '\G(\s*
2082             my $SIMPLEPAT = '((\\s+/[^/\\\\]*(?:\\\\.[^/\\\\]*)*/)?)';
2083             my $OPTIONAL = '\G\((\?)'.$SIMPLEPAT.'\)';
2084             my $ANY = '\G\((s\?)'.$SIMPLEPAT.'\)';
2085             my $MANY = '\G\((s|\.\.)'.$SIMPLEPAT.'\)';
2086             my $EXACTLY = '\G\(([1-9]\d*)'.$SIMPLEPAT.'\)';
2087             my $BETWEEN = '\G\((\d+)\.\.([1-9]\d*)'.$SIMPLEPAT.'\)';
2088             my $ATLEAST = '\G\((\d+)\.\.'.$SIMPLEPAT.'\)';
2089             my $ATMOST = '\G\(\.\.([1-9]\d*)'.$SIMPLEPAT.'\)';
2090             my $BADREP = '\G\((-?\d+)?\.\.(-?\d+)?'.$SIMPLEPAT.'\)';
2091             my $ACTION = '\G\s*\{';
2092             my $IMPLICITSUBRULE = '\G\s*\(';
2093             my $COMMENT = '\G\s*(#.*)';
2094             my $COMMITMK = '\G\s*';
2095             my $UNCOMMITMK = '\G\s*';
2096             my $QUOTELIKEMK = '\G\s*';
2097             my $CODEBLOCKMK = '\G\s*{}]+))?>';
2098             my $VARIABLEMK = '\G\s*';
2099             my $NOCHECKMK = '\G\s*';
2100             my $AUTOACTIONPATMK = '\G\s*
2101             my $AUTOTREEMK = '\G\s*';
2102             my $AUTOSTUBMK = '\G\s*';
2103             my $AUTORULEMK = '\G\s*';
2104             my $REJECTMK = '\G\s*';
2105             my $CONDREJECTMK = '\G\s*
2106             my $SCOREMK = '\G\s*
2107             my $AUTOSCOREMK = '\G\s*
2108             my $SKIPMK = '\G\s*
2109             my $OPMK = '\G\s*<(left|right)op(?:=(\'.*?\'))?:';
2110             my $ENDDIRECTIVEMK = '\G\s*>';
2111             my $RESYNCMK = '\G\s*';
2112             my $RESYNCPATMK = '\G\s*
2113             my $RULEVARPATMK = '\G\s*
2114             my $DEFERPATMK = '\G\s*
2115             my $TOKENPATMK = '\G\s*
2116             my $AUTOERRORMK = '\G\s*';
2117             my $MSGERRORMK = '\G\s*
2118             my $NOCHECK = '\G\s*';
2119             my $WARNMK = '\G\s*';
2120             my $HINTMK = '\G\s*';
2121             my $TRACEBUILDMK = '\G\s*';
2122             my $TRACEPARSEMK = '\G\s*';
2123             my $UNCOMMITPROD = $PROD.'\s*
2124             my $ERRORPROD = $PROD.'\s*
2125             my $LONECOLON = '\G\s*:';
2126             my $OTHER = '\G\s*([^\s]+)';
2127              
2128             my @lines = 0;
2129              
2130             sub _generate
2131             {
2132 66     67   177 my ($self, $grammar, $replace, $isimplicit, $isleftop) = (@_, 0);
2133              
2134 66         124 my $aftererror = 0;
2135 66         94 my $lookahead = 0;
2136 66         100 my $lookaheadspec = "";
2137 66         82 my $must_pop_lines;
2138 66 100       207 if (! $lines[-1]) {
2139 29         108 push @lines, _linecount($grammar) ;
2140 29         60 $must_pop_lines = 1;
2141             }
2142             $self->{_check}{itempos} = ($grammar =~ /\@itempos\b|\$itempos\s*\[/)
2143 66 100       725 unless $self->{_check}{itempos};
2144 66         164 for (qw(thisoffset thiscolumn prevline prevoffset prevcolumn))
2145             {
2146             $self->{_check}{$_} =
2147             ($grammar =~ /\$$_/) || $self->{_check}{itempos}
2148 330 100 33     4627 unless $self->{_check}{$_};
2149             }
2150 66         116 my $line;
2151              
2152 66         89 my $rule = undef;
2153 66         109 my $prod = undef;
2154 66         92 my $item = undef;
2155 66         103 my $lastgreedy = '';
2156 66         158 pos $grammar = 0;
2157 66         258 study $grammar;
2158              
2159 66         128 local $::RD_HINT = $::RD_HINT;
2160 66         92 local $::RD_WARN = $::RD_WARN;
2161 66         110 local $::RD_TRACE = $::RD_TRACE;
2162 66         108 local $::RD_CHECK = $::RD_CHECK;
2163              
2164 66         206 while (pos $grammar < length $grammar)
2165             {
2166 4344         7679 $line = $lines[-1] - _linecount($grammar) + 1;
2167 4344         5157 my $commitonly;
2168 4344         5070 my $code = "";
2169 4344         5913 my @components = ();
2170 4344 100 66     139553 if ($grammar =~ m/$COMMENT/gco)
    100 66        
    100 33        
    100 66        
    100 33        
    100 66        
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    50          
    50          
    0          
    0          
    0          
2171             {
2172 51         222 _parse("a comment",0,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2173 51         200 next;
2174             }
2175             elsif ($grammar =~ m/$NEGLOOKAHEAD/gco)
2176             {
2177 1         6 _parse("a negative lookahead",$aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2178 1 50       4 $lookahead = $lookahead ? -$lookahead : -1;
2179 1         3 $lookaheadspec .= $1;
2180 1         4 next; # SKIP LOOKAHEAD RESET AT END OF while LOOP
2181             }
2182             elsif ($grammar =~ m/$POSLOOKAHEAD/gco)
2183             {
2184 7         43 _parse("a positive lookahead",$aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2185 7 50       23 $lookahead = $lookahead ? $lookahead : 1;
2186 7         17 $lookaheadspec .= $1;
2187 7         25 next; # SKIP LOOKAHEAD RESET AT END OF while LOOP
2188             }
2189             elsif ($grammar =~ m/(?=$ACTION)/gco
2190 85         228 and do { ($code) = extract_codeblock($grammar); $code })
  85         211253  
2191             {
2192 85         223 _parse("an action", $aftererror, $line, $code);
2193 85         381 $item = new Parse::RecDescent::Action($code,$lookahead,$line);
2194 85 100 66     352 $prod and $prod->additem($item)
2195             or $self->_addstartcode($code);
2196             }
2197             elsif ($grammar =~ m/(?=$IMPLICITSUBRULE)/gco
2198 37         197 and do { ($code) = extract_codeblock($grammar,'{([',undef,'(',1);
2199 37         11663 $code })
2200             {
2201 37         267 $code =~ s/\A\s*\(|\)\Z//g;
2202 37         144 _parse("an implicit subrule", $aftererror, $line,
2203             "( $code )");
2204 37         123 my $implicit = $rule->nextimplicit;
2205             return undef
2206 37 50       244 if !$self->_generate("$implicit : $code",$replace,1);
2207 37         73 my $pos = pos $grammar;
2208 37         685 substr($grammar,$pos,0,$implicit);
2209 37         85 pos $grammar = $pos;;
2210             }
2211             elsif ($grammar =~ m/$ENDDIRECTIVEMK/gco)
2212             {
2213              
2214             # EXTRACT TRAILING REPETITION SPECIFIER (IF ANY)
2215              
2216 137         226 my ($minrep,$maxrep) = (1,$MAXREP);
2217 137 100       345 if ($grammar =~ m/\G[(]/gc)
2218             {
2219 3         7 pos($grammar)--;
2220              
2221 3 50       188 if ($grammar =~ m/$OPTIONAL/gco)
    50          
    0          
    0          
    0          
    0          
    0          
    0          
2222 0         0 { ($minrep, $maxrep) = (0,1) }
2223             elsif ($grammar =~ m/$ANY/gco)
2224 3         7 { $minrep = 0 }
2225             elsif ($grammar =~ m/$EXACTLY/gco)
2226 0         0 { ($minrep, $maxrep) = ($1,$1) }
2227             elsif ($grammar =~ m/$BETWEEN/gco)
2228 0         0 { ($minrep, $maxrep) = ($1,$2) }
2229             elsif ($grammar =~ m/$ATLEAST/gco)
2230 0         0 { $minrep = $1 }
2231             elsif ($grammar =~ m/$ATMOST/gco)
2232 0         0 { $maxrep = $1 }
2233             elsif ($grammar =~ m/$MANY/gco)
2234             { }
2235             elsif ($grammar =~ m/$BADREP/gco)
2236             {
2237 0         0 _parse("an invalid repetition specifier", 0,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2238 0         0 _error("Incorrect specification of a repeated directive",
2239             $line);
2240 0         0 _hint("Repeated directives cannot have
2241             a maximum repetition of zero, nor can they have
2242             negative components in their ranges.");
2243             }
2244             }
2245              
2246 137 50       476 $prod && $prod->enddirective($line,$minrep,$maxrep);
2247             }
2248             elsif ($grammar =~ m/\G\s*<[^m]/gc)
2249             {
2250 166         354 pos($grammar)-=2;
2251              
2252 166 100 66     3889 if ($grammar =~ m/$OPMK/gco)
    100 33        
    50 33        
    50 33        
    50 66        
    50 66        
    50 33        
    50 33        
    100 33        
    100 0        
    100          
    50          
    50          
    100          
    50          
    100          
    100          
    50          
    50          
    50          
    100          
    50          
    50          
    50          
    50          
    50          
    50          
    0          
    0          
2253             {
2254             # $DB::single=1;
2255 137         537 _parse("a $1-associative operator directive", $aftererror, $line, "<$1op:...>");
2256 137   100     696 $prod->adddirective($1, $line,$2||'');
2257             }
2258             elsif ($grammar =~ m/$UNCOMMITMK/gco)
2259             {
2260 2         10 _parse("an uncommit marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2261 2         8 $item = new Parse::RecDescent::Directive('$commit=0;1',
2262             $lookahead,$line,"");
2263 2 50 33     8 $prod and $prod->additem($item)
2264             or _no_rule("",$line);
2265             }
2266             elsif ($grammar =~ m/$QUOTELIKEMK/gco)
2267             {
2268 0         0 _parse("an perl quotelike marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2269 0         0 $item = new Parse::RecDescent::Directive(
2270             'my ($match,@res);
2271             ($match,$text,undef,@res) =
2272             Text::Balanced::extract_quotelike($text,$skip);
2273             $match ? \@res : undef;
2274             ', $lookahead,$line,"");
2275 0 0 0     0 $prod and $prod->additem($item)
2276             or _no_rule("",$line);
2277             }
2278             elsif ($grammar =~ m/$CODEBLOCKMK/gco)
2279             {
2280 0   0     0 my $outer = $1||"{}";
2281 0         0 _parse("an perl codeblock marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2282 0         0 $item = new Parse::RecDescent::Directive(
2283             'Text::Balanced::extract_codeblock($text,undef,$skip,\''.$outer.'\');
2284             ', $lookahead,$line,"");
2285 0 0 0     0 $prod and $prod->additem($item)
2286             or _no_rule("",$line);
2287             }
2288             elsif ($grammar =~ m/$VARIABLEMK/gco)
2289             {
2290 0         0 _parse("an perl variable marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2291 0         0 $item = new Parse::RecDescent::Directive(
2292             'Text::Balanced::extract_variable($text,$skip);
2293             ', $lookahead,$line,"");
2294 0 0 0     0 $prod and $prod->additem($item)
2295             or _no_rule("",$line);
2296             }
2297             elsif ($grammar =~ m/$NOCHECKMK/gco)
2298             {
2299 0         0 _parse("a disable checking marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2300 0 0       0 if ($rule)
2301             {
2302 0         0 _error(" directive not at start of grammar", $line);
2303 0         0 _hint("The directive can only
2304             be specified at the start of a
2305             grammar (before the first rule
2306             is defined.");
2307             }
2308             else
2309             {
2310 0         0 local $::RD_CHECK = 1;
2311             }
2312             }
2313             elsif ($grammar =~ m/$AUTOSTUBMK/gco)
2314             {
2315 0         0 _parse("an autostub marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2316 0         0 $::RD_AUTOSTUB = "";
2317             }
2318             elsif ($grammar =~ m/$AUTORULEMK/gco)
2319             {
2320 0         0 _parse("an autorule marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2321 0         0 $::RD_AUTOSTUB = $1;
2322             }
2323             elsif ($grammar =~ m/$AUTOTREEMK/gco)
2324             {
2325 3 100       12 my $base = defined($1) ? $1 : "";
2326 3         16 my $current_match = substr($grammar, $-[0], $+[0] - $-[0]);
2327 3 100 100     19 $base .= "::" if $base && $base !~ /::$/;
2328 3         10 _parse("an autotree marker", $aftererror,$line, $current_match);
2329 3 50       8 if ($rule)
2330             {
2331 0         0 _error(" directive not at start of grammar", $line);
2332 0         0 _hint("The directive can only
2333             be specified at the start of a
2334             grammar (before the first rule
2335             is defined.");
2336             }
2337             else
2338             {
2339 3         6 undef $self->{_AUTOACTION};
2340             $self->{_AUTOTREE}{NODE}
2341 3         21 = new Parse::RecDescent::Action(q({bless \%item, ').$base.q('.$item[0]}),0,-1);
2342             $self->{_AUTOTREE}{TERMINAL}
2343 3         12 = new Parse::RecDescent::Action(q({bless {__VALUE__=>$item[1]}, ').$base.q('.$item[0]}),0,-1);
2344             }
2345             }
2346              
2347             elsif ($grammar =~ m/$REJECTMK/gco)
2348             {
2349 1         5 _parse("an reject marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2350 1         8 $item = new Parse::RecDescent::UncondReject($lookahead,$line,"");
2351 1 50 33     4 $prod and $prod->additem($item)
2352             or _no_rule("",$line);
2353             }
2354             elsif ($grammar =~ m/(?=$CONDREJECTMK)/gco
2355 2         8 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2356 2         1549 $code })
2357             {
2358 2         5 _parse("a (conditional) reject marker", $aftererror,$line, $code );
2359 2         8 $code =~ /\A\s*\Z/s;
2360 2         4 my $cond = $1;
2361 2         17 $item = new Parse::RecDescent::Directive(
2362             "($1) ? undef : 1", $lookahead,$line,"");
2363 2 50 33     10 $prod and $prod->additem($item)
2364             or _no_rule("",$line);
2365             }
2366             elsif ($grammar =~ m/(?=$SCOREMK)/gco
2367 0         0 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2368 0         0 $code })
2369             {
2370 0         0 _parse("a score marker", $aftererror,$line, $code );
2371 0         0 $code =~ /\A\s*\Z/s;
2372 0 0 0     0 $prod and $prod->addscore($1, $lookahead, $line)
2373             or _no_rule($code,$line);
2374             }
2375             elsif ($grammar =~ m/(?=$AUTOSCOREMK)/gco
2376 0         0 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2377 0         0 $code;
2378             } )
2379             {
2380 0         0 _parse("an autoscore specifier", $aftererror,$line,$code);
2381 0         0 $code =~ /\A\s*\Z/s;
2382              
2383 0 0 0     0 $rule and $rule->addautoscore($1,$self)
2384             or _no_rule($code,$line);
2385              
2386 0         0 $item = new Parse::RecDescent::UncondReject($lookahead,$line,$code);
2387 0 0 0     0 $prod and $prod->additem($item)
2388             or _no_rule($code,$line);
2389             }
2390             elsif ($grammar =~ m/$RESYNCMK/gco)
2391             {
2392 8         45 _parse("a resync to newline marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2393 8         62 $item = new Parse::RecDescent::Directive(
2394             'if ($text =~ s/(\A[^\n]*\n)//) { $return = 0; $1; } else { undef }',
2395             $lookahead,$line,"");
2396 8 50 33     35 $prod and $prod->additem($item)
2397             or _no_rule("",$line);
2398             }
2399             elsif ($grammar =~ m/(?=$RESYNCPATMK)/gco
2400 0         0 and do { ($code) = extract_bracketed($grammar,'<');
2401 0         0 $code })
2402             {
2403 0         0 _parse("a resync with pattern marker", $aftererror,$line, $code );
2404 0         0 $code =~ /\A\s*\Z/s;
2405 0         0 $item = new Parse::RecDescent::Directive(
2406             'if ($text =~ s/(\A'.$1.')//) { $return = 0; $1; } else { undef }',
2407             $lookahead,$line,$code);
2408 0 0 0     0 $prod and $prod->additem($item)
2409             or _no_rule($code,$line);
2410             }
2411             elsif ($grammar =~ m/(?=$SKIPMK)/gco
2412 4         19 and do { ($code) = extract_codeblock($grammar,'<');
2413 4         1966 $code })
2414             {
2415 4         13 _parse("a skip marker", $aftererror,$line, $code );
2416 4         16 $code =~ /\A\s*\Z/s;
2417 4 100       12 if ($rule) {
2418 3         26 $item = new Parse::RecDescent::Directive(
2419             'my $oldskip = $skip; $skip='.$1.'; $oldskip',
2420             $lookahead,$line,$code);
2421 3 50 33     15 $prod and $prod->additem($item)
2422             or _no_rule($code,$line);
2423             } else {
2424             #global directive
2425 1         5 $self->{skip} = $1;
2426             }
2427             }
2428             elsif ($grammar =~ m/(?=$RULEVARPATMK)/gco
2429 1         3 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2430 1         571 $code;
2431             } )
2432             {
2433 1         15 _parse("a rule variable specifier", $aftererror,$line,$code);
2434 1         6 $code =~ /\A\s*\Z/s;
2435              
2436 1 50 33     10 $rule and $rule->addvar($1,$self)
2437             or _no_rule($code,$line);
2438              
2439 1         12 $item = new Parse::RecDescent::UncondReject($lookahead,$line,$code);
2440 1 50 33     6 $prod and $prod->additem($item)
2441             or _no_rule($code,$line);
2442             }
2443             elsif ($grammar =~ m/(?=$AUTOACTIONPATMK)/gco
2444 0         0 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2445 0         0 $code;
2446             } )
2447             {
2448 0         0 _parse("an autoaction specifier", $aftererror,$line,$code);
2449 0         0 $code =~ s/\A\s*\Z/$1/s;
2450 0 0       0 if ($code =~ /\A\s*[^{]|[^}]\s*\Z/) {
2451 0         0 $code = "{ $code }"
2452             }
2453             $self->{_check}{itempos} =
2454 0         0 $code =~ /\@itempos\b|\$itempos\s*\[/;
2455             $self->{_AUTOACTION}
2456 0         0 = new Parse::RecDescent::Action($code,0,-$line)
2457             }
2458             elsif ($grammar =~ m/(?=$DEFERPATMK)/gco
2459 0         0 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2460 0         0 $code;
2461             } )
2462             {
2463 0         0 _parse("a deferred action specifier", $aftererror,$line,$code);
2464 0         0 $code =~ s/\A\s*\Z/$1/s;
2465 0 0       0 if ($code =~ /\A\s*[^{]|[^}]\s*\Z/)
2466             {
2467 0         0 $code = "{ $code }"
2468             }
2469              
2470 0         0 $item = new Parse::RecDescent::Directive(
2471             "push \@{\$thisparser->{deferred}}, sub $code;",
2472             $lookahead,$line,"");
2473 0 0 0     0 $prod and $prod->additem($item)
2474             or _no_rule("",$line);
2475              
2476 0         0 $self->{deferrable} = 1;
2477             }
2478             elsif ($grammar =~ m/(?=$TOKENPATMK)/gco
2479 0         0 and do { ($code) = extract_codeblock($grammar,'{',undef,'<');
2480 0         0 $code;
2481             } )
2482             {
2483 0         0 _parse("a token constructor", $aftererror,$line,$code);
2484 0         0 $code =~ s/\A\s*\Z/$1/s;
2485              
2486 0   0     0 my $types = eval 'no strict; local $SIG{__WARN__} = sub {0}; my @arr=('.$code.'); @arr' || ();
2487 0 0       0 if (!$types)
2488             {
2489 0         0 _error("Incorrect token specification: \"$@\"", $line);
2490 0         0 _hint("The directive requires a list
2491             of one or more strings representing possible
2492             types of the specified token. For example:
2493             ");
2494             }
2495             else
2496             {
2497 0         0 $item = new Parse::RecDescent::Directive(
2498             'no strict;
2499             $return = { text => $item[-1] };
2500             @{$return->{type}}{'.$code.'} = (1..'.$types.');',
2501             $lookahead,$line,"");
2502 0 0 0     0 $prod and $prod->additem($item)
2503             or _no_rule("",$line);
2504             }
2505             }
2506             elsif ($grammar =~ m/$COMMITMK/gco)
2507             {
2508 1         6 _parse("an commit marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2509 1         6 $item = new Parse::RecDescent::Directive('$commit = 1',
2510             $lookahead,$line,"");
2511 1 50 33     7 $prod and $prod->additem($item)
2512             or _no_rule("",$line);
2513             }
2514             elsif ($grammar =~ m/$NOCHECKMK/gco) {
2515 0         0 _parse("an hint request", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2516 0         0 $::RD_CHECK = 0;
2517             }
2518             elsif ($grammar =~ m/$HINTMK/gco) {
2519 0         0 _parse("an hint request", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2520 0         0 $::RD_HINT = $self->{__HINT__} = 1;
2521             }
2522             elsif ($grammar =~ m/$WARNMK/gco) {
2523 0         0 _parse("an warning request", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2524 0 0       0 $::RD_WARN = $self->{__WARN__} = $1 ? $2+0 : 1;
2525             }
2526             elsif ($grammar =~ m/$TRACEBUILDMK/gco) {
2527 0         0 _parse("an grammar build trace request", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2528 0 0       0 $::RD_TRACE = $1 ? $2+0 : 1;
2529             }
2530             elsif ($grammar =~ m/$TRACEPARSEMK/gco) {
2531 0         0 _parse("an parse trace request", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2532 0 0       0 $self->{__TRACE__} = $1 ? $2+0 : 1;
2533             }
2534             elsif ($grammar =~ m/$AUTOERRORMK/gco)
2535             {
2536 7         21 $commitonly = $1;
2537 7         44 _parse("an error marker", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2538 7         63 $item = new Parse::RecDescent::Error('',$lookahead,$1,$line);
2539 7 50 33     43 $prod and $prod->additem($item)
2540             or _no_rule("",$line);
2541 7         16 $aftererror = !$commitonly;
2542             }
2543             elsif ($grammar =~ m/(?=$MSGERRORMK)/gco
2544 0         0 and do { $commitonly = $1;
2545 0         0 ($code) = extract_bracketed($grammar,'<');
2546 0         0 $code })
2547             {
2548 0         0 _parse("an error marker", $aftererror,$line,$code);
2549 0         0 $code =~ /\A\s*\Z/s;
2550 0         0 $item = new Parse::RecDescent::Error($1,$lookahead,$commitonly,$line);
2551 0 0 0     0 $prod and $prod->additem($item)
2552             or _no_rule("$code",$line);
2553 0         0 $aftererror = !$commitonly;
2554             }
2555 0         0 elsif (do { $commitonly = $1;
2556 0         0 ($code) = extract_bracketed($grammar,'<');
2557 0         0 $code })
2558             {
2559 0 0       0 if ($code =~ /^<[A-Z_]+>$/)
2560             {
2561 0         0 _error("Token items are not yet
2562             supported: \"$code\"",
2563             $line);
2564 0         0 _hint("Items like $code that consist of angle
2565             brackets enclosing a sequence of
2566             uppercase characters will eventually
2567             be used to specify pre-lexed tokens
2568             in a grammar. That functionality is not
2569             yet implemented. Or did you misspell
2570             \"$code\"?");
2571             }
2572             else
2573             {
2574 0         0 _error("Untranslatable item encountered: \"$code\"",
2575             $line);
2576 0         0 _hint("Did you misspell \"$code\"
2577             or forget to comment it out?");
2578             }
2579             }
2580             }
2581             elsif ($grammar =~ m/$RULE/gco)
2582             {
2583 662 50       3129 _parseunneg("a rule declaration", 0,
2584             $lookahead,$line, substr($grammar, $-[0], $+[0] - $-[0]) ) or next;
2585 662         1888 my $rulename = $1;
2586 662 50       2183 if ($rulename =~ /Replace|Extend|Precompile|PrecompiledRuntime|Save/ )
2587             {
2588 0 0       0 _warn(2,"Rule \"$rulename\" hidden by method
2589             Parse::RecDescent::$rulename",$line)
2590             and
2591             _hint("The rule named \"$rulename\" cannot be directly
2592             called through the Parse::RecDescent object
2593             for this grammar (although it may still
2594             be used as a subrule of other rules).
2595             It can't be directly called because
2596             Parse::RecDescent::$rulename is already defined (it
2597             is the standard method of all
2598             parsers).");
2599             }
2600 662         1643 $rule = new Parse::RecDescent::Rule($rulename,$self,$line,$replace);
2601 662 100       2304 $prod->check_pending($line) if $prod;
2602 662         1576 $prod = $rule->addprod( new Parse::RecDescent::Production );
2603 662         1020 $aftererror = 0;
2604             }
2605             elsif ($grammar =~ m/$UNCOMMITPROD/gco)
2606             {
2607 1         3 pos($grammar)-=9;
2608 1 50       7 _parseunneg("a new (uncommitted) production",
2609             0, $lookahead, $line, substr($grammar, $-[0], $+[0] - $-[0]) ) or next;
2610              
2611 1 50       6 $prod->check_pending($line) if $prod;
2612 1         2 $prod = new Parse::RecDescent::Production($line,1);
2613 1 50 33     11 $rule and $rule->addprod($prod)
2614             or _no_rule("",$line);
2615 1         2 $aftererror = 0;
2616             }
2617             elsif ($grammar =~ m/$ERRORPROD/gco)
2618             {
2619 7         19 pos($grammar)-=6;
2620 7 50       44 _parseunneg("a new (error) production", $aftererror,
2621             $lookahead,$line, substr($grammar, $-[0], $+[0] - $-[0]) ) or next;
2622 7 50       41 $prod->check_pending($line) if $prod;
2623 7         16 $prod = new Parse::RecDescent::Production($line,0,1);
2624 7 50 33     28 $rule and $rule->addprod($prod)
2625             or _no_rule("",$line);
2626 7         10 $aftererror = 0;
2627             }
2628             elsif ($grammar =~ m/$PROD/gco)
2629             {
2630 582 50       2601 _parseunneg("a new production", 0,
2631             $lookahead,$line, substr($grammar, $-[0], $+[0] - $-[0]) ) or next;
2632 582 50 33     2936 $rule
      33        
      33        
2633             and (!$prod || $prod->check_pending($line))
2634             and $prod = $rule->addprod(new Parse::RecDescent::Production($line))
2635             or _no_rule("production",$line);
2636 582         904 $aftererror = 0;
2637             }
2638             elsif ($grammar =~ m/$LITERAL/gco)
2639             {
2640 919         1633 my $literal = $1;
2641 919         1443 ($code = $literal) =~ s/\\\\/\\/g;
2642 919         1698 _parse("a literal terminal", $aftererror,$line,$literal);
2643 919         2370 $item = new Parse::RecDescent::Literal($code,$lookahead,$line);
2644 919 50 33     2937 $prod and $prod->additem($item)
2645             or _no_rule("literal terminal",$line,"'$literal'");
2646             }
2647             elsif ($grammar =~ m/$INTERPLIT/gco)
2648             {
2649 5         26 _parse("an interpolated literal terminal", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2650 5         30 $item = new Parse::RecDescent::InterpLit($1,$lookahead,$line);
2651 5 50 33     23 $prod and $prod->additem($item)
2652             or _no_rule("interpolated literal terminal",$line,"'$1'");
2653             }
2654             elsif ($grammar =~ m/$TOKEN/gco)
2655             {
2656 208         998 _parse("a /../ pattern terminal", $aftererror,$line, substr($grammar, $-[0], $+[0] - $-[0]) );
2657 208 100       1206 $item = new Parse::RecDescent::Token($1,'/',$3?$3:'',$lookahead,$line);
2658 208 50 33     906 $prod and $prod->additem($item)
2659             or _no_rule("pattern terminal",$line,"/$1/");
2660             }
2661             elsif ($grammar =~ m/(?=$MTOKEN)/gco
2662 0         0 and do { ($code, undef, @components)
2663             = extract_quotelike($grammar);
2664 0         0 $code }
2665             )
2666              
2667             {
2668 0         0 _parse("an m/../ pattern terminal", $aftererror,$line,$code);
2669 0         0 $item = new Parse::RecDescent::Token(@components[3,2,8],
2670             $lookahead,$line);
2671 0 0 0     0 $prod and $prod->additem($item)
2672             or _no_rule("pattern terminal",$line,$code);
2673             }
2674             elsif ($grammar =~ m/(?=$MATCHRULE)/gco
2675 2         9 and do { ($code) = extract_bracketed($grammar,'<');
2676 2         294 $code
2677             }
2678             or $grammar =~ m/$SUBRULE/gco
2679             and $code = $1)
2680             {
2681 1476         1860 my $name = $code;
2682 1476         1916 my $matchrule = 0;
2683 1476 100       3083 if (substr($name,0,1) eq '<')
2684             {
2685 2         22 $name =~ s/$MATCHRULE\s*//;
2686 2         7 $name =~ s/\s*>\Z//;
2687 2         4 $matchrule = 1;
2688             }
2689              
2690             # EXTRACT TRAILING ARG LIST (IF ANY)
2691              
2692 1476   100     3816 my ($argcode) = extract_codeblock($grammar, "[]",'') || '';
2693              
2694             # EXTRACT TRAILING REPETITION SPECIFIER (IF ANY)
2695              
2696 1476 100       93293 if ($grammar =~ m/\G[(]/gc)
2697             {
2698 456         897 pos($grammar)--;
2699              
2700 456 100       3035 if ($grammar =~ m/$OPTIONAL/gco)
    100          
    100          
    50          
    50          
    0          
    0          
    0          
2701             {
2702 246         922 _parse("an zero-or-one subrule match", $aftererror,$line,"$code$argcode($1)");
2703 246         774 $item = new Parse::RecDescent::Repetition($name,$1,0,1,
2704             $lookahead,$line,
2705             $self,
2706             $matchrule,
2707             $argcode);
2708 246 50 33     856 $prod and $prod->additem($item)
2709             or _no_rule("repetition",$line,"$code$argcode($1)");
2710              
2711 246 50 33     1188 !$matchrule and $rule and $rule->addcall($name);
2712             }
2713             elsif ($grammar =~ m/$ANY/gco)
2714             {
2715 30         129 _parse("a zero-or-more subrule match", $aftererror,$line,"$code$argcode($1)");
2716 30 100       108 if ($2)
2717             {
2718 1         2 my $pos = pos $grammar;
2719 1         7 substr($grammar,$pos,0,
2720             "(s?) ");
2721              
2722 1         3 pos $grammar = $pos;
2723             }
2724             else
2725             {
2726 29         129 $item = new Parse::RecDescent::Repetition($name,$1,0,$MAXREP,
2727             $lookahead,$line,
2728             $self,
2729             $matchrule,
2730             $argcode);
2731 29 50 33     121 $prod and $prod->additem($item)
2732             or _no_rule("repetition",$line,"$code$argcode($1)");
2733              
2734 29 50 33     152 !$matchrule and $rule and $rule->addcall($name);
2735              
2736 29 50       140 _check_insatiable($name,$1,$grammar,$line) if $::RD_CHECK;
2737             }
2738             }
2739             elsif ($grammar =~ m/$MANY/gco)
2740             {
2741 179         710 _parse("a one-or-more subrule match", $aftererror,$line,"$code$argcode($1)");
2742 179 100       536 if ($2)
2743             {
2744             # $DB::single=1;
2745 126         189 my $pos = pos $grammar;
2746 126         2192 substr($grammar,$pos,0,
2747             " ");
2748              
2749 126         309 pos $grammar = $pos;
2750             }
2751             else
2752             {
2753 53         291 $item = new Parse::RecDescent::Repetition($name,$1,1,$MAXREP,
2754             $lookahead,$line,
2755             $self,
2756             $matchrule,
2757             $argcode);
2758              
2759 53 50 33     252 $prod and $prod->additem($item)
2760             or _no_rule("repetition",$line,"$code$argcode($1)");
2761              
2762 53 50 33     341 !$matchrule and $rule and $rule->addcall($name);
2763              
2764 53 50       237 _check_insatiable($name,$1,$grammar,$line) if $::RD_CHECK;
2765             }
2766             }
2767             elsif ($grammar =~ m/$EXACTLY/gco)
2768             {
2769 0         0 _parse("an exactly-$1-times subrule match", $aftererror,$line,"$code$argcode($1)");
2770 0 0       0 if ($2)
2771             {
2772 0         0 my $pos = pos $grammar;
2773 0         0 substr($grammar,$pos,0,
2774             "($1) ");
2775              
2776 0         0 pos $grammar = $pos;
2777             }
2778             else
2779             {
2780 0         0 $item = new Parse::RecDescent::Repetition($name,$1,$1,$1,
2781             $lookahead,$line,
2782             $self,
2783             $matchrule,
2784             $argcode);
2785 0 0 0     0 $prod and $prod->additem($item)
2786             or _no_rule("repetition",$line,"$code$argcode($1)");
2787              
2788 0 0 0     0 !$matchrule and $rule and $rule->addcall($name);
2789             }
2790             }
2791             elsif ($grammar =~ m/$BETWEEN/gco)
2792             {
2793 1         10 _parse("a $1-to-$2 subrule match", $aftererror,$line,"$code$argcode($1..$2)");
2794 1 50       5 if ($3)
2795             {
2796 0         0 my $pos = pos $grammar;
2797 0         0 substr($grammar,$pos,0,
2798             "($1..$2) ");
2799              
2800 0         0 pos $grammar = $pos;
2801             }
2802             else
2803             {
2804 1         8 $item = new Parse::RecDescent::Repetition($name,"$1..$2",$1,$2,
2805             $lookahead,$line,
2806             $self,
2807             $matchrule,
2808             $argcode);
2809 1 50 33     18 $prod and $prod->additem($item)
2810             or _no_rule("repetition",$line,"$code$argcode($1..$2)");
2811              
2812 1 50 33     10 !$matchrule and $rule and $rule->addcall($name);
2813             }
2814             }
2815             elsif ($grammar =~ m/$ATLEAST/gco)
2816             {
2817 0         0 _parse("a $1-or-more subrule match", $aftererror,$line,"$code$argcode($1..)");
2818 0 0       0 if ($2)
2819             {
2820 0         0 my $pos = pos $grammar;
2821 0         0 substr($grammar,$pos,0,
2822             "($1..) ");
2823              
2824 0         0 pos $grammar = $pos;
2825             }
2826             else
2827             {
2828 0         0 $item = new Parse::RecDescent::Repetition($name,"$1..",$1,$MAXREP,
2829             $lookahead,$line,
2830             $self,
2831             $matchrule,
2832             $argcode);
2833 0 0 0     0 $prod and $prod->additem($item)
2834             or _no_rule("repetition",$line,"$code$argcode($1..)");
2835              
2836 0 0 0     0 !$matchrule and $rule and $rule->addcall($name);
2837 0 0       0 _check_insatiable($name,"$1..",$grammar,$line) if $::RD_CHECK;
2838             }
2839             }
2840             elsif ($grammar =~ m/$ATMOST/gco)
2841             {
2842 0         0 _parse("a one-to-$1 subrule match", $aftererror,$line,"$code$argcode(..$1)");
2843 0 0       0 if ($2)
2844             {
2845 0         0 my $pos = pos $grammar;
2846 0         0 substr($grammar,$pos,0,
2847             "(..$1) ");
2848              
2849 0         0 pos $grammar = $pos;
2850             }
2851             else
2852             {
2853 0         0 $item = new Parse::RecDescent::Repetition($name,"..$1",1,$1,
2854             $lookahead,$line,
2855             $self,
2856             $matchrule,
2857             $argcode);
2858 0 0 0     0 $prod and $prod->additem($item)
2859             or _no_rule("repetition",$line,"$code$argcode(..$1)");
2860              
2861 0 0 0     0 !$matchrule and $rule and $rule->addcall($name);
2862             }
2863             }
2864             elsif ($grammar =~ m/$BADREP/gco)
2865             {
2866 0         0 my $current_match = substr($grammar, $-[0], $+[0] - $-[0]);
2867 0         0 _parse("an subrule match with invalid repetition specifier", 0,$line, $current_match);
2868 0         0 _error("Incorrect specification of a repeated subrule",
2869             $line);
2870 0         0 _hint("Repeated subrules like \"$code$argcode$current_match\" cannot have
2871             a maximum repetition of zero, nor can they have
2872             negative components in their ranges.");
2873             }
2874             }
2875             else
2876             {
2877 1020         1830 _parse("a subrule match", $aftererror,$line,$code);
2878 1020         1302 my $desc;
2879 1020 50       1759 if ($name=~/\A_alternation_\d+_of_production_\d+_of_rule/)
2880 0         0 { $desc = $self->{"rules"}{$name}->expected }
2881 1020         2579 $item = new Parse::RecDescent::Subrule($name,
2882             $lookahead,
2883             $line,
2884             $desc,
2885             $matchrule,
2886             $argcode);
2887              
2888 1020 50 33     3450 $prod and $prod->additem($item)
2889             or _no_rule("(sub)rule",$line,$name);
2890              
2891 1020 100 66     5065 !$matchrule and $rule and $rule->addcall($name);
2892             }
2893             }
2894             elsif ($grammar =~ m/$LONECOLON/gco )
2895             {
2896 0         0 _error("Unexpected colon encountered", $line);
2897 0         0 _hint("Did you mean \"|\" (to start a new production)?
2898             Or perhaps you forgot that the colon
2899             in a rule definition must be
2900             on the same line as the rule name?");
2901             }
2902             elsif ($grammar =~ m/$ACTION/gco ) # BAD ACTION, ALREADY FAILED
2903             {
2904 0         0 _error("Malformed action encountered",
2905             $line);
2906 0         0 _hint("Did you forget the closing curly bracket
2907             or is there a syntax error in the action?");
2908             }
2909             elsif ($grammar =~ m/$OTHER/gco )
2910             {
2911 0         0 _error("Untranslatable item encountered: \"$1\"",
2912             $line);
2913 0         0 _hint("Did you misspell \"$1\"
2914             or forget to comment it out?");
2915             }
2916              
2917 4285 50       9399 if ($lookaheadspec =~ tr /././ > 3)
2918             {
2919 0         0 $lookaheadspec =~ s/\A\s+//;
2920 0 0       0 $lookahead = $lookahead<0
2921             ? 'a negative lookahead ("...!")'
2922             : 'a positive lookahead ("...")' ;
2923 0 0       0 _warn(1,"Found two or more lookahead specifiers in a
2924             row.",$line)
2925             and
2926             _hint("Multiple positive and/or negative lookaheads
2927             are simply multiplied together to produce a
2928             single positive or negative lookahead
2929             specification. In this case the sequence
2930             \"$lookaheadspec\" was reduced to $lookahead.
2931             Was this your intention?");
2932             }
2933 4285         5079 $lookahead = 0;
2934 4285         5636 $lookaheadspec = "";
2935              
2936 4285         14700 $grammar =~ m/\G\s+/gc;
2937             }
2938              
2939 66 100       180 if ($must_pop_lines) {
2940 29         49 pop @lines;
2941             }
2942              
2943 66 100 66     440 unless ($ERRORS or $isimplicit or !$::RD_CHECK)
      66        
2944             {
2945 29         135 $self->_check_grammar();
2946             }
2947              
2948 66 100 66     426 unless ($ERRORS or $isimplicit or $Parse::RecDescent::compiling)
      66        
2949             {
2950 20         87 my $code = $self->_code();
2951 20 50       73 if (defined $::RD_TRACE)
2952             {
2953 0 0       0 my $mode = ($nextnamespace eq "namespace000002") ? '>' : '>>';
2954 0         0 print STDERR "printing code (", length($code),") to RD_TRACE\n";
2955 0         0 local *TRACE_FILE;
2956 0 0 0     0 open TRACE_FILE, $mode, "RD_TRACE"
2957             and print TRACE_FILE "my \$ERRORS;\n$code"
2958             and close TRACE_FILE;
2959             }
2960              
2961 20 50 66 2   3600 unless ( eval "$code 1" )
  11 50 100 2   85  
  7 100 66 2   11  
  7 100 100 2   132  
  7 50 66 1   34  
  7 50 66 1   16  
  7 50 100 1   294  
  7 100 66 1   22  
  7 50 33 1   9  
  7 100 33 1   392  
  6 50 33 1   22  
  7 0 66 1   11  
  7 50 33 1   4593  
  6 0 33 1   14  
  6 50 33 1   13  
  6 50 33 1   1073  
  6 50 33 1   47  
  6 50 33 1   18  
  6 100 33 1   1125  
  6 50 33 1   18  
  6 100 33 1   13  
  2 50 33 1   1037  
  2 100 33 1   12  
  2 50 33 1   4  
  1 50 33 1   1271  
  2 50 0 1   9  
  2 50 0 1   5  
  2 100 0 1   2487  
  2 50 0 1   11  
  2 50 0 1   5  
  2 50 0 1   2423  
  2 50 33 1   7  
  2 50 33 1   7  
  2 50 33 1   4299  
  2 100 33 1   10  
  2 50 33 1   5  
  2 50 33 1   4252  
  2 50 33 1   9  
  6 50 33 1   23  
  6 50 33 1   1903  
  6 50 33 1   19  
  6 100 33 1   9  
  6 50 33 1   1540  
  6 50 66 1   16  
  6 100 33 1   14  
  6 100 33 1   2683  
  6 50 33 1   15  
  6 50 66 1   9  
  6 0 33 1   2992  
  6 0 33 1   40  
  6 0 33 1   41  
  3 50 33 1   2443  
  3 50 66 1   26  
  3 50 33 1   12  
  3 50 66 1   2030  
  5 0 33 1   39  
  5 50 33 1   16  
  5 50 33 1   2419  
  4 50 33 1   14  
  4 50 33 1   14  
  4 50 33 1   3723  
  4 50 33 8   13  
  5 50 33 3   17  
  3 0 33 1   2910  
  3 50 33 1   12  
  3 50 33 1   10  
  3 50 33 1   2890  
  3 50 33 1   12  
  3 0 33 1   10  
  3 50 33     3574  
  3 0 33     17  
  3 50 33     7  
  3 50 33     1481  
  3 50 33     21  
  3 50 33     19  
  2 50 33     669  
  2 50 33     11  
  1 50 33     2  
  1 50 33     342  
  2 50 33     11  
  3 50 33     11  
  2 50 33     805  
  2 50 33     10  
  3 100 33     7  
  3 50 33     1551  
  3 50 33     13  
  6 50 33     18  
  1 0 33     1061  
  1 0 33     7  
  2 0 33     5  
  6 50 33     1517  
  3 50 33     12  
  3 50 33     11  
  7 50 33     605  
  7 0 33     20  
  7 0 33     18  
  7 0 33     343  
  3 50 33     8  
  3 50 33     6  
  5 50 33     515  
  7 50 33     40  
  3 50 33     5  
  3 100 50     898  
  3 0 33     12  
  3 50 33     6  
  3 50 33     5244  
  3 50 33     11  
  3 50 33     6  
  3 50 33     2377  
  3 50 33     11  
  3 50 33     7  
  3 50 33     985  
  3 100 66     9  
  1 50 33     3  
  3 50 33     1211  
  3 50 33     13  
  3 100 33     5  
  3 50 33     1576  
  3 50 33     9  
  3 0 33     9  
  3 50 66     2358  
  3 50 33     13  
  3 50 66     8  
  3 50 66     1512  
  3 0 33     11  
  3 0 33     14  
  3 0 33     1026  
  3 50 66     13  
  3 50 33     14  
  3 50 33     719  
  3 0 33     22  
  3 50 33     6  
  3 50 33     1498  
  3 50 33     17  
  3 50 33     7  
  3 0 33     1445  
  3 0 33     10  
  3 0 33     9  
  3 50 50     48  
  3 50 33     8  
  3 50 33     7  
  3 50 33     145  
  3 0 33     23  
  3 50 33     8  
  3 50 33     157  
  3 50 33     12  
  3 50 33     16  
  3 50 33     2091  
  3 100 33     21  
  3 0 33     6  
  3 50 50     37  
  1 50 33     4  
  1 50 33     2  
  1 50 33     100  
  1 50 33     4  
  1 50 33     2  
  3 50 33     144  
  3 50 33     11  
  3 50 33     7  
  3 0 33     2687  
  3 0 33     15  
  3 0 33     11  
  3 50 33     40  
  3 50 33     17  
  3 50 33     16  
  1 50 33     117  
  1 0 33     5  
  1 50 33     1  
  3 50 33     145  
  1 50 33     4  
  1 50 33     2  
  3 0 33     1581  
  3 50 66     10  
  3 0 33     7  
  3 50 33     33  
  1 50 33     4  
  1 50 33     2  
  3 50 33     96  
  3 50 33     27  
  3 50 33     3  
  3 50 33     125  
  3 50 33     9  
  3 50 66     6  
  3 0 33     1351  
  8 0 66     48  
  10 0 33     15  
  10 50       285  
  10 50       38  
  10 50       16  
  10 50       965  
  10 0       40  
  10 50       18  
  10 0       1267  
  10 50       40  
  10 50       20  
  10 50       8677  
  12 0       67  
  12 0       23  
  12 0       6349  
  12 0       51  
  12 0       22  
  12 0       6140  
  11 0       48  
  11 0       18  
  11 0       5166  
  11 0       43  
  11 0       23  
  11 0       8064  
  9 0       41  
  9 0       16  
  9 0       4946  
  8 0       31  
  8 0       12  
  8 0       4325  
  8 0       33  
  8 50       19  
  8 50       4424  
  7 50       32  
  7 50       13  
  7 50       4236  
  7 50       34  
  6 0       18  
  6 50       3853  
  7 50       36  
  6 50       11  
  6 50       4029  
  6 0       29  
  6 50       12  
  6 0       3291  
  6 50       28  
  6 50       11  
  6 50       3681  
  5 50       32  
  5 50       18  
  5 50       2356  
  4 50       18  
  4 50       11  
  4 50       2099  
  3 0       14  
  3 0       7  
  3 0       2824  
  3 50       14  
  3 50       6  
  4 50       2434  
  3 50       14  
  3 0       10  
  3 50       1140  
  3 0       14  
  3 50       7  
  3 50       1950  
  2 50       10  
  2 50       7  
  2 50       653  
  2 50       7  
  2 50       6  
  1 50       492  
  1 50       6  
  2 50       6  
  2 50       696  
  2 50       6  
  2 100       7  
  2 50       551  
  2 50       7  
  2 50       7  
  2 50       1023  
  2 50       11  
  2 50       7  
  2 0       709  
  2 0       11  
  3 0       12  
  2 50       658  
  2 50       8  
  2 50       4  
  2 50       961  
  2 0       7  
  2 50       5  
  2 0       611  
  2 50       9  
  2 50       5  
  2 50       407  
  2 50       9  
  2 50       4  
  2 50       775  
  1 50       5  
  1 50       3  
  2 50       513  
  2 50       8  
  2 50       5  
  2 50       1037  
  2 100       8  
  2 50       6  
  2 50       1382  
  1 100       4  
  1 0       10  
  1 50       5  
  1 50       3  
  1 50       4  
  2 50       7  
  0 50       0  
  0 100       0  
  0 0       0  
  2 50       11  
  0 50       0  
  0 50       0  
  2 50       3  
  2 50       4  
  2 50       11  
  2 50       6  
  0 50       0  
  0 50       0  
  2 0       4  
  2 0       21  
  4 0       8  
  4 50       10  
  4 50       6  
  4 50       8  
  4 50       9  
  4 0       6  
  4 50       6  
  4 50       6  
  0 50       0  
  4 50       5  
  4 0       7  
  4 50       5  
  4 0       5  
  4 50       5  
  4 50       5  
  4 50       6  
  4 50       8  
  4 50       5  
  4 50       7  
  4 50       5  
  4 50       12  
  4 0       6  
  0 50       0  
  4 50       13  
  4 50       13  
  4 0       7  
  4 50       13  
  4 0       6  
  4 50       12  
  4 50       5  
  4 50       13  
  4 50       5  
  4 50       13  
  4 50       5  
  4 50       18  
  4 50       6  
  4 50       13  
  4 0       16  
  4 0       108  
  4 50       8  
  4 50       6  
  4 50       5  
  4 0       8  
  4 50       9  
  4 0       6  
  4 50       6  
  4 50       12  
  4 50       13  
  4 50       6  
  4 50       10  
  4 50       26  
  4 50       29  
  4 50       7  
  4 50       13  
  4 0       13  
  4 0       26  
  1 0       4  
  1 50       5  
  1 50       4  
  1 50       4  
  1 50       5  
  3 0       13  
  3 0       14  
  3 0       8  
  3 50       8  
  3 50       11  
  3 50       11  
  3 50       9  
  3 0       11  
  3 0       9  
  3 0       5  
  3 50       7  
  3 50       19  
  3 50       22  
  3 50       7  
  3 0       9  
  3 0       10  
  3 0       19  
  0 50       0  
  0 50       0  
  0 50       0  
  0 0       0  
  0 50       0  
  3 50       12  
  3 50       9  
  3 0       8  
  3 50       8  
  3 50       9  
  3 50       11  
  3 50       10  
  3 0       10  
  3 50       10  
  3 50       4  
  3 50       9  
  3 50       18  
  3 0       22  
  3 50       11  
  3 0       10  
  3 50       9  
  3 50       19  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  3 50       14  
  3 50       8  
  3 0       8  
  3 0       8  
  3 50       10  
  3 50       10  
  3 50       10  
  3 50       9  
  3 0       6  
  3 50       11  
  3 50       12  
  3 50       7  
  3 50       18  
  4 0       13  
  1 50       2  
  1 50       4  
  1 50       10  
  3 0       16  
  0 50       0  
  0 0       0  
  3 50       3  
  3 50       7  
  3 50       9  
  3 50       9  
  0 50       0  
  0 50       0  
  3 50       4  
  3 50       32  
  5 0       7  
  5 50       16  
  5 50       6  
  5 50       12  
  5 0       11  
  5 50       6  
  5 50       10  
  5 50       8  
  0 50       0  
  5 0       7  
  5 50       19  
  5 0       7  
  5 50       8  
  5 50       9  
  5 50       7  
  5 50       7  
  5 50       11  
  5 50       5  
  5 50       10  
  5 50       6  
  5 0       12  
  5 50       9  
  0 50       0  
  5 50       16  
  5 50       19  
  5 0       7  
  5 50       15  
  5 50       10  
  5 50       14  
  5 50       7  
  5 0       17  
  5 50       9  
  5 0       15  
  5 50       6  
  5 50       18  
  5 50       9  
  5 50       17  
  5 50       24  
  5 50       11  
  5 50       14  
  5 50       7  
  5 50       7  
  5 0       11  
  5 0       11  
  5 0       6  
  5 50       12  
  5 50       17  
  5 50       18  
  5 0       7  
  5 50       14  
  5 50       37  
  5 50       44  
  5 50       11  
  5 0       17  
  5 0       18  
  5 0       38  
  4 50       14  
  4 50       14  
  4 50       13  
  4 50       10  
  4 0       16  
  1 50       7  
  1 50       4  
  1 50       3  
  1 50       4  
  1 0       4  
  1 50       4  
  1 0       4  
  1 50       4  
  1 50       4  
  1 50       3  
  1 50       4  
  1 50       8  
  0 50       0  
  0 50       0  
  0 50       0  
  1 50       5  
  1 100       2  
  1 50       3  
  1 50       5  
  1 0       5  
  1 50       3  
  1 50       5  
  1 50       4  
  1 50       2  
  1 50       4  
  1 50       15  
  1 0       11  
  1 50       3  
  1 50       5  
  1 50       5  
  1 50       10  
  0 0       0  
  0 50       0  
  0 0       0  
  0 50       0  
  0 50       0  
  1 50       6  
  1 50       3  
  1 50       3  
  1 50       3  
  1 50       4  
  1 50       4  
  1 50       4  
  1 0       5  
  1 0       4  
  1 50       2  
  1 50       5  
  1 50       26  
  0 0       0  
  0 0       0  
  0 0       0  
  1 50       5  
  1 50       2  
  1 50       2  
  1 50       4  
  1 0       4  
  1 50       4  
  1 50       4  
  1 50       5  
  1 50       1  
  1 50       4  
  1 50       12  
  1 50       8  
  1 100       3  
  1 50       4  
  1 50       4  
  1 50       9  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  1 50       7  
  1 50       4  
  1 50       3  
  1 100       4  
  1 50       4  
  1 50       4  
  1 100       4  
  1 50       4  
  1 50       5  
  1 100       8  
  1 100       4  
  1 50       3  
  0 50       0  
  0 0       0  
  1 50       3  
  1 50       3  
  1 50       3  
  1 50       4  
  1 50       4  
  1 50       3  
  1 50       3  
  1 0       4  
  1 0       4  
  1 0       5  
  1 50       3  
  1 50       9  
  5 50       25  
  4 50       7  
  4 0       8  
  4 50       57  
  1 50       8  
  0 50       0  
  0 50       0  
  1 50       2  
  1 50       2  
  1 50       4  
  1 0       3  
  0 50       0  
  0 50       0  
  1 50       3  
  1 50       11  
  1 0       2  
  1 50       4  
  1 50       3  
  1 50       2  
  1 50       4  
  1 0       2  
  1 50       2  
  1 0       2  
  0 50       0  
  1 50       2  
  1 50       1  
  1 50       3  
  1 50       2  
  1 50       2  
  1 50       3  
  1 50       2  
  1 50       3  
  1 0       3  
  1 0       3  
  1 0       2  
  1 50       7  
  1 50       2  
  0 50       0  
  1 50       4  
  1 50       4  
  1 0       1  
  1 50       4  
  1 50       2  
  1 50       4  
  1 50       2  
  1 0       4  
  1 0       3  
  1 0       4  
  1 50       3  
  1 50       4  
  1 50       2  
  1 50       5  
  1 0       11  
  1 50       5  
  1 50       4  
  1 50       2  
  1 50       2  
  1 0       2  
  1 50       3  
  1 0       2  
  1 50       2  
  1 50       4  
  1 50       5  
  1 50       1  
  1 50       4  
  1 50       18  
  1 50       18  
  1 50       4  
  1 50       5  
  1 0       5  
  1 0       11  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 0       0  
  1 50       6  
  1 50       4  
  1 50       4  
  1 50       4  
  1 0       4  
  1 0       4  
  1 0       4  
  1 50       4  
  1 50       4  
  1 50       3  
  1 50       2  
  1 0       5  
  0 0       0  
  0 0       0  
  1 50       4  
  1 50       2  
  1 50       3  
  1 0       3  
  1 50       5  
  1 50       4  
  1 50       4  
  1 50       4  
  1 0       5  
  1 0       5  
  1 0       2  
  1 50       6  
  1 50       4  
  0 50       0  
  0 50       0  
  0 0       0  
  1 50       8  
  0 50       0  
  0 50       0  
  1 50       1  
  1 0       3  
  1 50       4  
  1 0       2  
  0 50       0  
  0 50       0  
  1 50       3  
  1 50       11  
  1 50       1  
  1 50       4  
  1 50       3  
  1 50       4  
  1 50       4  
  1 0       2  
  1 0       2  
  1 0       2  
  0 50       0  
  1 50       2  
  1 50       2  
  1 0       2  
  1 50       2  
  1 50       3  
  1 50       2  
  1 50       1  
  1 0       4  
  1 0       1  
  1 0       3  
  1 50       3  
  1 50       4  
  1 50       8  
  0 50       0  
  1 0       5  
  1 50       5  
  1 50       2  
  1 50       5  
  1 50       3  
  1 0       4  
  1 50       3  
  1 0       3  
  1 50       8  
  1 50       4  
  1 50       2  
  1 50       5  
  1 50       2  
  1 50       4  
  1 50       12  
  1 50       3  
  1 50       3  
  1 0       3  
  1 0       2  
  1 0       3  
  1 50       3  
  1 50       2  
  1 50       2  
  1 50       4  
  1 0       5  
  1 50       2  
  1 0       5  
  1 50       13  
  1 50       10  
  1 50       4  
  1 50       3  
  1 50       4  
  1 50       10  
  0 50       0  
  0 50       0  
  0 100       0  
  0 0       0  
  0 0       0  
  1 0       6  
  1 50       3  
  1 50       4  
  1 50       3  
  1 0       4  
  1 50       4  
  1 50       5  
  1 50       5  
  1 50       8  
  1 0       4  
  1 0       6  
  1 0       4  
  1 50       4  
  1 50       5  
  0 50       0  
  0 50       0  
  0 100       0  
  1 50       7  
  0 50       0  
  0 50       0  
  1 0       2  
  1 0       3  
  1 0       5  
  1 50       3  
  0 50       0  
  0 50       0  
  1 50       2  
  1 0       12  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 100       0  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 0       0  
  0 0       0  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 0       0  
  0 0       0  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 100       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0 100       0  
  0 0       0  
  0 50       0  
  0 50       0  
  0 50       0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         5  
  2         6  
  2         4  
  2         4  
  2         5  
  2         3  
  2         9  
  2         4  
  0         0  
  2         2  
  2         3  
  2         3  
  2         3  
  2         5  
  2         3  
  2         2  
  2         5  
  2         3  
  2         5  
  2         3  
  2         6  
  2         3  
  0         0  
  2         7  
  2         7  
  2         4  
  2         7  
  2         4  
  2         6  
  2         4  
  2         7  
  2         4  
  2         7  
  2         3  
  2         7  
  2         3  
  2         7  
  2         14  
  2         6  
  2         4  
  2         3  
  2         3  
  2         4  
  2         5  
  2         3  
  2         3  
  2         7  
  2         7  
  2         5  
  2         4  
  2         6  
  0         0  
  0         0  
  2         5  
  2         4  
  2         4  
  2         7  
  2         7  
  2         7  
  2         8  
  2         6  
  2         7  
  2         8  
  2         4  
  2         8  
  2         8  
  0         0  
  0         0  
  0         0  
  2         11  
  0         0  
  0         0  
  2         3  
  2         3  
  2         8  
  2         6  
  0         0  
  0         0  
  2         3  
  2         23  
  5         11  
  5         14  
  5         8  
  5         15  
  5         12  
  5         5  
  5         10  
  5         7  
  0         0  
  5         6  
  5         6  
  5         7  
  5         10  
  5         9  
  5         8  
  5         6  
  5         10  
  5         6  
  5         10  
  5         9  
  5         15  
  5         6  
  0         0  
  5         15  
  5         17  
  5         7  
  5         17  
  5         10  
  5         17  
  5         8  
  5         17  
  5         8  
  5         17  
  5         9  
  5         16  
  5         8  
  5         18  
  5         25  
  5         12  
  5         15  
  5         9  
  5         7  
  5         11  
  5         18  
  5         7  
  5         10  
  5         325  
  5         14  
  5         9  
  5         17  
  5         36  
  5         42  
  5         12  
  5         19  
  5         18  
  5         35  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  5         23  
  5         16  
  5         14  
  5         14  
  5         17  
  5         18  
  5         20  
  5         14  
  5         10  
  5         20  
  5         24  
  5         10  
  5         22  
  5         18  
  0         0  
  0         0  
  0         0  
  5         25  
  0         0  
  0         0  
  5         5  
  5         10  
  5         16  
  5         12  
  0         0  
  0         0  
  5         11  
  5         51  
  2         3  
  2         8  
  2         4  
  2         4  
  2         6  
  2         3  
  2         5  
  2         2  
  0         0  
  2         4  
  2         3  
  2         3  
  2         4  
  2         6  
  2         2  
  2         3  
  2         5  
  2         1  
  2         6  
  2         4  
  2         6  
  2         3  
  0         0  
  2         7  
  2         7  
  2         2  
  2         9  
  2         4  
  2         7  
  2         6  
  2         7  
  2         3  
  2         8  
  2         4  
  2         7  
  2         3  
  2         7  
  2         11  
  2         7  
  2         6  
  2         4  
  2         3  
  2         4  
  2         4  
  2         4  
  2         4  
  2         6  
  2         8  
  2         2  
  2         6  
  2         17  
  2         16  
  2         5  
  2         6  
  2         7  
  2         15  
  1         5  
  1         4  
  1         4  
  1         3  
  1         5  
  1         5  
  1         3  
  1         4  
  1         3  
  1         3  
  1         4  
  1         4  
  1         4  
  1         3  
  1         5  
  1         4  
  1         2  
  1         5  
  2         19  
  1         3  
  1         3  
  1         3  
  1         6  
  1         4  
  1         3  
  1         2  
  1         3  
  1         5  
  1         5  
  1         2  
  1         4  
  1         12  
  1         41  
  1         3  
  1         5  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         5  
  1         4  
  1         4  
  1         3  
  1         4  
  1         4  
  1         6  
  1         4  
  1         4  
  1         5  
  1         11  
  1         3  
  1         5  
  2         7  
  0         0  
  0         0  
  0         0  
  2         15  
  0         0  
  0         0  
  2         3  
  2         6  
  2         8  
  2         5  
  0         0  
  0         0  
  2         4  
  2         37  
  3         5  
  3         10  
  3         4  
  3         5  
  3         7  
  3         4  
  3         6  
  3         4  
  0         0  
  3         3  
  3         4  
  3         3  
  3         5  
  3         5  
  3         3  
  3         5  
  3         6  
  3         5  
  3         6  
  3         6  
  3         7  
  3         5  
  0         0  
  3         10  
  3         11  
  3         4  
  3         10  
  3         4  
  3         10  
  3         4  
  3         10  
  3         5  
  3         8  
  3         4  
  3         10  
  3         4  
  3         10  
  3         14  
  3         6  
  3         6  
  3         5  
  3         4  
  3         5  
  3         6  
  3         4  
  3         5  
  3         9  
  3         16  
  3         3  
  3         8  
  3         27  
  3         18  
  3         7  
  3         9  
  3         10  
  3         28  
  1         11  
  1         5  
  1         4  
  1         3  
  1         5  
  2         10  
  2         6  
  2         6  
  2         5  
  2         7  
  2         7  
  2         7  
  2         7  
  2         6  
  2         6  
  1         2  
  2         6  
  0         0  
  0         0  
  2         4  
  2         2  
  2         5  
  2         11  
  2         6  
  2         6  
  2         16  
  2         6  
  2         7  
  2         9  
  2         5  
  2         10  
  3         13  
  1         2  
  1         3  
  1         10  
  2         11  
  0         0  
  0         0  
  2         3  
  2         5  
  2         7  
  2         5  
  0         0  
  0         0  
  2         4  
  2         20  
  1         3  
  1         4  
  1         12  
  1         3  
  1         4  
  1         7  
  1         3  
  1         2  
  0         0  
  1         1  
  1         2  
  1         1  
  1         3  
  1         2  
  1         2  
  1         2  
  1         4  
  1         1  
  1         3  
  1         2  
  1         4  
  1         2  
  0         0  
  1         5  
  1         6  
  1         2  
  1         4  
  1         2  
  1         3  
  1         2  
  1         4  
  1         2  
  1         5  
  1         2  
  1         5  
  1         2  
  1         4  
  1         7  
  1         3  
  1         4  
  1         2  
  1         2  
  1         3  
  1         3  
  1         2  
  1         1  
  1         4  
  1         4  
  1         2  
  1         3  
  1         14  
  1         8  
  1         3  
  1         8  
  1         5  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         12  
  1         4  
  1         4  
  1         2  
  1         5  
  0         0  
  0         0  
  1         3  
  1         3  
  1         2  
  1         4  
  1         5  
  1         5  
  1         4  
  1         3  
  1         6  
  1         6  
  1         3  
  1         6  
  1         5  
  0         0  
  0         0  
  0         0  
  1         7  
  0         0  
  0         0  
  1         1  
  1         3  
  1         4  
  1         4  
  0         0  
  0         0  
  1         3  
  1         11  
  1         2  
  1         6  
  1         3  
  1         2  
  1         4  
  1         2  
  1         3  
  1         2  
  0         0  
  1         1  
  1         2  
  1         1  
  1         2  
  1         2  
  1         2  
  1         3  
  1         4  
  1         2  
  1         4  
  1         3  
  1         5  
  1         1  
  0         0  
  1         7  
  1         5  
  1         2  
  1         5  
  1         6  
  1         4  
  1         3  
  1         2  
  1         1  
  1         2  
  1         4  
  1         2  
  1         4  
  1         2  
  1         8  
  1         5  
  0         0  
  0         0  
  0         0  
  1         5  
  1         2  
  1         2  
  1         4  
  1         2  
  1         2  
  1         5  
  0         0  
  0         0  
  0         0  
  1         17  
  0         0  
  0         0  
  1         1  
  1         3  
  1         4  
  1         4  
  0         0  
  0         0  
  1         1  
  1         7  
  1         1  
  1         5  
  1         3  
  1         2  
  1         3  
  1         2  
  1         2  
  1         2  
  0         0  
  1         2  
  1         2  
  1         1  
  1         2  
  1         3  
  1         2  
  1         2  
  1         3  
  1         1  
  1         3  
  1         4  
  1         3  
  1         1  
  0         0  
  1         5  
  1         4  
  1         2  
  1         3  
  1         6  
  1         4  
  1         2  
  1         9  
  1         1  
  1         3  
  1         7  
  1         2  
  1         4  
  1         2  
  1         3  
  1         16  
  1         9  
  1         1  
  1         9  
  1         3  
  1         5  
  0         0  
  0         0  
  0         0  
  0         0  
  1         3  
  1         3  
  1         3  
  1         2  
  1         2  
  1         5  
  0         0  
  0         0  
  0         0  
  1         13  
  0         0  
  0         0  
  1         2  
  1         3  
  1         3  
  1         3  
  0         0  
  0         0  
  1         2  
  1         12  
  2         5  
  2         13  
  2         4  
  2         7  
  2         7  
  2         3  
  2         4  
  2         5  
  0         0  
  2         4  
  2         5  
  2         3  
  2         4  
  2         6  
  2         4  
  2         5  
  2         6  
  2         4  
  2         7  
  2         5  
  2         8  
  2         4  
  0         0  
  2         13  
  2         10  
  2         3  
  2         13  
  2         5  
  2         8  
  2         4  
  2         14  
  2         3  
  2         9  
  2         4  
  2         16  
  2         4  
  2         8  
  2         12  
  2         7  
  2         5  
  2         5  
  2         2  
  2         5  
  2         7  
  2         3  
  2         6  
  2         11  
  2         7  
  2         5  
  2         8  
  2         21  
  2         17  
  2         5  
  2         7  
  2         8  
  2         16  
  2         3  
  2         15  
  2         6  
  2         7  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         7  
  2         5  
  2         9  
  2         7  
  2         7  
  2         8  
  2         8  
  2         3  
  2         8  
  2         16  
  2         16  
  2         5  
  2         7  
  2         7  
  2         16  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         14  
  2         7  
  2         8  
  2         6  
  2         8  
  2         8  
  2         7  
  2         9  
  2         8  
  2         3  
  2         8  
  2         17  
  2         19  
  2         4  
  2         8  
  2         7  
  2         10  
  2         4  
  2         14  
  2         4  
  2         7  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         6  
  2         6  
  2         8  
  2         8  
  2         7  
  2         7  
  2         7  
  2         3  
  2         8  
  2         19  
  2         15  
  2         6  
  2         7  
  2         7  
  2         205  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         10  
  2         7  
  2         6  
  2         6  
  2         8  
  2         7  
  2         7  
  2         34  
  2         8  
  2         4  
  2         8  
  2         13  
  0         0  
  0         0  
  0         0  
  2         10  
  2         5  
  2         3  
  2         8  
  2         9  
  2         7  
  2         7  
  2         7  
  2         7  
  2         14  
  0         0  
  0         0  
  2         8  
  2         4  
  2         4  
  2         6  
  2         8  
  2         7  
  2         7  
  2         6  
  2         6  
  2         6  
  2         6  
  2         7  
  0         0  
  0         0  
  2         6  
  2         3  
  2         6  
  2         7  
  2         7  
  2         7  
  2         7  
  2         6  
  0         0  
  0         0  
  2         3  
  2         22  
  2         7  
  0         0  
  0         0  
  0         0  
  2         10  
  0         0  
  0         0  
  2         3  
  2         5  
  2         6  
  2         5  
  0         0  
  0         0  
  2         4  
  2         23  
  1         2  
  1         6  
  1         2  
  1         2  
  1         3  
  1         2  
  1         2  
  1         2  
  0         0  
  1         1  
  1         2  
  1         2  
  1         1  
  1         2  
  1         2  
  1         1  
  1         3  
  1         2  
  1         4  
  1         3  
  1         4  
  1         1  
  0         0  
  1         5  
  1         4  
  1         2  
  1         5  
  1         6  
  1         3  
  1         3  
  1         2  
  1         1  
  1         2  
  1         3  
  1         2  
  1         3  
  1         1  
  1         4  
  1         13  
  1         13  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         4  
  1         2  
  1         3  
  1         3  
  1         2  
  1         3  
  0         0  
  0         0  
  1         3  
  1         2  
  1         3  
  1         2  
  1         3  
  1         4  
  1         28  
  0         0  
  0         0  
  1         2  
  1         4  
  1         2  
  1         3  
  1         2  
  1         2  
  1         5  
  0         0  
  0         0  
  0         0  
  1         6  
  0         0  
  0         0  
  1         2  
  1         3  
  1         3  
  1         3  
  0         0  
  0         0  
  1         2  
  1         8  
  3         6  
  3         14  
  3         5  
  3         7  
  3         8  
  3         4  
  3         8  
  3         6  
  0         0  
  3         4  
  3         5  
  3         6  
  3         7  
  3         5  
  3         6  
  3         4  
  3         10  
  3         4  
  3         10  
  3         9  
  3         20  
  3         5  
  0         0  
  3         12  
  3         11  
  3         5  
  3         13  
  3         5  
  3         9  
  3         5  
  3         12  
  3         6  
  3         10  
  3         4  
  3         13  
  3         5  
  3         10  
  3         15  
  3         24  
  3         9  
  3         4  
  3         3  
  3         7  
  3         7  
  3         3  
  3         7  
  3         10  
  3         10  
  3         3  
  3         10  
  3         11  
  3         19  
  0         0  
  0         0  
  0         0  
  3         13  
  3         4  
  3         6  
  3         10  
  3         11  
  3         13  
  3         10  
  3         10  
  3         4  
  3         8  
  3         13  
  3         17  
  0         0  
  0         0  
  0         0  
  3         12  
  3         6  
  3         5  
  3         11  
  3         11  
  3         9  
  3         9  
  3         7  
  0         0  
  0         0  
  3         4  
  3         13  
  3         10  
  0         0  
  0         0  
  0         0  
  3         26  
  0         0  
  0         0  
  3         4  
  3         8  
  3         9  
  3         10  
  0         0  
  0         0  
  3         6  
  3         33  
  1         3  
  1         8  
  1         3  
  1         3  
  1         5  
  1         2  
  1         3  
  1         2  
  0         0  
  1         2  
  1         2  
  1         3  
  1         2  
  1         4  
  1         2  
  1         14  
  1         5  
  1         2  
  1         5  
  1         7  
  1         6  
  1         2  
  0         0  
  1         7  
  1         5  
  1         2  
  1         5  
  1         3  
  1         3  
  1         2  
  1         4  
  1         2  
  1         4  
  1         2  
  1         5  
  1         2  
  1         4  
  1         7  
  1         4  
  1         3  
  1         3  
  1         11  
  1         30  
  1         5  
  1         2  
  1         2  
  1         5  
  1         5  
  1         4  
  1         8  
  0         0  
  0         0  
  1         7  
  1         3  
  1         2  
  1         5  
  1         6  
  1         4  
  1         5  
  1         5  
  1         4  
  1         2  
  1         4  
  1         4  
  0         0  
  0         0  
  1         4  
  1         2  
  1         2  
  1         4  
  1         4  
  1         3  
  1         5  
  1         4  
  0         0  
  0         0  
  1         2  
  1         5  
  1         5  
  0         0  
  0         0  
  0         0  
  1         7  
  0         0  
  0         0  
  1         3  
  1         2  
  1         11  
  1         3  
  0         0  
  0         0  
  1         3  
  1         14  
  1         3  
  1         7  
  1         2  
  1         4  
  1         4  
  1         2  
  1         3  
  1         2  
  0         0  
  1         2  
  1         2  
  1         3  
  1         3  
  1         2  
  1         2  
  1         2  
  1         3  
  1         2  
  1         4  
  1         2  
  1         5  
  1         2  
  0         0  
  1         4  
  1         5  
  1         2  
  1         5  
  1         3  
  1         4  
  1         2  
  1         5  
  1         2  
  1         4  
  1         2  
  1         4  
  1         3  
  1         5  
  1         7  
  1         4  
  1         3  
  1         3  
  1         2  
  1         2  
  1         3  
  1         2  
  1         2  
  1         4  
  1         5  
  1         1  
  1         5  
  1         19  
  1         25  
  1         4  
  1         4  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         4  
  1         3  
  1         4  
  1         4  
  1         4  
  1         4  
  1         6  
  1         2  
  1         5  
  1         8  
  0         0  
  0         0  
  0         0  
  1         7  
  1         2  
  1         2  
  1         5  
  1         5  
  1         5  
  1         5  
  1         5  
  1         2  
  1         9  
  1         13  
  1         10  
  1         3  
  1         4  
  1         5  
  1         14  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         4  
  1         4  
  1         3  
  1         5  
  1         5  
  1         4  
  1         4  
  1         4  
  1         3  
  1         7  
  1         13  
  0         0  
  0         0  
  1         4  
  1         3  
  1         2  
  1         4  
  1         4  
  1         4  
  1         5  
  1         8  
  0         0  
  0         0  
  1         2  
  1         8  
  1         5  
  0         0  
  0         0  
  0         0  
  1         8  
  0         0  
  0         0  
  1         1  
  1         3  
  1         4  
  1         3  
  0         0  
  0         0  
  1         2  
  1         11  
  2         5  
  2         12  
  2         3  
  2         6  
  2         6  
  2         2  
  2         5  
  2         3  
  0         0  
  2         3  
  2         3  
  2         3  
  2         4  
  2         3  
  2         4  
  2         2  
  2         6  
  2         3  
  2         11  
  2         3  
  2         8  
  2         3  
  0         0  
  2         8  
  2         8  
  2         3  
  2         7  
  2         4  
  2         6  
  2         3  
  2         8  
  2         3  
  2         7  
  2         4  
  2         7  
  2         4  
  2         6  
  2         11  
  2         5  
  2         6  
  2         3  
  2         3  
  2         5  
  2         4  
  2         4  
  2         5  
  2         7  
  2         8  
  2         3  
  2         6  
  2         5  
  2         16  
  1         2  
  1         3  
  1         4  
  1         4  
  1         5  
  1         3  
  1         2  
  1         2  
  1         4  
  1         4  
  1         4  
  1         4  
  1         5  
  1         1  
  1         5  
  1         6  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         2  
  1         4  
  1         5  
  1         4  
  1         5  
  1         3  
  0         0  
  0         0  
  1         2  
  1         4  
  2         10  
  1         3  
  1         4  
  1         2  
  1         6  
  1         2  
  1         4  
  1         2  
  1         2  
  1         4  
  1         4  
  1         2  
  1         4  
  1         5  
  0         0  
  0         0  
  0         0  
  1         5  
  1         3  
  1         2  
  1         4  
  1         4  
  1         5  
  1         6  
  1         3  
  0         0  
  0         0  
  1         1  
  1         4  
  2         7  
  0         0  
  0         0  
  0         0  
  2         10  
  0         0  
  0         0  
  2         7  
  2         5  
  2         8  
  2         5  
  0         0  
  0         0  
  2         4  
  2         17  
  4         6  
  4         18  
  4         5  
  4         8  
  4         16  
  4         5  
  4         8  
  4         6  
  0         0  
  4         6  
  4         5  
  4         5  
  4         7  
  4         6  
  4         6  
  4         5  
  4         9  
  4         5  
  4         11  
  4         8  
  4         10  
  4         6  
  0         0  
  4         15  
  4         14  
  4         10  
  4         16  
  4         8  
  4         13  
  4         8  
  4         15  
  4         8  
  4         12  
  4         7  
  4         15  
  4         7  
  4         13  
  4         6  
  4         22  
  4         11  
  4         9  
  4         6  
  4         3  
  4         9  
  4         25  
  4         7  
  4         8  
  4         16  
  4         14  
  4         5  
  4         6  
  4         21  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  4         15  
  4         9  
  4         7  
  4         5  
  4         5  
  4         8  
  4         12  
  4         5  
  4         6  
  4         18  
  4         13  
  4         5  
  4         37  
  4         29  
  4         29  
  4         7  
  4         14  
  4         15  
  4         25  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  4         66  
  4         10  
  4         10  
  4         10  
  4         13  
  4         14  
  4         13  
  4         13  
  4         13  
  4         5  
  4         7  
  4         8  
  4         14  
  0         0  
  4         10  
  4         9  
  4         12  
  4         13  
  4         13  
  4         13  
  4         14  
  4         5  
  4         17  
  4         27  
  4         28  
  4         10  
  4         13  
  4         13  
  4         25  
  1         6  
  1         5  
  1         4  
  1         4  
  1         8  
  3         12  
  3         8  
  3         10  
  3         8  
  3         10  
  3         10  
  3         11  
  3         10  
  3         10  
  3         3  
  3         4  
  3         5  
  3         7  
  3         18  
  0         0  
  3         7  
  3         7  
  3         9  
  3         10  
  3         10  
  3         9  
  3         10  
  3         5  
  3         8  
  3         19  
  3         21  
  3         7  
  3         11  
  3         12  
  3         19  
  1         19  
  1         6  
  1         5  
  1         10  
  1         8  
  2         9  
  2         6  
  2         13  
  2         6  
  2         7  
  2         7  
  2         8  
  2         8  
  2         7  
  2         3  
  2         10  
  2         6  
  1         4  
  1         5  
  2         18  
  1         8  
  1         5  
  1         4  
  1         4  
  1         4  
  1         4  
  1         3  
  1         3  
  1         4  
  0         0  
  0         0  
  1         7  
  1         2  
  1         4  
  1         4  
  1         4  
  1         3  
  1         5  
  1         3  
  0         0  
  0         0  
  1         2  
  1         9  
  4         20  
  2         4  
  2         7  
  2         4  
  2         1  
  2         7  
  2         7  
  2         4  
  2         4  
  2         8  
  2         8  
  2         4  
  2         6  
  2         17  
  2         14  
  2         5  
  2         6  
  2         8  
  2         15  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         10  
  2         6  
  2         6  
  2         5  
  2         7  
  2         9  
  2         7  
  2         5  
  2         8  
  2         4  
  2         4  
  2         7  
  0         0  
  0         0  
  2         4  
  2         4  
  2         3  
  2         8  
  2         8  
  2         7  
  2         6  
  2         5  
  0         0  
  0         0  
  2         3  
  2         9  
  4         11  
  1         4  
  1         2  
  1         3  
  1         1  
  1         4  
  1         4  
  1         2  
  1         2  
  1         4  
  1         5  
  1         2  
  1         2  
  1         2  
  1         3  
  1         4  
  0         0  
  1         3  
  1         3  
  1         5  
  1         4  
  1         4  
  1         4  
  1         3  
  1         3  
  1         2  
  1         4  
  0         0  
  0         0  
  1         3  
  1         1  
  1         3  
  1         3  
  1         4  
  1         4  
  1         5  
  1         3  
  0         0  
  0         0  
  1         2  
  1         5  
  4         12  
  0         0  
  0         0  
  0         0  
  4         17  
  0         0  
  0         0  
  4         4  
  4         9  
  4         18  
  4         10  
  0         0  
  0         0  
  4         5  
  4         41  
  1         4  
  1         7  
  1         2  
  1         5  
  1         3  
  1         2  
  1         2  
  1         2  
  0         0  
  1         2  
  1         1  
  1         3  
  1         2  
  1         3  
  1         2  
  1         1  
  1         4  
  1         2  
  1         4  
  1         3  
  1         27  
  1         3  
  0         0  
  1         5  
  1         5  
  1         2  
  1         4  
  1         3  
  1         4  
  1         2  
  1         3  
  1         3  
  1         4  
  1         2  
  1         4  
  1         2  
  1         5  
  1         7  
  1         4  
  1         4  
  1         2  
  1         2  
  1         2  
  1         4  
  1         2  
  1         3  
  1         4  
  1         5  
  1         2  
  1         4  
  1         17  
  1         14  
  1         4  
  1         5  
  1         3  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         4  
  1         4  
  1         4  
  1         4  
  1         5  
  1         5  
  1         4  
  1         5  
  1         2  
  1         6  
  1         2  
  1         3  
  0         0  
  1         4  
  1         4  
  0         0  
  1         9  
  1         8  
  1         5  
  1         4  
  1         4  
  1         4  
  1         4  
  1         3  
  1         4  
  1         12  
  1         12  
  1         2  
  1         5  
  1         5  
  1         10  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  0         0  
  0         0  
  1         3  
  1         3  
  1         2  
  1         5  
  1         4  
  1         4  
  1         4  
  1         3  
  0         0  
  0         0  
  1         2  
  1         7  
  1         5  
  0         0  
  0         0  
  0         0  
  1         4  
  0         0  
  0         0  
  1         2  
  1         3  
  1         4  
  1         3  
  0         0  
  0         0  
  1         3  
  1         11  
  1         2  
  1         13  
  1         2  
  1         3  
  1         4  
  1         2  
  1         2  
  1         3  
  0         0  
  1         2  
  1         1  
  1         2  
  1         2  
  1         1  
  1         2  
  1         1  
  1         4  
  1         3  
  1         4  
  1         3  
  1         4  
  1         2  
  0         0  
  1         4  
  1         5  
  1         2  
  1         4  
  1         2  
  1         5  
  1         3  
  1         5  
  1         3  
  1         4  
  1         2  
  1         5  
  1         3  
  1         4  
  1         13  
  1         5  
  1         3  
  1         2  
  1         2  
  1         3  
  1         3  
  1         6  
  1         2  
  1         5  
  1         4  
  1         2  
  1         4  
  1         14  
  1         10  
  1         2  
  1         5  
  1         3  
  1         36  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         7  
  1         3  
  1         4  
  1         4  
  1         4  
  1         5  
  1         4  
  1         4  
  1         5  
  1         1  
  1         5  
  1         7  
  0         0  
  0         0  
  0         0  
  1         6  
  1         2  
  1         2  
  1         4  
  1         5  
  1         4  
  1         5  
  1         4  
  1         3  
  1         5  
  1         11  
  1         11  
  1         8  
  1         4  
  1         4  
  1         11  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         7  
  1         4  
  1         4  
  1         3  
  1         14  
  1         4  
  1         6  
  1         5  
  1         5  
  1         2  
  1         4  
  1         13  
  1         10  
  1         4  
  1         5  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         4  
  1         4  
  1         5  
  1         5  
  1         3  
  1         4  
  1         6  
  1         2  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  1         5  
  1         2  
  1         3  
  1         4  
  1         5  
  1         4  
  1         4  
  1         5  
  1         2  
  1         3  
  1         12  
  1         13  
  1         4  
  1         4  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         3  
  1         3  
  1         10  
  1         4  
  1         4  
  1         4  
  1         4  
  1         5  
  1         3  
  1         8  
  1         168  
  0         0  
  0         0  
  1         3  
  1         2  
  1         3  
  1         11  
  1         4  
  1         5  
  1         10  
  1         4  
  0         0  
  0         0  
  1         3  
  1         10  
  1         5  
  0         0  
  0         0  
  0         0  
  1         7  
  0         0  
  0         0  
  1         3  
  1         3  
  1         4  
  1         4  
  0         0  
  0         0  
  1         3  
  1         12  
  1         3  
  1         6  
  1         3  
  1         4  
  1         3  
  1         2  
  1         3  
  1         8  
  0         0  
  1         1  
  1         2  
  1         2  
  1         3  
  1         2  
  1         2  
  1         2  
  1         4  
  1         2  
  1         3  
  1         3  
  1         6  
  1         2  
  0         0  
  1         5  
  1         5  
  1         3  
  1         4  
  1         2  
  1         4  
  1         2  
  1         3  
  1         2  
  1         4  
  1         2  
  1         4  
  1         2  
  1         4  
  1         7  
  1         3  
  1         8  
  1         2  
  1         2  
  1         2  
  1         4  
  1         2  
  1         2  
  1         4  
  1         5  
  1         2  
  1         4  
  1         15  
  1         10  
  1         3  
  1         4  
  1         4  
  1         10  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         13  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         4  
  1         5  
  1         4  
  1         67  
  1         17  
  0         0  
  0         0  
  1         6  
  1         3  
  1         2  
  1         5  
  1         4  
  1         4  
  1         5  
  1         4  
  1         2  
  1         4  
  1         13  
  1         11  
  1         11  
  1         5  
  1         4  
  1         9  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  1         4  
  1         4  
  1         3  
  1         4  
  1         5  
  1         4  
  1         4  
  1         5  
  1         4  
  1         4  
  1         94  
  0         0  
  0         0  
  1         5  
  1         2  
  1         3  
  1         4  
  1         4  
  1         4  
  1         5  
  1         3  
  0         0  
  0         0  
  1         2  
  1         8  
  1         9  
  0         0  
  0         0  
  0         0  
  1         8  
  0         0  
  0         0  
  1         2  
  1         2  
  1         3  
  1         3  
  0         0  
  0         0  
  1         2  
  1         12  
  2         2  
  2         8  
  2         2  
  2         4  
  2         19  
  2         3  
  2         9  
  2         3  
  0         0  
  2         4  
  2         2  
  2         3  
  2         3  
  2         5  
  2         3  
  2         2  
  2         6  
  2         3  
  2         4  
  2         4  
  2         7  
  2         4  
  0         0  
  2         7  
  2         9  
  2         3  
  2         7  
  2         4  
  2         7  
  2         3  
  2         7  
  2         4  
  2         7  
  2         3  
  2         6  
  2         2  
  2         7  
  2         10  
  2         4  
  2         5  
  2         3  
  2         3  
  2         5  
  2         4  
  2         3  
  2         4  
  2         8  
  2         7  
  2         3  
  2         7  
  2         22  
  2         14  
  2         5  
  2         10  
  2         7  
  2         17  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         11  
  2         8  
  2         7  
  2         6  
  2         7  
  2         8  
  2         7  
  2         15  
  2         6  
  2         7  
  2         9  
  2         5  
  2         9  
  2         7  
  0         0  
  0         0  
  0         0  
  2         11  
  0         0  
  0         0  
  2         3  
  2         5  
  2         8  
  2         6  
  0         0  
  0         0  
  2         3  
  2         21  
  4         6  
  4         12  
  4         5  
  4         9  
  4         11  
  4         3  
  4         8  
  4         6  
  0         0  
  4         4  
  4         6  
  4         6  
  4         6  
  4         7  
  4         5  
  4         5  
  4         11  
  4         4  
  4         8  
  4         6  
  4         11  
  4         6  
  0         0  
  4         13  
  4         14  
  4         5  
  4         14  
  4         7  
  4         15  
  4         6  
  4         20  
  4         8  
  4         15  
  4         8  
  4         13  
  4         6  
  4         13  
  4         31  
  4         12  
  4         8  
  4         8  
  4         5  
  4         5  
  4         13  
  4         4  
  4         9  
  4         11  
  4         13  
  4         4  
  4         14  
  4         78  
  4         33  
  4         10  
  4         14  
  4         13  
  4         28  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  4         19  
  4         11  
  4         15  
  4         11  
  4         13  
  4         13  
  4         15  
  4         14  
  4         12  
  4         6  
  4         13  
  4         64  
  0         0  
  0         0  
  0         0  
  4         16  
  4         9  
  4         8  
  4         14  
  4         14  
  4         14  
  4         14  
  4         13  
  4         6  
  4         14  
  4         27  
  4         30  
  4         11  
  4         13  
  4         14  
  4         29  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  4         16  
  4         12  
  4         9  
  4         11  
  4         14  
  4         13  
  4         14  
  4         12  
  4         13  
  4         6  
  4         11  
  4         84  
  2         6  
  2         5  
  2         12  
  2         9  
  2         5  
  2         4  
  2         8  
  2         7  
  2         7  
  2         8  
  2         6  
  2         4  
  2         7  
  2         18  
  2         14  
  2         11  
  2         8  
  2         7  
  2         15  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         9  
  2         6  
  2         5  
  2         7  
  2         7  
  2         9  
  2         7  
  2         7  
  2         7  
  2         6  
  2         5  
  2         10  
  2         10  
  0         0  
  0         0  
  2         5  
  2         5  
  2         6  
  2         13  
  2         11  
  2         9  
  2         8  
  2         6  
  2         10  
  2         10  
  2         5  
  2         23  
  4         22  
  2         3  
  2         6  
  2         19  
  2         8  
  0         0  
  0         0  
  2         4  
  2         5  
  2         7  
  2         5  
  0         0  
  0         0  
  2         6  
  2         36  
  3         5  
  3         9  
  3         4  
  3         6  
  3         6  
  3         4  
  3         6  
  3         3  
  0         0  
  3         3  
  3         4  
  3         5  
  3         4  
  3         5  
  3         5  
  3         3  
  3         5  
  3         4  
  3         68  
  3         5  
  3         9  
  3         4  
  0         0  
  3         10  
  3         10  
  3         5  
  3         10  
  3         5  
  3         9  
  3         4  
  3         10  
  3         5  
  3         9  
  3         4  
  3         10  
  3         5  
  3         8  
  3         12  
  3         7  
  3         7  
  3         4  
  3         4  
  3         6  
  3         6  
  3         9  
  3         5  
  3         9  
  3         9  
  3         5  
  3         10  
  3         19  
  3         22  
  3         6  
  3         9  
  3         10  
  3         23  
  3         10  
  3         14  
  3         10  
  3         7  
  3         17  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  3         12  
  3         7  
  3         4  
  3         7  
  3         3  
  3         4  
  3         7  
  3         4  
  3         5  
  3         8  
  3         9  
  3         4  
  3         8  
  3         19  
  3         21  
  3         5  
  3         9  
  3         9  
  3         18  
  3         12  
  3         10  
  3         9  
  3         8  
  3         10  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  3         12  
  3         6  
  3         5  
  3         5  
  3         4  
  3         6  
  3         7  
  3         8  
  3         4  
  3         10  
  3         9  
  3         4  
  3         8  
  3         18  
  3         26  
  3         6  
  3         9  
  3         10  
  3         24  
  2         14  
  2         7  
  2         7  
  2         6  
  2         7  
  1         5  
  1         4  
  1         3  
  1         3  
  1         3  
  1         4  
  1         3  
  1         3  
  1         4  
  1         4  
  1         5  
  1         3  
  1         5  
  3         14  
  2         3  
  2         7  
  2         67  
  1         7  
  0         0  
  0         0  
  1         2  
  1         3  
  1         4  
  1         2  
  0         0  
  0         0  
  1         2  
  1         44  
2962             {
2963 0         0 _error("Internal error in generated parser code!");
2964 0         0 $@ =~ s/at grammar/in grammar at/;
2965 0         0 _hint($@);
2966             }
2967             }
2968              
2969 66 50 33     232 if ($ERRORS and !_verbosity("HINT"))
2970             {
2971 0 0       0 local $::RD_HINT = defined $::RD_HINT ? $::RD_HINT : 1;
2972 0         0 _hint('Set $::RD_HINT (or -RD_HINT if you\'re using "perl -s")
2973             for hints on fixing these problems. Use $::RD_HINT = 0
2974             to disable this message.');
2975             }
2976 66 50       163 if ($ERRORS) { $ERRORS=0; return }
  0         0  
  0         0  
2977 66         456 return $self;
2978             }
2979              
2980              
2981             sub _addstartcode($$)
2982             {
2983 5     6   18 my ($self, $code) = @_;
2984 3         9 $code =~ s/\A\s*\{(.*)\}\Z/$1/s;
2985              
2986 3         41 $self->{"startcode"} .= "$code;\n";
2987             }
2988              
2989             # CHECK FOR GRAMMAR PROBLEMS....
2990              
2991             sub _check_insatiable($$$$)
2992             {
2993 84     89   214 my ($subrule,$repspec,$grammar,$line) = @_;
2994 86         217 pos($grammar)=pos($_[2]);
2995 88 50 66     850 return if $grammar =~ m/$OPTIONAL/gco || $grammar =~ m/$ANY/gco;
2996 83         154 my $min = 1;
2997 83 100 66     2984 if ( $grammar =~ m/$MANY/gco
      66        
      66        
      66        
      66        
      66        
      66        
2998             || $grammar =~ m/$EXACTLY/gco
2999             || $grammar =~ m/$ATMOST/gco
3000 1         123 || $grammar =~ m/$BETWEEN/gco && do { $min=$2; 1 }
  1         4  
3001 1         3 || $grammar =~ m/$ATLEAST/gco && do { $min=$2; 1 }
  6         491  
3002             || $grammar =~ m/$SUBRULE(?!\s*:)/gco
3003             )
3004             {
3005 61 50 66     295 return unless $1 eq $subrule && $min > 0;
3006 5         9 my $current_match = substr($grammar, $-[0], $+[0] - $-[0]);
3007 2 50       510 _warn(3,"Subrule sequence \"$subrule($repspec) $current_match\" will
3008             (almost certainly) fail.",$line)
3009             and
3010             _hint("Unless subrule \"$subrule\" performs some cunning
3011             lookahead, the repetition \"$subrule($repspec)\" will
3012             insatiably consume as many matches of \"$subrule\" as it
3013             can, leaving none to match the \"$current_match\" that follows.");
3014             }
3015             }
3016              
3017             sub _check_grammar ($)
3018             {
3019 34     35   131 my $self = shift;
3020 36         82 my $rules = $self->{"rules"};
3021 34         599 my $rule;
3022 31         213 foreach $rule ( values %$rules )
3023             {
3024 739 100       1760 next if ! $rule->{"changed"};
3025              
3026             # CHECK FOR UNDEFINED RULES
3027              
3028 662         1439 my $call;
3029 662         720 foreach $call ( @{$rule->{"calls"}} )
  662         1482  
3030             {
3031 1035 100 66     2247 if (!defined ${$rules}{$call}
  1039         2980  
3032 2         24 &&!defined &{"Parse::RecDescent::$call"})
3033             {
3034 3 50       705 if (!defined $::RD_AUTOSTUB)
3035             {
3036 1 100       4 _warn(3,"Undefined (sub)rule \"$call\"
3037             used in a production.")
3038             and
3039             _hint("Will you be providing this rule
3040             later, or did you perhaps
3041             misspell \"$call\"? Otherwise
3042             it will be treated as an
3043             immediate .");
3044 1         3 eval "sub $self->{namespace}::$call {undef}";
3045             }
3046             else # EXPERIMENTAL
3047             {
3048 1         1108 my $rule = qq{'$call'};
3049 1 50 33     5 if ($::RD_AUTOSTUB and $::RD_AUTOSTUB ne "1") {
3050 1         3 $rule = $::RD_AUTOSTUB;
3051             }
3052 3 50       1378 _warn(1,"Autogenerating rule: $call")
3053             and
3054             _hint("A call was made to a subrule
3055             named \"$call\", but no such
3056             rule was specified. However,
3057             since \$::RD_AUTOSTUB
3058             was defined, a rule stub
3059             ($call : $rule) was
3060             automatically created.");
3061              
3062 2         11 $self->_generate("$call: $rule",0,1);
3063             }
3064             }
3065             }
3066              
3067             # CHECK FOR LEFT RECURSION
3068              
3069 663 50       1323 if ($rule->isleftrec($rules))
3070             {
3071 7         771 _error("Rule \"$rule->{name}\" is left-recursive.");
3072 7         25 _hint("Redesign the grammar so it's not left-recursive.
3073             That will probably mean you need to re-implement
3074             repetitions using the '(s)' notation.
3075             For example: \"$rule->{name}(s)\".");
3076 7         9 next;
3077             }
3078              
3079             # CHECK FOR PRODUCTIONS FOLLOWING EMPTY PRODUCTIONS
3080             {
3081 668         1235 my $hasempty;
  668         679  
3082             my $prod;
3083 668         676 foreach $prod ( @{$rule->{"prods"}} ) {
  668         2316  
3084 1264 50       2158 if ($hasempty) {
3085 1         2 _error("Production " . $prod->describe . " for \"$rule->{name}\"
3086             will never be reached (preceding empty production will
3087             always match first).");
3088 7         1295 _hint("Reorder the grammar so that the empty production
3089             is last in the list or productions.");
3090 7         13 last;
3091             }
3092 1264   66     3348 $hasempty ||= $prod->isempty();
3093             }
3094             }
3095             }
3096             }
3097              
3098             # GENERATE ACTUAL PARSER CODE
3099              
3100             sub _code($)
3101             {
3102 36     31   783 my $self = shift;
3103             my $initial_skip = defined($self->{skip}) ?
3104 36 100       253 '$skip = ' . $self->{skip} . ';' :
3105             $self->_dump([$skip],[qw(skip)]);
3106              
3107 36         2098 my $code = qq!
3108             package $self->{namespace};
3109             use strict;
3110             use vars qw(\$skip \$AUTOLOAD $self->{localvars} );
3111             \@$self->{namespace}\::ISA = ();
3112             $initial_skip
3113             $self->{startcode}
3114              
3115             {
3116             local \$SIG{__WARN__} = sub {0};
3117             # PRETEND TO BE IN Parse::RecDescent NAMESPACE
3118             *$self->{namespace}::AUTOLOAD = sub
3119             {
3120             no strict 'refs';
3121             !
3122             # This generated code uses ${"AUTOLOAD"} rather than $AUTOLOAD in
3123             # order to avoid the circular reference documented here:
3124             # https://rt.perl.org/rt3/Public/Bug/Display.html?id=110248
3125             # As a result of the investigation of
3126             # https://rt.cpan.org/Ticket/Display.html?id=53710
3127             . qq!
3128             \${"AUTOLOAD"} =~ s/^$self->{namespace}/Parse::RecDescent/;
3129             goto &{\${"AUTOLOAD"}};
3130             }
3131             }
3132              
3133             !;
3134 36         610 $code .= "push \@$self->{namespace}\::ISA, 'Parse::RecDescent';";
3135 36         78 $self->{"startcode"} = '';
3136              
3137 36         55 my $rule;
3138             # sort the rules to ensure the output is reproducible
3139 36         1044 foreach $rule ( sort { $a->{name} cmp $b->{name} }
  3412         4393  
3140 35         273 values %{$self->{"rules"}} )
3141             {
3142 744 100       1836 if ($rule->{"changed"})
3143             {
3144 661         1490 $code .= $rule->code($self->{"namespace"},$self);
3145 667         1554 $rule->{"changed"} = 0;
3146             }
3147             }
3148              
3149 35         6826 return $code;
3150             }
3151              
3152             # A wrapper for Data::Dumper->Dump, which localizes some variables to
3153             # keep the output in a form suitable for Parse::RecDescent.
3154             #
3155             # List of variables and their defaults taken from
3156             # $Data::Dumper::VERSION == 2.158
3157              
3158             sub _dump {
3159 43     40   10679 require Data::Dumper;
3160              
3161             #
3162             # Allow the user's settings to persist for some features in case
3163             # RD_TRACE is set. These shouldn't affect the eval()-ability of
3164             # the resulting parser.
3165             #
3166              
3167             #local $Data::Dumper::Indent = 2;
3168             #local $Data::Dumper::Useqq = 0;
3169             #local $Data::Dumper::Quotekeys = 1;
3170             #local $Data::Dumper::Useperl = 0;
3171              
3172             #
3173             # These may affect whether the output is valid perl code for
3174             # eval(), and must be controlled. Set them to their default
3175             # values.
3176             #
3177              
3178 43         57101 local $Data::Dumper::Purity = 0;
3179 43         99 local $Data::Dumper::Pad = "";
3180 43         82 local $Data::Dumper::Varname = "VAR";
3181 43         81 local $Data::Dumper::Terse = 0;
3182 43         91 local $Data::Dumper::Freezer = "";
3183 43         96 local $Data::Dumper::Toaster = "";
3184 43         88 local $Data::Dumper::Deepcopy = 0;
3185 43         82 local $Data::Dumper::Bless = "bless";
3186 43         86 local $Data::Dumper::Maxdepth = 0;
3187 43         99 local $Data::Dumper::Pair = ' => ';
3188 43         89 local $Data::Dumper::Deparse = 0;
3189 43         90 local $Data::Dumper::Sparseseen = 0;
3190              
3191             #
3192             # Modify the below options from their defaults.
3193             #
3194              
3195             # Sort the keys to ensure the output is reproducible
3196 43         96 local $Data::Dumper::Sortkeys = 1;
3197              
3198             # Don't stop recursing
3199 43         113 local $Data::Dumper::Maxrecurse = 0;
3200              
3201 43         412 return Data::Dumper->Dump(@_[1..$#_]);
3202             }
3203              
3204             # EXECUTING A PARSE....
3205              
3206             sub AUTOLOAD # ($parser, $text; $linenum, @args)
3207             {
3208 54 100   51   11625 croak "Could not find method: $AUTOLOAD\n" unless ref $_[0];
3209 54   33     173 my $class = ref($_[0]) || $_[0];
3210 54 50       179 my $text = ref($_[1]) eq 'SCALAR' ? ${$_[1]} : "$_[1]";
  6         6  
3211 54         151 $_[0]->{lastlinenum} = _linecount($text);
3212 54 100 33     185 $_[0]->{lastlinenum} += ($_[2]||0) if @_ > 2;
3213 54         204 $_[0]->{offsetlinenum} = $_[0]->{lastlinenum};
3214 54         110 $_[0]->{fulltext} = $text;
3215 54         117 $_[0]->{fulltextlen} = length $text;
3216 54         149 $_[0]->{linecounter_cache} = {};
3217 54         242 $_[0]->{deferred} = [];
3218 54         103 $_[0]->{errors} = [];
3219 54         171 my @args = @_[3..$#_];
3220 54     53   219 my $args = sub { [ @args ] };
  54         1310  
3221              
3222 50         416 $AUTOLOAD =~ s/$class/$_[0]->{namespace}/;
3223 13     13   217 no strict "refs";
  13         31  
  13         26889  
3224              
3225 50   66     169 local $::RD_WARN = $::RD_WARN || $_[0]->{__WARN__};
3226 50   33     195 local $::RD_HINT = $::RD_HINT || $_[0]->{__HINT__};
3227 50   66     166 local $::RD_TRACE = $::RD_TRACE || $_[0]->{__TRACE__};
3228              
3229 50 100       226 croak "Unknown starting rule ($AUTOLOAD) called\n"
3230             unless defined &$AUTOLOAD;
3231 52         112 my $retval = &{$AUTOLOAD}(
  52         1492  
3232             $_[0], # $parser
3233             $text, # $text
3234             undef, # $repeating
3235             undef, # $_noactions
3236             $args, # \@args
3237             undef, # $_itempos
3238             );
3239              
3240              
3241 52 100       153 if (defined $retval)
3242             {
3243 51         84 foreach ( @{$_[0]->{deferred}} ) { &$_; }
  51         202  
  4         13  
3244             }
3245             else
3246             {
3247 5         15 foreach ( @{$_[0]->{errors}} ) { _error(@$_); }
  5         17  
  4         8  
3248             }
3249              
3250 52 50       184 if (ref $_[1] eq 'SCALAR') { ${$_[1]} = $text }
  4         18  
  4         10  
3251              
3252 52         111 $ERRORS = 0;
3253 54         333 return $retval;
3254             }
3255              
3256             sub _parserepeat($$$$$$$$$) # RETURNS A REF TO AN ARRAY OF MATCHES
3257             {
3258 21     25   63 my ($parser, $text, $prod, $min, $max, $_noactions, $expectation, $argcode, $_itempos) = @_;
3259 21         46 my @tokens = ();
3260              
3261 21         54 my $itemposfirst;
3262             my $reps;
3263 23         86 for ($reps=0; $reps<$max;)
3264             {
3265 115         237 $expectation->at($text);
3266 115         167 my $_savetext = $text;
3267 119         153 my $prevtextlen = length $text;
3268 119         135 my $_tok;
3269 119 100       2884 if (! defined ($_tok = &$prod($parser,$text,1,$_noactions,$argcode,$_itempos)))
3270             {
3271 21         37 $text = $_savetext;
3272 17         28 last;
3273             }
3274              
3275 98 100 100     299 if (defined($_itempos) and !defined($itemposfirst))
3276             {
3277 7         15 $itemposfirst = Parse::RecDescent::Production::_duplicate_itempos($_itempos);
3278             }
3279              
3280 102 100       286 push @tokens, $_tok if defined $_tok;
3281 103 100 100     533 last if ++$reps >= $min and $prevtextlen == length $text;
3282             }
3283              
3284 24 100       101 do { $expectation->failed(); return undef} if $reps<$min;
  6         18  
  6         43  
3285              
3286 23 100       65 if (defined $itemposfirst)
3287             {
3288 8         20 Parse::RecDescent::Production::_update_itempos($_itempos, $itemposfirst, undef, [qw(from)]);
3289             }
3290              
3291 23         49 $_[1] = $text;
3292 23         505 return [@tokens];
3293             }
3294              
3295             sub set_autoflush {
3296 0     1 0 0 my $orig_selected = select $_[0];
3297 5         8 $| = 1;
3298 5         4 select $orig_selected;
3299 5         6 return;
3300             }
3301              
3302             # ERROR REPORTING....
3303              
3304             sub _write_ERROR {
3305 5     1   8 my ($errorprefix, $errortext) = @_;
3306 5 50       9 return if $errortext !~ /\S/;
3307 5         6 $errorprefix =~ s/\s+\Z//;
3308 5         9 local $^A = q{};
3309              
3310 5         11 formline(<<'END_FORMAT', $errorprefix, $errortext);
3311             @>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
3312             END_FORMAT
3313 5         5 formline(<<'END_FORMAT', $errortext);
3314             ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
3315             END_FORMAT
3316 5         11 print {*STDERR} $^A;
  5         8  
3317             }
3318              
3319             # TRACING
3320              
3321             my $TRACE_FORMAT = <<'END_FORMAT';
3322             @>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
3323             | ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
3324             END_FORMAT
3325              
3326             my $TRACECONTEXT_FORMAT = <<'END_FORMAT';
3327             @>|@|||||||||@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
3328             | ~~ | |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
3329             END_FORMAT
3330              
3331             sub _write_TRACE {
3332 5     0   15 my ($tracelevel, $tracerulename, $tracemsg) = @_;
3333 5 50       8 return if $tracemsg !~ /\S/;
3334 0         0 $tracemsg =~ s/\s*\Z//;
3335 5         19 local $^A = q{};
3336 5         18 my $bar = '|';
3337 5         7 formline($TRACE_FORMAT, $tracelevel, $tracerulename, $bar, $tracemsg, $tracemsg);
3338 5         19 print {*STDERR} $^A;
  5         6  
3339             }
3340              
3341             sub _write_TRACECONTEXT {
3342 5     2   16 my ($tracelevel, $tracerulename, $tracecontext) = @_;
3343 5 50       8 return if $tracecontext !~ /\S/;
3344 5         17 $tracecontext =~ s/\s*\Z//;
3345 5         8 local $^A = q{};
3346 5         18 my $bar = '|';
3347 5         8 formline($TRACECONTEXT_FORMAT, $tracelevel, $tracerulename, $bar, $tracecontext, $tracecontext);
3348 5         17 print {*STDERR} $^A;
  5         9  
3349             }
3350              
3351             sub _verbosity($)
3352             {
3353 4239 100 33 4239   65287 defined $::RD_TRACE
      33        
      100        
      66        
      33        
      66        
      66        
      66        
3354             or defined $::RD_HINT and $::RD_HINT and $_[0] =~ /ERRORS|WARN|HINT/
3355             or defined $::RD_WARN and $::RD_WARN and $_[0] =~ /ERRORS|WARN/
3356             or defined $::RD_ERRORS and $::RD_ERRORS and $_[0] =~ /ERRORS/
3357             }
3358              
3359             sub _error($;$)
3360             {
3361 5     2   25 $ERRORS++;
3362 5 50       13 return 0 if ! _verbosity("ERRORS");
3363 5         12 my $errortext = $_[0];
3364 5 50       7 my $errorprefix = "ERROR" . ($_[1] ? " (line $_[1])" : "");
3365 5         6 $errortext =~ s/\s+/ /g;
3366 5 100       15 print {*STDERR} "\n" if _verbosity("WARN");
  5         12  
3367 5         8 _write_ERROR($errorprefix, $errortext);
3368 5         7 return 1;
3369             }
3370              
3371             sub _warn($$;$)
3372             {
3373 32 100 66 30   62 return 0 unless _verbosity("WARN") && ($::RD_HINT || $_[0] >= ($::RD_WARN||1));
      66        
3374 5         20 my $errortext = $_[1];
3375 5 50       8 my $errorprefix = "Warning" . ($_[2] ? " (line $_[2])" : "");
3376 5 50       16 print {*STDERR} "\n" if _verbosity("HINT");
  5         28  
3377 4         9 $errortext =~ s/\s+/ /g;
3378 4         12 _write_ERROR($errorprefix, $errortext);
3379 4         13 return 1;
3380             }
3381              
3382             sub _hint($)
3383             {
3384 2 100   2   8 return 0 unless $::RD_HINT;
3385 1         2 my $errortext = $_[0];
3386 1 50       6 my $errorprefix = "Hint" . ($_[1] ? " (line $_[1])" : "");
3387 1         4 $errortext =~ s/\s+/ /g;
3388 1         6 _write_ERROR($errorprefix, $errortext);
3389 1         4 return 1;
3390             }
3391              
3392             sub _tracemax($)
3393             {
3394 1 0 33 1   5 if (defined $::RD_TRACE
      66        
      33        
3395             && $::RD_TRACE =~ /\d+/
3396             && $::RD_TRACE>1
3397             && $::RD_TRACE+10
3398             {
3399 1         4 my $count = length($_[0]) - $::RD_TRACE;
3400 1         5 return substr($_[0],0,$::RD_TRACE/2)
3401             . "...<$count>..."
3402             . substr($_[0],-$::RD_TRACE/2);
3403             }
3404             else
3405             {
3406 1         5 return substr($_[0],0,500);
3407             }
3408             }
3409              
3410             sub _tracefirst($)
3411             {
3412 1 50 33 1   3 if (defined $::RD_TRACE
      33        
      33        
3413             && $::RD_TRACE =~ /\d+/
3414             && $::RD_TRACE>1
3415             && $::RD_TRACE+10
3416             {
3417 1         4 my $count = length($_[0]) - $::RD_TRACE;
3418 5         26 return substr($_[0],0,$::RD_TRACE) . "...<+$count>";
3419             }
3420             else
3421             {
3422 4         10 return substr($_[0],0,500);
3423             }
3424             }
3425              
3426             my $lastcontext = '';
3427             my $lastrulename = '';
3428             my $lastlevel = '';
3429              
3430             sub _trace($;$$$)
3431             {
3432 4     2   9 my $tracemsg = $_[0];
3433 4   66     6 my $tracecontext = $_[1]||$lastcontext;
3434 4   33     5 my $tracerulename = $_[2]||$lastrulename;
3435 4   33     9 my $tracelevel = $_[3]||$lastlevel;
3436 4 50       11 if ($tracerulename) { $lastrulename = $tracerulename }
  4         5  
3437 4 50       8 if ($tracelevel) { $lastlevel = $tracelevel }
  4         13  
3438              
3439 4         15 $tracecontext =~ s/\n/\\n/g;
3440 4         7 $tracecontext =~ s/\s+/ /g;
3441 4         12 $tracerulename = qq{$tracerulename};
3442 4         25 _write_TRACE($tracelevel, $tracerulename, $tracemsg);
3443 2 0       5 if ($tracecontext ne $lastcontext)
3444             {
3445 2 50       6 if ($tracecontext)
3446             {
3447 2         8 $lastcontext = _tracefirst($tracecontext);
3448 2         12 $tracecontext = qq{"$tracecontext"};
3449             }
3450             else
3451             {
3452 2         7 $tracecontext = qq{};
3453             }
3454 2         4 _write_TRACECONTEXT($tracelevel, $tracerulename, $tracecontext);
3455             }
3456             }
3457              
3458             sub _matchtracemessage
3459             {
3460 5823     5822   7145 my ($self, $reject) = @_;
3461              
3462 5823         6148 my $prefix = '';
3463 5823         6317 my $postfix = '';
3464 5823         6786 my $matched = not $reject;
3465 5823         9496 my @t = ("Matched", "Didn't match");
3466 5823 100 66     14798 if (exists $self->{lookahead} and $self->{lookahead})
3467             {
3468 18 100       48 $postfix = $reject ? "(reject)" : "(keep)";
3469 18         27 $prefix = "...";
3470 18 100       51 if ($self->{lookahead} < 0)
3471             {
3472 7         27 $prefix .= '!';
3473 4         8 $matched = not $matched;
3474             }
3475             }
3476 5823 100       29450 $prefix . ($matched ? $t[0] : $t[1]) . $postfix;
3477             }
3478              
3479             sub _parseunneg($$$$$)
3480             {
3481 1254     1255   2501 _parse($_[0],$_[1],$_[3],$_[4]);
3482 1254 50       2896 if ($_[2]<0)
3483             {
3484 2         5 _error("Can't negate \"$_[4]\".",$_[3]);
3485 2         5 _hint("You can't negate $_[0]. Remove the \"...!\" before
3486             \"$_[4]\".");
3487 2         2 return 0;
3488             }
3489 1254         2608 return 1;
3490             }
3491              
3492             sub _parse($$$$)
3493             {
3494 4209     4208   6475 my $what = $_[3];
3495 4209         7342 $what =~ s/^\s+//;
3496 4209 100       8400 if ($_[1])
3497             {
3498 2 50       7 _warn(3,"Found $_[0] ($what) after an unconditional ",$_[2])
3499             and
3500             _hint("An unconditional always causes the
3501             production containing it to immediately fail.
3502             \u$_[0] that follows an
3503             will never be reached. Did you mean to use
3504             instead?");
3505             }
3506              
3507 4209 50       6540 return if ! _verbosity("TRACE");
3508 0         0 my $errortext = "Treating \"$what\" as $_[0]";
3509 0         0 my $errorprefix = "Parse::RecDescent";
3510 0         0 $errortext =~ s/\s+/ /g;
3511 2         8 _write_ERROR($errorprefix, $errortext);
3512             }
3513              
3514             sub _linecount($) {
3515 4714   100 4713   41471 scalar substr($_[0], pos $_[0]||0) =~ tr/\n//
3516             }
3517              
3518              
3519             package main;
3520              
3521 13     13   169 use vars qw ( $RD_ERRORS $RD_WARN $RD_HINT $RD_TRACE $RD_CHECK );
  13         34  
  13         1571  
3522             $::RD_CHECK = 1;
3523             $::RD_ERRORS = 1;
3524             $::RD_WARN = 3;
3525              
3526             1;
3527              
3528             __END__