1 using System;
2 using System.Lex;
3 using UriTokens;
4
5
6
7 public class UriLexer : System.Lex.Lexer
8 {
9 public UriLexer(const ustring& content_, const string& fileName_, int fileIndex_) :
10 base(content_, fileName_, fileIndex_)
11 {
12 UriClassMap.Init();
13 }
14 public UriLexer(const uchar* start_, const uchar* end_, const string& fileName_, int fileIndex_) :
15 base(start_, end_, fileName_, fileIndex_)
16 {
17 UriClassMap.Init();
18 }
19 public override int NextState(int state, uchar c)
20 {
21 int i = UriClassMap.GetClass(c);
22 switch (state)
23 {
24 case 0:
25 {
26 switch (i)
27 {
28 case 2:
29 {
30 return 1;
31 }
32 case 3:
33 {
34 return 2;
35 }
36 case 4:
37 {
38 return 3;
39 }
40 case 5:
41 {
42 return 4;
43 }
44 case 6:
45 {
46 return 5;
47 }
48 case 7:
49 {
50 return 6;
51 }
52 case 8:
53 {
54 return 7;
55 }
56 case 9:
57 {
58 return 8;
59 }
60 case 10:
61 {
62 return 9;
63 }
64 case 11:
65 {
66 return 10;
67 }
68 case 12:
69 {
70 return 11;
71 }
72 case 13:
73 {
74 return 12;
75 }
76 case 14:
77 {
78 return 13;
79 }
80 case 15:
81 {
82 return 14;
83 }
84 case 16:
85 {
86 return 15;
87 }
88 case 17:
89 {
90 return 16;
91 }
92 case 18:
93 {
94 return 17;
95 }
96 case 19:
97 {
98 return 18;
99 }
100 case 20:
101 {
102 return 19;
103 }
104 case 21:
105 {
106 return 20;
107 }
108 case 22:
109 {
110 return 21;
111 }
112 case 23:
113 {
114 return 22;
115 }
116 case 24:
117 {
118 return 23;
119 }
120 case 25:
121 {
122 return 24;
123 }
124 case 26:
125 {
126 return 25;
127 }
128 case 27:
129 {
130 return 26;
131 }
132 default:
133 {
134 return -1;
135 }
136 }
137 return -1;
138 }
139 case 26:
140 {
141 System.Lex.Lexeme prevMatch = token.match;
142 token.match = lexeme;
143 int tokenId = GetTokenId(25);
144 if (tokenId == CONTINUE_TOKEN)
145 {
146 token.id = CONTINUE_TOKEN;
147 return -1;
148 }
149 else
150 {
151 if (tokenId != INVALID_TOKEN)
152 {
153 token.id = tokenId;
154 }
155 else
156 {
157 token.match = prevMatch;
158 }
159 }
160 return -1;
161 }
162 case 25:
163 {
164 System.Lex.Lexeme prevMatch = token.match;
165 token.match = lexeme;
166 int tokenId = GetTokenId(24);
167 if (tokenId == CONTINUE_TOKEN)
168 {
169 token.id = CONTINUE_TOKEN;
170 return -1;
171 }
172 else
173 {
174 if (tokenId != INVALID_TOKEN)
175 {
176 token.id = tokenId;
177 }
178 else
179 {
180 token.match = prevMatch;
181 }
182 }
183 return -1;
184 }
185 case 24:
186 {
187 System.Lex.Lexeme prevMatch = token.match;
188 token.match = lexeme;
189 int tokenId = GetTokenId(23);
190 if (tokenId == CONTINUE_TOKEN)
191 {
192 token.id = CONTINUE_TOKEN;
193 return -1;
194 }
195 else
196 {
197 if (tokenId != INVALID_TOKEN)
198 {
199 token.id = tokenId;
200 }
201 else
202 {
203 token.match = prevMatch;
204 }
205 }
206 return -1;
207 }
208 case 23:
209 {
210 System.Lex.Lexeme prevMatch = token.match;
211 token.match = lexeme;
212 int tokenId = GetTokenId(22);
213 if (tokenId == CONTINUE_TOKEN)
214 {
215 token.id = CONTINUE_TOKEN;
216 return -1;
217 }
218 else
219 {
220 if (tokenId != INVALID_TOKEN)
221 {
222 token.id = tokenId;
223 }
224 else
225 {
226 token.match = prevMatch;
227 }
228 }
229 return -1;
230 }
231 case 22:
232 {
233 System.Lex.Lexeme prevMatch = token.match;
234 token.match = lexeme;
235 int tokenId = GetTokenId(21);
236 if (tokenId == CONTINUE_TOKEN)
237 {
238 token.id = CONTINUE_TOKEN;
239 return -1;
240 }
241 else
242 {
243 if (tokenId != INVALID_TOKEN)
244 {
245 token.id = tokenId;
246 }
247 else
248 {
249 token.match = prevMatch;
250 }
251 }
252 return -1;
253 }
254 case 21:
255 {
256 System.Lex.Lexeme prevMatch = token.match;
257 token.match = lexeme;
258 int tokenId = GetTokenId(20);
259 if (tokenId == CONTINUE_TOKEN)
260 {
261 token.id = CONTINUE_TOKEN;
262 return -1;
263 }
264 else
265 {
266 if (tokenId != INVALID_TOKEN)
267 {
268 token.id = tokenId;
269 }
270 else
271 {
272 token.match = prevMatch;
273 }
274 }
275 return -1;
276 }
277 case 20:
278 {
279 System.Lex.Lexeme prevMatch = token.match;
280 token.match = lexeme;
281 int tokenId = GetTokenId(19);
282 if (tokenId == CONTINUE_TOKEN)
283 {
284 token.id = CONTINUE_TOKEN;
285 return -1;
286 }
287 else
288 {
289 if (tokenId != INVALID_TOKEN)
290 {
291 token.id = tokenId;
292 }
293 else
294 {
295 token.match = prevMatch;
296 }
297 }
298 return -1;
299 }
300 case 19:
301 {
302 System.Lex.Lexeme prevMatch = token.match;
303 token.match = lexeme;
304 int tokenId = GetTokenId(18);
305 if (tokenId == CONTINUE_TOKEN)
306 {
307 token.id = CONTINUE_TOKEN;
308 return -1;
309 }
310 else
311 {
312 if (tokenId != INVALID_TOKEN)
313 {
314 token.id = tokenId;
315 }
316 else
317 {
318 token.match = prevMatch;
319 }
320 }
321 return -1;
322 }
323 case 18:
324 {
325 System.Lex.Lexeme prevMatch = token.match;
326 token.match = lexeme;
327 int tokenId = GetTokenId(17);
328 if (tokenId == CONTINUE_TOKEN)
329 {
330 token.id = CONTINUE_TOKEN;
331 return -1;
332 }
333 else
334 {
335 if (tokenId != INVALID_TOKEN)
336 {
337 token.id = tokenId;
338 }
339 else
340 {
341 token.match = prevMatch;
342 }
343 }
344 return -1;
345 }
346 case 17:
347 {
348 System.Lex.Lexeme prevMatch = token.match;
349 token.match = lexeme;
350 int tokenId = GetTokenId(16);
351 if (tokenId == CONTINUE_TOKEN)
352 {
353 token.id = CONTINUE_TOKEN;
354 return -1;
355 }
356 else
357 {
358 if (tokenId != INVALID_TOKEN)
359 {
360 token.id = tokenId;
361 }
362 else
363 {
364 token.match = prevMatch;
365 }
366 }
367 return -1;
368 }
369 case 16:
370 {
371 System.Lex.Lexeme prevMatch = token.match;
372 token.match = lexeme;
373 int tokenId = GetTokenId(15);
374 if (tokenId == CONTINUE_TOKEN)
375 {
376 token.id = CONTINUE_TOKEN;
377 return -1;
378 }
379 else
380 {
381 if (tokenId != INVALID_TOKEN)
382 {
383 token.id = tokenId;
384 }
385 else
386 {
387 token.match = prevMatch;
388 }
389 }
390 return -1;
391 }
392 case 15:
393 {
394 System.Lex.Lexeme prevMatch = token.match;
395 token.match = lexeme;
396 int tokenId = GetTokenId(14);
397 if (tokenId == CONTINUE_TOKEN)
398 {
399 token.id = CONTINUE_TOKEN;
400 return -1;
401 }
402 else
403 {
404 if (tokenId != INVALID_TOKEN)
405 {
406 token.id = tokenId;
407 }
408 else
409 {
410 token.match = prevMatch;
411 }
412 }
413 return -1;
414 }
415 case 14:
416 {
417 System.Lex.Lexeme prevMatch = token.match;
418 token.match = lexeme;
419 int tokenId = GetTokenId(13);
420 if (tokenId == CONTINUE_TOKEN)
421 {
422 token.id = CONTINUE_TOKEN;
423 return -1;
424 }
425 else
426 {
427 if (tokenId != INVALID_TOKEN)
428 {
429 token.id = tokenId;
430 }
431 else
432 {
433 token.match = prevMatch;
434 }
435 }
436 return -1;
437 }
438 case 13:
439 {
440 System.Lex.Lexeme prevMatch = token.match;
441 token.match = lexeme;
442 int tokenId = GetTokenId(12);
443 if (tokenId == CONTINUE_TOKEN)
444 {
445 token.id = CONTINUE_TOKEN;
446 return -1;
447 }
448 else
449 {
450 if (tokenId != INVALID_TOKEN)
451 {
452 token.id = tokenId;
453 }
454 else
455 {
456 token.match = prevMatch;
457 }
458 }
459 return -1;
460 }
461 case 12:
462 {
463 System.Lex.Lexeme prevMatch = token.match;
464 token.match = lexeme;
465 int tokenId = GetTokenId(11);
466 if (tokenId == CONTINUE_TOKEN)
467 {
468 token.id = CONTINUE_TOKEN;
469 return -1;
470 }
471 else
472 {
473 if (tokenId != INVALID_TOKEN)
474 {
475 token.id = tokenId;
476 }
477 else
478 {
479 token.match = prevMatch;
480 }
481 }
482 return -1;
483 }
484 case 11:
485 {
486 System.Lex.Lexeme prevMatch = token.match;
487 token.match = lexeme;
488 int tokenId = GetTokenId(10);
489 if (tokenId == CONTINUE_TOKEN)
490 {
491 token.id = CONTINUE_TOKEN;
492 return -1;
493 }
494 else
495 {
496 if (tokenId != INVALID_TOKEN)
497 {
498 token.id = tokenId;
499 }
500 else
501 {
502 token.match = prevMatch;
503 }
504 }
505 return -1;
506 }
507 case 10:
508 {
509 System.Lex.Lexeme prevMatch = token.match;
510 token.match = lexeme;
511 int tokenId = GetTokenId(9);
512 if (tokenId == CONTINUE_TOKEN)
513 {
514 token.id = CONTINUE_TOKEN;
515 return -1;
516 }
517 else
518 {
519 if (tokenId != INVALID_TOKEN)
520 {
521 token.id = tokenId;
522 }
523 else
524 {
525 token.match = prevMatch;
526 }
527 }
528 return -1;
529 }
530 case 9:
531 {
532 System.Lex.Lexeme prevMatch = token.match;
533 token.match = lexeme;
534 int tokenId = GetTokenId(8);
535 if (tokenId == CONTINUE_TOKEN)
536 {
537 token.id = CONTINUE_TOKEN;
538 return -1;
539 }
540 else
541 {
542 if (tokenId != INVALID_TOKEN)
543 {
544 token.id = tokenId;
545 }
546 else
547 {
548 token.match = prevMatch;
549 }
550 }
551 return -1;
552 }
553 case 8:
554 {
555 System.Lex.Lexeme prevMatch = token.match;
556 token.match = lexeme;
557 int tokenId = GetTokenId(7);
558 if (tokenId == CONTINUE_TOKEN)
559 {
560 token.id = CONTINUE_TOKEN;
561 return -1;
562 }
563 else
564 {
565 if (tokenId != INVALID_TOKEN)
566 {
567 token.id = tokenId;
568 }
569 else
570 {
571 token.match = prevMatch;
572 }
573 }
574 return -1;
575 }
576 case 7:
577 {
578 System.Lex.Lexeme prevMatch = token.match;
579 token.match = lexeme;
580 int tokenId = GetTokenId(6);
581 if (tokenId == CONTINUE_TOKEN)
582 {
583 token.id = CONTINUE_TOKEN;
584 return -1;
585 }
586 else
587 {
588 if (tokenId != INVALID_TOKEN)
589 {
590 token.id = tokenId;
591 }
592 else
593 {
594 token.match = prevMatch;
595 }
596 }
597 return -1;
598 }
599 case 6:
600 {
601 System.Lex.Lexeme prevMatch = token.match;
602 token.match = lexeme;
603 int tokenId = GetTokenId(5);
604 if (tokenId == CONTINUE_TOKEN)
605 {
606 token.id = CONTINUE_TOKEN;
607 return -1;
608 }
609 else
610 {
611 if (tokenId != INVALID_TOKEN)
612 {
613 token.id = tokenId;
614 }
615 else
616 {
617 token.match = prevMatch;
618 }
619 }
620 return -1;
621 }
622 case 5:
623 {
624 System.Lex.Lexeme prevMatch = token.match;
625 token.match = lexeme;
626 int tokenId = GetTokenId(4);
627 if (tokenId == CONTINUE_TOKEN)
628 {
629 token.id = CONTINUE_TOKEN;
630 return -1;
631 }
632 else
633 {
634 if (tokenId != INVALID_TOKEN)
635 {
636 token.id = tokenId;
637 }
638 else
639 {
640 token.match = prevMatch;
641 }
642 }
643 return -1;
644 }
645 case 4:
646 {
647 System.Lex.Lexeme prevMatch = token.match;
648 token.match = lexeme;
649 int tokenId = GetTokenId(3);
650 if (tokenId == CONTINUE_TOKEN)
651 {
652 token.id = CONTINUE_TOKEN;
653 return -1;
654 }
655 else
656 {
657 if (tokenId != INVALID_TOKEN)
658 {
659 token.id = tokenId;
660 }
661 else
662 {
663 token.match = prevMatch;
664 }
665 }
666 return -1;
667 }
668 case 3:
669 {
670 System.Lex.Lexeme prevMatch = token.match;
671 token.match = lexeme;
672 int tokenId = GetTokenId(1);
673 if (tokenId == CONTINUE_TOKEN)
674 {
675 token.id = CONTINUE_TOKEN;
676 return -1;
677 }
678 else
679 {
680 if (tokenId != INVALID_TOKEN)
681 {
682 token.id = tokenId;
683 }
684 else
685 {
686 token.match = prevMatch;
687 }
688 }
689 return -1;
690 }
691 case 2:
692 {
693 System.Lex.Lexeme prevMatch = token.match;
694 token.match = lexeme;
695 int tokenId = GetTokenId(2);
696 if (tokenId == CONTINUE_TOKEN)
697 {
698 token.id = CONTINUE_TOKEN;
699 return -1;
700 }
701 else
702 {
703 if (tokenId != INVALID_TOKEN)
704 {
705 token.id = tokenId;
706 }
707 else
708 {
709 token.match = prevMatch;
710 }
711 }
712 return -1;
713 }
714 case 1:
715 {
716 System.Lex.Lexeme prevMatch = token.match;
717 token.match = lexeme;
718 int tokenId = GetTokenId(0);
719 if (tokenId == CONTINUE_TOKEN)
720 {
721 token.id = CONTINUE_TOKEN;
722 return -1;
723 }
724 else
725 {
726 if (tokenId != INVALID_TOKEN)
727 {
728 token.id = tokenId;
729 }
730 else
731 {
732 token.match = prevMatch;
733 }
734 }
735 return -1;
736 }
737 }
738 return -1;
739 }
740 private int GetTokenId(int statementIndex)
741 {
742 switch (statementIndex)
743 {
744 case 0:
745 {
746 Retract();
747 return DIGIT;
748 break;
749 }
750 case 1:
751 {
752 Retract();
753 return HEX;
754 break;
755 }
756 case 2:
757 {
758 Retract();
759 return ALPHA;
760 break;
761 }
762 case 3:
763 {
764 Retract();
765 return COLON;
766 break;
767 }
768 case 4:
769 {
770 Retract();
771 return SEMICOLON;
772 break;
773 }
774 case 5:
775 {
776 Retract();
777 return SLASH;
778 break;
779 }
780 case 6:
781 {
782 Retract();
783 return QUEST;
784 break;
785 }
786 case 7:
787 {
788 Retract();
789 return DOT;
790 break;
791 }
792 case 8:
793 {
794 Retract();
795 return DASH;
796 break;
797 }
798 case 9:
799 {
800 Retract();
801 return UNDERSCORE;
802 break;
803 }
804 case 10:
805 {
806 Retract();
807 return TILDE;
808 break;
809 }
810 case 11:
811 {
812 Retract();
813 return AT;
814 break;
815 }
816 case 12:
817 {
818 Retract();
819 return EXCLAMATION;
820 break;
821 }
822 case 13:
823 {
824 Retract();
825 return LBRACKET;
826 break;
827 }
828 case 14:
829 {
830 Retract();
831 return RBRACKET;
832 break;
833 }
834 case 15:
835 {
836 Retract();
837 return DOLLAR;
838 break;
839 }
840 case 16:
841 {
842 Retract();
843 return AMP;
844 break;
845 }
846 case 17:
847 {
848 Retract();
849 return SQ;
850 break;
851 }
852 case 18:
853 {
854 Retract();
855 return LPAREN;
856 break;
857 }
858 case 19:
859 {
860 Retract();
861 return RPAREN;
862 break;
863 }
864 case 20:
865 {
866 Retract();
867 return ASTERISK;
868 break;
869 }
870 case 21:
871 {
872 Retract();
873 return PLUS;
874 break;
875 }
876 case 22:
877 {
878 Retract();
879 return COMMA;
880 break;
881 }
882 case 23:
883 {
884 Retract();
885 return EQ;
886 break;
887 }
888 case 24:
889 {
890 Retract();
891 return PERCENT;
892 break;
893 }
894 case 25:
895 {
896 Retract();
897 return HASH;
898 break;
899 }
900 }
901 return CONTINUE_TOKEN;
902 }
903 }