aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/one-true-awk/proctab.c
blob: def5b67a8758151f6d030d0a0c722dedb82a911e (plain) (blame)
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
#include <stdio.h>
#include "awk.h"
#include "ytab.h"

static char *printname[92] = {
	(char *) "FIRSTTOKEN",	/* 57346 */
	(char *) "PROGRAM",	/* 57347 */
	(char *) "PASTAT",	/* 57348 */
	(char *) "PASTAT2",	/* 57349 */
	(char *) "XBEGIN",	/* 57350 */
	(char *) "XEND",	/* 57351 */
	(char *) "NL",	/* 57352 */
	(char *) "ARRAY",	/* 57353 */
	(char *) "MATCH",	/* 57354 */
	(char *) "NOTMATCH",	/* 57355 */
	(char *) "MATCHOP",	/* 57356 */
	(char *) "FINAL",	/* 57357 */
	(char *) "DOT",	/* 57358 */
	(char *) "ALL",	/* 57359 */
	(char *) "CCL",	/* 57360 */
	(char *) "NCCL",	/* 57361 */
	(char *) "CHAR",	/* 57362 */
	(char *) "OR",	/* 57363 */
	(char *) "STAR",	/* 57364 */
	(char *) "QUEST",	/* 57365 */
	(char *) "PLUS",	/* 57366 */
	(char *) "AND",	/* 57367 */
	(char *) "BOR",	/* 57368 */
	(char *) "APPEND",	/* 57369 */
	(char *) "EQ",	/* 57370 */
	(char *) "GE",	/* 57371 */
	(char *) "GT",	/* 57372 */
	(char *) "LE",	/* 57373 */
	(char *) "LT",	/* 57374 */
	(char *) "NE",	/* 57375 */
	(char *) "IN",	/* 57376 */
	(char *) "ARG",	/* 57377 */
	(char *) "BLTIN",	/* 57378 */
	(char *) "BREAK",	/* 57379 */
	(char *) "CLOSE",	/* 57380 */
	(char *) "CONTINUE",	/* 57381 */
	(char *) "DELETE",	/* 57382 */
	(char *) "DO",	/* 57383 */
	(char *) "EXIT",	/* 57384 */
	(char *) "FOR",	/* 57385 */
	(char *) "FUNC",	/* 57386 */
	(char *) "SUB",	/* 57387 */
	(char *) "GSUB",	/* 57388 */
	(char *) "IF",	/* 57389 */
	(char *) "INDEX",	/* 57390 */
	(char *) "LSUBSTR",	/* 57391 */
	(char *) "MATCHFCN",	/* 57392 */
	(char *) "NEXT",	/* 57393 */
	(char *) "NEXTFILE",	/* 57394 */
	(char *) "ADD",	/* 57395 */
	(char *) "MINUS",	/* 57396 */
	(char *) "MULT",	/* 57397 */
	(char *) "DIVIDE",	/* 57398 */
	(char *) "MOD",	/* 57399 */
	(char *) "ASSIGN",	/* 57400 */
	(char *) "ASGNOP",	/* 57401 */
	(char *) "ADDEQ",	/* 57402 */
	(char *) "SUBEQ",	/* 57403 */
	(char *) "MULTEQ",	/* 57404 */
	(char *) "DIVEQ",	/* 57405 */
	(char *) "MODEQ",	/* 57406 */
	(char *) "POWEQ",	/* 57407 */
	(char *) "PRINT",	/* 57408 */
	(char *) "PRINTF",	/* 57409 */
	(char *) "SPRINTF",	/* 57410 */
	(char *) "ELSE",	/* 57411 */
	(char *) "INTEST",	/* 57412 */
	(char *) "CONDEXPR",	/* 57413 */
	(char *) "POSTINCR",	/* 57414 */
	(char *) "PREINCR",	/* 57415 */
	(char *) "POSTDECR",	/* 57416 */
	(char *) "PREDECR",	/* 57417 */
	(char *) "VAR",	/* 57418 */
	(char *) "IVAR",	/* 57419 */
	(char *) "VARNF",	/* 57420 */
	(char *) "CALL",	/* 57421 */
	(char *) "NUMBER",	/* 57422 */
	(char *) "STRING",	/* 57423 */
	(char *) "REGEXPR",	/* 57424 */
	(char *) "GETLINE",	/* 57425 */
	(char *) "RETURN",	/* 57426 */
	(char *) "SPLIT",	/* 57427 */
	(char *) "SUBSTR",	/* 57428 */
	(char *) "WHILE",	/* 57429 */
	(char *) "CAT",	/* 57430 */
	(char *) "NOT",	/* 57431 */
	(char *) "UMINUS",	/* 57432 */
	(char *) "POWER",	/* 57433 */
	(char *) "DECR",	/* 57434 */
	(char *) "INCR",	/* 57435 */
	(char *) "INDIRECT",	/* 57436 */
	(char *) "LASTTOKEN",	/* 57437 */
};


