1 #include <stdio.h>
2 #include "awk.h"
3 #include "ytab.h"
4
5 static char *printname[93] = {
6 (char *) "FIRSTTOKEN", /* 57346 */
7 (char *) "PROGRAM", /* 57347 */
8 (char *) "PASTAT", /* 57348 */
9 (char *) "PASTAT2", /* 57349 */
10 (char *) "XBEGIN", /* 57350 */
11 (char *) "XEND", /* 57351 */
12 (char *) "NL", /* 57352 */
13 (char *) "ARRAY", /* 57353 */
14 (char *) "MATCH", /* 57354 */
15 (char *) "NOTMATCH", /* 57355 */
16 (char *) "MATCHOP", /* 57356 */
17 (char *) "FINAL", /* 57357 */
18 (char *) "DOT", /* 57358 */
19 (char *) "ALL", /* 57359 */
20 (char *) "CCL", /* 57360 */
21 (char *) "NCCL", /* 57361 */
22 (char *) "CHAR", /* 57362 */
23 (char *) "OR", /* 57363 */
24 (char *) "STAR", /* 57364 */
25 (char *) "QUEST", /* 57365 */
26 (char *) "PLUS", /* 57366 */
27 (char *) "EMPTYRE", /* 57367 */
28 (char *) "AND", /* 57368 */
29 (char *) "BOR", /* 57369 */
30 (char *) "APPEND", /* 57370 */
31 (char *) "EQ", /* 57371 */
32 (char *) "GE", /* 57372 */
33 (char *) "GT", /* 57373 */
34 (char *) "LE", /* 57374 */
35 (char *) "LT", /* 57375 */
36 (char *) "NE", /* 57376 */
37 (char *) "IN", /* 57377 */
38 (char *) "ARG", /* 57378 */
39 (char *) "BLTIN", /* 57379 */
40 (char *) "BREAK", /* 57380 */
41 (char *) "CLOSE", /* 57381 */
42 (char *) "CONTINUE", /* 57382 */
43 (char *) "DELETE", /* 57383 */
44 (char *) "DO", /* 57384 */
45 (char *) "EXIT", /* 57385 */
46 (char *) "FOR", /* 57386 */
47 (char *) "FUNC", /* 57387 */
48 (char *) "SUB", /* 57388 */
49 (char *) "GSUB", /* 57389 */
50 (char *) "IF", /* 57390 */
51 (char *) "INDEX", /* 57391 */
52 (char *) "LSUBSTR", /* 57392 */
53 (char *) "MATCHFCN", /* 57393 */
54 (char *) "NEXT", /* 57394 */
55 (char *) "NEXTFILE", /* 57395 */
56 (char *) "ADD", /* 57396 */
57 (char *) "MINUS", /* 57397 */
58 (char *) "MULT", /* 57398 */
59 (char *) "DIVIDE", /* 57399 */
60 (char *) "MOD", /* 57400 */
61 (char *) "ASSIGN", /* 57401 */
62 (char *) "ASGNOP", /* 57402 */
63 (char *) "ADDEQ", /* 57403 */
64 (char *) "SUBEQ", /* 57404 */
65 (char *) "MULTEQ", /* 57405 */
66 (char *) "DIVEQ", /* 57406 */
67 (char *) "MODEQ", /* 57407 */
68 (char *) "POWEQ", /* 57408 */
69 (char *) "PRINT", /* 57409 */
70 (char *) "PRINTF", /* 57410 */
71 (char *) "SPRINTF", /* 57411 */
72 (char *) "ELSE", /* 57412 */
73 (char *) "INTEST", /* 57413 */
74 (char *) "CONDEXPR", /* 57414 */
75 (char *) "POSTINCR", /* 57415 */
76 (char *) "PREINCR", /* 57416 */
77 (char *) "POSTDECR", /* 57417 */
78 (char *) "PREDECR", /* 57418 */
79 (char *) "VAR", /* 57419 */
80 (char *) "IVAR", /* 57420 */
81 (char *) "VARNF", /* 57421 */
82 (char *) "CALL", /* 57422 */
83 (char *) "NUMBER", /* 57423 */
84 (char *) "STRING", /* 57424 */
85 (char *) "REGEXPR", /* 57425 */
86 (char *) "GETLINE", /* 57426 */
87 (char *) "RETURN", /* 57427 */
88 (char *) "SPLIT", /* 57428 */
89 (char *) "SUBSTR", /* 57429 */
90 (char *) "WHILE", /* 57430 */
91 (char *) "CAT", /* 57431 */
92 (char *) "NOT", /* 57432 */
93 (char *) "UMINUS", /* 57433 */
94 (char *) "POWER", /* 57434 */
95 (char *) "DECR", /* 57435 */
96 (char *) "INCR", /* 57436 */
97 (char *) "INDIRECT", /* 57437 */
98 (char *) "LASTTOKEN", /* 57438 */
99 };
100
101
102 Cell *(*proctab[93])(Node **, int) = {
103 nullproc, /* FIRSTTOKEN */
104 program, /* PROGRAM */
105 pastat, /* PASTAT */
106 dopa2, /* PASTAT2 */
107 nullproc, /* XBEGIN */
108 nullproc, /* XEND */
109 nullproc, /* NL */
110 array, /* ARRAY */
111 matchop, /* MATCH */
112 matchop, /* NOTMATCH */
113 nullproc, /* MATCHOP */
114 nullproc, /* FINAL */
115 nullproc, /* DOT */
116 nullproc, /* ALL */
117 nullproc, /* CCL */
118 nullproc, /* NCCL */
119 nullproc, /* CHAR */
120 nullproc, /* OR */
121 nullproc, /* STAR */
122 nullproc, /* QUEST */
123 nullproc, /* PLUS */
124 nullproc, /* EMPTYRE */
125 boolop, /* AND */
126 boolop, /* BOR */
127 nullproc, /* APPEND */
128 relop, /* EQ */
129 relop, /* GE */
130 relop, /* GT */
131 relop, /* LE */
132 relop, /* LT */
133 relop, /* NE */
134 instat, /* IN */
135 arg, /* ARG */
136 bltin, /* BLTIN */
137 jump, /* BREAK */
138 closefile, /* CLOSE */
139 jump, /* CONTINUE */
140 awkdelete, /* DELETE */
141 dostat, /* DO */
142 jump, /* EXIT */
143 forstat, /* FOR */
144 nullproc, /* FUNC */
145 sub, /* SUB */
146 gsub, /* GSUB */
147 ifstat, /* IF */
148 sindex, /* INDEX */
149 nullproc, /* LSUBSTR */
150 matchop, /* MATCHFCN */
151 jump, /* NEXT */
152 jump, /* NEXTFILE */
153 arith, /* ADD */
154 arith, /* MINUS */
155 arith, /* MULT */
156 arith, /* DIVIDE */
157 arith, /* MOD */
158 assign, /* ASSIGN */
159 nullproc, /* ASGNOP */
160 assign, /* ADDEQ */
161 assign, /* SUBEQ */
162 assign, /* MULTEQ */
163 assign, /* DIVEQ */
164 assign, /* MODEQ */
165 assign, /* POWEQ */
166 printstat, /* PRINT */
167 awkprintf, /* PRINTF */
168 awksprintf, /* SPRINTF */
169 nullproc, /* ELSE */
170 intest, /* INTEST */
171 condexpr, /* CONDEXPR */
172 incrdecr, /* POSTINCR */
173 incrdecr, /* PREINCR */
174 incrdecr, /* POSTDECR */
175 incrdecr, /* PREDECR */
176 nullproc, /* VAR */
177 nullproc, /* IVAR */
178 getnf, /* VARNF */
179 call, /* CALL */
180 nullproc, /* NUMBER */
181 nullproc, /* STRING */
182 nullproc, /* REGEXPR */
183 awkgetline, /* GETLINE */
184 jump, /* RETURN */
185 split, /* SPLIT */
186 substr, /* SUBSTR */
187 whilestat, /* WHILE */
188 cat, /* CAT */
189 boolop, /* NOT */
190 arith, /* UMINUS */
191 arith, /* POWER */
192 nullproc, /* DECR */
193 nullproc, /* INCR */
194 indirect, /* INDIRECT */
195 nullproc, /* LASTTOKEN */
196 };
197
tokname(int n)198 char *tokname(int n)
199 {
200 static char buf[100];
201
202 if (n < FIRSTTOKEN || n > LASTTOKEN) {
203 sprintf(buf, "token %d", n);
204 return buf;
205 }
206 return printname[n-FIRSTTOKEN];
207 }
208