1
/* Generated by re2rust 4.1 */
2
3
use std::collections::VecDeque;
4
5
use crate::Token;
6
7
const YYC_INIT: usize = 0;
8
const YYC_STR: usize = 26;
9
10
11
pub fn lex(input: &str) -> (VecDeque<Token>, Option<usize>) {
12
let bx = input.as_bytes();
13
let len = bx.len();
14
15
let mut cursor = 0;
16
let mut marker = 0;
17
let mut cond = YYC_INIT;
18
19
let mut tx = VecDeque::new();
20
21
#[allow(unused_mut)]
22
let mut t1;
23
24
let mut yyt1 = std::usize::MAX;
25
26
'lex: loop {
27
{
28
#[allow(unused_assignments)]
29
let mut yych : u8 = 0;
30
let mut yyaccept : usize = 0;
31
let mut yystate : usize = cond;
32
'yyl: loop {
33
match yystate {
34
0 => {
35
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
36
match yych {
37
0x00 => {
38
cursor += 1;
39
yystate = 1;
40
continue 'yyl;
41
}
42
0x09 ..= 0x0A |
43
0x0D |
44
0x20 => {
45
cursor += 1;
46
yystate = 4;
47
continue 'yyl;
48
}
49
0x22 => {
50
cursor += 1;
51
yystate = 5;
52
continue 'yyl;
53
}
54
0x28 => {
55
cursor += 1;
56
yystate = 6;
57
continue 'yyl;
58
}
59
0x29 => {
60
cursor += 1;
61
yystate = 7;
62
continue 'yyl;
63
}
64
0x2C => {
65
cursor += 1;
66
yystate = 8;
67
continue 'yyl;
68
}
69
0x2D => {
70
yyt1 = cursor;
71
cursor += 1;
72
yystate = 9;
73
continue 'yyl;
74
}
75
0x2E => {
76
yyt1 = cursor;
77
cursor += 1;
78
yystate = 10;
79
continue 'yyl;
80
}
81
0x30 ..= 0x39 => {
82
yyt1 = cursor;
83
cursor += 1;
84
yystate = 12;
85
continue 'yyl;
86
}
87
0x41 ..= 0x5A |
88
0x61 ..= 0x7A => {
89
yyt1 = cursor;
90
cursor += 1;
91
yystate = 14;
92
continue 'yyl;
93
}
94
0x5B => {
95
cursor += 1;
96
yystate = 16;
97
continue 'yyl;
98
}
99
0x5D => {
100
cursor += 1;
101
yystate = 17;
102
continue 'yyl;
103
}
104
_ => {
105
cursor += 1;
106
yystate = 2;
107
continue 'yyl;
108
}
109
}
110
}
111
1 => {
112
return (tx, None);
113
},
114
2 => {
115
yystate = 3;
116
continue 'yyl;
117
}
118
3 => { return (tx, Some(cursor - 1)); },
119
4 => { continue 'lex; },
120
5 => {
121
cond = YYC_STR;
122
{ tx.push_back(Token::StringOpen); continue 'lex; }
123
}
124
6 => { tx.push_back(Token::LeftParenthesis); continue 'lex; },
125
7 => { tx.push_back(Token::RightParenthesis); continue 'lex; },
126
8 => { tx.push_back(Token::Comma); continue 'lex; },
127
9 => {
128
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
129
match yych {
130
0x2E => {
131
cursor += 1;
132
yystate = 10;
133
continue 'yyl;
134
}
135
0x30 ..= 0x39 => {
136
cursor += 1;
137
yystate = 12;
138
continue 'yyl;
139
}
140
_ => {
141
yystate = 3;
142
continue 'yyl;
143
}
144
}
145
}
146
10 => {
147
yyaccept = 0;
148
marker = cursor;
149
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
150
match yych {
151
0x30 ..= 0x39 => {
152
cursor += 1;
153
yystate = 10;
154
continue 'yyl;
155
}
156
0x45 |
157
0x65 => {
158
cursor += 1;
159
yystate = 18;
160
continue 'yyl;
161
}
162
_ => {
163
yystate = 11;
164
continue 'yyl;
165
}
166
}
167
}
168
11 => {
169
t1 = yyt1;
170
{
171
tx.push_back(Token::Number(unsafe { std::str::from_utf8_unchecked(&bx[t1..cursor]) }.to_string()));
172
continue 'lex;
173
}
174
}
175
12 => {
176
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
177
match yych {
178
0x2E => {
179
cursor += 1;
180
yystate = 20;
181
continue 'yyl;
182
}
183
0x30 ..= 0x39 => {
184
cursor += 1;
185
yystate = 12;
186
continue 'yyl;
187
}
188
_ => {
189
yystate = 13;
190
continue 'yyl;
191
}
192
}
193
}
194
13 => {
195
t1 = yyt1;
196
{
197
tx.push_back(Token::Number(unsafe { std::str::from_utf8_unchecked(&bx[t1..cursor]) }.to_string()));
198
continue 'lex;
199
}
200
}
201
14 => {
202
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
203
match yych {
204
0x41 ..= 0x5A |
205
0x61 ..= 0x7A => {
206
cursor += 1;
207
yystate = 14;
208
continue 'yyl;
209
}
210
_ => {
211
yystate = 15;
212
continue 'yyl;
213
}
214
}
215
}
216
15 => {
217
t1 = yyt1;
218
{
219
tx.push_back(Token::Symbol(unsafe { std::str::from_utf8_unchecked(&bx[t1..cursor]) }.to_string()));
220
continue 'lex;
221
}
222
}
223
16 => { tx.push_back(Token::LeftBracket); continue 'lex; },
224
17 => { tx.push_back(Token::RightBracket); continue 'lex; },
225
18 => {
226
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
227
match yych {
228
0x2D => {
229
cursor += 1;
230
yystate = 21;
231
continue 'yyl;
232
}
233
0x30 ..= 0x39 => {
234
cursor += 1;
235
yystate = 22;
236
continue 'yyl;
237
}
238
_ => {
239
yystate = 19;
240
continue 'yyl;
241
}
242
}
243
}
244
19 => {
245
cursor = marker;
246
if yyaccept == 0 {
247
yystate = 11;
248
continue 'yyl;
249
} else {
250
yystate = 13;
251
continue 'yyl;
252
}
253
}
254
20 => {
255
yyaccept = 1;
256
marker = cursor;
257
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
258
match yych {
259
0x30 ..= 0x39 => {
260
cursor += 1;
261
yystate = 20;
262
continue 'yyl;
263
}
264
0x45 |
265
0x65 => {
266
cursor += 1;
267
yystate = 23;
268
continue 'yyl;
269
}
270
_ => {
271
yystate = 13;
272
continue 'yyl;
273
}
274
}
275
}
276
21 => {
277
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
278
match yych {
279
0x30 ..= 0x39 => {
280
cursor += 1;
281
yystate = 22;
282
continue 'yyl;
283
}
284
_ => {
285
yystate = 19;
286
continue 'yyl;
287
}
288
}
289
}
290
22 => {
291
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
292
match yych {
293
0x30 ..= 0x39 => {
294
cursor += 1;
295
yystate = 22;
296
continue 'yyl;
297
}
298
_ => {
299
yystate = 11;
300
continue 'yyl;
301
}
302
}
303
}
304
23 => {
305
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
306
match yych {
307
0x2D => {
308
cursor += 1;
309
yystate = 24;
310
continue 'yyl;
311
}
312
0x30 ..= 0x39 => {
313
cursor += 1;
314
yystate = 25;
315
continue 'yyl;
316
}
317
_ => {
318
yystate = 19;
319
continue 'yyl;
320
}
321
}
322
}
323
24 => {
324
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
325
match yych {
326
0x30 ..= 0x39 => {
327
cursor += 1;
328
yystate = 25;
329
continue 'yyl;
330
}
331
_ => {
332
yystate = 19;
333
continue 'yyl;
334
}
335
}
336
}
337
25 => {
338
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
339
match yych {
340
0x30 ..= 0x39 => {
341
cursor += 1;
342
yystate = 25;
343
continue 'yyl;
344
}
345
_ => {
346
yystate = 13;
347
continue 'yyl;
348
}
349
}
350
}
351
26 => {
352
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
353
match yych {
354
0x01 ..= 0x21 |
355
0x23 ..= 0x5B |
356
0x5D ..= 0x7F => {
357
yyt1 = cursor;
358
cursor += 1;
359
yystate = 29;
360
continue 'yyl;
361
}
362
0x22 => {
363
cursor += 1;
364
yystate = 32;
365
continue 'yyl;
366
}
367
0x5C => {
368
yyt1 = cursor;
369
cursor += 1;
370
yystate = 33;
371
continue 'yyl;
372
}
373
0xC2 ..= 0xDF => {
374
yyt1 = cursor;
375
cursor += 1;
376
yystate = 34;
377
continue 'yyl;
378
}
379
0xE0 => {
380
yyt1 = cursor;
381
cursor += 1;
382
yystate = 35;
383
continue 'yyl;
384
}
385
0xE1 ..= 0xEC |
386
0xEE ..= 0xEF => {
387
yyt1 = cursor;
388
cursor += 1;
389
yystate = 36;
390
continue 'yyl;
391
}
392
0xED => {
393
yyt1 = cursor;
394
cursor += 1;
395
yystate = 37;
396
continue 'yyl;
397
}
398
0xF0 => {
399
yyt1 = cursor;
400
cursor += 1;
401
yystate = 38;
402
continue 'yyl;
403
}
404
0xF1 ..= 0xF3 => {
405
yyt1 = cursor;
406
cursor += 1;
407
yystate = 39;
408
continue 'yyl;
409
}
410
0xF4 => {
411
yyt1 = cursor;
412
cursor += 1;
413
yystate = 40;
414
continue 'yyl;
415
}
416
_ => {
417
cursor += 1;
418
yystate = 27;
419
continue 'yyl;
420
}
421
}
422
}
423
27 => {
424
yystate = 28;
425
continue 'yyl;
426
}
427
28 => { return (tx, Some(cursor - 1)); },
428
29 => {
429
yyaccept = 0;
430
marker = cursor;
431
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
432
yystate = 30;
433
continue 'yyl;
434
}
435
30 => {
436
match yych {
437
0x01 ..= 0x21 |
438
0x23 ..= 0x7F => {
439
cursor += 1;
440
yystate = 29;
441
continue 'yyl;
442
}
443
0xC2 ..= 0xDF => {
444
cursor += 1;
445
yystate = 41;
446
continue 'yyl;
447
}
448
0xE0 => {
449
cursor += 1;
450
yystate = 43;
451
continue 'yyl;
452
}
453
0xE1 ..= 0xEC |
454
0xEE ..= 0xEF => {
455
cursor += 1;
456
yystate = 44;
457
continue 'yyl;
458
}
459
0xED => {
460
cursor += 1;
461
yystate = 45;
462
continue 'yyl;
463
}
464
0xF0 => {
465
cursor += 1;
466
yystate = 46;
467
continue 'yyl;
468
}
469
0xF1 ..= 0xF3 => {
470
cursor += 1;
471
yystate = 47;
472
continue 'yyl;
473
}
474
0xF4 => {
475
cursor += 1;
476
yystate = 48;
477
continue 'yyl;
478
}
479
_ => {
480
yystate = 31;
481
continue 'yyl;
482
}
483
}
484
}
485
31 => {
486
t1 = yyt1;
487
{
488
tx.push_back(Token::StringLiteralContent(unsafe { std::str::from_utf8_unchecked(&bx[t1..cursor]) }.to_string()));
489
continue 'lex;
490
}
491
}
492
32 => {
493
cond = YYC_INIT;
494
{ tx.push_back(Token::StringClose); continue 'lex; }
495
}
496
33 => {
497
yyaccept = 0;
498
marker = cursor;
499
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
500
match yych {
501
0x22 => {
502
cursor += 1;
503
yystate = 49;
504
continue 'yyl;
505
}
506
_ => {
507
yystate = 30;
508
continue 'yyl;
509
}
510
}
511
}
512
34 => {
513
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
514
match yych {
515
0x80 ..= 0xBF => {
516
cursor += 1;
517
yystate = 29;
518
continue 'yyl;
519
}
520
_ => {
521
yystate = 28;
522
continue 'yyl;
523
}
524
}
525
}
526
35 => {
527
yyaccept = 1;
528
marker = cursor;
529
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
530
match yych {
531
0xA0 ..= 0xBF => {
532
cursor += 1;
533
yystate = 41;
534
continue 'yyl;
535
}
536
_ => {
537
yystate = 28;
538
continue 'yyl;
539
}
540
}
541
}
542
36 => {
543
yyaccept = 1;
544
marker = cursor;
545
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
546
match yych {
547
0x80 ..= 0xBF => {
548
cursor += 1;
549
yystate = 41;
550
continue 'yyl;
551
}
552
_ => {
553
yystate = 28;
554
continue 'yyl;
555
}
556
}
557
}
558
37 => {
559
yyaccept = 1;
560
marker = cursor;
561
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
562
match yych {
563
0x80 ..= 0x9F => {
564
cursor += 1;
565
yystate = 41;
566
continue 'yyl;
567
}
568
_ => {
569
yystate = 28;
570
continue 'yyl;
571
}
572
}
573
}
574
38 => {
575
yyaccept = 1;
576
marker = cursor;
577
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
578
match yych {
579
0x90 ..= 0xBF => {
580
cursor += 1;
581
yystate = 44;
582
continue 'yyl;
583
}
584
_ => {
585
yystate = 28;
586
continue 'yyl;
587
}
588
}
589
}
590
39 => {
591
yyaccept = 1;
592
marker = cursor;
593
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
594
match yych {
595
0x80 ..= 0xBF => {
596
cursor += 1;
597
yystate = 44;
598
continue 'yyl;
599
}
600
_ => {
601
yystate = 28;
602
continue 'yyl;
603
}
604
}
605
}
606
40 => {
607
yyaccept = 1;
608
marker = cursor;
609
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
610
match yych {
611
0x80 ..= 0x8F => {
612
cursor += 1;
613
yystate = 44;
614
continue 'yyl;
615
}
616
_ => {
617
yystate = 28;
618
continue 'yyl;
619
}
620
}
621
}
622
41 => {
623
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
624
match yych {
625
0x80 ..= 0xBF => {
626
cursor += 1;
627
yystate = 29;
628
continue 'yyl;
629
}
630
_ => {
631
yystate = 42;
632
continue 'yyl;
633
}
634
}
635
}
636
42 => {
637
cursor = marker;
638
if yyaccept == 0 {
639
yystate = 31;
640
continue 'yyl;
641
} else {
642
yystate = 28;
643
continue 'yyl;
644
}
645
}
646
43 => {
647
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
648
match yych {
649
0xA0 ..= 0xBF => {
650
cursor += 1;
651
yystate = 41;
652
continue 'yyl;
653
}
654
_ => {
655
yystate = 42;
656
continue 'yyl;
657
}
658
}
659
}
660
44 => {
661
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
662
match yych {
663
0x80 ..= 0xBF => {
664
cursor += 1;
665
yystate = 41;
666
continue 'yyl;
667
}
668
_ => {
669
yystate = 42;
670
continue 'yyl;
671
}
672
}
673
}
674
45 => {
675
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
676
match yych {
677
0x80 ..= 0x9F => {
678
cursor += 1;
679
yystate = 41;
680
continue 'yyl;
681
}
682
_ => {
683
yystate = 42;
684
continue 'yyl;
685
}
686
}
687
}
688
46 => {
689
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
690
match yych {
691
0x90 ..= 0xBF => {
692
cursor += 1;
693
yystate = 44;
694
continue 'yyl;
695
}
696
_ => {
697
yystate = 42;
698
continue 'yyl;
699
}
700
}
701
}
702
47 => {
703
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
704
match yych {
705
0x80 ..= 0xBF => {
706
cursor += 1;
707
yystate = 44;
708
continue 'yyl;
709
}
710
_ => {
711
yystate = 42;
712
continue 'yyl;
713
}
714
}
715
}
716
48 => {
717
yych = unsafe {if cursor < len { *bx.get_unchecked(cursor) } else { 0 }};
718
match yych {
719
0x80 ..= 0x8F => {
720
cursor += 1;
721
yystate = 44;
722
continue 'yyl;
723
}
724
_ => {
725
yystate = 42;
726
continue 'yyl;
727
}
728
}
729
}
730
49 => {
731
t1 = yyt1;
732
{
733
tx.push_back(Token::StringLiteralContent(unsafe { std::str::from_utf8_unchecked(&bx[t1..cursor]) }.to_string()));
734
continue 'lex;
735
}
736
}
737
_ => panic!("internal lexer error"),
738
}
739
}
740
}
741
}
742
}
743