Cell *(*proctab[92])(Node **, int) = {
	nullproc,	/* FIRSTTOKEN */
	program,	/* PROGRAM */
	pastat,	/* PASTAT */
	dopa2,	/* PASTAT2 */
	nullproc,	/* XBEGIN */
	nullproc,	/* XEND */
	nullproc,	/* NL */
	array,	/* ARRAY */
	matchop,	/* MATCH */
	matchop,	/* NOTMATCH */
	nullproc,	/* MATCHOP */
	nullproc,	/* FINAL */
	nullproc,	/* DOT */
	nullproc,	/* ALL */
	nullproc,	/* CCL */
	nullproc,	/* NCCL */
	nullproc,	/* CHAR */
	nullproc,	/* OR */
	nullproc,	/* STAR */
	nullproc,	/* QUEST */
	nullproc,	/* PLUS */
	boolop,	/* AND */
	boolop,	/* BOR */
	nullproc,	/* APPEND */
	relop,	/* EQ */
	relop,	/* GE */
	relop,	/* GT */
	relop,	/* LE */
	relop,	/* LT */
	relop,	/* NE */
	instat,	/* IN */
	arg,	/* ARG */
	bltin,	/* BLTIN */
	jump,	/* BREAK */
	closefile,	/* CLOSE */
	jump,	/* CONTINUE */
	awkdelete,	/* DELETE */
	dostat,	/* DO */
	jump,	/* EXIT */
	forstat,	/* FOR */
	nullproc,	/* FUNC */
	sub,	/* SUB */
	gsub,	/* GSUB */
	ifstat,	/* IF */
	sindex,	/* INDEX */
	nullproc,	/* LSUBSTR */
	matchop,	/* MATCHFCN */
	jump,	/* NEXT */
	jump,	/* NEXTFILE */
	arith,	/* ADD */
	arith,	/* MINUS */
	arith,	/* MULT */
	arith,	/* DIVIDE */
	arith,	/* MOD */
	assign,	/* ASSIGN */
	nullproc,	/* ASGNOP */
	assign,	/* ADDEQ */
	assign,	/* SUBEQ */
	assign,	/* MULTEQ */
	assign,	/* DIVEQ */
	assign,	/* MODEQ */
	assign,	/* POWEQ */
	printstat,	/* PRINT */
	awkprintf,	/* PRINTF */
	awksprintf,	/* SPRINTF */
	nullproc,	/* ELSE */
	intest,	/* INTEST */
	condexpr,	/* CONDEXPR */
	incrdecr,	/* POSTINCR */
	incrdecr,	/* PREINCR */
	incrdecr,	/* POSTDECR */
	incrdecr,	/* PREDECR */
	nullproc,	/* VAR */
	nullproc,	/* IVAR */
	getnf,	/* VARNF */
	call,	/* CALL */
	nullproc,	/* NUMBER */
	nullproc,	/* STRING */
	nullproc,	/* REGEXPR */
	getline,	/* GETLINE */
	jump,	/* RETURN */
	split,	/* SPLIT */
	substr,	/* SUBSTR */
	whilestat,	/* WHILE */
	cat,	/* CAT */
	boolop,	/* NOT */
	arith,	/* UMINUS */
	arith,	/* POWER */
	nullproc,	/* DECR */
	nullproc,	/* INCR */
	indirect,	/* INDIRECT */
	nullproc,	/* LASTTOKEN */
};

char *tokname(int n)
{
	static char buf[100];

	if (n < FIRSTTOKEN || n > LASTTOKEN) {
		sprintf(buf, "token %d", n);
		return buf;
	}
	return printname[n-FIRSTTOKEN];
}