| 1 | package Regexp::Parser; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 19 | my ($nest_eval, $nest_logical); | |||||||||||||||||||||||||||||||||||||||||
| 4 | 19 | $nest_eval = qr[ (?> [^\\{}]+ | \\. | { (??{ $nest_eval }) } )* ]x; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 19 | $nest_logical = qr[ (?> [^\\{}]+ | \\. | { (??{ $nest_logical }) } )* ]x; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 359 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 359 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # /m, /s, /i, /x flags | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 359 | ▶ | $self->add_flag('m' => sub { 0x1 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 359 | ▶ | $self->add_flag('s' => sub { 0x2 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 359 | ▶ | $self->add_flag('i' => sub { 0x4 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 359 | ▶ | $self->add_flag('x' => sub { 0x8 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # /a, /d, /l, /u charset flags (Perl 5.14+) | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # These are mutually exclusive; the last one set wins. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 359 | ▶ | $self->add_flag('a' => sub { 0x10 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 359 | ▶ | $self->add_flag('d' => sub { 0x20 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 359 | ▶ | $self->add_flag('l' => sub { 0x40 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 359 | ▶ | $self->add_flag('u' => sub { 0x80 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # /n (no-capture) flag (Perl 5.22+) | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $self->add_flag('n' => sub { 0x100 }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | # (useless) /g, /c, /o flags | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | $self->add_flag('g' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my ($S, $plus) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | $S->warn($S->RPe_BADFLG, $plus ? "" : "-", "g", $plus ? "" : "don't ", "g"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | return 0x0; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | $self->add_flag('c' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | my ($S, $plus) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | $S->warn($S->RPe_BADFLG, $plus ? "" : "-", "c", $plus ? "" : "don't ", "gc"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | return 0x0; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | $self->add_flag('o' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | my ($S, $plus) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | $S->warn($S->RPe_BADFLG, $plus ? "" : "-", "o", $plus ? "" : "don't ", "o"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | return 0x0; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | ▶ | $self->add_handler('\a' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 10 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | ▶ | return $S->force_object(anyof_char => "\a", '\a') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | return $S->object(exact => "\a", '\a'); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | $self->add_handler('\e' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | return $S->force_object(anyof_char => "\e", '\e') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | return $S->object(exact => "\e", '\e'); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 10 | ▶ | $self->add_handler('\f' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 10 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 10 | ▶ | return $S->force_object(anyof_char => "\f", '\f') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | return $S->object(exact => "\f", '\f'); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | $self->add_handler('\n' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | return $S->force_object(anyof_char => "\n", '\n') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | return $S->object(exact => "\n", '\n'); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | ▶ | $self->add_handler('\r' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | return $S->force_object(anyof_char => "\r", '\r') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | return $S->object(exact => "\r", '\r'); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | $self->add_handler('\t' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | ▶ | return $S->force_object(anyof_char => "\t", '\t') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | return $S->object(exact => "\t", '\t'); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # \Q (quotemeta) — enter literal quoting mode until \E | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 50 | ▶ | $self->add_handler('\Q' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 50 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 50 | $S->{quotemeta} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 50 | return; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # \E — exit quotemeta mode (no-op if not in quotemeta) | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | $self->add_handler('\E' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $S->{quotemeta} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | # bol, mbol, sbol | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 24 | ▶ | $self->add_handler('^' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 24 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 24 | ▶ | my $type = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | &Rf & $S->FLAG_m ? 'mbol' : | ||||||||||||||||||||||||||||||||||||||||||
| 98 | &Rf & $S->FLAG_s ? 'sbol' : | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 'bol'; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | return $S->object(bol => $type, '^'); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # sbol (beginning of line in single-line mode) | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 10 | ▶ | $self->add_handler('\A' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 10 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 10 | ▶ | $S->warn($S->RPe_BADESC, "A", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 10 | ▶ | return $S->force_object(anyof_char => 'A') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | return $S->object(bol => 'sbol' => '\A'); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # nbound (not a word boundary) | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 29 | ▶ | $self->add_handler('\B' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 29 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 29 | ▶ | $S->warn($S->RPe_BADESC, "B", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 29 | ▶ | return $S->force_object(anyof_char => 'B') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | # extended boundary types: \B{gcb}, \B{g}, \B{wb}, \B{sb}, \B{lb} | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 28 | ▶ | if (${&Rx} =~ m{ \G \{ (gcb|g|wb|sb|lb) \} }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 18 | my $btype = $1; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 18 | return $S->object(bound => nbound => "\\B{$btype}", $btype); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 10 | return $S->object(bound => nbound => '\B'); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # bound (word boundary) | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 55 | ▶ | $self->add_handler('\b' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 55 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 55 | ▶ | return $S->force_object(anyof_char => "\b", '\b') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | # extended boundary types: \b{gcb}, \b{g}, \b{wb}, \b{sb}, \b{lb} | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 47 | ▶ | if (${&Rx} =~ m{ \G \{ (gcb|g|wb|sb|lb) \} }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 36 | my $btype = $1; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 36 | return $S->object(bound => bound => "\\b{$btype}", $btype); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 11 | return $S->object(bound => bound => '\b'); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | # cany (any byte) | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | $self->add_handler('\C' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | $S->warn($S->RPe_BADESC, "C", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | return $S->force_object(anyof_char => 'C') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return $S->object(reg_any => c_any => '\C'); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | # control character | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | ▶ | $self->add_handler('\c' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | ${&Rx} =~ m{ \G (.?) }xgc; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 8 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 8 | ▶ | return $S->force_object(anyof_char => chr(64 ^ ord $c), "\\c$c") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 8 | return $S->object(exact => chr(64 ^ ord $c), "\\c$c"); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # ndigit (not a digit) | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 12 | ▶ | $self->add_handler('\D' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 12 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 12 | ▶ | return $S->force_object(anyof_class => $S->force_object(digit => 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 8 | return $S->object(digit => 1); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # digit (a digit) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 37 | ▶ | $self->add_handler('\d' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 37 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 37 | ▶ | return $S->force_object(anyof_class => $S->force_object(digit => 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 32 | return $S->object(digit => 0); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # gpos (last global match end) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | $self->add_handler('\G' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | $S->warn($S->RPe_BADESC, "G", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | return $S->force_object(anyof_char => 'G') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | return $S->object(gpos => gpos => '\G'); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # \g{N}, \g{-N}, \gN backreferences (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 27 | ▶ | $self->add_handler('\g' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=26.8
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 27 | ▶ | if ($cc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $S->warn($S->RPe_BADESC, "g", " in character class"); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return $S->force_object(anyof_char => 'g'); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | # \g{...} form | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 27 | ▶ | if (${&Rx} =~ m{ \G \{ }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | # \g{name} — named backref | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 21 | ▶ | if (${&Rx} =~ m{ \G ([a-zA-Z_]\w*) \} }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return $S->object(gref => $name, "\\g{$name}"); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | # \g{N} or \g{-N} — numeric (possibly relative) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 21 | ▶ | if (${&Rx} =~ m{ \G (-?\d+) \} }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 20 | my $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 20 | my $abs; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 20 | ▶ | if ($num < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 10 | ▶ | $abs = (&SIZE_ONLY ? $S->{maxpar} : $S->{nparen}) + $num + 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | ▶ | $S->error($S->RPe_BGROUP) if !&SIZE_ONLY and $abs < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not &SIZE_ONLY and $abs < 1
MC/DC100%2/2
not &SIZE_ONLY and $abs < 1
not &SIZE_ONLY
$abs < 1
Truth table100%3/3
not(A) and B
A= not &SIZE_ONLYB= $abs < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 10 | $abs = $num; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | $S->error($S->RPe_BGROUP) if !&SIZE_ONLY and $abs > $S->{maxpar}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not &SIZE_ONLY and $abs > $S->{"maxpar"}
MC/DC100%2/2
not &SIZE_ONLY and $abs > $S->{"maxpar"}
not &SIZE_ONLY
$abs > $S->{"maxpar"}
Truth table100%3/3
not(A) and B
A= not &SIZE_ONLYB= $abs > $S->{"maxpar"}
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 16 | return $S->object(ref => $abs, "\\g{$num}"); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $S->error($S->RPe_RBRACE, 'g'); | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # \gN form (no braces, positive only) | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | ▶ | if (${&Rx} =~ m{ \G (\d+) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | my $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | ▶ | $S->error($S->RPe_BGROUP) if !&SIZE_ONLY and $num > $S->{maxpar}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not &SIZE_ONLY and $num > $S->{"maxpar"}
MC/DC0%0/2
not &SIZE_ONLY and $num > $S->{"maxpar"}
not &SIZE_ONLY
$num > $S->{"maxpar"}
Truth table66%2/3
not(A) and B
A= not &SIZE_ONLYB= $num > $S->{"maxpar"}
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | return $S->object(ref => $num, "\\g$num"); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | $S->error($S->RPe_BRACES, 'g'); | |||||||||||||||||||||||||||||||||||||||||
| 215 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # named (named character) | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 9 | ▶ | $self->add_handler('\N' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 9 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 9 | ▶ | $S->error($S->RPe_BRACES, 'N') if ${&Rx} !~ m{ \G \{ }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 8 | ▶ | $S->error($S->RPe_RBRACE, 'N') if ${&Rx} !~ m{ \G ([^\}]*) \} }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 7 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | ▶ | return $S->force_object(anyof_char => $S->nchar($name), "\\N{$name}") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | return $S->object(exact => $S->nchar($name), "\\N{$name}"); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # \o{NNN} octal escape (Perl 5.14+) | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 20 | ▶ | $self->add_handler('\o' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 20 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 20 | ▶ | $S->error($S->RPe_BRACES, 'o') if ${&Rx} !~ m{ \G \{ }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 20 | ▶ | $S->error($S->RPe_RBRACE, 'o') if ${&Rx} !~ m{ \G ([0-7]+) \} }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 19 | my $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 19 | my $rep = "\\o{$num}"; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 19 | ▶ | return $S->force_object(anyof_char => chr(oct $num), $rep) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 15 | return $S->object(exact => chr(oct $num), $rep); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # nprop (not a unicode property) | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 6 | ▶ | $self->add_handler('\P' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | ▶ | $S->error($S->RPe_EMPTYB, 'P') if ${&Rx} !~ m{ \G (.) }xgcs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 5 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | ▶ | if ($name eq '{') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | ▶ | $S->error($S->RPe_RBRACE, 'P') if ${&Rx} !~ m{ \G ([^\}]*) \} }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 5 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | ▶ | return $S->force_object(anyof_class => $S->force_object(prop => $name, 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | return $S->object(prop => $name, 1); | |||||||||||||||||||||||||||||||||||||||||
| 253 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # prop (a unicode property) | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | ▶ | $self->add_handler('\p' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ▶ | $S->error($S->RPe_EMPTYB, 'p') if ${&Rx} !~ m{ \G (.) }xgcs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | ▶ | if ($name eq '{') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | ▶ | $S->error($S->RPe_RBRACE, 'p') if ${&Rx} !~ m{ \G ([^\}]*) \} }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | ▶ | return $S->force_object(anyof_class => $S->force_object(prop => $name, 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | return $S->object(prop => $name, 0); | |||||||||||||||||||||||||||||||||||||||||
| 268 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | # nspace (not a space) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | ▶ | $self->add_handler('\S' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | ▶ | return $S->force_object(anyof_class => $S->force_object(space => 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | return $S->object(space => 1); | |||||||||||||||||||||||||||||||||||||||||
| 275 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # space (a space) | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 16 | ▶ | $self->add_handler('\s' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 16 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 16 | ▶ | return $S->force_object(anyof_class => $S->force_object(space => 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | return $S->object(space => 0); | |||||||||||||||||||||||||||||||||||||||||
| 282 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | # nalnum (not a word character) | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | ▶ | $self->add_handler('\W' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 8 | ▶ | return $S->force_object(anyof_class => $S->force_object(alnum => 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | return $S->object(alnum => 1); | |||||||||||||||||||||||||||||||||||||||||
| 289 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | # alnum (a word character) | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 29 | ▶ | $self->add_handler('\w' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 29 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 29 | ▶ | return $S->force_object(anyof_class => $S->force_object(alnum => 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 20 | return $S->object(alnum => 0); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # clump (a unicode clump) | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | ▶ | $self->add_handler('\X' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | ▶ | $S->warn($S->RPe_BADESC, 'X', ' in character class') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | ▶ | return $S->force_object(anyof_char => 'X') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | return $S->object(clump => '\X'); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | # hex character | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 18 | ▶ | $self->add_handler('\x' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 18 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 18 | ${&Rx} =~ m{ \G ( \{ | .{0,2} ) }sxgc; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 18 | my $brace = 0; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 18 | my $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 18 | ▶ | if ($num eq '{') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 14 | ▶ | $S->error($S->RPe_RBRACE, 'x') if ${&Rx} !~ m{ \G ( [^\}]* ) \} }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 13 | $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 13 | $brace = 1; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 4 | ▶ | my $good = ($num =~ s/^([a-fA-F0-9]*)// and $1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$num =~ s/^([a-fA-F0-9]*)// && $1
MC/DC0%0/2
$num =~ s/^([a-fA-F0-9]*)// && $1
$num =~ s/^([a-fA-F0-9]*)//
$1
Truth table33%1/3
A && B
A= $num =~ s/^([a-fA-F0-9]*)//B= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 4 | &RxPOS -= length $num; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | $num = $good; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 17 | ▶ | my $rep = $brace ? "\\x{$num}" : sprintf("\\x%02s", $num); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 17 | ▶ | return $S->force_object(anyof_char => chr hex $num, $rep) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | return $S->object(exact => chr hex $num, $rep); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | # eol, seol, meol | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 16 | ▶ | $self->add_handler('$' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 16 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 16 | ▶ | my $type = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | &Rf & $S->FLAG_m ? 'meol' : | ||||||||||||||||||||||||||||||||||||||||||
| 334 | &Rf & $S->FLAG_s ? 'seol' : | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 'eol'; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 16 | return $S->object(eol => $type, '$'); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | # seol (end of line, in single-line mode) | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | ▶ | $self->add_handler('\Z' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | ▶ | $S->warn($S->RPe_BADESC, "Z", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | ▶ | return $S->force_object(anyof_char => 'Z') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | return $S->object(eol => seol => '\Z'); | |||||||||||||||||||||||||||||||||||||||||
| 345 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | # eos (end of string) | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 5 | ▶ | $self->add_handler('\z' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 5 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 5 | ▶ | $S->warn($S->RPe_BADESC, "z", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 5 | ▶ | return $S->force_object(anyof_char => 'z') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | return $S->object(eol => eos => '\z'); | |||||||||||||||||||||||||||||||||||||||||
| 353 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # alpha POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 13 | ▶ | $self->add_handler('POSIX_alpha' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 13 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 13 | return $S->force_object(anyof_class => alpha => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 359 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | # alnum POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | $self->add_handler('POSIX_alnum' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return $S->force_object(anyof_class => alnum => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 365 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | # ascii POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $self->add_handler('POSIX_ascii' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $S->force_object(anyof_class => ascii => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | # cntrl POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | $self->add_handler('POSIX_cntrl' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | return $S->force_object(anyof_class => cntrl => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 377 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | # digit POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | ▶ | $self->add_handler('POSIX_digit' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | return $S->force_object(anyof_class => digit => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 383 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | # graph POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | $self->add_handler('POSIX_graph' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return $S->force_object(anyof_class => graph => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | # lower POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $self->add_handler('POSIX_lower' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return $S->force_object(anyof_class => lower => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | # print POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | $self->add_handler('POSIX_print' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return $S->force_object(anyof_class => print => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | # punct POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $self->add_handler('POSIX_punct' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return $S->force_object(anyof_class => punct => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 407 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # space POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | $self->add_handler('POSIX_space' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return $S->force_object(anyof_class => space => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 413 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | # upper POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $self->add_handler('POSIX_upper' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return $S->force_object(anyof_class => upper => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 419 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | # word POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $self->add_handler('POSIX_word' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return $S->force_object(anyof_class => word => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 425 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | # xdigit POSIX class | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $self->add_handler('POSIX_xdigit' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ($S, $neg, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return $S->force_object(anyof_class => xdigit => $neg, \$how); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 4631 | ▶ | $self->add_handler('atom' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 4631 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # \Q quotemeta mode: treat everything as literal until \E | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 4631 | ▶ | if ($S->{quotemeta}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 210 | ▶ | ${&Rx} =~ m{ \G (.) }xgcs or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 206 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 440 | 206 | push @{ $S->{next} }, qw< atom >; | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | # \E exits quotemeta mode | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 206 | ▶ | if ($c eq '\\') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 42 | ▶ | if (${&Rx} =~ m{ \G E }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 40 | $S->{quotemeta} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | # literal backslash | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | return $S->object(exact => '\\', '\\\\'); | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | # metacharacters get escaped visual, but match literally | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 164 | ▶ | my $vis = $c =~ /[\.\+\*\?\^\$\|\(\)\{\}\[\]\\]/ ? "\\$c" : $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 164 | return $S->object(exact => $c, $vis); | |||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 4421 | $S->nextchar; | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 4419 | ▶ | ${&Rx} =~ m{ \G (.) }xgcs or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 3499 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 3499 | push @{ $S->{next} }, qw< atom >; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 3499 | ▶ | return $S->$c if $S->can($c); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 1310 | return $S->object(exact => $c); | |||||||||||||||||||||||||||||||||||||||||
| 465 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 52 | ▶ | $self->add_handler('*' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 52 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 52 | push @{ $S->{next} }, qw< minmod >; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 52 | return $S->object(quant => 0, ''); | |||||||||||||||||||||||||||||||||||||||||
| 471 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 138 | ▶ | $self->add_handler('+' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 138 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 138 | push @{ $S->{next} }, qw< minmod >; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 138 | return $S->object(quant => 1, ''); | |||||||||||||||||||||||||||||||||||||||||
| 477 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 18 | ▶ | $self->add_handler('?' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 18 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 18 | push @{ $S->{next} }, qw< minmod >; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 18 | return $S->object(quant => 0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 42 | ▶ | $self->add_handler('{' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 42 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 42 | ▶ | if (${&Rx} =~ m{ \G (\d+) (,?) (\d*) \} }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 40 | my ($min, $range, $max) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||
| 489 | 40 | ▶ | $max = $min unless $range; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 40 | push @{ $S->{next} }, qw< minmod >; | |||||||||||||||||||||||||||||||||||||||||
| 491 | 40 | ▶ | $S->error($S->RPe_BCURLY) if length($max) and $min > $max; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $max and $min > $max
MC/DC100%2/2
length $max and $min > $max
length $max
$min > $max
Truth table100%3/3
A and B
A= length $maxB= $min > $max
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 37 | return $S->object(quant => $min, $max); | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | return $S->object(exact => '{'); | |||||||||||||||||||||||||||||||||||||||||
| 495 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 238 | ▶ | $self->add_handler('minmod' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 238 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 238 | $S->nextchar; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 238 | ▶ | return $S->object(minmod =>) if ${&Rx} =~ m{ \G \? }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 214 | ▶ | return $S->object(possessive =>) if ${&Rx} =~ m{ \G \+ }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 198 | return; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | # alternation branch | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 93 | ▶ | $self->add_handler('|' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 93 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 93 | return $S->object(branch =>); | |||||||||||||||||||||||||||||||||||||||||
| 509 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | # opening parenthesis (maybe capturing paren) | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 680 | ▶ | $self->add_handler('(' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 680 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 680 | my $c = '('; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 680 | $S->nextchar; | |||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 680 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 680 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 680 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 184 | &RxPOS--; | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 184 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 524 | 184 | ▶ | &SIZE_ONLY ? ++$S->{maxpar} : ++$S->{nparen}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 184 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 184 | return $S->object(open => $S->{nparen}); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | # any character | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 22 | ▶ | $self->add_handler('.' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 22 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 22 | ▶ | my $family = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | &Rf & $S->FLAG_s ? 'sany' : | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 'reg_any'; | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 22 | return $S->object(reg_any => $family, '.'); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | # backslash | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 557 | ▶ | $self->add_handler('\\' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=26.0
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 557 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 541 | 557 | my $c = '\\'; | |||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 557 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 555 | $c .= (my $n = $1); | |||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | 555 | ▶ | return $S->$c($cc) if $S->can($c); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 79 | ▶ | if ($n =~ /\d/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 22 | --&RxPOS; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 22 | my $v = ""; | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | # outside of char class, \nnn might be backref | ||||||||||||||||||||||||||||||||||||||||||
| 553 | 22 | ▶ | if (!&SIZE_ONLY and !$cc and $n != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not &SIZE_ONLY || $cc and $n != 0
&SIZE_ONLY || $cc
MC/DC33%1/3
not &SIZE_ONLY || $cc and $n != 0
&SIZE_ONLY
$cc
$n != 0
Truth table50%2/4
not(A || B) and C
A= &SIZE_ONLYB= $ccC= $n != 0
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 10 | ▶ | $v .= $1 while ${&Rx} =~ m{ \G (\d) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 10 | ▶ | if ($v > 9 and $v > $S->{maxpar}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$v > 9 and $v > $S->{"maxpar"}
MC/DC0%0/2
$v > 9 and $v > $S->{"maxpar"}
$v > 9
$v > $S->{"maxpar"}
Truth table33%1/3
A and B
A= $v > 9B= $v > $S->{"maxpar"}
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | &RxPOS -= length $v; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $v = ""; | |||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | elsif ($v > $S->{maxpar}) { $S->error($S->RPe_BGROUP) } | |||||||||||||||||||||||||||||||||||||||||
| 560 | 8 | else { return $S->object(ref => $v, "\\$v") } | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 12 | ▶ | $v .= $1 while ${&Rx} =~ m{ \G ([0-7]) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 12 | return $S->object(exact => chr oct $v, sprintf("\\%03s", $v)); | |||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 57 | ▶ | $S->warn($S->RPe_BADESC, $c = $n, "") if $n =~ /[a-zA-Z]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 57 | return $S->object(exact => $n, $c); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 2 | $S->error($S->RPe_ESLASH); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | # start of char class (and possible negation) | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 112 | ▶ | $self->add_handler('[' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 112 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 112 | push @{ $S->{next} }, qw< cce] cc cc] >; | |||||||||||||||||||||||||||||||||||||||||
| 579 | 112 | my $neg = ${&Rx} =~ m{ \G \^ }xgc; | |||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 112 | my $pos = &RxPOS; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 112 | ▶ | if (${&Rx} =~ m{ \G ([:.=]) .*? \1 ] }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 2 | $S->warn($S->RPe_OUTPOS, $1, $1); | |||||||||||||||||||||||||||||||||||||||||
| 584 | 2 | &RxPOS = $pos; | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | 112 | return $S->object(anyof => $neg); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | # char class ] at beginning | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 112 | ▶ | $self->add_handler('cc]' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 112 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 593 | 112 | ▶ | return unless ${&Rx} =~ m{ \G ] }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return $S->object(anyof_char => "]"); | |||||||||||||||||||||||||||||||||||||||||
| 595 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | # start of char class range (or maybe just char) | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 321 | ▶ | $self->add_handler('cc' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=20 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 321 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 321 | ▶ | return if ${&Rx} =~ m{ \G (?= ] | \z ) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 213 | push @{ $S->{next} }, qw< cc >; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 213 | my ($lhs, $rhs, $before_range); | |||||||||||||||||||||||||||||||||||||||||
| 603 | 213 | my $ret = \$lhs; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | { | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 213 | ▶ | if ($S->{quotemeta}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | # quotemeta mode: \E exits, everything else is literal | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 22 | ▶ | if (${&Rx} =~ m{ \G \\ E }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | 6 | $S->{quotemeta} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 610 | 6 | $ret = undef; | |||||||||||||||||||||||||||||||||||||||||
| 611 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 613 | 16 | elsif (${&Rx} =~ m{ \G (.) }xgcs) { | |||||||||||||||||||||||||||||||||||||||||
| 614 | # escape char class metacharacters for correct visual | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 16 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 616 | 16 | ▶ | my $vis = $c =~ /[\-\]\\^]/ ? "\\$c" : $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 16 | $$ret = $S->force_object(anyof_char => $c, $vis); | |||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 220 | elsif (${&Rx} =~ m{ \G ( \\ ) }xgcs) { | |||||||||||||||||||||||||||||||||||||||||
| 621 | 107 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 622 | 107 | my $qm_before = $S->{quotemeta}; | |||||||||||||||||||||||||||||||||||||||||
| 623 | 107 | $$ret = $S->$c(1); | |||||||||||||||||||||||||||||||||||||||||
| 624 | # \Q/\E change quotemeta state and return undef — redo to continue | ||||||||||||||||||||||||||||||||||||||||||
| 625 | 107 | ▶ | if (!defined $$ret && $S->{quotemeta} != $qm_before) { redo } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $$ret and $S->{"quotemeta"} != $qm_before
MC/DC100%2/2
not defined $$ret and $S->{"quotemeta"} != $qm_before
not defined $$ret
$S->{"quotemeta"} != $qm_before
Truth table100%3/3
not(A) and B
A= not defined $$retB= $S->{"quotemeta"} != $qm_before
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 113 | elsif (${&Rx} =~ m{ \G \[ ([.=:]) (\^?) (.*?) \1 \] }xgcs) { | |||||||||||||||||||||||||||||||||||||||||
| 628 | 20 | my ($how, $neg, $name) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||
| 629 | 20 | my $posix = "POSIX_$name"; | |||||||||||||||||||||||||||||||||||||||||
| 630 | 20 | ▶ | if ($S->can($posix)) { $$ret = $S->$posix($neg, $how) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | else { $S->error($S->RPe_BADPOS, "$how$neg$name$how") } | |||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 93 | elsif (${&Rx} =~ m{ \G (.) }xgcs) { | |||||||||||||||||||||||||||||||||||||||||
| 634 | 93 | $$ret = $S->force_object(anyof_char => $1); | |||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 228 | ▶ | if ($ret == \$lhs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 205 | ▶ | if (!$S->{quotemeta} && ${&Rx} =~ m{ \G (?= - (?! ] | \z ) ) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $S->{"quotemeta"} and ${&Rx;} =~ / \G (?= - (?! ] | \z ) ) /cgx
MC/DC100%2/2
not $S->{"quotemeta"} and ${&Rx;} =~ / \G (?= - (?! ] | \z ) ) /cgx
not $S->{"quotemeta"}
${&Rx;} =~ / \G (?= - (?! ] | \z ) ) /cgx
Truth table100%3/3
not(A) and B
A= not $S->{"quotemeta"}B= ${&Rx;} =~ / \G (?= - (?! ] | \z ) ) /cgx
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 25 | ▶ | if ($lhs->visual =~ /^(?:\[[:.=]|\\[dDsSwWpP])/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | $S->warn($S->RPe_FRANGE, $lhs->visual, ""); | |||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | $ret = $lhs; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | 23 | $before_range = &RxPOS++; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 23 | $ret = \$rhs; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 23 | redo; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 180 | $ret = $lhs; | |||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 650 | elsif ($ret == \$rhs) { | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 23 | ▶ | if ($rhs->visual =~ /^(?:\[[:.=]|\\[dDsSwWpP])/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $S->warn($S->RPe_FRANGE, $lhs->visual, $rhs->visual); | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | &RxPOS = $before_range; | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $ret = $lhs; | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | elsif (ord($lhs->data) > ord($rhs->data)) { | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 2 | $S->error($S->RPe_IRANGE, $lhs->visual, $rhs->visual); | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 21 | $ret = $S->object(anyof_range => $lhs, $rhs); | |||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 209 | ▶ | return if &SIZE_ONLY; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 85 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | # end of char class | ||||||||||||||||||||||||||||||||||||||||||
| 670 | 108 | ▶ | $self->add_handler('cce]' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | 108 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 672 | 108 | ▶ | $S->error($S->RPe_LBRACK) if ${&Rx} !~ m{ \G ] }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | 105 | return $S->object(anyof_close => "]"); | |||||||||||||||||||||||||||||||||||||||||
| 674 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | # closing paren coming from 'atom' | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 636 | ▶ | $self->add_handler(')' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 636 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 636 | pop @{ $S->{next} }; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 636 | &RxPOS--; | |||||||||||||||||||||||||||||||||||||||||
| 681 | 636 | return; | |||||||||||||||||||||||||||||||||||||||||
| 682 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | # closing paren coming from an opening paren | ||||||||||||||||||||||||||||||||||||||||||
| 685 | 562 | ▶ | $self->add_handler('c)' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 562 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 687 | 562 | ▶ | $S->error($S->RPe_LPAREN) if ${&Rx} !~ m{ \G \) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | 558 | pop @{ $S->{flags} }; | |||||||||||||||||||||||||||||||||||||||||
| 689 | 558 | return $S->object(close =>); | |||||||||||||||||||||||||||||||||||||||||
| 690 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | # some kind of assertion... | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 438 | ▶ | $self->add_handler('(?' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=22 SCAR=31.3
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 438 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 695 | 438 | my $c = '(?'; | |||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 438 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 437 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 699 | 437 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 176 | &RxPOS--; | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 1 | $S->error($S->RPe_SEQINC); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | # (?0) is equivalent to (?R) -- whole-pattern recursion | ||||||||||||||||||||||||||||||||||||||||||
| 707 | # (?1), (?2), ... -- numbered group recursion | ||||||||||||||||||||||||||||||||||||||||||
| 708 | # (?+1), (?-1) -- relative group recursion | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 176 | ▶ | if (${&Rx} =~ m{ \G ( [+-]? [0-9]+ ) \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 30 | my $num = $1; | |||||||||||||||||||||||||||||||||||||||||
| 711 | 30 | my $vis = "(?$num)"; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 30 | return $S->object(recurse => $num, $vis); | |||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | # Perl 5.14+ flag reset: (?^...) means default flags | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 146 | my $caret = 0; | |||||||||||||||||||||||||||||||||||||||||
| 717 | 146 | ▶ | if (${&Rx} =~ m{ \G \^ }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 718 | 12 | $caret = 1; | |||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | # flag assertion or non-capturing group | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 146 | ${&Rx} =~ m{ \G ([a-zA-Z]*) (-? [a-zA-Z]*) }xgc; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 146 | my ($on, $off) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 724 | 146 | my ($r_on, $r_off) = ("", ""); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 146 | my ($f_on, $f_off) = (0,0); | |||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | 146 | &RxPOS -= length($on.$off); | |||||||||||||||||||||||||||||||||||||||||
| 728 | 146 | my $old = &RxPOS; | |||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 146 | for (split //, $on) { | |||||||||||||||||||||||||||||||||||||||||
| 731 | 90 | &RxPOS++; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 90 | ▶ | if (my $f = $S->can("FLAG_$_")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 88 | ▶ | my $v = $S->$f(1) and $r_on .= $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | # /xx: if x is already on, set the xx bit (Perl 5.26+) | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 88 | ▶ | if ($_ eq 'x' && ($f_on & $v)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq "x" and $f_on & $v
MC/DC100%2/2
$_ eq "x" and $f_on & $v
$_ eq "x"
$f_on & $v
Truth table100%3/3
A and B
A= $_ eq "x"B= $f_on & $v
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | 10 | $f_on |= 0x200; # FLAG_xx | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | 88 | $f_on |= $v; | |||||||||||||||||||||||||||||||||||||||||
| 739 | 88 | next; | |||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 2 | my $bad = substr ${&Rx}, $old; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 2 | $S->error($S->RPe_NOTREC, &RxPOS - $old, $bad); | |||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 144 | ▶ | if (!$caret) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | 132 | ▶ | &RxPOS++ if $off =~ s/^-//; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | 132 | for (split //, $off) { | |||||||||||||||||||||||||||||||||||||||||
| 749 | 19 | &RxPOS++; | |||||||||||||||||||||||||||||||||||||||||
| 750 | 19 | ▶ | if (my $f = $S->can("FLAG_$_")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 19 | ▶ | my $v = $S->$f(0) and $r_off .= $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | # -xx: also turn off the xx bit (Perl 5.26+) | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 19 | ▶ | if ($_ eq 'x' && ($f_off & $v)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_ eq "x" and $f_off & $v
MC/DC0%0/2
$_ eq "x" and $f_off & $v
$_ eq "x"
$f_off & $v
Truth table33%1/3
A and B
A= $_ eq "x"B= $f_off & $v
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $f_off |= 0x200; # FLAG_xx | |||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 19 | $f_off |= $v; | |||||||||||||||||||||||||||||||||||||||||
| 757 | 19 | next; | |||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | my $bad = substr ${&Rx}, $old; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $S->error($S->RPe_NOTREC, &RxPOS - $old, $bad); | |||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | 144 | ▶ | if (${&Rx} =~ m{ \G ([:)]) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 765 | 144 | ▶ | my $type = $1 eq ':' ? 'group' : 'flags'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | 144 | ▶ | if ($type eq 'group') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 117 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 768 | 117 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 144 | ▶ | if ($caret) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | 12 | &Rf = 0; # reset all flags to default | |||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||
| 773 | 144 | &Rf |= $f_on; | |||||||||||||||||||||||||||||||||||||||||
| 774 | 144 | &Rf &= ~$f_off; | |||||||||||||||||||||||||||||||||||||||||
| 775 | 144 | ▶ | my $vis_on = $caret ? "^$r_on" : $r_on; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 776 | 144 | return $S->object($type => $vis_on, $r_off); | |||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | &RxPOS++; | |||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | my $l = length($on.$off) + 2; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $S->error($S->RPe_NOTREC, $l, substr(${&Rx}, $old)); | |||||||||||||||||||||||||||||||||||||||||
| 782 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | # comment | ||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | $self->add_handler('(?#' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ${&Rx} =~ m{ \G [^)]* }xgc; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | $S->error($S->RPe_NOTERM) unless ${&Rx} =~ m{ \G \) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 790 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | # not implemented (?$...) | ||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | $self->add_handler('(?$' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $S->error($S->RPe_NOTREC, 1, substr(${&Rx}, &RxPOS - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 796 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | # not implemented (?@...) | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | $self->add_handler('(?@' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | $S->error($S->RPe_NOTREC, 1, substr(${&Rx}, &RxPOS - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 802 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | # look-ahead | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 27 | ▶ | $self->add_handler('(?=' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 27 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 27 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 27 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 27 | return $S->object(ifmatch => 1); | |||||||||||||||||||||||||||||||||||||||||
| 810 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | # look-ahead (neg) | ||||||||||||||||||||||||||||||||||||||||||
| 813 | 16 | ▶ | $self->add_handler('(?!' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | 16 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 815 | 16 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 816 | 16 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 817 | 16 | return $S->object(unlessm => 1); | |||||||||||||||||||||||||||||||||||||||||
| 818 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | # look-behind prefix | ||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | $self->add_handler('(?<' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my $c = '(?<'; | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | $S->error($S->RPe_NOTREC, 2, substr(${&Rx}, &RxPOS - 2)); | |||||||||||||||||||||||||||||||||||||||||
| 831 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | # look-behind | ||||||||||||||||||||||||||||||||||||||||||
| 834 | 14 | ▶ | $self->add_handler('(?<=' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 835 | 14 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 14 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 14 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 14 | return $S->object(ifmatch => -1); | |||||||||||||||||||||||||||||||||||||||||
| 839 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | # look-behind (neg) | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 16 | ▶ | $self->add_handler('(?<!' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 16 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 16 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 845 | 16 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 846 | 16 | return $S->object(unlessm => -1); | |||||||||||||||||||||||||||||||||||||||||
| 847 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | # suspend | ||||||||||||||||||||||||||||||||||||||||||
| 850 | 13 | ▶ | $self->add_handler('(?>' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | 13 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 852 | 13 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 13 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 854 | 13 | return $S->object(suspend =>); | |||||||||||||||||||||||||||||||||||||||||
| 855 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | # eval | ||||||||||||||||||||||||||||||||||||||||||
| 858 | 15 | ▶ | $self->add_handler('(?{' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 15 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 860 | 15 | ▶ | if (${&Rx} =~ m{ \G ($nest_eval) \} \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 13 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 862 | 13 | return $S->object(eval => $1); | |||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | 2 | $S->error($S->RPe_NOTBAL); | |||||||||||||||||||||||||||||||||||||||||
| 865 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | # logical prefix | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 5 | ▶ | $self->add_handler('(??' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 869 | 5 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 870 | 5 | my $c = '(??'; | |||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | 5 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | 5 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 874 | 5 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | $S->error($S->RPe_NOTREC, 2, substr(${&Rx}, &RxPOS - 2)); | |||||||||||||||||||||||||||||||||||||||||
| 878 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | # logical | ||||||||||||||||||||||||||||||||||||||||||
| 881 | 6 | ▶ | $self->add_handler('(??{' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 882 | 6 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 6 | ▶ | if (${&Rx} =~ m{ \G ($nest_logical) \} \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | 6 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 885 | 6 | return $S->object(logical => $1); | |||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $S->error($S->RPe_NOTBAL); | |||||||||||||||||||||||||||||||||||||||||
| 888 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | # logical prefix | ||||||||||||||||||||||||||||||||||||||||||
| 891 | 1 | ▶ | $self->add_handler('(?p' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 1 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | my $c = '(?p'; | |||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | 1 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 896 | 1 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 897 | 1 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $S->error($S->RPe_NOTREC, 2, substr(${&Rx}, &RxPOS - 2)); | |||||||||||||||||||||||||||||||||||||||||
| 901 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | # logical | ||||||||||||||||||||||||||||||||||||||||||
| 904 | 1 | ▶ | $self->add_handler('(?p{' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | 1 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 906 | 1 | $S->warn($S->RPe_LOGDEP); | |||||||||||||||||||||||||||||||||||||||||
| 907 | 1 | my $c = "(??{"; | |||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | return $S->$c; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 99 | ▶ | $self->add_handler('(?(' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 912 | 99 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 913 | 99 | my $c = '(?('; | |||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | 99 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 916 | 99 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 917 | 99 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 918 | 99 | &RxPOS--; | |||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | 99 | push @{ $S->{next} }, qw< ifthen( >; | |||||||||||||||||||||||||||||||||||||||||
| 922 | 99 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 923 | 99 | return $S->object(ifthen =>); | |||||||||||||||||||||||||||||||||||||||||
| 924 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | # (?(...)t|f) condition | ||||||||||||||||||||||||||||||||||||||||||
| 927 | 99 | ▶ | $self->add_handler('ifthen(' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 928 | 99 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 929 | 99 | my $c = 'ifthen('; | |||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||
| 931 | 99 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | # (?(DEFINE)...) — always-false condition for defining groups | ||||||||||||||||||||||||||||||||||||||||||
| 934 | 99 | ▶ | if (${&Rx} =~ m{ \G DEFINE \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 935 | 14 | push @{ $S->{next} }, qw< ifthen|2 ifthen| ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 936 | 14 | return $S->object(define =>); | |||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | # (?(<name>)...) — named capture condition | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 85 | ▶ | if (${&Rx} =~ m{ \G < ([a-zA-Z_]\w*) > \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 941 | 6 | push @{ $S->{next} }, qw< ifthen|2 ifthen| ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 942 | 6 | return $S->object(grouppn => $1, '<'); | |||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | # (?('name')...) — named capture condition (alternate syntax) | ||||||||||||||||||||||||||||||||||||||||||
| 946 | 79 | ▶ | if (${&Rx} =~ m{ \G ' ([a-zA-Z_]\w*) ' \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 947 | 6 | push @{ $S->{next} }, qw< ifthen|2 ifthen| ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 948 | 6 | return $S->object(grouppn => $1, "'"); | |||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | 73 | ▶ | if (${&Rx} =~ m{ \G (.) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 73 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 953 | 73 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 954 | 20 | &RxPOS--; | |||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 20 | ▶ | if (${&Rx} =~ m{ \G ( [1-9]\d* ) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 11 | my $n = $1; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 11 | ▶ | $S->error($S->RPe_SWNREC) if ${&Rx} !~ m{ \G \) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | 8 | push @{ $S->{next} }, qw< ifthen|2 ifthen| ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 8 | return $S->object(groupp => $n); | |||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | 9 | $S->error($S->RPe_SWUNKN, &RxCUR); | |||||||||||||||||||||||||||||||||||||||||
| 965 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | # atom inside an ifthen | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 311 | ▶ | $self->add_handler('ifthen_atom' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 969 | 311 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 970 | 311 | $S->nextchar; | |||||||||||||||||||||||||||||||||||||||||
| 971 | 311 | ▶ | ${&Rx} =~ m{ \G ([^|]) }xgcs or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | 250 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | 250 | push @{ $S->{next} }, qw< ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 975 | 250 | ▶ | return $S->$c if $S->can($c); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | 152 | return $S->object(exact => $c); | |||||||||||||||||||||||||||||||||||||||||
| 977 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | # alternation branch inside ifthen | ||||||||||||||||||||||||||||||||||||||||||
| 980 | 75 | ▶ | $self->add_handler('ifthen|' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 981 | 75 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 982 | 75 | ▶ | return if ${&Rx} !~ m{ \G \| }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 983 | 59 | push @{ $S->{next} }, qw< ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 984 | 59 | return $S->object(branch =>); | |||||||||||||||||||||||||||||||||||||||||
| 985 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | # illegal 2nd alternation branch inside ifthen | ||||||||||||||||||||||||||||||||||||||||||
| 988 | 75 | ▶ | $self->add_handler('ifthen|2' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 989 | 75 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 990 | 75 | ▶ | return if ${&Rx} !~ m{ \G \| }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 2 | $S->error($S->RPe_SWBRAN); | |||||||||||||||||||||||||||||||||||||||||
| 992 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | 53 | ▶ | $self->add_handler('ifthen(?' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 995 | 53 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 996 | 53 | my $c = '(?'; | |||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | 53 | push @{ $S->{next} }, qw< ifthen|2 ifthen| ifthen_atom >; | |||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 53 | ▶ | if (${&Rx} =~ m{ \G ( (?: <? [!=] | \{ ) ) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 41 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 1002 | 41 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | &RxPOS -= length $1; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 12 | $S->error($S->RPe_SEQINC); | |||||||||||||||||||||||||||||||||||||||||
| 1007 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||
| 1009 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | ## Perl 5.10+ constructs | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | # \K (keep, reset match start) | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | 8 | ▶ | $self->add_handler('\K' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1016 | 8 | ▶ | $S->warn($S->RPe_BADESC, "K", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1017 | 8 | ▶ | return $S->force_object(anyof_char => 'K') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 7 | return $S->object(keep =>); | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | # \R (generic linebreak) | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | 10 | ▶ | $self->add_handler('\R' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 10 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | 10 | ▶ | $S->warn($S->RPe_BADESC, "R", " in character class") if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 10 | ▶ | return $S->force_object(anyof_char => 'R') if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 9 | return $S->object(lnbreak =>); | |||||||||||||||||||||||||||||||||||||||||
| 1027 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | # \h (horizontal whitespace) | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | 10 | ▶ | $self->add_handler('\h' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 10 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1032 | 10 | ▶ | return $S->force_object(anyof_class => $S->force_object(hspace => 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 8 | return $S->object(hspace => 0); | |||||||||||||||||||||||||||||||||||||||||
| 1034 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | # \H (not horizontal whitespace) | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | 6 | ▶ | $self->add_handler('\H' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 6 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 6 | ▶ | return $S->force_object(anyof_class => $S->force_object(hspace => 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 4 | return $S->object(hspace => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1041 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||
| 1043 | # \v (vertical whitespace) | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | 6 | ▶ | $self->add_handler('\v' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 6 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 6 | ▶ | return $S->force_object(anyof_class => $S->force_object(vspace => 0)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | 4 | return $S->object(vspace => 0); | |||||||||||||||||||||||||||||||||||||||||
| 1048 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | # \V (not vertical whitespace) | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | 4 | ▶ | $self->add_handler('\V' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1052 | 4 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1053 | 4 | ▶ | return $S->force_object(anyof_class => $S->force_object(vspace => 1)) if $cc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1054 | 4 | return $S->object(vspace => 1); | |||||||||||||||||||||||||||||||||||||||||
| 1055 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | # \k<name> or \k'name' (named backreference) | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | 8 | ▶ | $self->add_handler('\k' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 8 | my ($S, $cc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | 8 | ▶ | if ($cc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | $S->warn($S->RPe_BADESC, "k", " in character class"); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | return $S->force_object(anyof_char => 'k'); | |||||||||||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 8 | ▶ | if (${&Rx} =~ m{ \G < ([^>]+) > }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | 6 | return $S->object(named_ref => $1, "\\k<$1>"); | |||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | 2 | elsif (${&Rx} =~ m{ \G ' ([^']+) ' }xgc) { | |||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | return $S->object(named_ref => $1, "\\k'$1'"); | |||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $S->error($S->RPe_BADESC, "k", ""); | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||
| 1076 | # (?<name>...) named capture group | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | # We override the existing '(?<' handler to also support named captures | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | 68 | ▶ | $self->add_handler('(?<' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 68 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | 68 | my $c = '(?<'; | |||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||
| 1082 | # Check for lookbehind first: (?<= and (?<! | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | 68 | ▶ | if (${&Rx} =~ m{ \G ([!=]) }xgcs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 16 | my $n = "$c$1"; | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 16 | ▶ | return $S->$n if $S->can($n); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | # Named capture: (?<name>...) | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | 52 | ▶ | if (${&Rx} =~ m{ \G ([A-Za-z_]\w*) > }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1090 | 52 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | 52 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 1092 | 52 | ▶ | &SIZE_ONLY ? ++$S->{maxpar} : ++$S->{nparen}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | 52 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 1094 | 52 | ▶ | $S->{named_captures}{$name} = $S->{nparen} unless &SIZE_ONLY; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 52 | return $S->object(named_open => $S->{nparen}, $name); | |||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $S->error($S->RPe_NOTREC, 2, substr(${&Rx}, &RxPOS - 2)); | |||||||||||||||||||||||||||||||||||||||||
| 1099 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | # (?'name'...) alternate named capture syntax | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | $self->add_handler("(?\'" => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | if (${&Rx} =~ m{ \G ([A-Za-z_]\w*) ' }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | &SIZE_ONLY ? ++$S->{maxpar} : ++$S->{nparen}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | $S->{named_captures}{$name} = $S->{nparen} unless &SIZE_ONLY; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | return $S->object(named_open => $S->{nparen}, $name); | |||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | $S->error($S->RPe_NOTREC, 1, substr(${&Rx}, &RxPOS - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 1115 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | # (?R) -- whole-pattern recursion (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | 12 | ▶ | $self->add_handler('(?R' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 12 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | $S->error($S->RPe_NOTREC, 3, "(?R" . substr(${&Rx}, &RxPOS, 1)) | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 12 | ▶ | unless ${&Rx} =~ m{ \G \) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||
| 1124 | 12 | return $S->object(recurse => 0, '(?R)'); | |||||||||||||||||||||||||||||||||||||||||
| 1125 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||
| 1127 | # (?&name) -- named subpattern recursion (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | 8 | ▶ | $self->add_handler('(?&' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1129 | 8 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 8 | ▶ | if (${&Rx} =~ m{ \G ([A-Za-z_]\w*) \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1132 | 8 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1133 | 8 | return $S->object(named_recurse => $name, "(?&$name)"); | |||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | $S->error($S->RPe_NOTREC, 3, "(?&" . substr(${&Rx}, &RxPOS, 5)); | |||||||||||||||||||||||||||||||||||||||||
| 1137 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | # (?P<name>...) -- Python-compatible named capture (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | # (?P=name) -- Python-compatible named backreference (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | # (?P>name) -- Python-compatible named recursion (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | 10 | ▶ | $self->add_handler('(?P' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 10 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | # (?P<name>...) named capture | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | 10 | ▶ | if (${&Rx} =~ m{ \G < ([A-Za-z_]\w*) > }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 6 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1148 | 6 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 1149 | 6 | ▶ | &SIZE_ONLY ? ++$S->{maxpar} : ++$S->{nparen}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1150 | 6 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | 6 | ▶ | $S->{named_captures}{$name} = $S->{nparen} unless &SIZE_ONLY; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 6 | return $S->object(named_open => $S->{nparen}, $name); | |||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||
| 1155 | # (?P=name) named backreference | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 4 | ▶ | if (${&Rx} =~ m{ \G = ([A-Za-z_]\w*) \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 2 | return $S->object(named_ref => $name, "(?P=$name)"); | |||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | # (?P>name) named recursion | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | 2 | ▶ | if (${&Rx} =~ m{ \G > ([A-Za-z_]\w*) \) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1163 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1164 | 2 | return $S->object(named_recurse => $name, "(?P>$name)"); | |||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | $S->error($S->RPe_NOTREC, 3, "(?P" . substr(${&Rx}, &RxPOS, 5)); | |||||||||||||||||||||||||||||||||||||||||
| 1168 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | # possessive quantifier modifier (a++, a*+, a?+, a{n,m}+) | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | $self->add_handler('posmod' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | $S->nextchar; | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | ▶ | return $S->object(possessive =>) if ${&Rx} =~ m{ \G \+ }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1176 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | ## Perl 5.10+ branch reset group: (?|...) | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | 14 | ▶ | $self->add_handler('(?|' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1182 | 14 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1183 | 14 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 1184 | 14 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 1185 | 14 | return $S->object(branch_reset =>); | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | ## Perl 5.10+ backtracking control verbs: (*VERB) and (*VERB:arg) | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | ## Also Perl 5.28+ alphabetic assertions: (*positive_lookahead:...) etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | 58 | ▶ | $self->add_handler('(*' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 58 | my ($S) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||
| 1195 | # Match the verb/keyword name | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | 58 | ▶ | if (${&Rx} =~ m{ \G ([A-Za-z_]\w*) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1197 | 58 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | # Alphabetic assertion forms (Perl 5.28+) | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | # These are grouping constructs: (*name:pattern) | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | 58 | my %alpha_assert = ( | |||||||||||||||||||||||||||||||||||||||||
| 1202 | positive_lookahead => ['ifmatch', 1], | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | pla => ['ifmatch', 1], | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | negative_lookahead => ['unlessm', 1], | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | nla => ['unlessm', 1], | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | positive_lookbehind => ['ifmatch', -1], | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | plb => ['ifmatch', -1], | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | negative_lookbehind => ['unlessm', -1], | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | nlb => ['unlessm', -1], | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | atomic => ['suspend', undef], | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | script_run => ['script_run', undef], | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | sr => ['script_run', undef], | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | atomic_script_run => ['asr', undef], | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | asr => ['asr', undef], | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 58 | ▶ | if (my $spec = $alpha_assert{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1218 | $S->error($S->RPe_NOTREC, length($name) + 1, "*$name") | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | 30 | ▶ | if ${&Rx} !~ m{ \G : }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1220 | 30 | push @{ $S->{next} }, qw< c) atom >; | |||||||||||||||||||||||||||||||||||||||||
| 1221 | 30 | push @{ $S->{flags} }, &Rf; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | 30 | my ($type, $dir) = @$spec; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 30 | ▶ | return $S->object($type => $dir) if defined $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | 10 | return $S->object($type =>); | |||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||
| 1227 | # Backtracking control verbs (Perl 5.10+) | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | 28 | my $arg; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | 28 | ▶ | if (${&Rx} =~ m{ \G : ([^)]*) }xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 10 | $arg = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | 28 | ▶ | $S->error($S->RPe_LPAREN) if ${&Rx} !~ m{ \G \) }xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | # Validate known verbs | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | 28 | my %known_verb = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 1236 | qw(ACCEPT FAIL F MARK SKIP PRUNE COMMIT THEN); | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | 28 | ▶ | if (!$known_verb{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | $S->error($S->RPe_NOTREC, length($name) + 1, "*$name"); | |||||||||||||||||||||||||||||||||||||||||
| 1239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | 28 | return $S->object(verb => $name, $arg); | |||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | $S->error($S->RPe_NOTREC, 1, substr(${&Rx}, &RxPOS - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 1244 | 359 | }); | |||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||
| 1248 | 19 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||
| 1250 | __END__ | ||||||||||||||||||||||||||||||||||||||||||