-
Notifications
You must be signed in to change notification settings - Fork 2
/
token.c
98 lines (96 loc) · 1.36 KB
/
token.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
#include "awk.h"
struct tok
{ char *tnm;
int yval;
} tok[] = {
"FIRSTTOKEN", 257,
"FINAL", 258,
"FATAL", 259,
"LT", 260,
"LE", 261,
"GT", 262,
"GE", 263,
"EQ", 264,
"NE", 265,
"MATCH", 266,
"NOTMATCH", 267,
"APPEND", 268,
"ADD", 269,
"MINUS", 270,
"MULT", 271,
"DIVIDE", 272,
"MOD", 273,
"UMINUS", 274,
"ASSIGN", 275,
"ADDEQ", 276,
"SUBEQ", 277,
"MULTEQ", 278,
"DIVEQ", 279,
"MODEQ", 280,
"JUMP", 281,
"XBEGIN", 282,
"XEND", 283,
"NL", 284,
"PRINT", 285,
"PRINTF", 286,
"SPRINTF", 287,
"SPLIT", 288,
"IF", 289,
"ELSE", 290,
"WHILE", 291,
"FOR", 292,
"IN", 293,
"NEXT", 294,
"EXIT", 295,
"BREAK", 296,
"CONTINUE", 297,
"PROGRAM", 298,
"PASTAT", 299,
"PASTAT2", 300,
"ASGNOP", 301,
"BOR", 302,
"AND", 303,
"NOT", 304,
"NUMBER", 305,
"VAR", 306,
"ARRAY", 307,
"FNCN", 308,
"SUBSTR", 309,
"LSUBSTR", 310,
"INDEX", 311,
"RELOP", 312,
"MATCHOP", 313,
"OR", 314,
"STRING", 315,
"DOT", 316,
"CCL", 317,
"NCCL", 318,
"CHAR", 319,
"CAT", 320,
"STAR", 321,
"PLUS", 322,
"QUEST", 323,
"POSTINCR", 324,
"PREINCR", 325,
"POSTDECR", 326,
"PREDECR", 327,
"INCR", 328,
"DECR", 329,
"FIELD", 330,
"INDIRECT", 331,
"LASTTOKEN", 332,
};
ptoken(n)
{
if(n<128) printf("lex: %c\n",n);
else if(n<=256) printf("lex:? %o\n",n);
else if(n<LASTTOKEN) printf("lex: %s\n",tok[n-257].tnm);
else printf("lex:? %o\n",n);
return;
}
char *tokname(n)
{
if (n<=256 || n >= LASTTOKEN)
n = 257;
return(tok[n-257].tnm);
}