FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MagicPython/test/atom-spec/python-re-spec.js at master · MagicStack/MagicPython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
MagicStack
/
MagicPython
Public
Notifications
You must be signed in to change notification settings
Fork
98
Star
1.4k
Code
Issues
65
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
MagicPython
/
test
/
atom-spec
/
python-re-spec.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
556 lines (530 loc) · 37 KB
Breadcrumbs
MagicPython
/
test
/
atom-spec
/
python-re-spec.js
Copy path
File metadata and controls
556 lines (530 loc) · 37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
// !!! autogenerated; do not edit !!!
describe
(
"Grammar Tests"
,
function
(
)
{
var
grammar
=
null
;
beforeEach
(
function
(
)
{
waitsForPromise
(
function
(
)
{
return
atom
.
packages
.
activatePackage
(
"MagicPython"
)
}
)
;
runs
(
function
(
)
{
grammar
=
atom
.
grammars
.
grammarForScopeName
(
"source.regexp.python"
)
}
)
;
}
)
;
it
(
"test/regexp/comments1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"foo(?#comment)bar"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"(?#"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"comment"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.end.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/comments2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(?x)\n foo (?#\ncomment 1\n ) bar\n baz (?#comment 2)"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"(?x)"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"storage.modifier.flag.regexp"
]
)
;
expect
(
tokens
[
1
]
[
0
]
.
value
)
.
toBe
(
" foo "
)
;
expect
(
tokens
[
1
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
1
]
[
1
]
.
value
)
.
toBe
(
"(?#"
)
;
expect
(
tokens
[
1
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.begin.regexp"
]
)
;
expect
(
tokens
[
2
]
[
0
]
.
value
)
.
toBe
(
"comment 1"
)
;
expect
(
tokens
[
2
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
]
)
;
expect
(
tokens
[
3
]
[
0
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
3
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
]
)
;
expect
(
tokens
[
3
]
[
1
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
3
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.end.regexp"
]
)
;
expect
(
tokens
[
3
]
[
2
]
.
value
)
.
toBe
(
" bar"
)
;
expect
(
tokens
[
3
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
4
]
[
0
]
.
value
)
.
toBe
(
" baz "
)
;
expect
(
tokens
[
4
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
4
]
[
1
]
.
value
)
.
toBe
(
"(?#"
)
;
expect
(
tokens
[
4
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.begin.regexp"
]
)
;
expect
(
tokens
[
4
]
[
2
]
.
value
)
.
toBe
(
"comment 2"
)
;
expect
(
tokens
[
4
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
]
)
;
expect
(
tokens
[
4
]
[
3
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
4
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/comments3.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"foo(?#NOTE:comment)bar"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"(?#"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"NOTE"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"keyword.codetag.notation.python"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
":comment"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"comment.regexp"
,
"punctuation.comment.end.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/conditional1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(<)?(\\w+@\\w+(?:\\.\\w+)+)(?(1)>|$)"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"<"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"?"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"\\w"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"@"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"\\w"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"(?:"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.non-capturing.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"\\."
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"\\w"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
14
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
14
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.non-capturing.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
15
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
15
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
16
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
16
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
0
]
[
17
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
17
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.conditional.regexp"
,
"punctuation.parenthesis.conditional.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
18
]
.
value
)
.
toBe
(
"?(1)"
)
;
expect
(
tokens
[
0
]
[
18
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.conditional.regexp"
]
)
;
expect
(
tokens
[
0
]
[
19
]
.
value
)
.
toBe
(
">"
)
;
expect
(
tokens
[
0
]
[
19
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
20
]
.
value
)
.
toBe
(
"|"
)
;
expect
(
tokens
[
0
]
[
20
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.disjunction.regexp"
]
)
;
expect
(
tokens
[
0
]
[
21
]
.
value
)
.
toBe
(
"$"
)
;
expect
(
tokens
[
0
]
[
21
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.end.regexp"
]
)
;
expect
(
tokens
[
0
]
[
22
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
22
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.conditional.end.regexp keyword.operator.conditional.negative.regexp"
]
)
;
}
)
;
it
(
"test/regexp/escaping1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"foo\\\nbar"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"\\"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
1
]
[
0
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
1
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/escaping2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"start\\A\\b\\B\\d\\D\\s\\S\\w\\W\\Z\\\\\\1\\01\\1111\\0011\\xfab\\u123fb\\U1234aaaab\\c"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"start"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"\\A"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"\\b"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"\\B"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"\\d"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"\\D"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"\\s"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"\\S"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"\\w"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"\\W"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"\\Z"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"\\\\"
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"\\1"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.backreference.regexp"
,
"entity.name.tag.backreference.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"\\01"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
14
]
.
value
)
.
toBe
(
"\\111"
)
;
expect
(
tokens
[
0
]
[
14
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
15
]
.
value
)
.
toBe
(
"1"
)
;
expect
(
tokens
[
0
]
[
15
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
16
]
.
value
)
.
toBe
(
"\\001"
)
;
expect
(
tokens
[
0
]
[
16
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
17
]
.
value
)
.
toBe
(
"1"
)
;
expect
(
tokens
[
0
]
[
17
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
18
]
.
value
)
.
toBe
(
"\\xfa"
)
;
expect
(
tokens
[
0
]
[
18
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
19
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
19
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
20
]
.
value
)
.
toBe
(
"\\u123f"
)
;
expect
(
tokens
[
0
]
[
20
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.unicode.regexp"
]
)
;
expect
(
tokens
[
0
]
[
21
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
21
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
22
]
.
value
)
.
toBe
(
"\\U1234aaaa"
)
;
expect
(
tokens
[
0
]
[
22
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.unicode.regexp"
]
)
;
expect
(
tokens
[
0
]
[
23
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
23
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
24
]
.
value
)
.
toBe
(
"\\c"
)
;
expect
(
tokens
[
0
]
[
24
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"constant.character.escape.regexp"
]
)
;
}
)
;
it
(
"test/regexp/escaping3.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"[start\\A\\b\\B\\d\\D\\s\\S\\w\\W\\Z\\\\\\1\\01\\1111\\0011\\xfab\\u123fb\\U1234aaaab\\c]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"s"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"t"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"a"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"r"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"t"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"\\A"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"\\b"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"\\B"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"\\d"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"\\D"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"\\s"
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"\\S"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"\\w"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
14
]
.
value
)
.
toBe
(
"\\W"
)
;
expect
(
tokens
[
0
]
[
14
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
15
]
.
value
)
.
toBe
(
"\\Z"
)
;
expect
(
tokens
[
0
]
[
15
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
16
]
.
value
)
.
toBe
(
"\\\\"
)
;
expect
(
tokens
[
0
]
[
16
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
17
]
.
value
)
.
toBe
(
"\\1"
)
;
expect
(
tokens
[
0
]
[
17
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
18
]
.
value
)
.
toBe
(
"\\01"
)
;
expect
(
tokens
[
0
]
[
18
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
19
]
.
value
)
.
toBe
(
"\\111"
)
;
expect
(
tokens
[
0
]
[
19
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
20
]
.
value
)
.
toBe
(
"1"
)
;
expect
(
tokens
[
0
]
[
20
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
21
]
.
value
)
.
toBe
(
"\\001"
)
;
expect
(
tokens
[
0
]
[
21
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
22
]
.
value
)
.
toBe
(
"1"
)
;
expect
(
tokens
[
0
]
[
22
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
23
]
.
value
)
.
toBe
(
"\\xfa"
)
;
expect
(
tokens
[
0
]
[
23
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
24
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
24
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
25
]
.
value
)
.
toBe
(
"\\u123f"
)
;
expect
(
tokens
[
0
]
[
25
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.unicode.regexp"
]
)
;
expect
(
tokens
[
0
]
[
26
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
26
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
27
]
.
value
)
.
toBe
(
"\\U1234aaaa"
)
;
expect
(
tokens
[
0
]
[
27
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.unicode.regexp"
]
)
;
expect
(
tokens
[
0
]
[
28
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
28
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
29
]
.
value
)
.
toBe
(
"\\c"
)
;
expect
(
tokens
[
0
]
[
29
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
30
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
30
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/escaping4.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"[start\\a\\b\\c\\d\\f\\n\\r\\t\\v]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"s"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"t"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"a"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"r"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"t"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"\\a"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"\\b"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"\\c"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"\\d"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"support.other.escape.special.regexp"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"\\f"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"\\n"
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"\\r"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"\\t"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
14
]
.
value
)
.
toBe
(
"\\v"
)
;
expect
(
tokens
[
0
]
[
14
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
15
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
15
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/flags1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(?aiLmsux)foo"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"(?aiLmsux)"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"storage.modifier.flag.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/group1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(?x)\n (?:not) (foo)\n .* (?P<bar>BAR)\n \\1 (?P=bar)"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"(?x)"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"storage.modifier.flag.regexp"
]
)
;
expect
(
tokens
[
1
]
[
0
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
1
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
1
]
[
1
]
.
value
)
.
toBe
(
"(?:"
)
;
expect
(
tokens
[
1
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.non-capturing.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
1
]
[
2
]
.
value
)
.
toBe
(
"not"
)
;
expect
(
tokens
[
1
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
1
]
[
3
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
1
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.non-capturing.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
1
]
[
4
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
1
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
1
]
[
5
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
1
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
1
]
[
6
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
1
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
1
]
[
7
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
1
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
2
]
[
0
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
2
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
2
]
[
1
]
.
value
)
.
toBe
(
"."
)
;
expect
(
tokens
[
2
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.any.regexp"
]
)
;
expect
(
tokens
[
2
]
[
2
]
.
value
)
.
toBe
(
"*"
)
;
expect
(
tokens
[
2
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
2
]
[
3
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
2
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
2
]
[
4
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
2
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.named.regexp"
,
"punctuation.parenthesis.named.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
2
]
[
5
]
.
value
)
.
toBe
(
"?P<bar>"
)
;
expect
(
tokens
[
2
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.named.regexp"
,
"entity.name.tag.named.group.regexp"
]
)
;
expect
(
tokens
[
2
]
[
6
]
.
value
)
.
toBe
(
"BAR"
)
;
expect
(
tokens
[
2
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.named.regexp"
]
)
;
expect
(
tokens
[
2
]
[
7
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
2
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.named.regexp"
,
"punctuation.parenthesis.named.end.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
3
]
[
0
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
3
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
3
]
[
1
]
.
value
)
.
toBe
(
"\\1"
)
;
expect
(
tokens
[
3
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.backreference.regexp"
,
"entity.name.tag.backreference.regexp"
]
)
;
expect
(
tokens
[
3
]
[
2
]
.
value
)
.
toBe
(
" "
)
;
expect
(
tokens
[
3
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
3
]
[
3
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
3
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.backreference.named.regexp"
,
"punctuation.parenthesis.backreference.named.begin.regexp support.other.parenthesis.regexp"
]
)
;
expect
(
tokens
[
3
]
[
4
]
.
value
)
.
toBe
(
"?P=bar"
)
;
expect
(
tokens
[
3
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.backreference.named.regexp"
,
"entity.name.tag.named.backreference.regexp"
]
)
;
expect
(
tokens
[
3
]
[
5
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
3
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.backreference.named.regexp"
,
"punctuation.parenthesis.backreference.named.end.regexp support.other.parenthesis.regexp"
]
)
;
}
)
;
it
(
"test/regexp/lookahead1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"foo(?=bar)"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookahead.regexp"
,
"punctuation.parenthesis.lookahead.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"?="
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookahead.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.regexp"
]
)
;
}
)
;
it
(
"test/regexp/lookahead2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"foo(?!bar)"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookahead.negative.regexp"
,
"punctuation.parenthesis.lookahead.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"?!"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookahead.negative.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.lookahead.end.regexp keyword.operator.lookahead.negative.regexp"
]
)
;
}
)
;
it
(
"test/regexp/lookbehind1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(?<=foo)bar"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookbehind.regexp"
,
"punctuation.parenthesis.lookbehind.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"?<="
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookbehind.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.lookbehind.end.regexp keyword.operator.lookbehind.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/lookbehind2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"(?<!foo)bar"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookbehind.negative.regexp"
,
"punctuation.parenthesis.lookbehind.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"?<!"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.lookbehind.negative.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"foo"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"punctuation.parenthesis.lookbehind.end.regexp keyword.operator.lookbehind.negative.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"bar"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
it
(
"test/regexp/quantifiers1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"^a+b*c?d*?e+?f??$"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"a"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"*"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"c"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"?"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"d"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"*?"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"e"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"+?"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"f"
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"??"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"$"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/quantifiers2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"^a{10}b{,10}c{10,}d{10,100}$"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"a"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"{10}"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"b"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"{,10}"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"c"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"{10,}"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"d"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"{10,100}"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"keyword.operator.quantifier.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"$"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/set1.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"[]]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/set2.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"[^]]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"keyword.operator.negation.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/set3.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"[][(){}|*+?.\\]\\\\]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"("
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
")"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
5
]
.
value
)
.
toBe
(
"{"
)
;
expect
(
tokens
[
0
]
[
5
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
6
]
.
value
)
.
toBe
(
"}"
)
;
expect
(
tokens
[
0
]
[
6
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
7
]
.
value
)
.
toBe
(
"|"
)
;
expect
(
tokens
[
0
]
[
7
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
8
]
.
value
)
.
toBe
(
"*"
)
;
expect
(
tokens
[
0
]
[
8
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
9
]
.
value
)
.
toBe
(
"+"
)
;
expect
(
tokens
[
0
]
[
9
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
10
]
.
value
)
.
toBe
(
"?"
)
;
expect
(
tokens
[
0
]
[
10
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
11
]
.
value
)
.
toBe
(
"."
)
;
expect
(
tokens
[
0
]
[
11
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
12
]
.
value
)
.
toBe
(
"\\]"
)
;
expect
(
tokens
[
0
]
[
12
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
13
]
.
value
)
.
toBe
(
"\\\\"
)
;
expect
(
tokens
[
0
]
[
13
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.escape.regexp"
]
)
;
expect
(
tokens
[
0
]
[
14
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
14
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/set4.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"^[^^]"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"support.other.match.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
1
]
.
value
)
.
toBe
(
"["
)
;
expect
(
tokens
[
0
]
[
1
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.begin.regexp"
]
)
;
expect
(
tokens
[
0
]
[
2
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
2
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"keyword.operator.negation.regexp"
]
)
;
expect
(
tokens
[
0
]
[
3
]
.
value
)
.
toBe
(
"^"
)
;
expect
(
tokens
[
0
]
[
3
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.character.set.regexp"
]
)
;
expect
(
tokens
[
0
]
[
4
]
.
value
)
.
toBe
(
"]"
)
;
expect
(
tokens
[
0
]
[
4
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
,
"meta.character.set.regexp"
,
"constant.other.set.regexp punctuation.character.set.end.regexp"
]
)
;
}
)
;
it
(
"test/regexp/trivial.re"
,
function
(
)
{
tokens
=
grammar
.
tokenizeLines
(
"trivial"
)
expect
(
tokens
[
0
]
[
0
]
.
value
)
.
toBe
(
"trivial"
)
;
expect
(
tokens
[
0
]
[
0
]
.
scopes
)
.
toEqual
(
[
"source.regexp.python"
]
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL