File: rx_quantifiers

package info (click to toggle)
nqp 2022.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,436 kB
  • sloc: java: 28,030; perl: 3,394; ansic: 451; makefile: 200; javascript: 68; sh: 1
file content (190 lines) | stat: -rw-r--r-- 6,435 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
##  Quantifiers

xa*			xaaaay		<xaaaa @ 0>	star 2+
xa*			xay		<xa @ 0>	star 1
xa*			xy		<x @ 0>		star 0
xa*y			xaaaay		<xaaaay @ 0>	star 2+
xa*y			xay		<xay @ 0>	star 1
xa*y			xy		<xy @ 0>	star 0

xa+			xaaaay		<xaaaa @ 0>	plus 2+
xa+			xay		<xa @ 0>	plus 1
xa+			xy		n		plus 0
xa+y			xaaaay		<xaaaay @ 0>	plus 2+
xa+y			xay		<xay @ 0>	plus 1
xa+y			xy		n		plus 0

xa?			xaaaay		<xa @ 0>	ques 2+
xa?			xay		<xa @ 0>	ques 1
xa?			xy		<x @ 0>		ques 0
xa?y			xaaaay		n		ques 2+
xa?y			xay		<xay @ 0>	ques 1
xa?y			xy		<xy @ 0>	ques 0

xa*!			xaaaay		<xaaaa @ 0>	star greedy 2+
xa*!			xay		<xa @ 0>	star greedy 1
xa*!			xy		<x @ 0>	star greedy 0
xa*!y			xaaaay		<xaaaay @ 0>	star greedy 2+
xa*!y			xay		<xay @ 0>	star greedy 1
xa*!y			xy		<xy @ 0>	star greedy 0

xa+!			xaaaay		<xaaaa @ 0>	plus greedy 2+
xa+!			xay		<xa @ 0>	plus greedy 1
xa+!			xy		n		plus greedy 0
xa+!y			xaaaay		<xaaaay @ 0>	plus greedy 2+
xa+!y			xay		<xay @ 0>	plus greedy 1
xa+!y			xy		n		plus greedy 0

xa?!			xaaaay		<xa @ 0>	ques greedy 2+
xa?!			xay		<xa @ 0>	ques greedy 1
xa?!			xy		<x @ 0>	ques greedy 0
xa?!y			xaaaay		n		ques greedy 2+
xa?!y			xay		<xay @ 0>	ques greedy 1
xa?!y			xy		<xy @ 0>	ques greedy 0

xa*:!			xaaaay		<xaaaa @ 0>	star :greedy 2+
xa*:!			xay		<xa @ 0>	star :greedy 1
xa*:!			xy		<x @ 0>	star :greedy 0
xa*:!y			xaaaay		<xaaaay @ 0>	star :greedy 2+
xa*:!y			xay		<xay @ 0>	star :greedy 1
xa*:!y			xy		<xy @ 0>	star :greedy 0

xa+:!			xaaaay		<xaaaa @ 0>	plus :greedy 2+
xa+:!			xay		<xa @ 0>	plus :greedy 1
xa+:!			xy		n		plus :greedy 0
xa+:!y			xaaaay		<xaaaay @ 0>	plus :greedy 2+
xa+:!y			xay		<xay @ 0>	plus :greedy 1
xa+:!y			xy		n		plus :greedy 0

xa?:!			xaaaay		<xa @ 0>	ques :greedy 2+
xa?:!			xay		<xa @ 0>	ques :greedy 1
xa?:!			xy		<x @ 0>	ques :greedy 0
xa?:!y			xaaaay		n		ques :greedy 2+
xa?:!y			xay		<xay @ 0>	ques :greedy 1
xa?:!y			xy		<xy @ 0>	ques :greedy 0

xa*?			xaaaay		<x @ 0>	star eager 2+
xa*?			xay		<x @ 0>	star eager 1
xa*?			xy		<x @ 0>	star eager 0
xa*?y			xaaaay		<xaaaay @ 0>	star eager 2+
xa*?y			xay		<xay @ 0>	star eager 1
xa*?y			xy		<xy @ 0>	star eager 0

xa+?			xaaaay		<xa @ 0>	plus eager 2+
xa+?			xay		<xa @ 0>	plus eager 1
xa+?			xy		n		plus eager 0
xa+?y			xaaaay		<xaaaay @ 0>	plus eager 2+
xa+?y			xay		<xay @ 0>	plus eager 1
xa+?y			xy		n		plus eager 0

xa??			xaaaay		<x @ 0>	ques eager 2+
xa??			xay		<x @ 0>	ques eager 1
xa??			xy		<x @ 0>	ques eager 0
xa??y			xaaaay		n		ques eager 2+
xa??y			xay		<xay @ 0>	ques eager 1
xa??y			xy		<xy @ 0>	ques eager 0

xa*:?			xaaaay		<x @ 0>	star :eager 2+
xa*:?			xay		<x @ 0>	star :eager 1
xa*:?			xy		<x @ 0>	star :eager 0
xa*:?y			xaaaay		<xaaaay @ 0>	star :eager 2+
xa*:?y			xay		<xay @ 0>	star :eager 1
xa*:?y			xy		<xy @ 0>	star :eager 0

xa+:?			xaaaay		<xa @ 0>	plus :eager 2+
xa+:?			xay		<xa @ 0>	plus :eager 1
xa+:?			xy		n		plus :eager 0
xa+:?y			xaaaay		<xaaaay @ 0>	plus :eager 2+
xa+:?y			xay		<xay @ 0>	plus :eager 1
xa+:?y			xy		n		plus :eager 0

