line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAPE::Regex::Element; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '4.00'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
24
|
50
|
|
24
|
1
|
328
|
sub text { exists $_[0]{TEXT} ? $_[0]{TEXT} : "" } |
7
|
36
|
|
|
36
|
1
|
72
|
sub string { $_[0]->text . "$_[0]{QUANT}$_[0]{NGREED}" } |
8
|
39
|
|
|
39
|
1
|
114
|
sub fullstring { $_[0]->string } |
9
|
0
|
|
|
0
|
1
|
0
|
sub quant { "$_[0]{QUANT}$_[0]{NGREED}" } |
10
|
0
|
|
|
0
|
1
|
0
|
sub ngreed { $_[0]{NGREED} } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package YAPE::Regex::anchor; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
17
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
|
0
|
sub type { 'anchor' } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package YAPE::Regex::macro; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
28
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
|
0
|
sub text { "\\$_[0]{TEXT}" } |
32
|
0
|
|
|
0
|
|
0
|
sub type { 'macro' } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package YAPE::Regex::oct; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
40
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
|
0
|
sub text { "\\$_[0]{TEXT}" } |
44
|
0
|
|
|
0
|
|
0
|
sub type { 'oct' } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package YAPE::Regex::hex; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
1
|
|
|
1
|
|
3
|
my ($class,$match,$q,$ng) = @_; |
52
|
1
|
|
|
|
|
12
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
31
|
sub text { "\\x$_[0]{TEXT}" } |
56
|
0
|
|
|
0
|
|
0
|
sub type { 'hex' } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package YAPE::Regex::backref; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
63
|
1
|
|
|
1
|
|
3
|
my ($class,$match,$q,$ng) = @_; |
64
|
1
|
|
|
|
|
6
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
18
|
sub text { "\\$_[0]{TEXT}" } |
68
|
0
|
|
|
0
|
|
0
|
sub type { 'backref' } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package YAPE::Regex::ctrl; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new { |
75
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
76
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
|
0
|
sub text { "\\c$_[0]{TEXT}" } |
80
|
0
|
|
|
0
|
|
0
|
sub type { 'ctrl' } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
package YAPE::Regex::named; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new { |
87
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
88
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
|
0
|
sub text { "\\N{$_[0]{TEXT}}" } |
92
|
0
|
|
|
0
|
|
0
|
sub type { 'named' } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
package YAPE::Regex::Cchar; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub new { |
99
|
0
|
|
|
0
|
|
0
|
my ($class,$q,$ng) = @_; |
100
|
0
|
|
|
|
|
0
|
bless { QUANT => $q, NGREED => $ng }, $class; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
|
0
|
sub text { '\C' } |
104
|
0
|
|
|
0
|
|
0
|
sub type { 'Cchar' } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
package YAPE::Regex::slash; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub new { |
111
|
0
|
|
|
0
|
|
0
|
my ($class,$match,$q,$ng) = @_; |
112
|
0
|
|
|
|
|
0
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
0
|
|
0
|
sub text { "\\$_[0]{TEXT}" } |
116
|
0
|
|
|
0
|
|
0
|
sub type { 'slash' } |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
package YAPE::Regex::any; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub new { |
123
|
0
|
|
|
0
|
|
0
|
my ($class,$q,$ng) = @_; |
124
|
0
|
|
|
|
|
0
|
bless { TEXT => '.', QUANT => $q, NGREED => $ng }, $class; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
0
|
|
0
|
sub type { 'any' } |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
package YAPE::Regex::class; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub new { |
134
|
6
|
|
|
6
|
|
11
|
my ($class,$match,$neg,$q,$ng) = @_; |
135
|
6
|
|
|
|
|
35
|
bless { TEXT => $match, NEG => $neg, QUANT => $q, NGREED => $ng }, $class; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub text { |
139
|
6
|
50
|
|
6
|
|
63
|
$_[0]{NEG} =~ /[pP]/ ? |
140
|
|
|
|
|
|
|
"\\$_[0]{NEG}\{$_[0]{TEXT}\}" : |
141
|
|
|
|
|
|
|
"[$_[0]{NEG}$_[0]{TEXT}]" |
142
|
|
|
|
|
|
|
} |
143
|
0
|
|
|
0
|
|
0
|
sub type { 'class' } |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
package YAPE::Regex::text; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub new { |
150
|
25
|
|
|
25
|
|
44
|
my ($class,$match,$q,$ng) = @_; |
151
|
25
|
|
|
|
|
146
|
bless { TEXT => $match, QUANT => $q, NGREED => $ng }, $class; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
0
|
|
0
|
sub type { 'text' } |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
package YAPE::Regex::alt; |
159
|
|
|
|
|
|
|
|
160
|
4
|
|
|
4
|
|
18
|
sub new { bless { NGREED => "", QUANT => "" }, $_[0] } |
161
|
0
|
|
|
0
|
|
0
|
sub text { '' } |
162
|
3
|
|
|
3
|
|
9
|
sub string { '|' } |
163
|
0
|
|
|
0
|
|
0
|
sub type { 'alt' } |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package YAPE::Regex::comment; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub new { |
170
|
0
|
|
|
0
|
|
0
|
my ($class,$text,$X) = @_; |
171
|
0
|
|
|
|
|
0
|
bless { TEXT => $text, XCOMM => $X }, $class; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
0
|
0
|
|
0
|
|
0
|
sub string { $_[0]{XCOMM} ? " # $_[0]{TEXT}" : "(?#$_[0]{TEXT})" } |
175
|
0
|
|
|
0
|
|
0
|
sub xcomm { $_[0]{XCOMM} } |
176
|
0
|
|
|
0
|
|
0
|
sub type { 'comment' } |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
package YAPE::Regex::whitespace; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub new { |
183
|
0
|
|
|
0
|
|
0
|
my ($class,$text) = @_; |
184
|
0
|
|
|
|
|
0
|
bless { TEXT => $text }, $class; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
0
|
|
0
|
sub type { 'whitespace' } |
188
|
0
|
|
|
0
|
|
0
|
sub string { $_[0]{TEXT} } |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
package YAPE::Regex::flags; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub new { |
195
|
0
|
|
|
0
|
|
0
|
my ($class,$add,$sub) = @_; |
196
|
0
|
|
0
|
|
|
0
|
my %mode = map { $_ => 1 } split //, $add ||= ""; |
|
0
|
|
|
|
|
0
|
|
197
|
0
|
|
0
|
|
|
0
|
delete @mode{split //, $sub ||= ""}; |
198
|
0
|
|
|
|
|
0
|
$add = join "", sort split //, $add; |
199
|
0
|
|
|
|
|
0
|
$sub = join "", sort split //, $sub; |
200
|
0
|
|
|
|
|
0
|
bless { MODE => \%mode, ON => $add, OFF => $sub }, $class; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
0
|
0
|
|
0
|
sub string { "(?$_[0]{ON}" . ($_[0]{OFF} && "-$_[0]{OFF}") . ')' } |
204
|
0
|
|
|
0
|
|
0
|
sub type { 'flags' } |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
package YAPE::Regex::cut; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub new { |
211
|
0
|
|
0
|
0
|
|
0
|
bless { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
212
|
|
|
|
|
|
|
CONTENT => $_[1] || [], |
213
|
|
|
|
|
|
|
QUANT => $_[2] || "", |
214
|
|
|
|
|
|
|
NGREED => $_[3] || "", |
215
|
|
|
|
|
|
|
}, $_[0] |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub fullstring { |
219
|
0
|
|
|
|
|
0
|
join "", |
220
|
|
|
|
|
|
|
$_[0]->string, |
221
|
0
|
|
|
0
|
|
0
|
map($_->fullstring, @{ $_[0]{CONTENT} }), |
222
|
|
|
|
|
|
|
")$_[0]{QUANT}$_[0]{NGREED}" |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
0
|
|
0
|
sub string { '(?>' } |
226
|
0
|
|
|
0
|
|
0
|
sub type { 'cut' } |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
package YAPE::Regex::lookahead; |
231
|
|
|
|
|
|
|
|
232
|
3
|
|
50
|
3
|
|
27
|
sub new { bless { POS => $_[1], CONTENT => $_[2] || [] }, $_[0] } |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub fullstring { |
235
|
3
|
|
|
|
|
17
|
join "", |
236
|
|
|
|
|
|
|
$_[0]->string, |
237
|
3
|
|
|
3
|
|
9
|
map($_->fullstring, @{ $_[0]{CONTENT} }), |
238
|
|
|
|
|
|
|
')' |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
3
|
|
|
3
|
|
9
|
sub string { '(?' . ('!','=')[$_[0]{POS}] } |
242
|
4
|
|
|
4
|
|
15
|
sub type { 'lookahead' } |
243
|
0
|
|
|
0
|
|
0
|
sub pos { $_[0]{POS} } |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
package YAPE::Regex::lookbehind; |
248
|
|
|
|
|
|
|
|
249
|
3
|
|
50
|
3
|
|
41
|
sub new { bless { POS => $_[1], CONTENT => $_[2] || [] }, $_[0] } |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub fullstring { |
252
|
3
|
|
|
|
|
15
|
join "", |
253
|
|
|
|
|
|
|
$_[0]->string, |
254
|
3
|
|
|
3
|
|
10
|
map($_->fullstring, @{ $_[0]{CONTENT} }), |
255
|
|
|
|
|
|
|
')' |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
3
|
|
|
3
|
|
10
|
sub string { '(?<' . ('!','=')[$_[0]{POS}] } |
259
|
0
|
|
|
0
|
|
0
|
sub type { 'lookbehind' } |
260
|
0
|
|
|
0
|
|
0
|
sub pos { $_[0]{POS} } |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
package YAPE::Regex::conditional; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub new { |
267
|
7
|
|
100
|
7
|
|
146
|
bless { |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
268
|
|
|
|
|
|
|
OPTS => 1, |
269
|
|
|
|
|
|
|
CONTENT => $_[1] || [], |
270
|
|
|
|
|
|
|
TRUE => $_[2] || [], |
271
|
|
|
|
|
|
|
FALSE => $_[3] || [], |
272
|
|
|
|
|
|
|
QUANT => $_[4] || "", |
273
|
|
|
|
|
|
|
NGREED => $_[5] || "", |
274
|
|
|
|
|
|
|
}, $_[0]; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub fullstring { |
278
|
7
|
|
|
|
|
22
|
join "", |
279
|
|
|
|
|
|
|
$_[0]->string, |
280
|
1
|
|
|
|
|
6
|
map($_->fullstring, @{ $_[0]{TRUE} }), |
281
|
|
|
|
|
|
|
$_[0]{OPTS} == 2 ? ( |
282
|
7
|
100
|
|
7
|
|
23
|
'|', map($_->fullstring, @{ $_[0]{FALSE} }), |
283
|
|
|
|
|
|
|
) : (), |
284
|
|
|
|
|
|
|
")$_[0]{QUANT}$_[0]{NGREED}"; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub string { |
288
|
7
|
100
|
|
7
|
|
34
|
'(?' . (ref $_[0]{CONTENT} ? |
289
|
|
|
|
|
|
|
$_[0]{CONTENT}[0]->fullstring : |
290
|
|
|
|
|
|
|
"($_[0]{CONTENT})" |
291
|
|
|
|
|
|
|
) |
292
|
|
|
|
|
|
|
} |
293
|
0
|
|
|
0
|
|
0
|
sub backref { $_[0]{CONTENT} } |
294
|
8
|
|
|
8
|
|
84
|
sub type { 'cond' } |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
package YAPE::Regex::group; |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub new { |
301
|
13
|
|
100
|
13
|
|
75
|
my $on = join "", sort split //, $_[1] || ""; |
302
|
13
|
|
100
|
|
|
79
|
my $off = join "", sort split //, $_[2] || ""; |
303
|
13
|
|
50
|
|
|
178
|
bless { |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
304
|
|
|
|
|
|
|
ON => $on, |
305
|
|
|
|
|
|
|
OFF => $off, |
306
|
|
|
|
|
|
|
CONTENT => $_[3] || [], |
307
|
|
|
|
|
|
|
QUANT => $_[4] || "", |
308
|
|
|
|
|
|
|
NGREED => $_[5] || "", |
309
|
|
|
|
|
|
|
}, $_[0] |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub fullstring { |
313
|
11
|
|
|
|
|
45
|
join "", |
314
|
|
|
|
|
|
|
$_[0]->string, |
315
|
11
|
|
|
11
|
|
30
|
map($_->fullstring, @{ $_[0]{CONTENT} }), |
316
|
|
|
|
|
|
|
")$_[0]{QUANT}$_[0]{NGREED}" |
317
|
|
|
|
|
|
|
} |
318
|
11
|
100
|
|
11
|
|
59
|
sub string { $_[0]{OFF} ? "(?$_[0]{ON}-$_[0]{OFF}:" : "(?$_[0]{ON}:" } |
319
|
12
|
|
|
12
|
|
87
|
sub type { 'group' } |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
package YAPE::Regex::capture; |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub new { |
326
|
2
|
|
50
|
2
|
|
26
|
bless { |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
327
|
|
|
|
|
|
|
CONTENT => $_[1] || [], |
328
|
|
|
|
|
|
|
QUANT => $_[2] || "", |
329
|
|
|
|
|
|
|
NGREED => $_[3] || "", |
330
|
|
|
|
|
|
|
}, $_[0] |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub fullstring { |
334
|
2
|
|
|
|
|
8
|
join "", |
335
|
|
|
|
|
|
|
$_[0]->string, |
336
|
2
|
|
|
2
|
|
7
|
map($_->fullstring, @{ $_[0]{CONTENT} }), |
337
|
|
|
|
|
|
|
")$_[0]{QUANT}$_[0]{NGREED}" |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
2
|
|
|
2
|
|
4
|
sub string { '(' } |
341
|
4
|
|
|
4
|
|
22
|
sub type { 'capture' } |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
package YAPE::Regex::code; |
346
|
|
|
|
|
|
|
|
347
|
2
|
|
|
2
|
|
14
|
sub new { bless { CONTENT => $_[1], QUANT => "", NGREED => "", }, $_[0] } |
348
|
2
|
|
|
2
|
|
12
|
sub text { "(?$_[0]{CONTENT})" } |
349
|
0
|
|
|
0
|
|
0
|
sub type { 'code' } |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
package YAPE::Regex::later; |
354
|
|
|
|
|
|
|
|
355
|
2
|
|
|
2
|
|
12
|
sub new { bless { CONTENT => $_[1], QUANT => "", NGREED => "", }, $_[0] } |
356
|
2
|
|
|
2
|
|
13
|
sub text { "(??$_[0]{CONTENT})" } |
357
|
0
|
|
|
0
|
|
0
|
sub type { 'later' } |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
package YAPE::Regex::close; |
362
|
|
|
|
|
|
|
|
363
|
30
|
|
50
|
30
|
|
399
|
sub new { bless { QUANT => $_[1] || "", NGREED => $_[2] || "" }, $_[0] } |
|
|
|
50
|
|
|
|
|
364
|
0
|
|
|
0
|
|
|
sub string { ")$_[0]{QUANT}$_[0]{NGREED}" } |
365
|
0
|
|
|
0
|
|
|
sub type { 'close' } |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
1; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head1 NAME |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
YAPE::Regex::Element - sub-classes for YAPE::Regex elements |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=head1 VERSION |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
This document refers to YAPE::Regex::Element version 4.00. |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=head1 SYNOPSIS |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
use YAPE::Regex 'MyExt::Mod'; |
382
|
|
|
|
|
|
|
# this sets up inheritence in MyExt::Mod |
383
|
|
|
|
|
|
|
# see YAPE::Regex documentation |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=head1 C MODULES |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
The C hierarchy of modules is an attempt at a unified means of parsing |
388
|
|
|
|
|
|
|
and extracting content. It attempts to maintain a generic interface, to |
389
|
|
|
|
|
|
|
promote simplicity and reusability. The API is powerful, yet simple. The |
390
|
|
|
|
|
|
|
modules do tokenization (which can be intercepted) and build trees, so that |
391
|
|
|
|
|
|
|
extraction of specific nodes is doable. |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=head1 DESCRIPTION |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
This module provides the classes for the C objects. The base |
396
|
|
|
|
|
|
|
class for these objects is C. The objects classes are |
397
|
|
|
|
|
|
|
numerous. |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=head2 Methods for C |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
This class contains fallback methods for the other classes. |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=over 4 |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=item * Ctext;> |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
Returns a string representation of the content of the regex node I, not |
408
|
|
|
|
|
|
|
any nodes contained in it. This is C for non-text nodes. |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
=item * Cstring;> |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
Returns a string representation of the regex node I, not any nodes |
413
|
|
|
|
|
|
|
contained in it. |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=item * Cfullstring;> |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
Returns a string representation of the regex node, including any nodes contained |
418
|
|
|
|
|
|
|
in it. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=item * Cquant;> |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
Returns a string with the quantity, and a C> if the node is non-greedy. The |
423
|
|
|
|
|
|
|
quantity is one of C<*>, C<+>, C>, C<{I,I}>, or an empty string. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=item * Cngreed;> |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Returns a C> if the node is non-greedy, and an empty string otherwise. |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=back |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=head2 Methods for C |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
This class represents anchors. Objects have the following methods: |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=over 4 |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the anchor |
440
|
|
|
|
|
|
|
(C<^>, C<\A>, C<$>, C<\Z>, C<\z>, C<\B>, C<\b>, or C<\G>), the quantity, and |
441
|
|
|
|
|
|
|
the non-greedy flag. The quantity I be an empty string. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
my $anc = YAPE::Regex::anchor->new('\A', '', '?'); |
444
|
|
|
|
|
|
|
# /\A?/ |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=item * Ctype;> |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
Returns the string C. |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=back |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
=head2 Methods for C |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
This class represents character-class macros. Objects have the following |
455
|
|
|
|
|
|
|
methods: |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=over 4 |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the macro |
462
|
|
|
|
|
|
|
(C, C, C, C, C, or C), the quantity, and the non-greedy |
463
|
|
|
|
|
|
|
flag. |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
my $macro = YAPE::Regex::macro->new('s', '{3,5}'); |
466
|
|
|
|
|
|
|
# /\s{3,5}/ |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=item * Ctext;> |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
Returns the macro. |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
print $macro->text; # '\s' |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=item * Ctype;> |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Returns the string C. |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=back |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=head2 Methods for C |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
This class represents octal escapes. Objects have the following methods: |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=over 4 |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the octal number |
489
|
|
|
|
|
|
|
(as a string), the quantity, and the non-greedy flag. |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
my $oct = YAPE::Regex::oct->new('040'); |
492
|
|
|
|
|
|
|
# /\040/ |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=item * Ctext;> |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
Returns the octal escape. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
print $oct->text; # '\040' |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=item * Ctype;> |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Returns the string C. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=back |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=head2 Methods for C |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
This class represents hexadecimal escapes. Objects have the following methods: |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=over 4 |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the hexadecimal |
515
|
|
|
|
|
|
|
number (as a string), the quantity, and the non-greedy flag. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
my $hex = YAPE::Regex::hex->new('20','{2,}'); |
518
|
|
|
|
|
|
|
# /\x20{2,}/ |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=item * Ctext;> |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Returns the hexadecimal escape. |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
print $hex->text; # '\x20' |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=item * Ctype;> |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
Returns the string C. |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=back |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head2 Methods for C |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
This class represents UTF hexadecimal escapes. Objects have the following |
535
|
|
|
|
|
|
|
methods: |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=over 4 |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the |
542
|
|
|
|
|
|
|
hexadecimal number (as a string), the quantity, and the non-greedy flag. |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
my $utf8hex = YAPE::Regex::utf8hex->new('beef','{0,4}'); |
545
|
|
|
|
|
|
|
# /\x{beef}{2,}/ |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=item * Ctext;> |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Returns the hexadecimal escape. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
print $utf8hex->text; # '\x{beef}' |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=item * Ctype;> |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
Returns the string C. |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=back |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=head2 Methods for C |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
This class represents back-references. Objects have the following methods: |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=over 4 |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the number of |
568
|
|
|
|
|
|
|
the back-reference, the quantity, and the non-greedy flag. |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
my $bref = YAPE::Regex::bref->new(2,'','?'); |
571
|
|
|
|
|
|
|
# /\2?/ |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=item * Ctext;> |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
Returns the backescape. |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
print $bref->text; # '\2' |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=item * Ctype;> |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
Returns the string C. |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=back |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=head2 Methods for C |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
This class represents control character escapes. Objects have the following |
588
|
|
|
|
|
|
|
methods: |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=over 4 |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the control |
595
|
|
|
|
|
|
|
character, the quantity, and the non-greedy flag. |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
my $ctrl = YAPE::Regex::ctrl->new('M'); |
598
|
|
|
|
|
|
|
# /\cM/ |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=item * Ctext;> |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
Returns the control character escape. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
print $ctrl->text; # '\cM' |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
=item * Ctype;> |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
Returns the string C. |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=back |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head2 Methods for C |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
This class represents named characters. Objects have the following methods: |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=over 4 |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the name of the |
621
|
|
|
|
|
|
|
character, the quantity, and the non-greedy flag. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
my $named = YAPE::Regex::named->new('GREEK SMALL LETTER BETA'); |
624
|
|
|
|
|
|
|
# /\N{GREEK SMALL LETTER BETA}/ |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
=item * Ctext;> |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
Returns the character escape text. |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
print $named->text; # '\N{GREEK SMALL LETTER BETA}' |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=item * Ctype;> |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
Returns the string C. |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=back |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head2 Methods for C |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
This class represents C characters. Objects have the following methods: |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=over 4 |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=item * Cnew($q,$ng);> |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: the quantity and |
647
|
|
|
|
|
|
|
the non-greedy flag. |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
my $named = YAPE::Regex::Char->new(2); |
650
|
|
|
|
|
|
|
# /\C{2}/ |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=item * Ctext;> |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
Returns the escape sequence. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
print $Cchar->text; # '\C' |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=item * Ctype;> |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
Returns the string C. |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=back |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=head2 Methods for C |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
This class represents any other escaped characters. Objects have the following |
667
|
|
|
|
|
|
|
methods: |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
=over 4 |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=item * Cnew($type,$q,$ng);> |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the backslashed |
674
|
|
|
|
|
|
|
character, the quantity, and the non-greedy flag. |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
my $slash = YAPE::Regex::slash->new('t','','?'); |
677
|
|
|
|
|
|
|
# /\t?/ |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=item * Ctext;> |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
Returns the escaped character. |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
print $slash->text; # '\t' |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
=item * Ctype;> |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
Returns the string C. |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=back |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
=head2 Methods for C |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
This class represents the dot metacharacter. Objects have the following methods: |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=over 4 |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
=item * Cnew($q,$ng);> |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: the quantity, and |
700
|
|
|
|
|
|
|
the non-greedy flag. |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
my $any = YAPE::Regex::any->new('{1,3}'); |
703
|
|
|
|
|
|
|
# /.{1,3}/ |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
=item * Ctype;> |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
Returns the string C. |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=back |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=head2 Methods for C |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
This class represents character classes. Objects have the following methods: |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=over 4 |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=item * Cnew($chars,$neg,$q,$ng);> |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
Creates a C object. Takes four arguments: the characters |
720
|
|
|
|
|
|
|
in the class, a C<^> if the class is negated (an empty string otherwise), the |
721
|
|
|
|
|
|
|
quantity, and the non-greedy flag. |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
my $class = YAPE::Regex::class->new('aeiouy','^'); |
724
|
|
|
|
|
|
|
# /[^aeiouy]/ |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
=item * Ctext;> |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
Returns the character class. |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
print $class->text; # [^aeiouy] |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=item * Ctype;> |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
Returns the string C. |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=back |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
=head2 Methods for C |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
This class represents hexadecimal escapes. Objects have the following methods: |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
=over 4 |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
=item * Cnew($text,$q,$ng);> |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: the text, the |
747
|
|
|
|
|
|
|
quantity, and the non-greedy flag. The quantity and non-greedy modifier should |
748
|
|
|
|
|
|
|
only be present for I text, because of the way the parser |
749
|
|
|
|
|
|
|
renders the quantity and non-greedy modifier. |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
my $text = YAPE::Regex::text->new('alphabet',''); |
752
|
|
|
|
|
|
|
# /alphabet/ |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
my $text = YAPE::Regex::text->new('x','?','?'); |
755
|
|
|
|
|
|
|
# /x??/ |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=item * Ctype;> |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
Returns the string C. |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=back |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
=head2 Methods for C |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
This class represents alternation. Objects have the following methods: |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
=over 4 |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=item * Cnew;> |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
Creates a C object. |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
my $alt = YAPE::Regex::alt->new; |
774
|
|
|
|
|
|
|
# /|/ |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=item * Ctype;> |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
Returns the string C. |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=back |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
=head2 Methods for C |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
This class represents in-line comments. Objects have the following methods: |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=over 4 |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
=item * Cnew($comment,$x);> |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: the text of the |
791
|
|
|
|
|
|
|
comment, and whether or not the C regex modifier is in effect for this |
792
|
|
|
|
|
|
|
comment. Note that Perl's regex engine will stop a C<(?#...)> comment at the |
793
|
|
|
|
|
|
|
first C<)>, regardless of what you do. |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
my $comment = YAPE::Regex::comment->new( |
796
|
|
|
|
|
|
|
"match an optional string of digits" |
797
|
|
|
|
|
|
|
); |
798
|
|
|
|
|
|
|
# /(?#match an optional string of digits)/ |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
my $comment = YAPE::Regex::comment->new( |
801
|
|
|
|
|
|
|
"match an optional string of digits", |
802
|
|
|
|
|
|
|
1 |
803
|
|
|
|
|
|
|
); |
804
|
|
|
|
|
|
|
# /# match an optional string of digits/ |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
=item * Ctype;> |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
Returns the string C. |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
=item * Cxcomm;> |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
Returns true or false, depending on whether the comment is under the C regex |
813
|
|
|
|
|
|
|
modifier. |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=back |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
=head2 Methods for C |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
This class represents whitespace under the C regex modifier. Objects have |
820
|
|
|
|
|
|
|
the following methods: |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
=over 4 |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
=item * Cnew($text);> |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
Creates a C object. Takes one argument: the text of |
827
|
|
|
|
|
|
|
the whitespace. |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
my $ws = YAPE::Regex::whitespace->new(' '); |
830
|
|
|
|
|
|
|
# / /x |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
=item * Ctext;> |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
Returns the whitespace. |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
print $ws->text; # ' ' |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
=item * Ctype;> |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
Returns the string C. |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
=back |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
=head2 Methods for C |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
This class represents C<(?ismx)> flags. Objects have the following methods: |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
=over 4 |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=item * Cnew($add,$sub);> |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: a string of the |
853
|
|
|
|
|
|
|
modes to have on, and a string of the modes to explicitly turn off. The flags |
854
|
|
|
|
|
|
|
are displayed in alphabetical order. |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
my $flags = YAPE::Regex::flags->new('is','m'); |
857
|
|
|
|
|
|
|
# /(?is-m)/ |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
=item * Ctype;> |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
Returns the string C. |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
=back |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
=head2 Methods for C |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
This class represents the cut assertion. Objects have the following methods: |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=over 4 |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
=item * Cnew(\@nodes);> |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
Creates a C object. Takes one arguments: a reference to an |
874
|
|
|
|
|
|
|
array of objects to be contained in the cut. |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
my $REx = YAPE::Regex::class->new('aeiouy','','+'); |
877
|
|
|
|
|
|
|
my $look = YAPE::Regex::cut->new(0,[$REx]); |
878
|
|
|
|
|
|
|
# /(?>[aeiouy]+)/ |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
=item * Ctype;> |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
Returns the string C. |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
=back |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=head2 Methods for C |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
This class represents lookaheads. Objects have the following methods: |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
=over 4 |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=item * Cnew($pos,\@nodes);> |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: a boolean |
895
|
|
|
|
|
|
|
value indicating whether or not the lookahead is positive, and a reference to an |
896
|
|
|
|
|
|
|
array of objects to be contained in the lookahead. |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
my $REx = YAPE::Regex::class->new('aeiouy'); |
899
|
|
|
|
|
|
|
my $look = YAPE::Regex::lookahead->new(0,[$REx]); |
900
|
|
|
|
|
|
|
# /(?![aeiouy])/ |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
=item * Cpos;> |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
Returns true if the lookahead is positive. |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
print $look->pos ? 'pos' : 'neg'; # 'neg' |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
=item * Ctype;> |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
Returns the string C or C. |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
=back |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
=head2 Methods for C |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
This class represents lookbehinds. Objects have the following methods: |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
=over 4 |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=item * Cnew($pos,\@nodes);> |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: a boolean |
923
|
|
|
|
|
|
|
value indicating whether or not the lookbehind is positive, and a reference to |
924
|
|
|
|
|
|
|
an array of objects to be contained in the lookbehind. |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
my $REx = YAPE::Regex::class->new('aeiouy','^'); |
927
|
|
|
|
|
|
|
my $look = YAPE::Regex::lookbehind->new(1,[$REx]); |
928
|
|
|
|
|
|
|
# /(?<=[^aeiouy])/ |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
=item * Cpos;> |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
Returns true if the lookbehind is positive. |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
print $look->pos ? 'pos' : 'neg'; # 'pos' |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
=item * Ctype;> |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
Returns the string C or C. |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
=back |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
=head2 Methods for C |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
This class represents conditionals. Objects have the following methods: |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
=over 4 |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
=item * Cnew($br,$t,$f,$q,$ng);> |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
Creates a C object. Takes five arguments: the number of the |
951
|
|
|
|
|
|
|
back-reference (that's all that's supported in the current version), an array |
952
|
|
|
|
|
|
|
reference to the "true" pattern, an array reference to the "false" pattern, and |
953
|
|
|
|
|
|
|
the quantity and non-greedy flag. |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
my $cond = YAPE::Regex::conditional->new( |
956
|
|
|
|
|
|
|
2, |
957
|
|
|
|
|
|
|
[], |
958
|
|
|
|
|
|
|
[ YAPE::Regex::text->new('foo') ], |
959
|
|
|
|
|
|
|
'?', |
960
|
|
|
|
|
|
|
); |
961
|
|
|
|
|
|
|
# /(?(2)|foo)?/ |
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
=item * Cbackref;> |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
Returns the number of the back-reference the conditional depends on. |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
print $br->backref; # 2 |
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
=item * Ctype;> |
970
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
Returns the string C)>, where I is the number of the |
972
|
|
|
|
|
|
|
back-reference. |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
=back |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
=head2 Methods for C |
977
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
This class represents non-capturing groups. Objects have the following methods: |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
=over 4 |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=item * Cnew($on,$off,\@nodes,$q,$ng);> |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
Creates a C object. Takes five arguments: the modes turned |
985
|
|
|
|
|
|
|
on, the modes explicitly turned off, a reference to an array of objects in the |
986
|
|
|
|
|
|
|
group, the quantity, and the non-greedy flag. The modes are displayed in |
987
|
|
|
|
|
|
|
alphabetical order. |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
my $group = YAPE::Regex::group->new( |
990
|
|
|
|
|
|
|
'i', |
991
|
|
|
|
|
|
|
's', |
992
|
|
|
|
|
|
|
[ |
993
|
|
|
|
|
|
|
YAPE::Regex::macro->new('d', '{2}'), |
994
|
|
|
|
|
|
|
YAPE::Regex::macro->new('s'), |
995
|
|
|
|
|
|
|
YAPE::Regex::macro->new('d', '{2}'), |
996
|
|
|
|
|
|
|
], |
997
|
|
|
|
|
|
|
'?', |
998
|
|
|
|
|
|
|
); |
999
|
|
|
|
|
|
|
# /(?i-s:\d{2}\s\d{2})?/ |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=item * Ctype;> |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
Returns the string C. |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
=back |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
=head2 Methods for C |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
This class represents capturing groups. Objects have the following methods: |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=over 4 |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
=item * Cnew(\@nodes,$q,$ng);> |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
Creates a C object. Takes three arguments: a reference |
1016
|
|
|
|
|
|
|
to an array of objects in the group, the quantity, and the non-greedy flag. |
1017
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
my $capture = YAPE::Regex::capture->new( |
1019
|
|
|
|
|
|
|
[ |
1020
|
|
|
|
|
|
|
YAPE::Regex::macro->new('d', '{2}'), |
1021
|
|
|
|
|
|
|
YAPE::Regex::macro->new('s'), |
1022
|
|
|
|
|
|
|
YAPE::Regex::macro->new('d', '{2}'), |
1023
|
|
|
|
|
|
|
], |
1024
|
|
|
|
|
|
|
); |
1025
|
|
|
|
|
|
|
# /(\d{2}\s\d{2})/ |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=item * Ctype;> |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
Returns the string C. |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
=back |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
=head2 Methods for C |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
This class represents code blocks. Objects have the following methods: |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
=over 4 |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
=item * Cnew($block);> |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
Creates a C object. Takes one arguments: a string holding |
1042
|
|
|
|
|
|
|
a block of code. |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
my $code = YAPE::Regex::code->new(q({ push @poss, $1 })); |
1045
|
|
|
|
|
|
|
# /(?{ push @poss, $1 })/ |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
=item * Ctype;> |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
Returns the string C. |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=back |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
=head2 Methods for C |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
This class represents closed parentheses. Objects have the following methods: |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
=over 4 |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=item * Cnew($block);> |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
Creates a C object. Takes one arguments: a string holding |
1062
|
|
|
|
|
|
|
a block of code. |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
my $later = YAPE::Regex::later->new(q({ push @poss, $1 })); |
1065
|
|
|
|
|
|
|
# /(?{{ push @poss, $1 }})/ |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
=item * Ctype;> |
1068
|
|
|
|
|
|
|
|
1069
|
|
|
|
|
|
|
Returns the string C. |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
=back |
1072
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
=head2 Methods for C |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
This class represents closed parentheses. Objects have the following methods: |
1076
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
=over 4 |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
=item * Cnew($q,$ng);> |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
Creates a C object. Takes two arguments: the quantity, and |
1082
|
|
|
|
|
|
|
the non-greedy flag. This object is never needed in the tree; however, they are |
1083
|
|
|
|
|
|
|
returned in the parsing stage, so that you know when they've been reached. |
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
my $close = YAPE::Regex::close->new('?','?'); |
1086
|
|
|
|
|
|
|
# /)??/ |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
=item * Ctype;> |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
Returns the string C. |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
=back |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
=head1 TO DO |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
This is a listing of things to add to future versions of this module. |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
=over 4 |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
=item * None! |
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
=back |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
=head1 BUGS |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
Following is a list of known or reported bugs. |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
=over 4 |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
=item * This documentation might be incomplete. |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
=back |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
=head1 SUPPORT |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
Visit C's web site at F. |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
=head1 SEE ALSO |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
The C documentation, for information on the main class. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
=head1 AUTHOR |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
The original author is Jeff "japhy" Pinyan (CPAN ID: PINYAN). |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
Gene Sullivan (gsullivan@cpan.org) is a co-maintainer. |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=head1 LICENSE |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify |
1131
|
|
|
|
|
|
|
it under the same terms as Perl itself. See L. |
1132
|
|
|
|
|
|
|
|
1133
|
|
|
|
|
|
|
=cut |