1 using System;
  2 using System.Lex;
  3 using BigNumTokens;
  4 
  5 // this file has been automatically generated from 'D:/work/cmajorm/cmajor/projects/examples/BigNumCalc/BigNumLexer.lexer' using soulcm lexer generator scmlg version 3.0.0
  6 
  7 public class BigNumLexer : System.Lex.Lexer
  8 {
  9     public BigNumLexer(const ustring& content_const string& fileName_int fileIndex_) : 
 10         base(content_fileName_fileIndex_)
 11     {
 12         BigNumClassMap.Init();
 13     }
 14     public BigNumLexer(const uchar* start_const uchar* end_const string& fileName_int fileIndex_) : 
 15         base(start_end_fileName_fileIndex_)
 16     {
 17         BigNumClassMap.Init();
 18     }
 19     public override int NextState(int stateuchar c)
 20     {
 21         int i = BigNumClassMap.GetClass(c);
 22         switch (state)
 23         {
 24             case 0:
 25             {
 26                 switch (i)
 27                 {
 28                     case 2: case 3: case 4: case 5:
 29                     {
 30                         return 1;
 31                     }
 32                     case 9:
 33                     {
 34                         return 2;
 35                     }
 36                     case 10:
 37                     {
 38                         return 3;
 39                     }
 40                     case 11:
 41                     {
 42                         return 4;
 43                     }
 44                     case 12:
 45                     {
 46                         return 5;
 47                     }
 48                     case 14:
 49                     {
 50                         return 6;
 51                     }
 52                     case 15:
 53                     {
 54                         return 7;
 55                     }
 56                     case 16:
 57                     {
 58                         return 8;
 59                     }
 60                     case 17:
 61                     {
 62                         return 9;
 63                     }
 64                     default:
 65                     {
 66                         return -1;
 67                     }
 68                 }
 69                 return -1;
 70             }
 71             case 9:
 72             {
 73                 System.Lex.Lexeme prevMatch = token.match;
 74                 token.match = lexeme;
 75                 int tokenId = GetTokenId(9);
 76                 if (tokenId == CONTINUE_TOKEN)
 77                 {
 78                     token.id = CONTINUE_TOKEN;
 79                     return -1;
 80                 }
 81                 else
 82                 {
 83                     if (tokenId != INVALID_TOKEN)
 84                     {
 85                         token.id = tokenId;
 86                     }
 87                     else
 88                     {
 89                         token.match = prevMatch;
 90                     }
 91                 }
 92                 return -1;
 93             }
 94             case 8:
 95             {
 96                 System.Lex.Lexeme prevMatch = token.match;
 97                 token.match = lexeme;
 98                 int tokenId = GetTokenId(8);
 99                 if (tokenId == CONTINUE_TOKEN)
100                 {
101                     token.id = CONTINUE_TOKEN;
102                     return -1;
103                 }
104                 else
105                 {
106                     if (tokenId != INVALID_TOKEN)
107                     {
108                         token.id = tokenId;
109                     }
110                     else
111                     {
112                         token.match = prevMatch;
113                     }
114                 }
115                 return -1;
116             }
117             case 7:
118             {
119                 System.Lex.Lexeme prevMatch = token.match;
120                 token.match = lexeme;
121                 int tokenId = GetTokenId(6);
122                 if (tokenId == CONTINUE_TOKEN)
123                 {
124                     token.id = CONTINUE_TOKEN;
125                     return -1;
126                 }
127                 else
128                 {
129                     if (tokenId != INVALID_TOKEN)
130                     {
131                         token.id = tokenId;
132                     }
133                     else
134                     {
135                         token.match = prevMatch;
136                     }
137                 }
138                 return -1;
139             }
140             case 6:
141             {
142                 System.Lex.Lexeme prevMatch = token.match;
143                 token.match = lexeme;
144                 int tokenId = GetTokenId(3);
145                 if (tokenId == CONTINUE_TOKEN)
146                 {
147                     token.id = CONTINUE_TOKEN;
148                     return -1;
149                 }
150                 else
151                 {
152                     if (tokenId != INVALID_TOKEN)
153                     {
154                         token.id = tokenId;
155                     }
156                     else
157                     {
158                         token.match = prevMatch;
159                     }
160                 }
161                 switch (i)
162                 {
163                     case 14:
164                     {
165                         return 6;
166                     }
167                     case 6:
168                     {
169                         return 10;
170                     }
171                     case 7:
172                     {
173                         return 11;
174                     }
175                     case 8:
176                     {
177                         return 12;
178                     }
179                     default:
180                     {
181                         return -1;
182                     }
183                 }
184                 return -1;
185             }
186             case 12:
187             {
188                 switch (i)
189                 {
190                     case 9:
191                     {
192                         return 13;
193                     }
194                     case 10:
195                     {
196                         return 14;
197                     }
198                     case 14:
199                     {
200                         return 15;
201                     }
202                     default:
203                     {
204                         return -1;
205                     }
206                 }
207                 return -1;
208             }
209             case 15:
210             {
211                 System.Lex.Lexeme prevMatch = token.match;
212                 token.match = lexeme;
213                 int tokenId = GetTokenId(1);
214                 if (tokenId == CONTINUE_TOKEN)
215                 {
216                     token.id = CONTINUE_TOKEN;
217                     return -1;
218                 }
219                 else
220                 {
221                     if (tokenId != INVALID_TOKEN)
222                     {
223                         token.id = tokenId;
224                     }
225                     else
226                     {
227                         token.match = prevMatch;
228                     }
229                 }
230                 switch (i)
231                 {
232                     case 14:
233                     {
234                         return 15;
235                     }
236                     default:
237                     {
238                         return -1;
239                     }
240                 }
241                 return -1;
242             }
243             case 14:
244             {
245                 switch (i)
246                 {
247                     case 14:
248                     {
249                         return 15;
250                     }
251                     default:
252                     {
253                         return -1;
254                     }
255                 }
256                 return -1;
257             }
258             case 13:
259             {
260                 switch (i)
261                 {
262                     case 14:
263                     {
264                         return 15;
265                     }
266                     default:
267                     {
268                         return -1;
269                     }
270                 }
271                 return -1;
272             }
273             case 11:
274             {
275                 switch (i)
276                 {
277                     case 9:
278                     {
279                         return 13;
280                     }
281                     case 10:
282                     {
283                         return 14;
284                     }
285                     case 14:
286                     {
287                         return 15;
288                     }
289                     default:
290                     {
291                         return -1;
292                     }
293                 }
294                 return -1;
295             }
296             case 10:
297             {
298                 switch (i)
299                 {
300                     case 14:
301                     {
302                         return 16;
303                     }
304                     default:
305                     {
306                         return -1;
307                     }
308                 }
309                 return -1;
310             }
311             case 16:
312             {
313                 System.Lex.Lexeme prevMatch = token.match;
314                 token.match = lexeme;
315                 int tokenId = GetTokenId(1);
316                 if (tokenId == CONTINUE_TOKEN)
317                 {
318                     token.id = CONTINUE_TOKEN;
319                     return -1;
320                 }
321                 else
322                 {
323                     if (tokenId != INVALID_TOKEN)
324                     {
325                         token.id = tokenId;
326                     }
327                     else
328                     {
329                         token.match = prevMatch;
330                     }
331                 }
332                 switch (i)
333                 {
334                     case 14:
335                     {
336                         return 16;
337                     }
338                     case 7:
339                     {
340                         return 17;
341                     }
342                     case 8:
343                     {
344                         return 18;
345                     }
346                     default:
347                     {
348                         return -1;
349                     }
350                 }
351                 return -1;
352             }
353             case 18:
354             {
355                 switch (i)
356                 {
357                     case 9:
358                     {
359                         return 19;
360                     }
361                     case 10:
362                     {
363                         return 20;
364                     }
365                     case 14:
366                     {
367                         return 21;
368                     }
369                     default:
370                     {
371                         return -1;
372                     }
373                 }
374                 return -1;
375             }
376             case 21:
377             {
378                 System.Lex.Lexeme prevMatch = token.match;
379                 token.match = lexeme;
380                 int tokenId = GetTokenId(1);
381                 if (tokenId == CONTINUE_TOKEN)
382                 {
383                     token.id = CONTINUE_TOKEN;
384                     return -1;
385                 }
386                 else
387                 {
388                     if (tokenId != INVALID_TOKEN)
389                     {
390                         token.id = tokenId;
391                     }
392                     else
393                     {
394                         token.match = prevMatch;
395                     }
396                 }
397                 switch (i)
398                 {
399                     case 14:
400                     {
401                         return 21;
402                     }
403                     default:
404                     {
405                         return -1;
406                     }
407                 }
408                 return -1;
409             }
410             case 20:
411             {
412                 switch (i)
413                 {
414                     case 14:
415                     {
416                         return 21;
417                     }
418                     default:
419                     {
420                         return -1;
421                     }
422                 }
423                 return -1;
424             }
425             case 19:
426             {
427                 switch (i)
428                 {
429                     case 14:
430                     {
431                         return 21;
432                     }
433                     default:
434                     {
435                         return -1;
436                     }
437                 }
438                 return -1;
439             }
440             case 17:
441             {
442                 switch (i)
443                 {
444                     case 9:
445                     {
446                         return 19;
447                     }
448                     case 10:
449                     {
450                         return 20;
451                     }
452                     case 14:
453                     {
454                         return 21;
455                     }
456                     default:
457                     {
458                         return -1;
459                     }
460                 }
461                 return -1;
462             }
463             case 5:
464             {
465                 System.Lex.Lexeme prevMatch = token.match;
466                 token.match = lexeme;
467                 int tokenId = GetTokenId(7);
468                 if (tokenId == CONTINUE_TOKEN)
469                 {
470                     token.id = CONTINUE_TOKEN;
471                     return -1;
472                 }
473                 else
474                 {
475                     if (tokenId != INVALID_TOKEN)
476                     {
477                         token.id = tokenId;
478                     }
479                     else
480                     {
481                         token.match = prevMatch;
482                     }
483                 }
484                 return -1;
485             }
486             case 4:
487             {
488                 switch (i)
489                 {
490                     case 14:
491                     {
492                         return 22;
493                     }
494                     default:
495                     {
496                         return -1;
497                     }
498                 }
499                 return -1;
500             }
501             case 22:
502             {
503                 switch (i)
504                 {
505                     case 14:
506                     {
507                         return 22;
508                     }
509                     case 12:
510                     {
511                         return 23;
512                     }
513                     case 13:
514                     {
515                         return 24;
516                     }
517                     default:
518                     {
519                         return -1;
520                     }
521                 }
522                 return -1;
523             }
524             case 24:
525             {
526                 System.Lex.Lexeme prevMatch = token.match;
527                 token.match = lexeme;
528                 int tokenId = GetTokenId(2);
529                 if (tokenId == CONTINUE_TOKEN)
530                 {
531                     token.id = CONTINUE_TOKEN;
532                     return -1;
533                 }
534                 else
535                 {
536                     if (tokenId != INVALID_TOKEN)
537                     {
538                         token.id = tokenId;
539                     }
540                     else
541                     {
542                         token.match = prevMatch;
543                     }
544                 }
545                 return -1;
546             }
547             case 23:
548             {
549                 switch (i)
550                 {
551                     case 14:
552                     {
553                         return 25;
554                     }
555                     default:
556                     {
557                         return -1;
558                     }
559                 }
560                 return -1;
561             }
562             case 25:
563             {
564                 switch (i)
565                 {
566                     case 13:
567                     {
568                         return 24;
569                     }
570                     case 14:
571                     {
572                         return 25;
573                     }
574                     default:
575                     {
576                         return -1;
577                     }
578                 }
579                 return -1;
580             }
581             case 3:
582             {
583                 System.Lex.Lexeme prevMatch = token.match;
584                 token.match = lexeme;
585                 int tokenId = GetTokenId(5);
586                 if (tokenId == CONTINUE_TOKEN)
587                 {
588                     token.id = CONTINUE_TOKEN;
589                     return -1;
590                 }
591                 else
592                 {
593                     if (tokenId != INVALID_TOKEN)
594                     {
595                         token.id = tokenId;
596                     }
597                     else
598                     {
599                         token.match = prevMatch;
600                     }
601                 }
602                 return -1;
603             }
604             case 2:
605             {
606                 System.Lex.Lexeme prevMatch = token.match;
607                 token.match = lexeme;
608                 int tokenId = GetTokenId(4);
609                 if (tokenId == CONTINUE_TOKEN)
610                 {
611                     token.id = CONTINUE_TOKEN;
612                     return -1;
613                 }
614                 else
615                 {
616                     if (tokenId != INVALID_TOKEN)
617                     {
618                         token.id = tokenId;
619                     }
620                     else
621                     {
622                         token.match = prevMatch;
623                     }
624                 }
625                 return -1;
626             }
627             case 1:
628             {
629                 System.Lex.Lexeme prevMatch = token.match;
630                 token.match = lexeme;
631                 int tokenId = GetTokenId(0);
632                 if (tokenId == CONTINUE_TOKEN)
633                 {
634                     token.id = CONTINUE_TOKEN;
635                     return -1;
636                 }
637                 else
638                 {
639                     if (tokenId != INVALID_TOKEN)
640                     {
641                         token.id = tokenId;
642                     }
643                     else
644                     {
645                         token.match = prevMatch;
646                     }
647                 }
648                 switch (i)
649                 {
650                     case 2: case 3: case 4: case 5:
651                     {
652                         return 1;
653                     }
654                     default:
655                     {
656                         return -1;
657                     }
658                 }
659                 return -1;
660             }
661         }
662         return -1;
663     }
664     private int GetTokenId(int statementIndex)
665     {
666         switch (statementIndex)
667         {
668             case 0:
669             {
670                 Retract();
671                 break;
672             }
673             case 1:
674             {
675                 Retract();
676                 return FLOAT;
677                 break;
678             }
679             case 2:
680             {
681                 Retract();
682                 return RATIONAL;
683                 break;
684             }
685             case 3:
686             {
687                 Retract();
688                 return INTEGER;
689                 break;
690             }
691             case 4:
692             {
693                 Retract();
694                 return PLUS;
695                 break;
696             }
697             case 5:
698             {
699                 Retract();
700                 return MINUS;
701                 break;
702             }
703             case 6:
704             {
705                 Retract();
706                 return MUL;
707                 break;
708             }
709             case 7:
710             {
711                 Retract();
712                 return DIV;
713                 break;
714             }
715             case 8:
716             {
717                 Retract();
718                 return LPAREN;
719                 break;
720             }
721             case 9:
722             {
723                 Retract();
724                 return RPAREN;
725                 break;
726             }
727         }
728         return CONTINUE_TOKEN;
729     }
730 }