xa?:?			xaaaay		<x @ 0>	ques :eager 2+
xa?:?			xay		<x @ 0>	ques :eager 1
xa?:?			xy		<x @ 0>	ques :eager 0
xa?:?y			xaaaay		n		ques :eager 2+
xa?:?y			xay		<xay @ 0>	ques :eager 1
xa?:?y			xy		<xy @ 0>	ques :eager 0

xa*:y			xaaaay		<xaaaay @ 0>	star cut 2+
xa*:y			xay		<xay @ 0>	star cut 1
xa*:y			xy		<xy @ 0>	star cut 0
xa*:a			xaaaay		n		star cut 2+
xa*:a			xay		n		star cut 1

xa+:y			xaaaay		<xaaaay @ 0>	plus cut 2+
xa+:y			xay		<xay @ 0>	plus cut 1
xa+:y			xy		n		plus cut 0
xa+:a			xaaaay		n		plus cut 2+
xa+:a			xay		n		plus cut 1

xa?:y			xaaaay		n		ques cut 2+
xa?:y			xay		<xay @ 0>	ques cut 1
xa?:y			xy		<xy @ 0>	ques cut 0
xa?:a			xaaaay		<xaa @ 0>	ques cut 2+
xa?:a			xay		n		ques cut 1

:ratchet xa*y			xaaaay		<xaaaay @ 0>	star ratchet 2+
:ratchet xa*y			xay		<xay @ 0>	star ratchet 1
:ratchet xa*y			xy		<xy @ 0>	star ratchet 0
:ratchet xa*a			xaaaay		n		star ratchet 2+
:ratchet xa*a			xay		n		star ratchet 1

:ratchet xa+y			xaaaay		<xaaaay @ 0>	plus ratchet 2+
:ratchet xa+y			xay		<xay @ 0>	plus ratchet 1
:ratchet xa+y			xy		n		plus ratchet 0
:ratchet xa+a			xaaaay		n		plus ratchet 2+
:ratchet xa+a			xay		n		plus ratchet 1

:ratchet xa?y			xaaaay		n		ques ratchet 2+
:ratchet xa?y			xay		<xay @ 0>	ques ratchet 1
:ratchet xa?y			xy		<xy @ 0>	ques ratchet 0
:ratchet xa?a			xaaaay		<xaa @ 0>	ques ratchet 2+
:ratchet xa?a			xay		n		ques ratchet 1

:ratchet xa*!y			xaaaay		<xaaaay @ 0>	star ratchet greedy 2+
:ratchet xa*!y			xay		<xay @ 0>	star ratchet greedy 1
:ratchet xa*!y			xy		<xy @ 0>	star ratchet greedy 0
:ratchet xa*!a			xaaaay		<xaaaa @ 0>	star ratchet greedy 2+
:ratchet xa*!a			xay		<xa @ 0>	star ratchet greedy 1

:ratchet xa+!y			xaaaay		<xaaaay @ 0>	plus ratchet greedy 2+
:ratchet xa+!y			xay		<xay @ 0>	plus ratchet greedy 1
:ratchet xa+!y			xy		n		plus ratchet greedy 0
:ratchet xa+!a			xaaaay		<xaaaa @ 0>	plus ratchet greedy 2+
:ratchet xa+!a			xay		n		plus ratchet greedy 1

:ratchet xa?!y			xaaaay		n		ques ratchet greedy 2+
:ratchet xa?!y			xay		<xay @ 0>	ques ratchet greedy 1
:ratchet xa?!y			xy		<xy @ 0>	ques ratchet greedy 0
:ratchet xa?!a			xaaaay		<xaa @ 0>	ques ratchet greedy 2+
:ratchet xa?!a			xay		<xa @ 0>	ques ratchet greedy 1


## Quantifier bare range
.**2			a			n	only one character
.**2			ab			y	two characters
a**2			foobar		n	only one "a" character
a**2			baabaa		y	two "a" characters
a**0..4			bbbbbbb		y	no "a" characters
a**2..4			bababab		n	not two consecutive "a" characters
a**2..4			baabbbb		y	two "a" characters
a**0b10..0b100		baabbbb		y	two "a" characters (using binary representation)
a**2..4			baaabbb		y	three "a" characters
a**2..4			baaaabb		y	four "a" characters
a**2..4			baaaaaa		y	four "a" characters
a**2..*			baaaaaa		y	six "a" characters
a**?2..*		baaaaaa		y	two "a" characters (non-greedy)
a**:?2..*		baaaaaa		y	two "a" characters (non-greedy)
a**!2..*		baaaaaa		y	six "a" characters (explicit greed)
a**:!2..*		baaaaaa		y	six "a" characters (explicit greed)
a**?2..4		baaabbb		y	two "a" characters (non-greedy)
a**:?2..4		baaabbb		y	two "a" characters (non-greedy)
a**!2..4		baaabbb		y	three "a" characters (explicit greed)
a**:!2..4		baaabbb		y	three "a" characters (explicit greed)
xa**0			xaa		<x @ 0>	nothing matched by ** 0
xa**0..0		xaa		<x @ 0>	nothing matched by ** 0..0
a**^10			aaaaaaaaa	y	9 "a" characters
a**^10			bbbbbbbb	y	no "a" characters
a**1..^10		bbaaaaaaaaa	y	9 "a" characters
a**2..^10		bba			n	only 1 "a" characters
a**1^..^10		bba			n	only 1 "a" characters