-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexicalAnalyzer.c
1245 lines (1145 loc) · 38.1 KB
/
lexicalAnalyzer.c
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define KEYSIZE 33
#define BUFFERSIZE 1000
#define IDCAPACITY 1000
#define KEY 0
#define ID 1
#define REL 4
#define ASS 5
#define BIT 6
#define LOG 7
#define ARI 8
#define SPE 9
#define NOT 10
#define SYM 11
#define SEL 12
#define STR 13
#define CHR 14
#define U 15
#define UL 16
#define ULL 17
#define I 18
#define L 19
#define LL 20
#define F 21
#define D 22
#define LD 23
int token_num[24]; //存放各种记号单词的数量
union attributes {
int inum;
long lnum;
long long llnum;
float fnum;
double dnum;
long double ldnum;
unsigned int unum;
unsigned long ulnum;
unsigned long long ullnum;
}; //存放二元组中的属性
struct tokens {
int token;
union attributes attribute;
};
struct tokens binary; //存放当前单词二元组
char* signTable; //存放用户自定义字符的符号表
char* strTable; //存放字符串
int signPos; //符号表当前末尾位置
int str_signPos; //字符串常量表当前末尾位置
char keyTable[KEYSIZE][10] = {"auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else",
"enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", "register",
"restrict", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef",
"union", "unsigned", "void", "volatile"}; //存放关键字字符
int state; //当前状态指示
char C; //存放当前读入的字符
int isKey; //值为-1表示识别出的单词是用户自定义的标识符,否则,表示识别出的单词是关键字,其值为关键字的记号
char token[1000]; //存放当前正在识别的单词字符串
int pos; //token中的字符串尾部;
int forward; //向前指针
int line; //当前行数
int total; //不带换行和空格的字符总数
int total_ns; //带换行和空格的字符总数
char buffer[BUFFERSIZE * 2]; //输入缓冲区
FILE* fp; //文件指针
int re_flag; //向前指针回退时的标记,避免重复加载缓冲区
void get_char(); //根据向前指针forward的指示从输入缓冲区中读一个字符放入变量C中,然后移动forward,使之指向下一个字符
void get_nbc(void); //检查C中的字符是否为空格,若是,则反复调用get_char,直到C中进入一个非空字符为止
void cat(void); //把C中字符链接在token中的字符串后面
void retract(void); //向前指针forward后退一个字符,同时将token的最后一个字符删去
void combine(int tokens, long long attribute_i, long double attribute_f); //把单词的记号和属性组合成一个二元组
void error(int log); //对发现的错误进行相应的处理
int letter(void); //判断C中的字符是否为字母,若是则返回1,否则返回0
int digit(void); //判断C中的字符是否为数字,若是则返回1,否则返回0
int reserve(void); //根据token中的单词查关键字表,若token中的单词是关键字,则返回该关键字的记号,否则,返回值“-1”
void table_insert(void); //将识别出来的用户自定义标识符,即token中的单词,插入符号表,返回该单词在符号表中的位置指针
void str_table_insert(void); //将识别出来的字符串,即token中的单次,插入字符串常量表,返回该字符串在表中的位置指针
void token_print(void); //打印识别出来的记号
void buffer_fill(int start); //填充一半的缓冲区
void outcome_print(void); //打印统计结果
int letter(void) {
return ((C>='a'&&C<='z')||(C>='A'&&C<='Z'))?1:0;
}
int digit(void) {
return (C>='0'&&C<='9')?1:0;
}
void get_char() {
C = buffer[forward];
if (C == '\n') {
line++;
}
forward++;
if (forward == BUFFERSIZE && re_flag == 0) {
buffer_fill(BUFFERSIZE);
}
else if (forward == BUFFERSIZE * 2 && re_flag == 0) {
buffer_fill(0);
}
re_flag = 0;
forward = (forward + BUFFERSIZE * 2) % (BUFFERSIZE * 2);
}
void get_nbc(void) {
while (C == ' ' || C == '\n' || C == '\t') {
get_char();
}
}
void cat(void) {
token[pos++] = C;
token[pos] = '\0';
}
void retract(void) {
re_flag = 1;
forward = (forward + BUFFERSIZE * 2 - 1) % (BUFFERSIZE * 2);
if (C == '\n') {
line--;
}
}
void combine(int tokens, long long attribute_i, long double attribute_f) {
binary.token = tokens;
if (binary.token == F) {
binary.attribute.fnum = (float)attribute_f;
} else if (binary.token == D) {
binary.attribute.dnum = (double)attribute_f;
} else if (binary.token == LD) {
binary.attribute.ldnum = attribute_f;
} else if (binary.token == I) {
binary.attribute.inum = (int)attribute_i;
} else if (binary.token == L) {
binary.attribute.lnum = (long)attribute_i;
} else if (binary.token == LL) {
binary.attribute.llnum = attribute_i;
} else if (binary.token == U) {
binary.attribute.unum = (unsigned int)attribute_i;
} else if (binary.token == UL) {
binary.attribute.ulnum = (unsigned long)attribute_i;
} else if (binary.token == ULL) {
binary.attribute.ullnum = (unsigned long long)attribute_i;
} else {
binary.attribute.inum = (int)attribute_i;
}
token_print();
pos = 0;
}
void token_print() {
token_num[binary.token]++;
printf("\t<%s, ", token);
switch (binary.token)
{
case KEY:
printf("KEY, %ld>\n", binary.attribute.inum);
break;
case ID:
printf("ID, %ld>\n", binary.attribute.inum);
break;
case REL:
printf("REL, %ld>\n", binary.attribute.inum);
break;
case ASS:
printf("ASS, %ld>\n", binary.attribute.inum);
break;
case BIT:
printf("BIT, %ld>\n", binary.attribute.inum);
break;
case LOG:
printf("LOG, %ld>\n", binary.attribute.inum);
break;
case ARI:
printf("ARI, %ld>\n", binary.attribute.inum);
break;
case SPE:
printf("SPE, %ld>\n", binary.attribute.inum);
break;
case NOT:
printf("NOT, %ld>\n", binary.attribute.inum);
break;
case SYM:
printf("SYM, %ld>\n", binary.attribute.inum);
break;
case SEL:
printf("SEL, %ld>\n", binary.attribute.inum);
break;
case STR:
printf("STR, %s>\n", &strTable[binary.attribute.inum]);
break;
case CHR:
printf("CHR, %s>\n", &strTable[binary.attribute.inum]);
break;
case U:
printf("U, %u>\n", binary.attribute.unum); break;
case UL:
printf("UL, %lu>\n", binary.attribute.ulnum); break;
case ULL:
printf("ULL, %llu>\n", binary.attribute.ullnum); break;
case I:
printf("I, %d>\n", binary.attribute.inum); break;
case L:
printf("L, %ld>\n", binary.attribute.lnum); break;
case LL:
printf("LL, %lld>\n", binary.attribute.llnum); break;
case F:
printf("F, %f>\n", binary.attribute.fnum); break;
case D:
printf("D, %lf>\n", binary.attribute.dnum); break;
case LD:
printf("LD, %llf>\n", binary.attribute.ldnum); break;
default:
break;
}
}
int reserve(void) {
token[pos++] = '\0';
for (int i = 0; i < KEYSIZE; i++) {
if (strcmp(keyTable[i], token) == 0) {
return i;
}
}
return -1;
}
//将当前token添加到符号表中,同时增加signPos的值。为了区分不同的ID,每两个ID之间添加一个\0。
void table_insert(void) {
int i;
//自动扩容
char* copy;
if (signPos == 0) {
signTable = malloc(IDCAPACITY);
}
if (signPos + strlen(token) + 1 >= IDCAPACITY){
copy = malloc(sizeof(signTable) + IDCAPACITY);
for (i = 0; i<sizeof(signTable); i++) {
copy[i] = signTable[i];
}
free(signTable);
signTable = copy;
}
//若先执行了combine,此时虽然token的pos已经指向0,但是/0仍然在原处,可以顺利读取token
for (i = 0; i < strlen(token); i++) {
signTable[signPos++] = token[i];
}
signTable[signPos++] = '\0';
}
void str_table_insert(void) {
int i;
char* copy;
if (str_signPos == 0) {
strTable = malloc(IDCAPACITY);
}
if (str_signPos + strlen(token) + 1 >= IDCAPACITY){
copy = malloc(sizeof(strTable) + IDCAPACITY);
for (i = 0; i<sizeof(strTable); i++) {
copy[i] = strTable[i];
}
free(strTable);
strTable = copy;
}
for (i = 0; i < strlen(token); i++) {
strTable[str_signPos++] = token[i];
}
strTable[str_signPos++] = '\0';
}
void error(int log) {
int eline;
if (C == '\n') {
eline = line - 1;
}
else {
eline = line;
}
switch (log) {
case 1:
printf("\t[Error] exponent has no digits. (line %d)\n", eline); break;
case 2:
printf("\t[Error] exponent has no digits. (line %d)\n", eline); break;
case 3:
printf("\t[Error] stray '%c' in program. (line %d)\n", C, eline); break;
case 4:
printf("\t[Error] invalid suffix \"b\" on integer constant. (line %d)\n", eline); break;
case 5:
printf("\t[Error] invalid suffix \"x\" on integer constant. (line %d)\n", eline); break;
}
pos = 0;
}
void buffer_fill(int start) {
int i = 0;
char c;
while (i < BUFFERSIZE && (c = fgetc(fp)) != EOF) {
buffer[start + i] = c;
i++;
total_ns++;
if (c != ' ' && c != '\n') {
total++;
}
}
if (c == EOF) {
buffer[start + i] = '\0';
}
}
void lexicalAnalyzer(void) {
state = 0;
pos = 0;
do {
switch(state) {
case 0: //初始状态
get_char();
get_nbc();
if (letter() || C == '_') {
state = 1; //设置标识符状态
}
else if (digit() && C != '0') {
state = 2;
}
else if (C == '.') {
state = 3;
}
else if (C == '0') {
state = 10;
}
else {
switch(C) {
case '<': state = 58; break;
case '>': state = 60; break;
case '=': state = 62; break;
case '!': state = 62; break;
case '+': state = 64; break;
case '-': state = 65; break;
case '&': state = 66; break;
case '|': state = 67; break;
case '*': state = 68; break;
case '/': state = 69; break;
case '%': state = 72; break;
case '^': state = 73; break;
case '{':
cat(); state = 0; combine(SYM, 0, 0); break;
case '}':
cat(); state = 0; combine(SYM, 1, 0); break;
case '(':
cat(); state = 0; combine(SPE, 0, 0); break;
case ')':
cat(); state = 0; combine(SPE, 1, 0); break;
case '[':
cat(); state = 0; combine(SPE, 2, 0); break;
case ']':
cat(); state = 0; combine(SPE, 3, 0); break;
case ':':
cat(); state = 0; combine(SYM, 2, 0); break;
case ';':
cat(); state = 0; combine(SYM, 5, 0); break;
case '?':
cat(); state = 0; combine(SEL, 0, 0); break;
case ',':
cat(); state = 0; combine(SYM, 6, 0); break;
case '#':
cat(); state = 0; combine(SYM, 7, 0); break;
case '~':
cat(); state = 0; combine(ASS, 11, 0); break;
case '\"':
cat(); state = 76; combine(SYM, 4, 0); break;//26
case '\'':
cat(); state = 77; combine(SYM, 3, 0); break;//27
default: state = 74; break;
}
}
break;
case 1: //标识符状态
cat();
get_char();
if (letter() || digit() || C == '_') {
state = 1;
}
else {
state = 0;
isKey = reserve(); //查关键字表
if (isKey != -1) {
combine(KEY, isKey, 0); //是关键字
}
else { //识别出用户自定义标识符
combine(ID, signPos, 0);
table_insert();
}
retract();
}
break;
case 2:
cat();
get_char();
switch (C) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': state = 2; break;
case '.': state = 4; break;
case 'e':
case 'E': state = 5; break;
case 'l':
case 'L': state = 30; break;
case 'u':
case 'U': state = 34; break;
default: //识别出常整数
retract();
state = 0;
combine(I, atoi(token), 0);
break;
}
break;
case 3: //小数点状态
cat();
get_char();
if (digit()) {
state = 4;
}
else {
retract(); state = 0; combine(SPE, 5, 0);
}
break;
case 4: //小数状态
cat();
get_char();
switch (C) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': state = 4; break;
case 'e':
case 'E': state = 5; break;
case 'l':
case 'L': state = 8; break;
case 'f':
case 'F': state = 9; break;
default: //识别出小数
retract();
state = 0;
combine(D, 0, strtod(token ,NULL));
break;
}
break;
case 5: //指数状态
cat();
get_char();
switch (C) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': state = 7; break;
case '+':
case '-':state = 6; break;
default:
retract(); error(1); state = 0; break;
}
break;
case 6:
cat();
get_char();
if (digit()) {
state = 7;
}
else {
retract(); error(2); state = 0;
}
break;
case 7:
cat();
get_char();
if(digit()) {
state = 7;
}
else if (C == 'L' || C == 'l') {
state = 8;
}
else if (C == 'F' || C == 'f') {
state = 9;
}
else {
retract(); state = 0; combine(D, 0, strtod(token ,NULL));
}
break;
case 8:
cat();
state = 0;
combine(LD, 0, strtold(token ,NULL));
break;
case 9:
cat();
state = 0;
combine(F, 0, atof(token));
break;
case 10:
cat();
get_char();
switch(C) {
case '.': state = 4; break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7': state = 20; break;
case 'X':
case 'x': state = 11; break;
case 'B':
case 'b': state = 21; break;
default: state = 0; combine(I, 0, 0); break;
}
break;
case 11:
cat();
get_char();
if(digit()){
state = 12; break;
}
switch(C) {
case 'A': case 'B': case 'C': case 'D': case 'E': case'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case'f':
state = 12; break;
default: retract(); state = 0; error(5); break;
}
break;
case 12:
cat();
get_char();
if(digit()){
state = 12; break;
}
switch(C) {
case 'A': case 'B': case 'C': case 'D': case 'E': case'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case'f':
state = 12; break;
case 'p':
case 'P': state = 15; break;
case 'l':
case 'L': state = 40; break;
case 'u':
case 'U': state = 44; break;
default:
retract();
state = 0;
combine(I, strtol(token, NULL, 16), 0);
break;
}
break;
case 15:
cat();
get_char();
if(digit()){
state = 17; break;
}
switch(C) {
case 'A': case 'B': case 'C': case 'D': case 'E': case'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case'f':
state = 17; break;
case '+':
case '-': state = 16; break;
default:
retract(); error(1); state = 0; break;
}
break;
case 16:
cat();
get_char();
if (digit()) {
state = 17;
}
else {
retract(); error(2); state = 0;
}
break;
case 17:
cat();
get_char();
if(digit()){
state = 17; break;
}
switch(C) {
case 'A': case 'B': case 'C': case 'D': case 'E': case'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case'f':
state = 17; break;
case 'L':
case 'l': state = 18; break;
default: retract(); state = 0; combine(D, 0, strtod(token, NULL));
}
break;
case 18:
cat();
state = 0;
combine(LD, 0, strtold(token, NULL));
break;
case 20:
cat();
get_char();
switch (C) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7': state = 20; break;
case 'L':
case 'l': state = 50; break;
case 'U':
case 'u': state = 54; break;
default: retract(); state = 0; combine(I, strtol(token, NULL, 8), 0); break;
}
break;
case 21:
cat();
get_char();
if (C == '0' || C == '1') {
state = 22;
}
else {
retract();
state = 0;
error(4);
}
break;
case 22:
cat();
get_char();
switch (C) {
case '0':
case '1': state = 22; break;
case 'U':
case 'u': state = 25; break;
case 'L':
case 'l': state = 23; break;
default:
retract();
state = 0;
combine(I, strtol(token, NULL, 2), 0);
}
break;
case 23:
cat();
get_char();
switch (C) {
case 'U':
case 'u': cat(); state = 0; combine(UL, strtoul(token, NULL, 2), 0); break;
case 'L':
case 'l': state = 24; break;
default: retract(); state = 0; combine(L, strtol(token, NULL, 2), 0); break;
}
break;
case 24:
cat();
get_char();
switch (C) {
case 'U':
case 'u': cat(); state = 0; combine(ULL, strtoull(token, NULL, 2), 0); break;
default: retract(); state = 0; combine(LL, strtoll(token, NULL, 2), 0); break;
}
break;
case 25:
cat();
get_char();
switch (C) {
case 'L':
case 'l': state = 26; break;
default: retract(); state = 0; combine(U, strtoul(token, NULL, 2), 0); break;
}
break;
case 26:
cat();
get_char();
switch (C) {
case 'L':
case 'l': cat(); state = 0; combine(ULL, strtoull(token, NULL, 2), 0); break;
default: retract(); state = 0; combine(U, strtoul(token, NULL, 2), 0); break;
}
break;
case 30:
cat();
get_char();
switch (C) {
case 'U':
case 'u': state = 31; break;
case 'L':
case 'l': state = 32; break;
default: retract(); state = 0; combine(L, strtol(token, NULL, 10), 0); break;
}
break;
case 31:
cat();
state = 0;
combine(UL, strtoul(token, NULL, 10), 0);
break;
case 32:
cat();
get_char();
switch (C) {
case 'U':
case 'u': state = 33; break;
default: retract(); state = 0; combine(LL, strtoll(token, NULL, 10), 0); break;
}
break;
case 33:
cat();
state = 0;
combine (ULL, strtoull(token, NULL, 10), 0);
break;
case 34:
cat();
get_char();
if (C == 'L' || C == 'l') {
state = 35;
}
else {
retract();
state = 0;
combine(U, strtoul(token, NULL, 10), 0);//
}
break;
case 35:
cat();
get_char();
if (C == 'L' || C == 'l') {
state = 36;
}
else {
retract();
state = 0;
combine(UL, strtoul(token, NULL, 10), 0);
}
break;
case 36:
cat();
state = 0;
combine(ULL, strtoull(token, NULL, 10), 0);
break;
case 40:
cat();
get_char();
switch (C) {
case 'U':
case 'u': state = 41; break;
case 'L':
case 'l': state = 42; break;
default: retract(); state = 0; combine(L, strtol(token, NULL, 16), 0);
break;
}
break;
case 41:
cat();
state = 0;
combine(UL, strtoul(token, NULL, 16), 0);
break;
case 42:
cat();
get_char();
if(C == 'U' || C == 'u') {
state = 43;
}
else {
retract();
state = 0;
combine(LL, strtoll(token, NULL, 16), 0);
}
break;
case 43:
cat();
state = 0;
combine(ULL, strtoull(token, NULL, 16), 0);
break;
case 44:
cat();
get_char();
if(C == 'L' || C == 'l') {
state = 45; }
else{
retract();
state = 0;
combine(U, strtoul(token, NULL, 16), 0);
}
break;
case 45:
cat();
get_char();
if(C == 'L' || C == 'l') {
state = 46;
}
else{
retract();
state = 0;
combine(UL, strtoul(token, NULL, 16), 0);
}
break;
case 46:
cat();
state = 0;
combine(ULL, strtoull(token, NULL, 16), 0);
break;
case 50:
cat();
get_char();
if(C == 'U' || C == 'u') {
state = 51;
}
else if(C == 'L' || C == 'l') {
state = 52;
}
else {
retract();
state = 0;
combine(L, strtol(token, NULL, 8), 0);
}
break;
case 51:
cat();
state = 0;
combine(UL, strtoul(token, NULL, 8), 0);
break;
case 52:
cat();
get_char();
state = 0;
if(C == 'U' || C == 'u'){
state = 53;
}
else {
retract();
state = 0;
combine(LL, strtoll(token, NULL, 8), 0);
}
break;
case 53:
cat();
state = 0;
combine(ULL, strtoull(token, NULL, 8), 0);
break;
case 54:
cat();
get_char();
if(C == 'L' || C == 'l') {
state = 55;
}
else {
retract();
state = 0;
combine(U, strtoul(token, NULL, 8), 0);//
}
break;
case 55:
cat();
get_char();
if(C == 'L' || C == 'l') {
state = 56;
}
else {
retract();
state = 0;
combine(UL, strtoul(token, NULL, 8), 0);
}
break;
case 56:
cat();
state = 0;
combine(ULL, strtoull(token, NULL, 8), 0);
break;
case 58: // <
cat();
get_char();
switch (C) {
case '=':
cat(); state = 0; combine(REL, 1, 0); break; // <=
case '<':
state = 59; break; // <<?
default:
retract(); state = 0; combine(REL, 0, 0); break; // <
}
break;
case 59: // <<
cat();
get_char();
if (C == '=') {
cat(); state = 0; combine(ASS, 10, 0); // <<=
}
else {
retract(); state = 0; combine(BIT, 4, 0); // <<
}
break;
case 60: // >
cat();
get_char();
switch (C) {
case '=':
cat(); state = 0; combine(REL, 3, 0); break; // >=
case '>':
state = 61; break; // >>
default:
retract(); state = 0; combine(REL, 2, 0); break; // >
}
break;
case 61: // >>
cat();
get_char();
if (C == '=') {
cat(); state = 0; combine(ASS, 9, 0); // >>=
}
else {
retract(); state = 0; combine(BIT, 5, 0); // >>
}
break;
case 62: // =
cat();
get_char();
if (C == '=') {
cat(); state = 0; combine(REL, 4, 0); // ==
}