1 |
|
|
#include <stdio.h> |
2 |
|
|
#include "awk.h" |
3 |
|
|
#include "ytab.h" |
4 |
|
|
|
5 |
|
|
static char *printname[93] = { |
6 |
|
|
(char *) "FIRSTTOKEN", /* 257 */ |
7 |
|
|
(char *) "PROGRAM", /* 258 */ |
8 |
|
|
(char *) "PASTAT", /* 259 */ |
9 |
|
|
(char *) "PASTAT2", /* 260 */ |
10 |
|
|
(char *) "XBEGIN", /* 261 */ |
11 |
|
|
(char *) "XEND", /* 262 */ |
12 |
|
|
(char *) "NL", /* 263 */ |
13 |
|
|
(char *) "ARRAY", /* 264 */ |
14 |
|
|
(char *) "MATCH", /* 265 */ |
15 |
|
|
(char *) "NOTMATCH", /* 266 */ |
16 |
|
|
(char *) "MATCHOP", /* 267 */ |
17 |
|
|
(char *) "FINAL", /* 268 */ |
18 |
|
|
(char *) "DOT", /* 269 */ |
19 |
|
|
(char *) "ALL", /* 270 */ |
20 |
|
|
(char *) "CCL", /* 271 */ |
21 |
|
|
(char *) "NCCL", /* 272 */ |
22 |
|
|
(char *) "CHAR", /* 273 */ |
23 |
|
|
(char *) "OR", /* 274 */ |
24 |
|
|
(char *) "STAR", /* 275 */ |
25 |
|
|
(char *) "QUEST", /* 276 */ |
26 |
|
|
(char *) "PLUS", /* 277 */ |
27 |
|
|
(char *) "EMPTYRE", /* 278 */ |
28 |
|
|
(char *) "AND", /* 279 */ |
29 |
|
|
(char *) "BOR", /* 280 */ |
30 |
|
|
(char *) "APPEND", /* 281 */ |
31 |
|
|
(char *) "EQ", /* 282 */ |
32 |
|
|
(char *) "GE", /* 283 */ |
33 |
|
|
(char *) "GT", /* 284 */ |
34 |
|
|
(char *) "LE", /* 285 */ |
35 |
|
|
(char *) "LT", /* 286 */ |
36 |
|
|
(char *) "NE", /* 287 */ |
37 |
|
|
(char *) "IN", /* 288 */ |
38 |
|
|
(char *) "ARG", /* 289 */ |
39 |
|
|
(char *) "BLTIN", /* 290 */ |
40 |
|
|
(char *) "BREAK", /* 291 */ |
41 |
|
|
(char *) "CLOSE", /* 292 */ |
42 |
|
|
(char *) "CONTINUE", /* 293 */ |
43 |
|
|
(char *) "DELETE", /* 294 */ |
44 |
|
|
(char *) "DO", /* 295 */ |
45 |
|
|
(char *) "EXIT", /* 296 */ |
46 |
|
|
(char *) "FOR", /* 297 */ |
47 |
|
|
(char *) "FUNC", /* 298 */ |
48 |
|
|
(char *) "SUB", /* 299 */ |
49 |
|
|
(char *) "GSUB", /* 300 */ |
50 |
|
|
(char *) "IF", /* 301 */ |
51 |
|
|
(char *) "INDEX", /* 302 */ |
52 |
|
|
(char *) "LSUBSTR", /* 303 */ |
53 |
|
|
(char *) "MATCHFCN", /* 304 */ |
54 |
|
|
(char *) "NEXT", /* 305 */ |
55 |
|
|
(char *) "NEXTFILE", /* 306 */ |
56 |
|
|
(char *) "ADD", /* 307 */ |
57 |
|
|
(char *) "MINUS", /* 308 */ |
58 |
|
|
(char *) "MULT", /* 309 */ |
59 |
|
|
(char *) "DIVIDE", /* 310 */ |
60 |
|
|
(char *) "MOD", /* 311 */ |
61 |
|
|
(char *) "ASSIGN", /* 312 */ |
62 |
|
|
(char *) "ASGNOP", /* 313 */ |
63 |
|
|
(char *) "ADDEQ", /* 314 */ |
64 |
|
|
(char *) "SUBEQ", /* 315 */ |
65 |
|
|
(char *) "MULTEQ", /* 316 */ |
66 |
|
|
(char *) "DIVEQ", /* 317 */ |
67 |
|
|
(char *) "MODEQ", /* 318 */ |
68 |
|
|
(char *) "POWEQ", /* 319 */ |
69 |
|
|
(char *) "PRINT", /* 320 */ |
70 |
|
|
(char *) "PRINTF", /* 321 */ |
71 |
|
|
(char *) "SPRINTF", /* 322 */ |
72 |
|
|
(char *) "ELSE", /* 323 */ |
73 |
|
|
(char *) "INTEST", /* 324 */ |
74 |
|
|
(char *) "CONDEXPR", /* 325 */ |
75 |
|
|
(char *) "POSTINCR", /* 326 */ |
76 |
|
|
(char *) "PREINCR", /* 327 */ |
77 |
|
|
(char *) "POSTDECR", /* 328 */ |
78 |
|
|
(char *) "PREDECR", /* 329 */ |
79 |
|
|
(char *) "VAR", /* 330 */ |
80 |
|
|
(char *) "IVAR", /* 331 */ |
81 |
|
|
(char *) "VARNF", /* 332 */ |
82 |
|
|
(char *) "CALL", /* 333 */ |
83 |
|
|
(char *) "NUMBER", /* 334 */ |
84 |
|
|
(char *) "STRING", /* 335 */ |
85 |
|
|
(char *) "REGEXPR", /* 336 */ |
86 |
|
|
(char *) "GETLINE", /* 337 */ |
87 |
|
|
(char *) "RETURN", /* 338 */ |
88 |
|
|
(char *) "SPLIT", /* 339 */ |
89 |
|
|
(char *) "SUBSTR", /* 340 */ |
90 |
|
|
(char *) "WHILE", /* 341 */ |
91 |
|
|
(char *) "CAT", /* 342 */ |
92 |
|
|
(char *) "NOT", /* 343 */ |
93 |
|
|
(char *) "UMINUS", /* 344 */ |
94 |
|
|
(char *) "POWER", /* 345 */ |
95 |
|
|
(char *) "DECR", /* 346 */ |
96 |
|
|
(char *) "INCR", /* 347 */ |
97 |
|
|
(char *) "INDIRECT", /* 348 */ |
98 |
|
|
(char *) "LASTTOKEN", /* 349 */ |
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 |
|
|
|
198 |
|
|
char *tokname(int n) |
199 |
|
|
{ |
200 |
|
|
static char buf[100]; |
201 |
|
|
|
202 |
|
|
if (n < FIRSTTOKEN || n > LASTTOKEN) { |
203 |
|
|
snprintf(buf, sizeof buf, "token %d", n); |
204 |
|
|
return buf; |
205 |
|
|
} |
206 |
|
|
return printname[n-FIRSTTOKEN]; |
207 |
|
|
} |