12 my ($id, $rest) = /\A(\d+): (.*)\z/;
13 if ($rest =~ /"(.)"/) {
19 for my $seq (split /\|/, $rest) {
20 push @alts, [ $seq =~ /(\d+)/g ];
21 push @subalts, ($seq =~ /(\d+)/g);
24 $subrules{$id} = \@subalts;
29 for my $id (keys %rules) {
30 for my $subr (@{ $subrules{$id} }) {
31 next RULE if !defined $final{$subr};
34 $final{$id} = $final{42} . '+';
40 $final{$id} = '(?:' . join('|',
41 $final{42} . $final{31},
42 $final{42} x 2 . $final{31} x 2,
43 $final{42} x 3 . $final{31} x 3,
44 $final{42} x 4 . $final{31} x 4,
45 $final{42} x 5 . $final{31} x 5,
46 $final{42} x 6 . $final{31} x 6,
47 $final{42} x 7 . $final{31} x 7,
48 $final{42} x 8 . $final{31} x 8,
49 $final{42} x 9 . $final{31} x 9,
50 $final{42} x 10 . $final{31} x 10,
51 $final{42} x 11 . $final{31} x 11,
52 $final{42} x 12 . $final{31} x 12,
58 $final{$id} = '(?:(?:' . join(')|(?:', map {
59 join('', map { $final{$_} } @$_)
60 } @{ $rules{$id} }) .'))';
61 print "\$final{$id} = $final{$id}\n";
66 my $re = '\A'.$final{0}.'\z';
71 $count++ if ($_ =~ /$re/);
74 print "$count matched\n";