BSD 4_4_Lite2 development
[unix-history] / usr / src / contrib / gawk-2.15.2 / awktab.c
CommitLineData
b5fbb1a0
C
1
2/* A Bison parser, made from awk.y */
3
4#define YYBISON 1 /* Identify Bison output. */
5
6#define FUNC_CALL 258
7#define NAME 259
8#define REGEXP 260
9#define ERROR 261
10#define YNUMBER 262
11#define YSTRING 263
12#define RELOP 264
13#define APPEND_OP 265
14#define ASSIGNOP 266
15#define MATCHOP 267
16#define NEWLINE 268
17#define CONCAT_OP 269
18#define LEX_BEGIN 270
19#define LEX_END 271
20#define LEX_IF 272
21#define LEX_ELSE 273
22#define LEX_RETURN 274
23#define LEX_DELETE 275
24#define LEX_WHILE 276
25#define LEX_DO 277
26#define LEX_FOR 278
27#define LEX_BREAK 279
28#define LEX_CONTINUE 280
29#define LEX_PRINT 281
30#define LEX_PRINTF 282
31#define LEX_NEXT 283
32#define LEX_EXIT 284
33#define LEX_FUNCTION 285
34#define LEX_GETLINE 286
35#define LEX_IN 287
36#define LEX_AND 288
37#define LEX_OR 289
38#define INCREMENT 290
39#define DECREMENT 291
40#define LEX_BUILTIN 292
41#define LEX_LENGTH 293
42#define UNARY 294
43
44#line 26 "awk.y"
45
46#ifdef DEBUG
47#define YYDEBUG 12
48#endif
49
50#include "awk.h"
51
52static void yyerror (); /* va_alist */
53static char *get_src_buf P((void));
54static int yylex P((void));
55static NODE *node_common P((NODETYPE op));
56static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
57static NODE *mkrangenode P((NODE *cpair));
58static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
59static NODE *append_right P((NODE *list, NODE *new));
60static void func_install P((NODE *params, NODE *def));
61static void pop_var P((NODE *np, int freeit));
62static void pop_params P((NODE *params));
63static NODE *make_param P((char *name));
64static NODE *mk_rexp P((NODE *exp));
65
66static int want_assign; /* lexical scanning kludge */
67static int want_regexp; /* lexical scanning kludge */
68static int can_return; /* lexical scanning kludge */
69static int io_allowed = 1; /* lexical scanning kludge */
70static char *lexptr; /* pointer to next char during parsing */
71static char *lexend;
72static char *lexptr_begin; /* keep track of where we were for error msgs */
73static char *lexeme; /* beginning of lexeme for debugging */
74static char *thisline = NULL;
75#define YYDEBUG_LEXER_TEXT (lexeme)
76static int param_counter;
77static char *tokstart = NULL;
78static char *token = NULL;
79static char *tokend;
80
81NODE *variables[HASHSIZE];
82
83extern char *source;
84extern int sourceline;
85extern struct src *srcfiles;
86extern int numfiles;
87extern int errcount;
88extern NODE *begin_block;
89extern NODE *end_block;
90
91#line 73 "awk.y"
92typedef union {
93 long lval;
94 AWKNUM fval;
95 NODE *nodeval;
96 NODETYPE nodetypeval;
97 char *sval;
98 NODE *(*ptrval)();
99} YYSTYPE;
100
101#ifndef YYLTYPE
102typedef
103 struct yyltype
104 {
105 int timestamp;
106 int first_line;
107 int first_column;
108 int last_line;
109 int last_column;
110 char *text;
111 }
112 yyltype;
113
114#define YYLTYPE yyltype
115#endif
116
117#include <stdio.h>
118
119#ifndef __STDC__
120#define const
121#endif
122
123
124
125#define YYFINAL 306
126#define YYFLAG -32768
127#define YYNTBASE 61
128
129#define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 106)
130
131static const char yytranslate[] = { 0,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 49, 2, 2, 52, 48, 2, 2, 53,
136 54, 46, 44, 60, 45, 2, 47, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 40, 59, 41,
138 2, 42, 39, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 55, 2, 56, 51, 2, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 57, 43, 58, 2, 2, 2, 2, 2,
145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
157 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
158 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
159 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
160 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
161 36, 37, 38, 50
162};
163
164#if YYDEBUG != 0
165static const short yyprhs[] = { 0,
166 0, 4, 6, 9, 11, 14, 15, 19, 20, 24,
167 27, 30, 33, 35, 38, 41, 43, 45, 47, 49,
168 51, 52, 60, 65, 67, 71, 72, 77, 83, 88,
169 90, 93, 95, 98, 100, 103, 106, 109, 113, 115,
170 122, 131, 140, 151, 161, 164, 167, 174, 179, 183,
171 187, 188, 193, 200, 203, 205, 207, 214, 224, 226,
172 229, 230, 232, 233, 236, 237, 240, 243, 246, 247,
173 249, 251, 255, 257, 260, 264, 265, 267, 268, 270,
174 272, 276, 278, 281, 285, 289, 290, 292, 294, 298,
175 300, 303, 307, 311, 312, 317, 323, 328, 332, 336,
176 340, 344, 346, 349, 353, 357, 361, 365, 371, 373,
177 376, 377, 382, 386, 390, 394, 396, 399, 403, 407,
178 411, 417, 419, 422, 424, 428, 432, 436, 440, 444,
179 448, 451, 454, 457, 461, 466, 471, 473, 478, 480,
180 483, 486, 488, 490, 493, 496, 497, 499, 501, 506,
181 509, 512, 515, 517, 518, 520, 522
182};
183
184#endif
185
186static const short yyrhs[] = { 82,
187 62, 82, 0, 63, 0, 62, 63, 0, 1, 0,
188 62, 1, 0, 0, 15, 64, 74, 0, 0, 16,
189 65, 74, 0, 15, 76, 0, 16, 76, 0, 71,
190 74, 0, 74, 0, 71, 76, 0, 68, 70, 0,
191 4, 0, 3, 0, 67, 0, 37, 0, 38, 0,
192 0, 30, 69, 66, 53, 85, 102, 82, 0, 100,
193 75, 101, 103, 0, 92, 0, 92, 105, 92, 0,
194 0, 47, 73, 5, 47, 0, 100, 75, 101, 103,
195 82, 0, 100, 101, 103, 82, 0, 77, 0, 75,
196 77, 0, 1, 0, 75, 1, 0, 81, 0, 104,
197 82, 0, 104, 82, 0, 100, 101, 0, 100, 75,
198 101, 0, 80, 0, 21, 53, 92, 102, 82, 77,
199 0, 22, 82, 77, 21, 53, 92, 102, 82, 0,
200 23, 53, 4, 32, 4, 102, 82, 77, 0, 23,
201 53, 87, 104, 92, 104, 87, 102, 82, 77, 0,
202 23, 53, 87, 104, 104, 87, 102, 82, 77, 0,
203 24, 76, 0, 25, 76, 0, 79, 53, 91, 102,
204 84, 76, 0, 79, 88, 84, 76, 0, 28, 87,
205 76, 0, 29, 87, 76, 0, 0, 19, 78, 87,
206 76, 0, 20, 4, 55, 91, 56, 76, 0, 92,
207 76, 0, 26, 0, 27, 0, 17, 53, 92, 102,
208 82, 77, 0, 17, 53, 92, 102, 82, 77, 18,
209 82, 77, 0, 13, 0, 81, 13, 0, 0, 81,
210 0, 0, 41, 96, 0, 0, 42, 92, 0, 10,
211 92, 0, 43, 92, 0, 0, 86, 0, 4, 0,
212 86, 105, 4, 0, 1, 0, 86, 1, 0, 86,
213 105, 1, 0, 0, 92, 0, 0, 89, 0, 94,
214 0, 89, 105, 94, 0, 1, 0, 89, 1, 0,
215 89, 1, 94, 0, 89, 105, 1, 0, 0, 91,
216 0, 92, 0, 91, 105, 92, 0, 1, 0, 91,
217 1, 0, 91, 1, 92, 0, 91, 105, 1, 0,
218 0, 99, 11, 93, 92, 0, 53, 91, 102, 32,
219 4, 0, 92, 43, 31, 98, 0, 31, 98, 83,
220 0, 92, 33, 92, 0, 92, 34, 92, 0, 92,
221 12, 92, 0, 72, 0, 49, 72, 0, 92, 32,
222 4, 0, 92, 9, 92, 0, 92, 41, 92, 0,
223 92, 42, 92, 0, 92, 39, 92, 40, 92, 0,
224 96, 0, 92, 96, 0, 0, 99, 11, 95, 94,
225 0, 94, 33, 94, 0, 94, 34, 94, 0, 31,
226 98, 83, 0, 72, 0, 49, 72, 0, 94, 12,
227 94, 0, 94, 32, 4, 0, 94, 9, 94, 0,
228 94, 39, 94, 40, 94, 0, 96, 0, 94, 96,
229 0, 97, 0, 96, 51, 96, 0, 96, 46, 96,
230 0, 96, 47, 96, 0, 96, 48, 96, 0, 96,
231 44, 96, 0, 96, 45, 96, 0, 99, 35, 0,
232 99, 36, 0, 49, 96, 0, 53, 92, 102, 0,
233 37, 53, 90, 102, 0, 38, 53, 90, 102, 0,
234 38, 0, 3, 53, 90, 102, 0, 99, 0, 35,
235 99, 0, 36, 99, 0, 7, 0, 8, 0, 45,
236 96, 0, 44, 96, 0, 0, 99, 0, 4, 0,
237 4, 55, 91, 56, 0, 52, 97, 0, 57, 82,
238 0, 58, 82, 0, 54, 0, 0, 104, 0, 59,
239 0, 60, 82, 0
240};
241
242#if YYDEBUG != 0
243static const short yyrline[] = { 0,
244 133, 138, 146, 162, 163, 167, 169, 183, 185, 199,
245 205, 211, 213, 215, 228, 237, 239, 241, 251, 252,
246 256, 260, 268, 277, 279, 288, 290, 308, 310, 315,
247 317, 325, 327, 332, 333, 337, 339, 341, 343, 345,
248 347, 349, 354, 358, 363, 366, 369, 371, 382, 400,
249 402, 404, 406, 408, 413, 415, 420, 425, 432, 434,
250 438, 439, 443, 445, 450, 452, 454, 456, 461, 463,
251 468, 470, 472, 474, 476, 482, 484, 489, 491, 496,
252 498, 504, 506, 508, 510, 515, 517, 522, 524, 530,
253 532, 534, 536, 541, 544, 549, 551, 556, 562, 564,
254 566, 572, 574, 582, 584, 590, 592, 594, 596, 598,
255 603, 606, 607, 609, 611, 617, 619, 621, 623, 625,
256 627, 629, 631, 636, 638, 640, 642, 644, 646, 648,
257 650, 652, 657, 659, 661, 664, 666, 674, 678, 679,
258 681, 683, 685, 688, 695, 700, 702, 707, 709, 717,
259 722, 726, 730, 734, 735, 739, 742
260};
261
262static const char * const yytname[] = { "$","error","$illegal.","FUNC_CALL",
263"NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
264"NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
265"LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
266"LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_IN","LEX_AND",
267"LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'","'<'",
268"'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY","'^'","'$'","'('","')'",
269"'['","']'","'{'","'}'","';'","','","start","program","rule","@1","@2","func_name",
270"lex_builtin","function_prologue","@3","function_body","pattern","regexp","@4",
271"action","statements","statement_term","statement","@5","print","if_statement",
272"nls","opt_nls","input_redir","output_redir","opt_param_list","param_list","opt_exp",
273"opt_rexpression_list","rexpression_list","opt_expression_list","expression_list",
274"exp","@6","rexp","@7","simp_exp","non_post_simp_exp","opt_variable","variable",
275"l_brace","r_brace","r_paren","opt_semi","semi","comma",""
276};
277#endif
278
279static const short yyr1[] = { 0,
280 61, 62, 62, 62, 62, 64, 63, 65, 63, 63,
281 63, 63, 63, 63, 63, 66, 66, 66, 67, 67,
282 69, 68, 70, 71, 71, 73, 72, 74, 74, 75,
283 75, 75, 75, 76, 76, 77, 77, 77, 77, 77,
284 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
285 78, 77, 77, 77, 79, 79, 80, 80, 81, 81,
286 82, 82, 83, 83, 84, 84, 84, 84, 85, 85,
287 86, 86, 86, 86, 86, 87, 87, 88, 88, 89,
288 89, 89, 89, 89, 89, 90, 90, 91, 91, 91,
289 91, 91, 91, 93, 92, 92, 92, 92, 92, 92,
290 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
291 95, 94, 94, 94, 94, 94, 94, 94, 94, 94,
292 94, 94, 94, 96, 96, 96, 96, 96, 96, 96,
293 96, 96, 97, 97, 97, 97, 97, 97, 97, 97,
294 97, 97, 97, 97, 97, 98, 98, 99, 99, 99,
295 100, 101, 102, 103, 103, 104, 105
296};
297
298static const short yyr2[] = { 0,
299 3, 1, 2, 1, 2, 0, 3, 0, 3, 2,
300 2, 2, 1, 2, 2, 1, 1, 1, 1, 1,
301 0, 7, 4, 1, 3, 0, 4, 5, 4, 1,
302 2, 1, 2, 1, 2, 2, 2, 3, 1, 6,
303 8, 8, 10, 9, 2, 2, 6, 4, 3, 3,
304 0, 4, 6, 2, 1, 1, 6, 9, 1, 2,
305 0, 1, 0, 2, 0, 2, 2, 2, 0, 1,
306 1, 3, 1, 2, 3, 0, 1, 0, 1, 1,
307 3, 1, 2, 3, 3, 0, 1, 1, 3, 1,
308 2, 3, 3, 0, 4, 5, 4, 3, 3, 3,
309 3, 1, 2, 3, 3, 3, 3, 5, 1, 2,
310 0, 4, 3, 3, 3, 1, 2, 3, 3, 3,
311 5, 1, 2, 1, 3, 3, 3, 3, 3, 3,
312 2, 2, 2, 3, 4, 4, 1, 4, 1, 2,
313 2, 1, 1, 2, 2, 0, 1, 1, 4, 2,
314 2, 2, 1, 0, 1, 1, 2
315};
316
317static const short yydefact[] = { 61,
318 59, 62, 0, 60, 4, 0, 148, 142, 143, 6,
319 8, 21, 146, 0, 0, 0, 137, 0, 0, 26,
320 0, 0, 0, 61, 0, 2, 0, 0, 102, 13,
321 24, 109, 124, 139, 0, 0, 0, 156, 0, 10,
322 34, 61, 0, 11, 0, 63, 147, 140, 141, 0,
323 0, 0, 0, 145, 139, 144, 0, 103, 133, 150,
324 139, 90, 0, 88, 151, 5, 3, 1, 15, 0,
325 12, 14, 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 61, 110, 0, 0, 0, 0, 0, 0, 0,
327 94, 131, 132, 32, 0, 51, 0, 0, 61, 0,
328 0, 0, 55, 56, 76, 76, 61, 0, 30, 0,
329 39, 0, 0, 154, 61, 0, 0, 88, 0, 7,
330 35, 9, 17, 16, 19, 20, 0, 18, 0, 98,
331 0, 0, 0, 0, 91, 153, 0, 0, 134, 0,
332 105, 101, 104, 99, 100, 0, 106, 107, 146, 157,
333 25, 129, 130, 126, 127, 128, 125, 0, 0, 76,
334 0, 0, 0, 76, 45, 46, 0, 77, 0, 152,
335 33, 31, 154, 82, 146, 0, 0, 116, 65, 0,
336 80, 122, 139, 54, 0, 37, 61, 155, 36, 138,
337 149, 0, 64, 135, 136, 27, 92, 0, 93, 89,
338 154, 0, 97, 95, 0, 0, 0, 0, 0, 148,
339 0, 49, 50, 61, 63, 117, 0, 0, 0, 0,
340 0, 83, 0, 0, 0, 0, 0, 0, 0, 123,
341 111, 38, 29, 73, 71, 0, 0, 96, 23, 108,
342 61, 52, 0, 61, 0, 0, 0, 28, 115, 65,
343 67, 66, 68, 48, 84, 85, 81, 120, 118, 119,
344 113, 114, 0, 0, 61, 74, 0, 0, 0, 0,
345 0, 0, 0, 76, 0, 0, 112, 22, 75, 72,
346 57, 53, 40, 0, 61, 76, 0, 47, 121, 61,
347 61, 0, 0, 61, 0, 41, 42, 61, 0, 58,
348 0, 44, 43, 0, 0, 0
349};
350
351static const short yydefgoto[] = { 304,
352 25, 26, 39, 43, 127, 128, 27, 45, 69, 28,
353 29, 57, 30, 108, 40, 109, 160, 110, 111, 2,
354 3, 130, 221, 236, 237, 167, 179, 180, 116, 117,
355 112, 158, 181, 264, 32, 33, 46, 34, 113, 114,
356 139, 187, 115, 138
357};
358
359static const short yypact[] = { -6,
360-32768, 8, 1094,-32768,-32768, -26, -11,-32768,-32768, -1,
361 -1,-32768, 1, 1, 1, 16, 31, 1738, 1738,-32768,
362 1691, 1738, 1186, -6, 890,-32768, -5, -2,-32768,-32768,
363 836, 69,-32768, 83, 612, 1166, 1186,-32768, -5,-32768,
364 8, -6, -5,-32768, 101, 20,-32768,-32768,-32768, 1166,
365 1166, 1738, 1606, 36, 2, 36, 62,-32768, 36,-32768,
366-32768,-32768, 5, 1299,-32768,-32768,-32768,-32768,-32768, 726,
367-32768,-32768, 1606, 1606, 93, 1606, 1606, 1606, 1606, 1606,
368 70, -6, 69, 1606, 1738, 1738, 1738, 1738, 1738, 1738,
369-32768,-32768,-32768,-32768, 54,-32768, 105, 58, -6, 68,
370 -1, -1,-32768,-32768, 1606, 1606, -6, 679,-32768, 783,
371-32768, 994, 612, 78, -6, 86, 18, 1398, 23,-32768,
372-32768,-32768,-32768,-32768,-32768,-32768, 90,-32768, 1738,-32768,
373 86, 86, 1299, 97, 1606,-32768, 104, 1233,-32768, 679,
374 1373, 1753,-32768, 1506, 1445, 1351, 1373, 1373, 1,-32768,
375 1398, 130, 130, 36, 36, 36, 36, 1606, 1606, 1606,
376 92, 1606, 937, 1625,-32768,-32768, -1, 1398, -1,-32768,
377-32768,-32768, 78,-32768, 1, 1691, 1186,-32768, 0, 3,
378 1528, 69, 89,-32768, 679,-32768, -6,-32768,-32768,-32768,
379-32768, 14, 69,-32768,-32768,-32768, 1398, 144,-32768, 1398,
380 78, 1606,-32768, 1398, 1299, -1, 1186, 1299, 131, -15,
381 78,-32768,-32768, -6, 20,-32768, 5, 1606, 1606, 1606,
382 -1, 1672, 1252, 1672, 1672, 147, 1672, 1672, 1672, 69,
383-32768,-32768,-32768,-32768,-32768, 86, 28,-32768,-32768, 1398,
384 -6,-32768, 29, -6, 100, 150, 1119,-32768,-32768, 0,
385 1398, 1398, 1398,-32768, 1528,-32768, 1528, 802, 1013,-32768,
386 1586, 1567, 1467, 1672, -6,-32768, 35, 937, -1, 937,
387 1606, 86, 1047, 1606, -1, 1672, 1528,-32768,-32768,-32768,
388 140,-32768,-32768, 1299, -6, 1606, 86,-32768, 1528, -6,
389 -6, 937, 86, -6, 937,-32768,-32768, -6, 937,-32768,
390 937,-32768,-32768, 160, 172,-32768
391};
392
393static const short yypgoto[] = {-32768,
394-32768, 148,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
395 91,-32768, 106, -47, 82, -99,-32768,-32768,-32768, 21,
396 155, -40, -65,-32768,-32768, -104,-32768,-32768, 76, -9,
397 -3,-32768, 11,-32768, 325, 164, -124, 77, 103, -105,
398 247, -147, 406, -30
399};
400
401
402#define YYLAST 1806
403
404
405static const short yytable[] = { 31,
406 84, 169, 173, 222, 7, 135, 1, 186, 172, 218,
407 1, 1, -79, 63, 234, -79, 246, 235, 135, 64,
408 4, 31, 140, 135, 203, 214, 36, 119, 266, 135,
409 41, 41, 118, 118, 201, 279, 92, 93, 280, 37,
410 172, 219, 220, 37, -79, -79, 118, 118, 41, 133,
411 215, 24, 22, 239, 24, 206, 38, 38, 136, 211,
412 129, -79, 82, 209, 82, 185, 134, -69, 50, 141,
413 142, -87, 144, 145, 146, 147, 148, 82, 191, 232,
414 151, -70, 82, 51, 269, 172, 90, 82, 82, 47,
415 48, 49, 44, 91, 55, 55, 143, 55, 61, 231,
416 149, 168, 168, 123, 124, 35, 159, 55, 161, 72,
417 162, 58, 85, 86, 87, 88, 89, 92, 93, 90,
418 164, 41, 41, 92, 93, 131, 132, 35, 55, 70,
419 35, 197, 41, 71, 200, 198, 38, 125, 126, 136,
420 55, 35, 192, 196, 120, 35, 207, 238, 122, 223,
421 260, 245, 271, 272, 204, 205, 168, 290, 208, 305,
422 168, 55, 55, 55, 55, 55, 55, 217, 281, 287,
423 283, 306, 67, 64, 249, 87, 88, 89, 65, 68,
424 90, 293, 165, 166, 275, 60, 183, 41, 55, 41,
425 0, 0, 297, 184, 55, 300, 121, 243, 240, 302,
426 178, 303, 0, 118, 0, 55, 267, 0, 0, 55,
427 0, 0, 0, 0, 251, 252, 253, 55, 55, 0,
428 55, 55, 55, 55, 55, 47, 41, 55, 0, 0,
429 0, 0, 255, 257, 258, 259, 150, 261, 262, 263,
430 0, 41, 0, 273, 55, 0, 0, 0, 212, 0,
431 213, 47, 55, 163, 0, 0, 0, 55, 0, 0,
432 0, 170, 0, 0, 0, 0, 216, 284, 0, 189,
433 168, 0, 0, 55, 277, 0, 55, 0, 0, 0,
434 55, 55, 168, 0, 55, 0, 289, 242, 0, 41,
435 0, 0, 0, 0, 0, 41, 0, 0, 183, 183,
436 183, 183, 254, 183, 183, 183, 0, 0, 0, 137,
437 0, 0, 178, 178, 178, 178, 55, 178, 178, 178,
438 0, 0, 0, 0, 0, 0, 0, 55, 55, 55,
439 0, 55, 0, 55, 55, 55, 0, 55, 55, 55,
440 183, 233, 54, 56, 0, 59, 0, 0, 0, 55,
441 282, 0, 183, 55, 178, 83, 288, 0, 0, 0,
442 55, 0, 190, 0, 0, 55, 178, 0, 248, 0,
443 0, 0, 0, 0, 0, 0, 59, 194, 195, 0,
444 0, 0, 0, 0, 0, 0, 0, 0, 83, 0,
445 0, 0, 0, 0, 0, 268, 0, 0, 270, 0,
446 0, 0, 0, 0, 0, 0, 0, 0, 0, 152,
447 153, 154, 155, 156, 157, 42, 42, 0, 0, 278,
448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
449 0, 0, 0, 42, 182, 0, 83, 0, 0, 292,
450 0, 0, 83, 0, 295, 296, 0, 0, 299, 0,
451 0, 241, 301, 193, 244, 0, 0, 83, 0, 0,
452 0, 0, 0, 250, 0, 83, 83, 0, 83, 83,
453 83, 83, 83, 0, 0, 83, 0, 0, 0, 0,
454 0, 0, 265, 0, 0, 0, 0, 0, 0, 0,
455 0, 0, 83, 0, 0, 0, 0, 0, 0, 0,
456 59, 0, 0, 0, 0, 230, 42, 42, 0, 0,
457 0, 0, 0, 0, 0, 0, 0, 42, 285, 188,
458 0, 83, 0, 0, 83, 0, 0, 0, 83, 83,
459 291, 0, 83, 294, 0, 0, 0, 0, 0, 298,
460 0, 0, 0, 0, 0, 0, 182, 182, 182, 182,
461 0, 182, 182, 182, 0, 0, 0, 0, 0, 0,
462 0, 0, 0, 0, 83, 0, 0, 0, 0, 0,
463 0, 0, 42, 0, 42, 83, 83, 83, 188, 230,
464 0, 230, 230, 230, 0, 230, 230, 230, 182, 0,
465 0, 0, 0, 0, 0, 0, 0, 83, 0, 0,
466 182, 230, 0, 0, 0, 0, 188, 0, 83, 0,
467 0, 42, 94, 230, 6, 7, 247, 0, 8, 9,
468 0, 0, 0, 0, 0, 0, 42, 0, 95, 0,
469 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
470 106, 0, 13, 0, 0, 0, 14, 15, 16, 17,
471 0, 0, 274, 0, 0, 18, 19, 0, 20, 0,
472 21, 0, 0, 22, 23, 0, 0, 0, 24, 107,
473 38, 0, 0, 0, 42, 0, 0, 0, 286, 171,
474 42, 6, 7, 0, 0, 8, 9, 0, 0, 0,
475 0, 0, 0, 0, 0, 95, 0, 96, 97, 98,
476 99, 100, 101, 102, 103, 104, 105, 106, 0, 13,
477 0, 0, 0, 14, 15, 16, 17, 0, 0, 0,
478 0, 0, 18, 19, 0, 20, 94, 21, 6, 7,
479 22, 23, 8, 9, 0, 24, 107, 38, 0, 0,
480 0, 0, 95, 0, 96, 97, 98, 99, 100, 101,
481 102, 103, 104, 105, 106, 0, 13, 0, 0, 0,
482 14, 15, 16, 17, 0, 0, 0, 0, 0, 18,
483 19, 0, 20, 0, 21, 0, 0, 22, 23, 0,
484 0, 0, 24, 174, 38, 6, 7, 0, 0, 8,
485 9, 0, -78, 0, 0, -78, 0, 0, 0, 0,
486 0, 0, 0, 0, 0, 7, 0, 0, 8, 9,
487-32768, 0, 0, 175, 0, 0, 0, 14, 15, 16,
488 17, 0, 0, 0, -78, -78, 18, 19, 0, 20,
489 0, 176, 0, 0, 22, 177, 14, 15, 6, 7,
490 0, -78, 8, 9, 73, 18, 19, 74, 0, 0,
491 52, 0, 0, 22, 53, 0, 0, 0, 0, 0,
492 0, 0, 0, 0, 0, 0, 0, 75, 76, 77,
493 14, 15, 16, 17, 78, 0, 79, 80, 81, 18,
494 19, 0, 0, 0, 52, 0, 0, 22, 53, -61,
495 66, 0, 6, 7, 0, 82, 8, 9, 0, 0,
496 0, 0, 1, 0, 10, 11, 0, 0, 0, 0,
497 0, 0, 0, 0, 0, 0, 0, 0, 0, 12,
498 13, 0, 0, 0, 14, 15, 16, 17, 0, 0,
499 0, 0, 0, 18, 19, 0, 20, 0, 21, 6,
500 7, 22, 23, 8, 9, 0, 24, 0, 0, 0,
501 0, 0, 0, 95, 0, 96, 97, 98, 99, 100,
502 101, 102, 103, 104, 105, 106, 0, 13, 0, 0,
503 0, 14, 15, 16, 17, 0, 0, 0, 0, 0,
504 18, 19, 0, 20, 0, 21, 0, 0, 22, 23,
505 0, 0, 0, 24, 0, 38, 6, 7, 0, 0,
506 8, 9, 73, 0, 0, 74, 1, 0, 0, 0,
507 0, 0, 0, 0, 0, 0, 7, 0, 0, 8,
508 9, 224, 0, 0,-32768, 75, 76, 77, 14, 15,
509 16, 17, 78, 0, 79, 80, 81, 18, 19, 0,
510 0, 0, 52, 0, 0, 22, 53, 14, 15, 6,
511 7, 0, 38, 8, 9, 73, 18, 19, 74, 0,
512 0, 52, 0, 0, 22, 53, 0, 0, 0, 0,
513 0, 0, 0, 0, 0, 0, 0, 0, 75, 76,
514 77, 14, 15, 16, 17, 78, 0, 79, 80, 81,
515 18, 19, 0, 0, 5, 52, 6, 7, 22, 53,
516 8, 9, 0, 0, 0, 38, 0, 0, 10, 11,
517 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
518 0, 6, 7, 12, 13, 8, 9, 0, 14, 15,
519 16, 17, 0, 0, 0, 0, 0, 18, 19, 0,
520 20, 0, 21, 0, 0, 22, 23, 0, 0, 13,
521 24, 0, 0, 14, 15, 16, 17, 0, 0, 0,
522 0, 0, 18, 19, 0, 20, 62, 21, 6, 7,
523 22, 23, 8, 9, 0, 0, 0, 38, 0, 0,
524 0, 0, 0, 0, 0, 0, 62, 0, 6, 7,
525 0, 0, 8, 9, 0, 0, 13, 0, 0, 0,
526 14, 15, 16, 17, 0, 0, 0, 0, 0, 18,
527 19, 0, 20, 0, 21, 0, 13, 22, 23, -86,
528 14, 15, 16, 17, 0, 0, 0, 0, 0, 18,
529 19, 0, 20, 199, 21, 6, 7, 22, 23, 8,
530 9, 0, 0, 0, 0, 0, 0, 0, 0, 0,
531 0, 0, 256, 0, 6, 7, 0, 0, 8, 9,
532 0, 0, 0, 13, 0, 0, 0, 14, 15, 16,
533 17, 0, 0, 0, 0, 0, 18, 19, 0, 20,
534 0, 21, 175, 0, 22, 23, 14, 15, 16, 17,
535 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
536 176, 6, 7, 22, 53, 8, 9, 73, 0, 0,
537 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
538 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
539 75, 76, 77, 14, 15, 16, 17, 78, 0, 79,
540 80, 81, 18, 19, 0, 0, 0, 52, 0, 0,
541 22, 53, 136, 6, 7, 0, 0, 8, 9, 73,
542 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
543 0, 0, 0, 0, 0, 0, 7, 0, 0, 8,
544 9,-32768, 75, 76, 77, 14, 15, 16, 17, 78,
545 202, 79, 80, 81, 18, 19, 0, 0, 0, 52,
546 6, 7, 22, 53, 8, 9, 73, 14, 15, 74,
547 0, 0, 0,-32768,-32768,-32768, 18, 19, 0, 0,
548 0, 52, 0, 0, 22, 53, 0, 0, 0, 75,
549 76, 77, 14, 15, 16, 17, 78, 0, 79, 80,
550 81, 18, 19, 0, 0, 0, 52, 6, 7, 22,
551 53, 8, 9, 73, 0, 0, 74, 0, 0, 0,
552 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
553 7, 0, 0, 8, 9, 224, 75, 76, 225, 14,
554 15, 16, 17, 0, 0, 79, 80, 81, 18, 19,
555 0, 0, 0, 52, 0, 0, 22, 53, 226, 227,
556 228, 14, 15, 16, 17, 229, 276, 0, 6, 7,
557 18, 19, 8, 9, 73, 52, 0, 74, 22, 53,
558 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
559 6, 7, 0, 0, 8, 9, 224, 75, 0, 225,
560 14, 15, 16, 17, 0, 0, 79, 80, 81, 18,
561 19, 0, 0, 0, 52, 0, 0, 22, 53, 226,
562 227, 228, 14, 15, 16, 17, 229, 0, 0, 6,
563 7, 18, 19, 8, 9, 224, 52, 0, 225, 22,
564 53, 0, 0, 0, 0, 0, 0, 0, 6, 7,
565 0, 0, 8, 9, 224, 0, 0, 225, 226, 227,
566 0, 14, 15, 16, 17, 0, 0, 0, 6, 7,
567 18, 19, 8, 9, 0, 52, 0, 226, 22, 53,
568 14, 15, 16, 17, 0, 0, 0, 6, 210, 18,
569 19, 8, 9, 0, 52, 0, 13, 22, 53, 0,
570 14, 15, 16, 17, 0, 0, 0, 0, 0, 18,
571 19, 0, 20, 0, 21, 13, 0, 22, 23, 14,
572 15, 16, 17, 0, 0, 0, 0, 0, 18, 19,
573 0, 20, 0, 21, 6, 7, 22, 23, 8, 9,
574 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
575 0, 0, 0, 6, 7, 0, 0, 8, 9, 0,
576 0, 0, 175, 0, 0, 0, 14, 15, 16, 17,
577 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
578 176, 0, 0, 22, 53, 14, 15, 16, 17, 0,
579 0, 0, 0, 0, 18, 19, 0, 20, 0, 52,
580 6, 7, 22, 53, 8, 9, 0, 0, 0, 0,
581 0, 0, 0, 0, 0, 0, 7, 0, 0, 8,
582 9, 73, 0, 0,-32768, 0, 0, 0, 0, 0,
583 0, 0, 14, 15, 16, 17, 0, 0, 0, 0,
584 0, 18, 19, 0, 0, 0, 52, 14, 15, 22,
585 53, 0, 0, 79, 80, 81, 18, 19, 0, 0,
586 0, 52, 0, 0, 22, 53
587};
588
589static const short yycheck[] = { 3,
590 31, 106, 108, 1, 4, 1, 13, 113, 108, 10,
591 13, 13, 10, 23, 1, 13, 32, 4, 1, 23,
592 13, 25, 70, 1, 149, 173, 53, 37, 1, 1,
593 10, 11, 36, 37, 140, 1, 35, 36, 4, 55,
594 140, 42, 43, 55, 42, 43, 50, 51, 28, 53,
595 175, 57, 52, 201, 57, 160, 59, 59, 54, 164,
596 41, 59, 60, 163, 60, 113, 5, 54, 53, 73,
597 74, 54, 76, 77, 78, 79, 80, 60, 56, 185,
598 84, 54, 60, 53, 56, 185, 51, 60, 60, 13,
599 14, 15, 11, 11, 18, 19, 4, 21, 22, 11,
600 31, 105, 106, 3, 4, 3, 53, 31, 4, 28,
601 53, 21, 44, 45, 46, 47, 48, 35, 36, 51,
602 53, 101, 102, 35, 36, 50, 51, 25, 52, 27,
603 28, 135, 112, 28, 138, 32, 59, 37, 38, 54,
604 64, 39, 53, 47, 39, 43, 55, 4, 43, 180,
605 4, 21, 53, 4, 158, 159, 160, 18, 162, 0,
606 164, 85, 86, 87, 88, 89, 90, 177, 268, 274,
607 270, 0, 25, 177, 215, 46, 47, 48, 24, 25,
608 51, 286, 101, 102, 250, 22, 110, 167, 112, 169,
609 -1, -1, 292, 112, 118, 295, 42, 207, 202, 299,
610 110, 301, -1, 207, -1, 129, 237, -1, -1, 133,
611 -1, -1, -1, -1, 218, 219, 220, 141, 142, -1,
612 144, 145, 146, 147, 148, 149, 206, 151, -1, -1,
613 -1, -1, 222, 223, 224, 225, 82, 227, 228, 229,
614 -1, 221, -1, 247, 168, -1, -1, -1, 167, -1,
615 169, 175, 176, 99, -1, -1, -1, 181, -1, -1,
616 -1, 107, -1, -1, -1, -1, 176, 271, -1, 115,
617 274, -1, -1, 197, 264, -1, 200, -1, -1, -1,
618 204, 205, 286, -1, 208, -1, 276, 206, -1, 269,
619 -1, -1, -1, -1, -1, 275, -1, -1, 222, 223,
620 224, 225, 221, 227, 228, 229, -1, -1, -1, 63,
621 -1, -1, 222, 223, 224, 225, 240, 227, 228, 229,
622 -1, -1, -1, -1, -1, -1, -1, 251, 252, 253,
623 -1, 255, -1, 257, 258, 259, -1, 261, 262, 263,
624 264, 187, 18, 19, -1, 21, -1, -1, -1, 273,
625 269, -1, 276, 277, 264, 31, 275, -1, -1, -1,
626 284, -1, 116, -1, -1, 289, 276, -1, 214, -1,
627 -1, -1, -1, -1, -1, -1, 52, 131, 132, -1,
628 -1, -1, -1, -1, -1, -1, -1, -1, 64, -1,
629 -1, -1, -1, -1, -1, 241, -1, -1, 244, -1,
630 -1, -1, -1, -1, -1, -1, -1, -1, -1, 85,
631 86, 87, 88, 89, 90, 10, 11, -1, -1, 265,
632 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
633 -1, -1, -1, 28, 110, -1, 112, -1, -1, 285,
634 -1, -1, 118, -1, 290, 291, -1, -1, 294, -1,
635 -1, 205, 298, 129, 208, -1, -1, 133, -1, -1,
636 -1, -1, -1, 217, -1, 141, 142, -1, 144, 145,
637 146, 147, 148, -1, -1, 151, -1, -1, -1, -1,
638 -1, -1, 236, -1, -1, -1, -1, -1, -1, -1,
639 -1, -1, 168, -1, -1, -1, -1, -1, -1, -1,
640 176, -1, -1, -1, -1, 181, 101, 102, -1, -1,
641 -1, -1, -1, -1, -1, -1, -1, 112, 272, 114,
642 -1, 197, -1, -1, 200, -1, -1, -1, 204, 205,
643 284, -1, 208, 287, -1, -1, -1, -1, -1, 293,
644 -1, -1, -1, -1, -1, -1, 222, 223, 224, 225,
645 -1, 227, 228, 229, -1, -1, -1, -1, -1, -1,
646 -1, -1, -1, -1, 240, -1, -1, -1, -1, -1,
647 -1, -1, 167, -1, 169, 251, 252, 253, 173, 255,
648 -1, 257, 258, 259, -1, 261, 262, 263, 264, -1,
649 -1, -1, -1, -1, -1, -1, -1, 273, -1, -1,
650 276, 277, -1, -1, -1, -1, 201, -1, 284, -1,
651 -1, 206, 1, 289, 3, 4, 211, -1, 7, 8,
652 -1, -1, -1, -1, -1, -1, 221, -1, 17, -1,
653 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
654 29, -1, 31, -1, -1, -1, 35, 36, 37, 38,
655 -1, -1, 247, -1, -1, 44, 45, -1, 47, -1,
656 49, -1, -1, 52, 53, -1, -1, -1, 57, 58,
657 59, -1, -1, -1, 269, -1, -1, -1, 273, 1,
658 275, 3, 4, -1, -1, 7, 8, -1, -1, -1,
659 -1, -1, -1, -1, -1, 17, -1, 19, 20, 21,
660 22, 23, 24, 25, 26, 27, 28, 29, -1, 31,
661 -1, -1, -1, 35, 36, 37, 38, -1, -1, -1,
662 -1, -1, 44, 45, -1, 47, 1, 49, 3, 4,
663 52, 53, 7, 8, -1, 57, 58, 59, -1, -1,
664 -1, -1, 17, -1, 19, 20, 21, 22, 23, 24,
665 25, 26, 27, 28, 29, -1, 31, -1, -1, -1,
666 35, 36, 37, 38, -1, -1, -1, -1, -1, 44,
667 45, -1, 47, -1, 49, -1, -1, 52, 53, -1,
668 -1, -1, 57, 1, 59, 3, 4, -1, -1, 7,
669 8, -1, 10, -1, -1, 13, -1, -1, -1, -1,
670 -1, -1, -1, -1, -1, 4, -1, -1, 7, 8,
671 9, -1, -1, 31, -1, -1, -1, 35, 36, 37,
672 38, -1, -1, -1, 42, 43, 44, 45, -1, 47,
673 -1, 49, -1, -1, 52, 53, 35, 36, 3, 4,
674 -1, 59, 7, 8, 9, 44, 45, 12, -1, -1,
675 49, -1, -1, 52, 53, -1, -1, -1, -1, -1,
676 -1, -1, -1, -1, -1, -1, -1, 32, 33, 34,
677 35, 36, 37, 38, 39, -1, 41, 42, 43, 44,
678 45, -1, -1, -1, 49, -1, -1, 52, 53, 0,
679 1, -1, 3, 4, -1, 60, 7, 8, -1, -1,
680 -1, -1, 13, -1, 15, 16, -1, -1, -1, -1,
681 -1, -1, -1, -1, -1, -1, -1, -1, -1, 30,
682 31, -1, -1, -1, 35, 36, 37, 38, -1, -1,
683 -1, -1, -1, 44, 45, -1, 47, -1, 49, 3,
684 4, 52, 53, 7, 8, -1, 57, -1, -1, -1,
685 -1, -1, -1, 17, -1, 19, 20, 21, 22, 23,
686 24, 25, 26, 27, 28, 29, -1, 31, -1, -1,
687 -1, 35, 36, 37, 38, -1, -1, -1, -1, -1,
688 44, 45, -1, 47, -1, 49, -1, -1, 52, 53,
689 -1, -1, -1, 57, -1, 59, 3, 4, -1, -1,
690 7, 8, 9, -1, -1, 12, 13, -1, -1, -1,
691 -1, -1, -1, -1, -1, -1, 4, -1, -1, 7,
692 8, 9, -1, -1, 12, 32, 33, 34, 35, 36,
693 37, 38, 39, -1, 41, 42, 43, 44, 45, -1,
694 -1, -1, 49, -1, -1, 52, 53, 35, 36, 3,
695 4, -1, 59, 7, 8, 9, 44, 45, 12, -1,
696 -1, 49, -1, -1, 52, 53, -1, -1, -1, -1,
697 -1, -1, -1, -1, -1, -1, -1, -1, 32, 33,
698 34, 35, 36, 37, 38, 39, -1, 41, 42, 43,
699 44, 45, -1, -1, 1, 49, 3, 4, 52, 53,
700 7, 8, -1, -1, -1, 59, -1, -1, 15, 16,
701 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
702 -1, 3, 4, 30, 31, 7, 8, -1, 35, 36,
703 37, 38, -1, -1, -1, -1, -1, 44, 45, -1,
704 47, -1, 49, -1, -1, 52, 53, -1, -1, 31,
705 57, -1, -1, 35, 36, 37, 38, -1, -1, -1,
706 -1, -1, 44, 45, -1, 47, 1, 49, 3, 4,
707 52, 53, 7, 8, -1, -1, -1, 59, -1, -1,
708 -1, -1, -1, -1, -1, -1, 1, -1, 3, 4,
709 -1, -1, 7, 8, -1, -1, 31, -1, -1, -1,
710 35, 36, 37, 38, -1, -1, -1, -1, -1, 44,
711 45, -1, 47, -1, 49, -1, 31, 52, 53, 54,
712 35, 36, 37, 38, -1, -1, -1, -1, -1, 44,
713 45, -1, 47, 1, 49, 3, 4, 52, 53, 7,
714 8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
715 -1, -1, 1, -1, 3, 4, -1, -1, 7, 8,
716 -1, -1, -1, 31, -1, -1, -1, 35, 36, 37,
717 38, -1, -1, -1, -1, -1, 44, 45, -1, 47,
718 -1, 49, 31, -1, 52, 53, 35, 36, 37, 38,
719 -1, -1, -1, -1, -1, 44, 45, -1, 47, -1,
720 49, 3, 4, 52, 53, 7, 8, 9, -1, -1,
721 12, -1, -1, -1, -1, -1, -1, -1, -1, -1,
722 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
723 32, 33, 34, 35, 36, 37, 38, 39, -1, 41,
724 42, 43, 44, 45, -1, -1, -1, 49, -1, -1,
725 52, 53, 54, 3, 4, -1, -1, 7, 8, 9,
726 -1, -1, 12, -1, -1, -1, -1, -1, -1, -1,
727 -1, -1, -1, -1, -1, -1, 4, -1, -1, 7,
728 8, 9, 32, 33, 34, 35, 36, 37, 38, 39,
729 40, 41, 42, 43, 44, 45, -1, -1, -1, 49,
730 3, 4, 52, 53, 7, 8, 9, 35, 36, 12,
731 -1, -1, -1, 41, 42, 43, 44, 45, -1, -1,
732 -1, 49, -1, -1, 52, 53, -1, -1, -1, 32,
733 33, 34, 35, 36, 37, 38, 39, -1, 41, 42,
734 43, 44, 45, -1, -1, -1, 49, 3, 4, 52,
735 53, 7, 8, 9, -1, -1, 12, -1, -1, -1,
736 -1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
737 4, -1, -1, 7, 8, 9, 32, 33, 12, 35,
738 36, 37, 38, -1, -1, 41, 42, 43, 44, 45,
739 -1, -1, -1, 49, -1, -1, 52, 53, 32, 33,
740 34, 35, 36, 37, 38, 39, 40, -1, 3, 4,
741 44, 45, 7, 8, 9, 49, -1, 12, 52, 53,
742 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
743 3, 4, -1, -1, 7, 8, 9, 32, -1, 12,
744 35, 36, 37, 38, -1, -1, 41, 42, 43, 44,
745 45, -1, -1, -1, 49, -1, -1, 52, 53, 32,
746 33, 34, 35, 36, 37, 38, 39, -1, -1, 3,
747 4, 44, 45, 7, 8, 9, 49, -1, 12, 52,
748 53, -1, -1, -1, -1, -1, -1, -1, 3, 4,
749 -1, -1, 7, 8, 9, -1, -1, 12, 32, 33,
750 -1, 35, 36, 37, 38, -1, -1, -1, 3, 4,
751 44, 45, 7, 8, -1, 49, -1, 32, 52, 53,
752 35, 36, 37, 38, -1, -1, -1, 3, 4, 44,
753 45, 7, 8, -1, 49, -1, 31, 52, 53, -1,
754 35, 36, 37, 38, -1, -1, -1, -1, -1, 44,
755 45, -1, 47, -1, 49, 31, -1, 52, 53, 35,
756 36, 37, 38, -1, -1, -1, -1, -1, 44, 45,
757 -1, 47, -1, 49, 3, 4, 52, 53, 7, 8,
758 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
759 -1, -1, -1, 3, 4, -1, -1, 7, 8, -1,
760 -1, -1, 31, -1, -1, -1, 35, 36, 37, 38,
761 -1, -1, -1, -1, -1, 44, 45, -1, 47, -1,
762 49, -1, -1, 52, 53, 35, 36, 37, 38, -1,
763 -1, -1, -1, -1, 44, 45, -1, 47, -1, 49,
764 3, 4, 52, 53, 7, 8, -1, -1, -1, -1,
765 -1, -1, -1, -1, -1, -1, 4, -1, -1, 7,
766 8, 9, -1, -1, 12, -1, -1, -1, -1, -1,
767 -1, -1, 35, 36, 37, 38, -1, -1, -1, -1,
768 -1, 44, 45, -1, -1, -1, 49, 35, 36, 52,
769 53, -1, -1, 41, 42, 43, 44, 45, -1, -1,
770 -1, 49, -1, -1, 52, 53
771};
772/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
773#line 3 "/local/lib/bison.simple"
774
775/* Skeleton output parser for bison,
776 Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
777
778 This program is free software; you can redistribute it and/or modify
779 it under the terms of the GNU General Public License as published by
780 the Free Software Foundation; either version 1, or (at your option)
781 any later version.
782
783 This program is distributed in the hope that it will be useful,
784 but WITHOUT ANY WARRANTY; without even the implied warranty of
785 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
786 GNU General Public License for more details.
787
788 You should have received a copy of the GNU General Public License
789 along with this program; if not, write to the Free Software
790 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
791
792
793#ifndef alloca
794#ifdef __GNUC__
795#define alloca __builtin_alloca
796#else /* not GNU C. */
797#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc)
798#include <alloca.h>
799#else /* not sparc */
800#if defined (MSDOS) && !defined (__TURBOC__)
801#include <malloc.h>
802#else /* not MSDOS, or __TURBOC__ */
803#if defined(_AIX)
804#include <malloc.h>
805 #pragma alloca
806#endif /* not _AIX */
807#endif /* not MSDOS, or __TURBOC__ */
808#endif /* not sparc. */
809#endif /* not GNU C. */
810#endif /* alloca not defined. */
811
812/* This is the parser code that is written into each bison parser
813 when the %semantic_parser declaration is not specified in the grammar.
814 It was written by Richard Stallman by simplifying the hairy parser
815 used when %semantic_parser is specified. */
816
817/* Note: there must be only one dollar sign in this file.
818 It is replaced by the list of actions, each action
819 as one case of the switch. */
820
821#define yyerrok (yyerrstatus = 0)
822#define yyclearin (yychar = YYEMPTY)
823#define YYEMPTY -2
824#define YYEOF 0
825#define YYACCEPT return(0)
826#define YYABORT return(1)
827#define YYERROR goto yyerrlab1
828/* Like YYERROR except do call yyerror.
829 This remains here temporarily to ease the
830 transition to the new meaning of YYERROR, for GCC.
831 Once GCC version 2 has supplanted version 1, this can go. */
832#define YYFAIL goto yyerrlab
833#define YYRECOVERING() (!!yyerrstatus)
834#define YYBACKUP(token, value) \
835do \
836 if (yychar == YYEMPTY && yylen == 1) \
837 { yychar = (token), yylval = (value); \
838 yychar1 = YYTRANSLATE (yychar); \
839 YYPOPSTACK; \
840 goto yybackup; \
841 } \
842 else \
843 { yyerror ("syntax error: cannot back up"); YYERROR; } \
844while (0)
845
846#define YYTERROR 1
847#define YYERRCODE 256
848
849#ifndef YYPURE
850#define YYLEX yylex()
851#endif
852
853#ifdef YYPURE
854#ifdef YYLSP_NEEDED
855#define YYLEX yylex(&yylval, &yylloc)
856#else
857#define YYLEX yylex(&yylval)
858#endif
859#endif
860
861/* If nonreentrant, generate the variables here */
862
863#ifndef YYPURE
864
865int yychar; /* the lookahead symbol */
866YYSTYPE yylval; /* the semantic value of the */
867 /* lookahead symbol */
868
869#ifdef YYLSP_NEEDED
870YYLTYPE yylloc; /* location data for the lookahead */
871 /* symbol */
872#endif
873
874int yynerrs; /* number of parse errors so far */
875#endif /* not YYPURE */
876
877#if YYDEBUG != 0
878int yydebug; /* nonzero means print parse trace */
879/* Since this is uninitialized, it does not stop multiple parsers
880 from coexisting. */
881#endif
882
883/* YYINITDEPTH indicates the initial size of the parser's stacks */
884
885#ifndef YYINITDEPTH
886#define YYINITDEPTH 200
887#endif
888
889/* YYMAXDEPTH is the maximum size the stacks can grow to
890 (effective only if the built-in stack extension method is used). */
891
892#if YYMAXDEPTH == 0
893#undef YYMAXDEPTH
894#endif
895
896#ifndef YYMAXDEPTH
897#define YYMAXDEPTH 10000
898#endif
899\f
900#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
901#define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
902#else /* not GNU C or C++ */
903#ifndef __cplusplus
904
905/* This is the most reliable way to avoid incompatibilities
906 in available built-in functions on various systems. */
907static void
908__yy_bcopy (from, to, count)
909 char *from;
910 char *to;
911 int count;
912{
913 register char *f = from;
914 register char *t = to;
915 register int i = count;
916
917 while (i-- > 0)
918 *t++ = *f++;
919}
920
921#else /* __cplusplus */
922
923/* This is the most reliable way to avoid incompatibilities
924 in available built-in functions on various systems. */
925static void
926__yy_bcopy (char *from, char *to, int count)
927{
928 register char *f = from;
929 register char *t = to;
930 register int i = count;
931
932 while (i-- > 0)
933 *t++ = *f++;
934}
935
936#endif
937#endif
938\f
939#line 169 "/local/lib/bison.simple"
940int
941yyparse()
942{
943 register int yystate;
944 register int yyn;
945 register short *yyssp;
946 register YYSTYPE *yyvsp;
947 int yyerrstatus; /* number of tokens to shift before error messages enabled */
948 int yychar1; /* lookahead token as an internal (translated) token number */
949
950 short yyssa[YYINITDEPTH]; /* the state stack */
951 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
952
953 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
954 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
955
956#ifdef YYLSP_NEEDED
957 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
958 YYLTYPE *yyls = yylsa;
959 YYLTYPE *yylsp;
960
961#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
962#else
963#define YYPOPSTACK (yyvsp--, yyssp--)
964#endif
965
966 int yystacksize = YYINITDEPTH;
967
968#ifdef YYPURE
969 int yychar;
970 YYSTYPE yylval;
971 int yynerrs;
972#ifdef YYLSP_NEEDED
973 YYLTYPE yylloc;
974#endif
975#endif
976
977 YYSTYPE yyval; /* the variable used to return */
978 /* semantic values from the action */
979 /* routines */
980
981 int yylen;
982
983#if YYDEBUG != 0
984 if (yydebug)
985 fprintf(stderr, "Starting parse\n");
986#endif
987
988 yystate = 0;
989 yyerrstatus = 0;
990 yynerrs = 0;
991 yychar = YYEMPTY; /* Cause a token to be read. */
992
993 /* Initialize stack pointers.
994 Waste one element of value and location stack
995 so that they stay on the same level as the state stack.
996 The wasted elements are never initialized. */
997
998 yyssp = yyss - 1;
999 yyvsp = yyvs;
1000#ifdef YYLSP_NEEDED
1001 yylsp = yyls;
1002#endif
1003
1004/* Push a new state, which is found in yystate . */
1005/* In all cases, when you get here, the value and location stacks
1006 have just been pushed. so pushing a state here evens the stacks. */
1007yynewstate:
1008
1009 *++yyssp = yystate;
1010
1011 if (yyssp >= yyss + yystacksize - 1)
1012 {
1013 /* Give user a chance to reallocate the stack */
1014 /* Use copies of these so that the &'s don't force the real ones into memory. */
1015 YYSTYPE *yyvs1 = yyvs;
1016 short *yyss1 = yyss;
1017#ifdef YYLSP_NEEDED
1018 YYLTYPE *yyls1 = yyls;
1019#endif
1020
1021 /* Get the current used size of the three stacks, in elements. */
1022 int size = yyssp - yyss + 1;
1023
1024#ifdef yyoverflow
1025 /* Each stack pointer address is followed by the size of
1026 the data in use in that stack, in bytes. */
1027 yyoverflow("parser stack overflow",
1028 &yyss1, size * sizeof (*yyssp),
1029 &yyvs1, size * sizeof (*yyvsp),
1030#ifdef YYLSP_NEEDED
1031 &yyls1, size * sizeof (*yylsp),
1032#endif
1033 &yystacksize);
1034
1035 yyss = yyss1; yyvs = yyvs1;
1036#ifdef YYLSP_NEEDED
1037 yyls = yyls1;
1038#endif
1039#else /* no yyoverflow */
1040 /* Extend the stack our own way. */
1041 if (yystacksize >= YYMAXDEPTH)
1042 {
1043 yyerror("parser stack overflow");
1044 return 2;
1045 }
1046 yystacksize *= 2;
1047 if (yystacksize > YYMAXDEPTH)
1048 yystacksize = YYMAXDEPTH;
1049 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
1050 __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
1051 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
1052 __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
1053#ifdef YYLSP_NEEDED
1054 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
1055 __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
1056#endif
1057#endif /* no yyoverflow */
1058
1059 yyssp = yyss + size - 1;
1060 yyvsp = yyvs + size - 1;
1061#ifdef YYLSP_NEEDED
1062 yylsp = yyls + size - 1;
1063#endif
1064
1065#if YYDEBUG != 0
1066 if (yydebug)
1067 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1068#endif
1069
1070 if (yyssp >= yyss + yystacksize - 1)
1071 YYABORT;
1072 }
1073
1074#if YYDEBUG != 0
1075 if (yydebug)
1076 fprintf(stderr, "Entering state %d\n", yystate);
1077#endif
1078
1079 goto yybackup;
1080 yybackup:
1081
1082/* Do appropriate processing given the current state. */
1083/* Read a lookahead token if we need one and don't already have one. */
1084/* yyresume: */
1085
1086 /* First try to decide what to do without reference to lookahead token. */
1087
1088 yyn = yypact[yystate];
1089 if (yyn == YYFLAG)
1090 goto yydefault;
1091
1092 /* Not known => get a lookahead token if don't already have one. */
1093
1094 /* yychar is either YYEMPTY or YYEOF
1095 or a valid token in external form. */
1096
1097 if (yychar == YYEMPTY)
1098 {
1099#if YYDEBUG != 0
1100 if (yydebug)
1101 fprintf(stderr, "Reading a token: ");
1102#endif
1103 yychar = YYLEX;
1104 }
1105
1106 /* Convert token to internal form (in yychar1) for indexing tables with */
1107
1108 if (yychar <= 0) /* This means end of input. */
1109 {
1110 yychar1 = 0;
1111 yychar = YYEOF; /* Don't call YYLEX any more */
1112
1113#if YYDEBUG != 0
1114 if (yydebug)
1115 fprintf(stderr, "Now at end of input.\n");
1116#endif
1117 }
1118 else
1119 {
1120 yychar1 = YYTRANSLATE(yychar);
1121
1122#if YYDEBUG != 0
1123 if (yydebug)
1124 {
1125 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1126 /* Give the individual parser a way to print the precise meaning
1127 of a token, for further debugging info. */
1128#ifdef YYPRINT
1129 YYPRINT (stderr, yychar, yylval);
1130#endif
1131 fprintf (stderr, ")\n");
1132 }
1133#endif
1134 }
1135
1136 yyn += yychar1;
1137 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1138 goto yydefault;
1139
1140 yyn = yytable[yyn];
1141
1142 /* yyn is what to do for this token type in this state.
1143 Negative => reduce, -yyn is rule number.
1144 Positive => shift, yyn is new state.
1145 New state is final state => don't bother to shift,
1146 just return success.
1147 0, or most negative number => error. */
1148
1149 if (yyn < 0)
1150 {
1151 if (yyn == YYFLAG)
1152 goto yyerrlab;
1153 yyn = -yyn;
1154 goto yyreduce;
1155 }
1156 else if (yyn == 0)
1157 goto yyerrlab;
1158
1159 if (yyn == YYFINAL)
1160 YYACCEPT;
1161
1162 /* Shift the lookahead token. */
1163
1164#if YYDEBUG != 0
1165 if (yydebug)
1166 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1167#endif
1168
1169 /* Discard the token being shifted unless it is eof. */
1170 if (yychar != YYEOF)
1171 yychar = YYEMPTY;
1172
1173 *++yyvsp = yylval;
1174#ifdef YYLSP_NEEDED
1175 *++yylsp = yylloc;
1176#endif
1177
1178 /* count tokens shifted since error; after three, turn off error status. */
1179 if (yyerrstatus) yyerrstatus--;
1180
1181 yystate = yyn;
1182 goto yynewstate;
1183
1184/* Do the default action for the current state. */
1185yydefault:
1186
1187 yyn = yydefact[yystate];
1188 if (yyn == 0)
1189 goto yyerrlab;
1190
1191/* Do a reduction. yyn is the number of a rule to reduce with. */
1192yyreduce:
1193 yylen = yyr2[yyn];
1194 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1195
1196#if YYDEBUG != 0
1197 if (yydebug)
1198 {
1199 int i;
1200
1201 fprintf (stderr, "Reducing via rule %d (line %d), ",
1202 yyn, yyrline[yyn]);
1203
1204 /* Print the symbols being reduced, and their result. */
1205 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1206 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1207 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1208 }
1209#endif
1210
1211
1212 switch (yyn) {
1213
1214case 1:
1215#line 134 "awk.y"
1216{ expression_value = yyvsp[-1].nodeval; ;
1217 break;}
1218case 2:
1219#line 139 "awk.y"
1220{
1221 if (yyvsp[0].nodeval != NULL)
1222 yyval.nodeval = yyvsp[0].nodeval;
1223 else
1224 yyval.nodeval = NULL;
1225 yyerrok;
1226 ;
1227 break;}
1228case 3:
1229#line 148 "awk.y"
1230{
1231 if (yyvsp[0].nodeval == NULL)
1232 yyval.nodeval = yyvsp[-1].nodeval;
1233 else if (yyvsp[-1].nodeval == NULL)
1234 yyval.nodeval = yyvsp[0].nodeval;
1235 else {
1236 if (yyvsp[-1].nodeval->type != Node_rule_list)
1237 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
1238 (NODE*)NULL);
1239 yyval.nodeval = append_right (yyvsp[-1].nodeval,
1240 node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
1241 }
1242 yyerrok;
1243 ;
1244 break;}
1245case 4:
1246#line 162 "awk.y"
1247{ yyval.nodeval = NULL; ;
1248 break;}
1249case 5:
1250#line 163 "awk.y"
1251{ yyval.nodeval = NULL; ;
1252 break;}
1253case 6:
1254#line 167 "awk.y"
1255{ io_allowed = 0; ;
1256 break;}
1257case 7:
1258#line 169 "awk.y"
1259{
1260 if (begin_block) {
1261 if (begin_block->type != Node_rule_list)
1262 begin_block = node(begin_block, Node_rule_list,
1263 (NODE *)NULL);
1264 (void) append_right (begin_block, node(
1265 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
1266 Node_rule_list, (NODE *)NULL) );
1267 } else
1268 begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
1269 yyval.nodeval = NULL;
1270 io_allowed = 1;
1271 yyerrok;
1272 ;
1273 break;}
1274case 8:
1275#line 183 "awk.y"
1276{ io_allowed = 0; ;
1277 break;}
1278case 9:
1279#line 185 "awk.y"
1280{
1281 if (end_block) {
1282 if (end_block->type != Node_rule_list)
1283 end_block = node(end_block, Node_rule_list,
1284 (NODE *)NULL);
1285 (void) append_right (end_block, node(
1286 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
1287 Node_rule_list, (NODE *)NULL));
1288 } else
1289 end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
1290 yyval.nodeval = NULL;
1291 io_allowed = 1;
1292 yyerrok;
1293 ;
1294 break;}
1295case 10:
1296#line 200 "awk.y"
1297{
1298 warning("BEGIN blocks must have an action part");
1299 errcount++;
1300 yyerrok;
1301 ;
1302 break;}
1303case 11:
1304#line 206 "awk.y"
1305{
1306 warning("END blocks must have an action part");
1307 errcount++;
1308 yyerrok;
1309 ;
1310 break;}
1311case 12:
1312#line 212 "awk.y"
1313{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
1314 break;}
1315case 13:
1316#line 214 "awk.y"
1317{ yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
1318 break;}
1319case 14:
1320#line 216 "awk.y"
1321{
1322 yyval.nodeval = node (yyvsp[-1].nodeval,
1323 Node_rule_node,
1324 node(node(node(make_number(0.0),
1325 Node_field_spec,
1326 (NODE *) NULL),
1327 Node_expression_list,
1328 (NODE *) NULL),
1329 Node_K_print,
1330 (NODE *) NULL));
1331 yyerrok;
1332 ;
1333 break;}
1334case 15:
1335#line 229 "awk.y"
1336{
1337 func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
1338 yyval.nodeval = NULL;
1339 yyerrok;
1340 ;
1341 break;}
1342case 16:
1343#line 238 "awk.y"
1344{ yyval.sval = yyvsp[0].sval; ;
1345 break;}
1346case 17:
1347#line 240 "awk.y"
1348{ yyval.sval = yyvsp[0].sval; ;
1349 break;}
1350case 18:
1351#line 242 "awk.y"
1352{
1353 yyerror("%s() is a built-in function, it cannot be redefined",
1354 tokstart);
1355 errcount++;
1356 /* yyerrok; */
1357 ;
1358 break;}
1359case 21:
1360#line 257 "awk.y"
1361{
1362 param_counter = 0;
1363 ;
1364 break;}
1365case 22:
1366#line 261 "awk.y"
1367{
1368 yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
1369 can_return = 1;
1370 ;
1371 break;}
1372case 23:
1373#line 269 "awk.y"
1374{
1375 yyval.nodeval = yyvsp[-2].nodeval;
1376 can_return = 0;
1377 ;
1378 break;}
1379case 24:
1380#line 278 "awk.y"
1381{ yyval.nodeval = yyvsp[0].nodeval; ;
1382 break;}
1383case 25:
1384#line 280 "awk.y"
1385{ yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
1386 break;}
1387case 26:
1388#line 289 "awk.y"
1389{ ++want_regexp; ;
1390 break;}
1391case 27:
1392#line 291 "awk.y"
1393{
1394 NODE *n;
1395 int len;
1396
1397 getnode(n);
1398 n->type = Node_regex;
1399 len = strlen(yyvsp[-1].sval);
1400 n->re_exp = make_string(yyvsp[-1].sval, len);
1401 n->re_reg = make_regexp(yyvsp[-1].sval, len, 0, 1);
1402 n->re_text = NULL;
1403 n->re_flags = CONST;
1404 n->re_cnt = 1;
1405 yyval.nodeval = n;
1406 ;
1407 break;}
1408case 28:
1409#line 309 "awk.y"
1410{ yyval.nodeval = yyvsp[-3].nodeval ; ;
1411 break;}
1412case 29:
1413#line 311 "awk.y"
1414{ yyval.nodeval = NULL; ;
1415 break;}
1416case 30:
1417#line 316 "awk.y"
1418{ yyval.nodeval = yyvsp[0].nodeval; ;
1419 break;}
1420case 31:
1421#line 318 "awk.y"
1422{
1423 if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
1424 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
1425 yyval.nodeval = append_right(yyvsp[-1].nodeval,
1426 node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
1427 yyerrok;
1428 ;
1429 break;}
1430case 32:
1431#line 326 "awk.y"
1432{ yyval.nodeval = NULL; ;
1433 break;}
1434case 33:
1435#line 328 "awk.y"
1436{ yyval.nodeval = NULL; ;
1437 break;}
1438case 36:
1439#line 338 "awk.y"
1440{ yyval.nodeval = NULL; ;
1441 break;}
1442case 37:
1443#line 340 "awk.y"
1444{ yyval.nodeval = NULL; ;
1445 break;}
1446case 38:
1447#line 342 "awk.y"
1448{ yyval.nodeval = yyvsp[-1].nodeval; ;
1449 break;}
1450case 39:
1451#line 344 "awk.y"
1452{ yyval.nodeval = yyvsp[0].nodeval; ;
1453 break;}
1454case 40:
1455#line 346 "awk.y"
1456{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
1457 break;}
1458case 41:
1459#line 348 "awk.y"
1460{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
1461 break;}
1462case 42:
1463#line 350 "awk.y"
1464{
1465 yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval,1),
1466 (NODE *)NULL, variable(yyvsp[-3].sval,1)));
1467 ;
1468 break;}
1469case 43:
1470#line 355 "awk.y"
1471{
1472 yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
1473 ;
1474 break;}
1475case 44:
1476#line 359 "awk.y"
1477{
1478 yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
1479 (NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
1480 ;
1481 break;}
1482case 45:
1483#line 365 "awk.y"
1484{ yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
1485 break;}
1486case 46:
1487#line 368 "awk.y"
1488{ yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
1489 break;}
1490case 47:
1491#line 370 "awk.y"
1492{ yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
1493 break;}
1494case 48:
1495#line 372 "awk.y"
1496{
1497 if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL)
1498 yyvsp[-2].nodeval = node(node(make_number(0.0),
1499 Node_field_spec,
1500 (NODE *) NULL),
1501 Node_expression_list,
1502 (NODE *) NULL);
1503
1504 yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
1505 ;
1506 break;}
1507case 49:
1508#line 383 "awk.y"
1509{ NODETYPE type;
1510
1511 if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) {
1512 if (do_lint)
1513 warning("`next file' is a gawk extension");
1514 else if (do_unix || do_posix)
1515 yyerror("`next file' is a gawk extension");
1516 else if (! io_allowed)
1517 yyerror("`next file' used in BEGIN or END action");
1518 type = Node_K_nextfile;
1519 } else {
1520 if (! io_allowed)
1521 yyerror("next used in BEGIN or END action");
1522 type = Node_K_next;
1523 }
1524 yyval.nodeval = node ((NODE *)NULL, type, (NODE *)NULL);
1525 ;
1526 break;}
1527case 50:
1528#line 401 "awk.y"
1529{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
1530 break;}
1531case 51:
1532#line 403 "awk.y"
1533{ if (! can_return) yyerror("return used outside function context"); ;
1534 break;}
1535case 52:
1536#line 405 "awk.y"
1537{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
1538 break;}
1539case 53:
1540#line 407 "awk.y"
1541{ yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ;
1542 break;}
1543case 54:
1544#line 409 "awk.y"
1545{ yyval.nodeval = yyvsp[-1].nodeval; ;
1546 break;}
1547case 55:
1548#line 414 "awk.y"
1549{ yyval.nodetypeval = yyvsp[0].nodetypeval; ;
1550 break;}
1551case 56:
1552#line 416 "awk.y"
1553{ yyval.nodetypeval = yyvsp[0].nodetypeval; ;
1554 break;}
1555case 57:
1556#line 421 "awk.y"
1557{
1558 yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if,
1559 node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
1560 ;
1561 break;}
1562case 58:
1563#line 427 "awk.y"
1564{ yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
1565 node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
1566 break;}
1567case 59:
1568#line 433 "awk.y"
1569{ want_assign = 0; ;
1570 break;}
1571case 63:
1572#line 444 "awk.y"
1573{ yyval.nodeval = NULL; ;
1574 break;}
1575case 64:
1576#line 446 "awk.y"
1577{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
1578 break;}
1579case 65:
1580#line 451 "awk.y"
1581{ yyval.nodeval = NULL; ;
1582 break;}
1583case 66:
1584#line 453 "awk.y"
1585{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
1586 break;}
1587case 67:
1588#line 455 "awk.y"
1589{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
1590 break;}
1591case 68:
1592#line 457 "awk.y"
1593{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
1594 break;}
1595case 69:
1596#line 462 "awk.y"
1597{ yyval.nodeval = NULL; ;
1598 break;}
1599case 70:
1600#line 464 "awk.y"
1601{ yyval.nodeval = yyvsp[0].nodeval; ;
1602 break;}
1603case 71:
1604#line 469 "awk.y"
1605{ yyval.nodeval = make_param(yyvsp[0].sval); ;
1606 break;}
1607case 72:
1608#line 471 "awk.y"
1609{ yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
1610 break;}
1611case 73:
1612#line 473 "awk.y"
1613{ yyval.nodeval = NULL; ;
1614 break;}
1615case 74:
1616#line 475 "awk.y"
1617{ yyval.nodeval = NULL; ;
1618 break;}
1619case 75:
1620#line 477 "awk.y"
1621{ yyval.nodeval = NULL; ;
1622 break;}
1623case 76:
1624#line 483 "awk.y"
1625{ yyval.nodeval = NULL; ;
1626 break;}
1627case 77:
1628#line 485 "awk.y"
1629{ yyval.nodeval = yyvsp[0].nodeval; ;
1630 break;}
1631case 78:
1632#line 490 "awk.y"
1633{ yyval.nodeval = NULL; ;
1634 break;}
1635case 79:
1636#line 492 "awk.y"
1637{ yyval.nodeval = yyvsp[0].nodeval; ;
1638 break;}
1639case 80:
1640#line 497 "awk.y"
1641{ yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
1642 break;}
1643case 81:
1644#line 499 "awk.y"
1645{
1646 yyval.nodeval = append_right(yyvsp[-2].nodeval,
1647 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
1648 yyerrok;
1649 ;
1650 break;}
1651case 82:
1652#line 505 "awk.y"
1653{ yyval.nodeval = NULL; ;
1654 break;}
1655case 83:
1656#line 507 "awk.y"
1657{ yyval.nodeval = NULL; ;
1658 break;}
1659case 84:
1660#line 509 "awk.y"
1661{ yyval.nodeval = NULL; ;
1662 break;}
1663case 85:
1664#line 511 "awk.y"
1665{ yyval.nodeval = NULL; ;
1666 break;}
1667case 86:
1668#line 516 "awk.y"
1669{ yyval.nodeval = NULL; ;
1670 break;}
1671case 87:
1672#line 518 "awk.y"
1673{ yyval.nodeval = yyvsp[0].nodeval; ;
1674 break;}
1675case 88:
1676#line 523 "awk.y"
1677{ yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
1678 break;}
1679case 89:
1680#line 525 "awk.y"
1681{
1682 yyval.nodeval = append_right(yyvsp[-2].nodeval,
1683 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
1684 yyerrok;
1685 ;
1686 break;}
1687case 90:
1688#line 531 "awk.y"
1689{ yyval.nodeval = NULL; ;
1690 break;}
1691case 91:
1692#line 533 "awk.y"
1693{ yyval.nodeval = NULL; ;
1694 break;}
1695case 92:
1696#line 535 "awk.y"
1697{ yyval.nodeval = NULL; ;
1698 break;}
1699case 93:
1700#line 537 "awk.y"
1701{ yyval.nodeval = NULL; ;
1702 break;}
1703case 94:
1704#line 542 "awk.y"
1705{ want_assign = 0; ;
1706 break;}
1707case 95:
1708#line 544 "awk.y"
1709{
1710 if (do_lint && yyvsp[0].nodeval->type == Node_regex)
1711 warning("Regular expression on left of assignment.");
1712 yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
1713 ;
1714 break;}
1715case 96:
1716#line 550 "awk.y"
1717{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ;
1718 break;}
1719case 97:
1720#line 552 "awk.y"
1721{
1722 yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
1723 node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
1724 ;
1725 break;}
1726case 98:
1727#line 557 "awk.y"
1728{
1729 if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
1730 warning("non-redirected getline undefined inside BEGIN or END action");
1731 yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
1732 ;
1733 break;}
1734case 99:
1735#line 563 "awk.y"
1736{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
1737 break;}
1738case 100:
1739#line 565 "awk.y"
1740{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
1741 break;}
1742case 101:
1743#line 567 "awk.y"
1744{
1745 if (yyvsp[-2].nodeval->type == Node_regex)
1746 warning("Regular expression on left of MATCH operator.");
1747 yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
1748 ;
1749 break;}
1750case 102:
1751#line 573 "awk.y"
1752{ yyval.nodeval = yyvsp[0].nodeval; ;
1753 break;}
1754case 103:
1755#line 575 "awk.y"
1756{
1757 yyval.nodeval = node(node(make_number(0.0),
1758 Node_field_spec,
1759 (NODE *) NULL),
1760 Node_nomatch,
1761 yyvsp[0].nodeval);
1762 ;
1763 break;}
1764case 104:
1765#line 583 "awk.y"
1766{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
1767 break;}
1768case 105:
1769#line 585 "awk.y"
1770{
1771 if (do_lint && yyvsp[0].nodeval->type == Node_regex)
1772 warning("Regular expression on left of comparison.");
1773 yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
1774 ;
1775 break;}
1776case 106:
1777#line 591 "awk.y"
1778{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
1779 break;}
1780case 107:
1781#line 593 "awk.y"
1782{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
1783 break;}
1784case 108:
1785#line 595 "awk.y"
1786{ yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
1787 break;}
1788case 109:
1789#line 597 "awk.y"
1790{ yyval.nodeval = yyvsp[0].nodeval; ;
1791 break;}
1792case 110:
1793#line 599 "awk.y"
1794{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
1795 break;}
1796case 111:
1797#line 604 "awk.y"
1798{ want_assign = 0; ;
1799 break;}
1800case 112:
1801#line 606 "awk.y"
1802{ yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
1803 break;}
1804case 113:
1805#line 608 "awk.y"
1806{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
1807 break;}
1808case 114:
1809#line 610 "awk.y"
1810{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
1811 break;}
1812case 115:
1813#line 612 "awk.y"
1814{
1815 if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
1816 warning("non-redirected getline undefined inside BEGIN or END action");
1817 yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
1818 ;
1819 break;}
1820case 116:
1821#line 618 "awk.y"
1822{ yyval.nodeval = yyvsp[0].nodeval; ;
1823 break;}
1824case 117:
1825#line 620 "awk.y"
1826{ yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
1827 break;}
1828case 118:
1829#line 622 "awk.y"
1830{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
1831 break;}
1832case 119:
1833#line 624 "awk.y"
1834{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
1835 break;}
1836case 120:
1837#line 626 "awk.y"
1838{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
1839 break;}
1840case 121:
1841#line 628 "awk.y"
1842{ yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
1843 break;}
1844case 122:
1845#line 630 "awk.y"
1846{ yyval.nodeval = yyvsp[0].nodeval; ;
1847 break;}
1848case 123:
1849#line 632 "awk.y"
1850{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
1851 break;}
1852case 125:
1853#line 639 "awk.y"
1854{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
1855 break;}
1856case 126:
1857#line 641 "awk.y"
1858{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
1859 break;}
1860case 127:
1861#line 643 "awk.y"
1862{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
1863 break;}
1864case 128:
1865#line 645 "awk.y"
1866{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
1867 break;}
1868case 129:
1869#line 647 "awk.y"
1870{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
1871 break;}
1872case 130:
1873#line 649 "awk.y"
1874{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
1875 break;}
1876case 131:
1877#line 651 "awk.y"
1878{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
1879 break;}
1880case 132:
1881#line 653 "awk.y"
1882{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
1883 break;}
1884case 133:
1885#line 658 "awk.y"
1886{ yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
1887 break;}
1888case 134:
1889#line 660 "awk.y"
1890{ yyval.nodeval = yyvsp[-1].nodeval; ;
1891 break;}
1892case 135:
1893#line 663 "awk.y"
1894{ yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
1895 break;}
1896case 136:
1897#line 665 "awk.y"
1898{ yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
1899 break;}
1900case 137:
1901#line 667 "awk.y"
1902{
1903 if (do_lint)
1904 warning("call of `length' without parentheses is not portable");
1905 yyval.nodeval = snode ((NODE *)NULL, Node_builtin, (int) yyvsp[0].lval);
1906 if (do_posix)
1907 warning( "call of `length' without parentheses is deprecated by POSIX");
1908 ;
1909 break;}
1910case 138:
1911#line 675 "awk.y"
1912{
1913 yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
1914 ;
1915 break;}
1916case 140:
1917#line 680 "awk.y"
1918{ yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
1919 break;}
1920case 141:
1921#line 682 "awk.y"
1922{ yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
1923 break;}
1924case 142:
1925#line 684 "awk.y"
1926{ yyval.nodeval = yyvsp[0].nodeval; ;
1927 break;}
1928case 143:
1929#line 686 "awk.y"
1930{ yyval.nodeval = yyvsp[0].nodeval; ;
1931 break;}
1932case 144:
1933#line 689 "awk.y"
1934{ if (yyvsp[0].nodeval->type == Node_val) {
1935 yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
1936 yyval.nodeval = yyvsp[0].nodeval;
1937 } else
1938 yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL);
1939 ;
1940 break;}
1941case 145:
1942#line 696 "awk.y"
1943{ yyval.nodeval = yyvsp[0].nodeval; ;
1944 break;}
1945case 146:
1946#line 701 "awk.y"
1947{ yyval.nodeval = NULL; ;
1948 break;}
1949case 147:
1950#line 703 "awk.y"
1951{ yyval.nodeval = yyvsp[0].nodeval; ;
1952 break;}
1953case 148:
1954#line 708 "awk.y"
1955{ yyval.nodeval = variable(yyvsp[0].sval,1); ;
1956 break;}
1957case 149:
1958#line 710 "awk.y"
1959{
1960 if (yyvsp[-1].nodeval->rnode == NULL) {
1961 yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval->lnode);
1962 freenode(yyvsp[-1].nodeval);
1963 } else
1964 yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval);
1965 ;
1966 break;}
1967case 150:
1968#line 718 "awk.y"
1969{ yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
1970 break;}
1971case 152:
1972#line 726 "awk.y"
1973{ yyerrok; ;
1974 break;}
1975case 153:
1976#line 730 "awk.y"
1977{ yyerrok; ;
1978 break;}
1979case 156:
1980#line 739 "awk.y"
1981{ yyerrok; want_assign = 0; ;
1982 break;}
1983case 157:
1984#line 742 "awk.y"
1985{ yyerrok; ;
1986 break;}
1987}
1988 /* the action file gets copied in in place of this dollarsign */
1989#line 442 "/local/lib/bison.simple"
1990\f
1991 yyvsp -= yylen;
1992 yyssp -= yylen;
1993#ifdef YYLSP_NEEDED
1994 yylsp -= yylen;
1995#endif
1996
1997#if YYDEBUG != 0
1998 if (yydebug)
1999 {
2000 short *ssp1 = yyss - 1;
2001 fprintf (stderr, "state stack now");
2002 while (ssp1 != yyssp)
2003 fprintf (stderr, " %d", *++ssp1);
2004 fprintf (stderr, "\n");
2005 }
2006#endif
2007
2008 *++yyvsp = yyval;
2009
2010#ifdef YYLSP_NEEDED
2011 yylsp++;
2012 if (yylen == 0)
2013 {
2014 yylsp->first_line = yylloc.first_line;
2015 yylsp->first_column = yylloc.first_column;
2016 yylsp->last_line = (yylsp-1)->last_line;
2017 yylsp->last_column = (yylsp-1)->last_column;
2018 yylsp->text = 0;
2019 }
2020 else
2021 {
2022 yylsp->last_line = (yylsp+yylen-1)->last_line;
2023 yylsp->last_column = (yylsp+yylen-1)->last_column;
2024 }
2025#endif
2026
2027 /* Now "shift" the result of the reduction.
2028 Determine what state that goes to,
2029 based on the state we popped back to
2030 and the rule number reduced by. */
2031
2032 yyn = yyr1[yyn];
2033
2034 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2035 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2036 yystate = yytable[yystate];
2037 else
2038 yystate = yydefgoto[yyn - YYNTBASE];
2039
2040 goto yynewstate;
2041
2042yyerrlab: /* here on detecting error */
2043
2044 if (! yyerrstatus)
2045 /* If not already recovering from an error, report this error. */
2046 {
2047 ++yynerrs;
2048
2049#ifdef YYERROR_VERBOSE
2050 yyn = yypact[yystate];
2051
2052 if (yyn > YYFLAG && yyn < YYLAST)
2053 {
2054 int size = 0;
2055 char *msg;
2056 int x, count;
2057
2058 count = 0;
2059 for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
2060 if (yycheck[x + yyn] == x)
2061 size += strlen(yytname[x]) + 15, count++;
2062 msg = (char *) malloc(size + 15);
2063 if (msg != 0)
2064 {
2065 strcpy(msg, "parse error");
2066
2067 if (count < 5)
2068 {
2069 count = 0;
2070 for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
2071 if (yycheck[x + yyn] == x)
2072 {
2073 strcat(msg, count == 0 ? ", expecting `" : " or `");
2074 strcat(msg, yytname[x]);
2075 strcat(msg, "'");
2076 count++;
2077 }
2078 }
2079 yyerror(msg);
2080 free(msg);
2081 }
2082 else
2083 yyerror ("parse error; also virtual memory exceeded");
2084 }
2085 else
2086#endif /* YYERROR_VERBOSE */
2087 yyerror("parse error");
2088 }
2089
2090 goto yyerrlab1;
2091yyerrlab1: /* here on error raised explicitly by an action */
2092
2093 if (yyerrstatus == 3)
2094 {
2095 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2096
2097 /* return failure if at end of input */
2098 if (yychar == YYEOF)
2099 YYABORT;
2100
2101#if YYDEBUG != 0
2102 if (yydebug)
2103 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2104#endif
2105
2106 yychar = YYEMPTY;
2107 }
2108
2109 /* Else will try to reuse lookahead token
2110 after shifting the error token. */
2111
2112 yyerrstatus = 3; /* Each real token shifted decrements this */
2113
2114 goto yyerrhandle;
2115
2116yyerrdefault: /* current state does not do anything special for the error token. */
2117
2118#if 0
2119 /* This is wrong; only states that explicitly want error tokens
2120 should shift them. */
2121 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2122 if (yyn) goto yydefault;
2123#endif
2124
2125yyerrpop: /* pop the current state because it cannot handle the error token */
2126
2127 if (yyssp == yyss) YYABORT;
2128 yyvsp--;
2129 yystate = *--yyssp;
2130#ifdef YYLSP_NEEDED
2131 yylsp--;
2132#endif
2133
2134#if YYDEBUG != 0
2135 if (yydebug)
2136 {
2137 short *ssp1 = yyss - 1;
2138 fprintf (stderr, "Error: state stack now");
2139 while (ssp1 != yyssp)
2140 fprintf (stderr, " %d", *++ssp1);
2141 fprintf (stderr, "\n");
2142 }
2143#endif
2144
2145yyerrhandle:
2146
2147 yyn = yypact[yystate];
2148 if (yyn == YYFLAG)
2149 goto yyerrdefault;
2150
2151 yyn += YYTERROR;
2152 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2153 goto yyerrdefault;
2154
2155 yyn = yytable[yyn];
2156 if (yyn < 0)
2157 {
2158 if (yyn == YYFLAG)
2159 goto yyerrpop;
2160 yyn = -yyn;
2161 goto yyreduce;
2162 }
2163 else if (yyn == 0)
2164 goto yyerrpop;
2165
2166 if (yyn == YYFINAL)
2167 YYACCEPT;
2168
2169#if YYDEBUG != 0
2170 if (yydebug)
2171 fprintf(stderr, "Shifting error token, ");
2172#endif
2173
2174 *++yyvsp = yylval;
2175#ifdef YYLSP_NEEDED
2176 *++yylsp = yylloc;
2177#endif
2178
2179 yystate = yyn;
2180 goto yynewstate;
2181}
2182#line 745 "awk.y"
2183
2184
2185struct token {
2186 char *operator; /* text to match */
2187 NODETYPE value; /* node type */
2188 int class; /* lexical class */
2189 unsigned flags; /* # of args. allowed and compatability */
2190# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
2191# define A(n) (1<<(n))
2192# define VERSION 0xFF00 /* old awk is zero */
2193# define NOT_OLD 0x0100 /* feature not in old awk */
2194# define NOT_POSIX 0x0200 /* feature not in POSIX */
2195# define GAWKX 0x0400 /* gawk extension */
2196 NODE *(*ptr) (); /* function that implements this keyword */
2197};
2198
2199extern NODE
2200 *do_exp(), *do_getline(), *do_index(), *do_length(),
2201 *do_sqrt(), *do_log(), *do_sprintf(), *do_substr(),
2202 *do_split(), *do_system(), *do_int(), *do_close(),
2203 *do_atan2(), *do_sin(), *do_cos(), *do_rand(),
2204 *do_srand(), *do_match(), *do_tolower(), *do_toupper(),
2205 *do_sub(), *do_gsub(), *do_strftime(), *do_systime();
2206
2207/* Tokentab is sorted ascii ascending order, so it can be binary searched. */
2208
2209static struct token tokentab[] = {
2210{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
2211{"END", Node_illegal, LEX_END, 0, 0},
2212{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
2213{"break", Node_K_break, LEX_BREAK, 0, 0},
2214{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
2215{"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
2216{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
2217{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
2218{"do", Node_K_do, LEX_DO, NOT_OLD, 0},
2219{"else", Node_illegal, LEX_ELSE, 0, 0},
2220{"exit", Node_K_exit, LEX_EXIT, 0, 0},
2221{"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp},
2222{"for", Node_K_for, LEX_FOR, 0, 0},
2223{"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0},
2224{"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0},
2225{"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0},
2226{"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub},
2227{"if", Node_K_if, LEX_IF, 0, 0},
2228{"in", Node_illegal, LEX_IN, 0, 0},
2229{"index", Node_builtin, LEX_BUILTIN, A(2), do_index},
2230{"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
2231{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
2232{"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
2233{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
2234{"next", Node_K_next, LEX_NEXT, 0, 0},
2235{"print", Node_K_print, LEX_PRINT, 0, 0},
2236{"printf", Node_K_printf, LEX_PRINTF, 0, 0},
2237{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
2238{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
2239{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
2240{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
2241{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
2242{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
2243{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
2244{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_strftime},
2245{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
2246{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
2247{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
2248{"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime},
2249{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
2250{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
2251{"while", Node_K_while, LEX_WHILE, 0, 0},
2252};
2253
2254/* VARARGS0 */
2255static void
2256yyerror(va_alist)
2257va_dcl
2258{
2259 va_list args;
2260 char *mesg = NULL;
2261 register char *bp, *cp;
2262 char *scan;
2263 char buf[120];
2264
2265 errcount++;
2266 /* Find the current line in the input file */
2267 if (lexptr) {
2268 if (!thisline) {
2269 cp = lexeme;
2270 if (*cp == '\n') {
2271 cp--;
2272 mesg = "unexpected newline";
2273 }
2274 for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
2275 ;
2276 if (*cp == '\n')
2277 cp++;
2278 thisline = cp;
2279 }
2280 /* NL isn't guaranteed */
2281 bp = lexeme;
2282 while (bp < lexend && *bp && *bp != '\n')
2283 bp++;
2284 } else {
2285 thisline = "(END OF FILE)";
2286 bp = thisline + 13;
2287 }
2288 msg("%.*s", (int) (bp - thisline), thisline);
2289 bp = buf;
2290 cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
2291 if (lexptr) {
2292 scan = thisline;
2293 while (bp < cp && scan < lexeme)
2294 if (*scan++ == '\t')
2295 *bp++ = '\t';
2296 else
2297 *bp++ = ' ';
2298 *bp++ = '^';
2299 *bp++ = ' ';
2300 }
2301 va_start(args);
2302 if (mesg == NULL)
2303 mesg = va_arg(args, char *);
2304 strcpy(bp, mesg);
2305 err("", buf, args);
2306 va_end(args);
2307 exit(2);
2308}
2309
2310static char *
2311get_src_buf()
2312{
2313 static int samefile = 0;
2314 static int nextfile = 0;
2315 static char *buf = NULL;
2316 static int fd;
2317 int n;
2318 register char *scan;
2319 static int len = 0;
2320 static int did_newline = 0;
2321# define SLOP 128 /* enough space to hold most source lines */
2322
2323 if (nextfile > numfiles)
2324 return NULL;
2325
2326 if (srcfiles[nextfile].stype == CMDLINE) {
2327 if (len == 0) {
2328 len = strlen(srcfiles[nextfile].val);
2329 sourceline = 1;
2330 lexptr = lexptr_begin = srcfiles[nextfile].val;
2331 lexend = lexptr + len;
2332 } else if (!did_newline && *(lexptr-1) != '\n') {
2333 /*
2334 * The following goop is to ensure that the source
2335 * ends with a newline and that the entire current
2336 * line is available for error messages.
2337 */
2338 int offset;
2339
2340 did_newline = 1;
2341 offset = lexptr - lexeme;
2342 for (scan = lexeme; scan > lexptr_begin; scan--)
2343 if (*scan == '\n') {
2344 scan++;
2345 break;
2346 }
2347 len = lexptr - scan;
2348 emalloc(buf, char *, len+1, "get_src_buf");
2349 memcpy(buf, scan, len);
2350 thisline = buf;
2351 lexptr = buf + len;
2352 *lexptr = '\n';
2353 lexeme = lexptr - offset;
2354 lexptr_begin = buf;
2355 lexend = lexptr + 1;
2356 } else {
2357 len = 0;
2358 lexeme = lexptr = lexptr_begin = NULL;
2359 }
2360 if (lexptr == NULL && ++nextfile <= numfiles)
2361 return get_src_buf();
2362 return lexptr;
2363 }
2364 if (!samefile) {
2365 source = srcfiles[nextfile].val;
2366 if (source == NULL) {
2367 if (buf) {
2368 free(buf);
2369 buf = NULL;
2370 }
2371 len = 0;
2372 return lexeme = lexptr = lexptr_begin = NULL;
2373 }
2374 fd = pathopen(source);
2375 if (fd == -1)
2376 fatal("can't open source file \"%s\" for reading (%s)",
2377 source, strerror(errno));
2378 len = optimal_bufsize(fd);
2379 if (buf)
2380 free(buf);
2381 emalloc(buf, char *, len + SLOP, "get_src_buf");
2382 lexptr_begin = buf + SLOP;
2383 samefile = 1;
2384 sourceline = 1;
2385 } else {
2386 /*
2387 * Here, we retain the current source line (up to length SLOP)
2388 * in the beginning of the buffer that was overallocated above
2389 */
2390 int offset;
2391 int linelen;
2392
2393 offset = lexptr - lexeme;
2394 for (scan = lexeme; scan > lexptr_begin; scan--)
2395 if (*scan == '\n') {
2396 scan++;
2397 break;
2398 }
2399 linelen = lexptr - scan;
2400 if (linelen > SLOP)
2401 linelen = SLOP;
2402 thisline = buf + SLOP - linelen;
2403 memcpy(thisline, scan, linelen);
2404 lexeme = buf + SLOP - offset;
2405 lexptr_begin = thisline;
2406 }
2407 n = read(fd, buf + SLOP, len);
2408 if (n == -1)
2409 fatal("can't read sourcefile \"%s\" (%s)",
2410 source, strerror(errno));
2411 if (n == 0) {
2412 samefile = 0;
2413 nextfile++;
2414 len = 0;
2415 return get_src_buf();
2416 }
2417 lexptr = buf + SLOP;
2418 lexend = lexptr + n;
2419 return buf;
2420}
2421
2422#define tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token)
2423
2424char *
2425tokexpand()
2426{
2427 static int toksize = 60;
2428 int tokoffset;
2429
2430 tokoffset = token - tokstart;
2431 toksize *= 2;
2432 if (tokstart)
2433 erealloc(tokstart, char *, toksize, "tokexpand");
2434 else
2435 emalloc(tokstart, char *, toksize, "tokexpand");
2436 tokend = tokstart + toksize;
2437 token = tokstart + tokoffset;
2438 return token;
2439}
2440
2441#if DEBUG
2442char
2443nextc() {
2444 if (lexptr && lexptr < lexend)
2445 return *lexptr++;
2446 else if (get_src_buf())
2447 return *lexptr++;
2448 else
2449 return '\0';
2450}
2451#else
2452#define nextc() ((lexptr && lexptr < lexend) ? \
2453 *lexptr++ : \
2454 (get_src_buf() ? *lexptr++ : '\0') \
2455 )
2456#endif
2457#define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
2458
2459/*
2460 * Read the input and turn it into tokens.
2461 */
2462
2463static int
2464yylex()
2465{
2466 register int c;
2467 int seen_e = 0; /* These are for numbers */
2468 int seen_point = 0;
2469 int esc_seen; /* for literal strings */
2470 int low, mid, high;
2471 static int did_newline = 0;
2472 char *tokkey;
2473
2474 if (!nextc())
2475 return 0;
2476 pushback();
2477 lexeme = lexptr;
2478 thisline = NULL;
2479 if (want_regexp) {
2480 int in_brack = 0;
2481
2482 want_regexp = 0;
2483 token = tokstart;
2484 while ((c = nextc()) != 0) {
2485 switch (c) {
2486 case '[':
2487 in_brack = 1;
2488 break;
2489 case ']':
2490 in_brack = 0;
2491 break;
2492 case '\\':
2493 if ((c = nextc()) == '\0') {
2494 yyerror("unterminated regexp ends with \\ at end of file");
2495 } else if (c == '\n') {
2496 sourceline++;
2497 continue;
2498 } else
2499 tokadd('\\');
2500 break;
2501 case '/': /* end of the regexp */
2502 if (in_brack)
2503 break;
2504
2505 pushback();
2506 tokadd('\0');
2507 yylval.sval = tokstart;
2508 return REGEXP;
2509 case '\n':
2510 pushback();
2511 yyerror("unterminated regexp");
2512 case '\0':
2513 yyerror("unterminated regexp at end of file");
2514 }
2515 tokadd(c);
2516 }
2517 }
2518retry:
2519 while ((c = nextc()) == ' ' || c == '\t')
2520 ;
2521
2522 lexeme = lexptr ? lexptr - 1 : lexptr;
2523 thisline = NULL;
2524 token = tokstart;
2525 yylval.nodetypeval = Node_illegal;
2526
2527 switch (c) {
2528 case 0:
2529 return 0;
2530
2531 case '\n':
2532 sourceline++;
2533 return NEWLINE;
2534
2535 case '#': /* it's a comment */
2536 while ((c = nextc()) != '\n') {
2537 if (c == '\0')
2538 return 0;
2539 }
2540 sourceline++;
2541 return NEWLINE;
2542
2543 case '\\':
2544#ifdef RELAXED_CONTINUATION
2545 if (!do_unix) { /* strip trailing white-space and/or comment */
2546 while ((c = nextc()) == ' ' || c == '\t') continue;
2547 if (c == '#')
2548 while ((c = nextc()) != '\n') if (!c) break;
2549 pushback();
2550 }
2551#endif /*RELAXED_CONTINUATION*/
2552 if (nextc() == '\n') {
2553 sourceline++;
2554 goto retry;
2555 } else
2556 yyerror("inappropriate use of backslash");
2557 break;
2558
2559 case '$':
2560 want_assign = 1;
2561 return '$';
2562
2563 case ')':
2564 case ']':
2565 case '(':
2566 case '[':
2567 case ';':
2568 case ':':
2569 case '?':
2570 case '{':
2571 case ',':
2572 return c;
2573
2574 case '*':
2575 if ((c = nextc()) == '=') {
2576 yylval.nodetypeval = Node_assign_times;
2577 return ASSIGNOP;
2578 } else if (do_posix) {
2579 pushback();
2580 return '*';
2581 } else if (c == '*') {
2582 /* make ** and **= aliases for ^ and ^= */
2583 static int did_warn_op = 0, did_warn_assgn = 0;
2584
2585 if (nextc() == '=') {
2586 if (do_lint && ! did_warn_assgn) {
2587 did_warn_assgn = 1;
2588 warning("**= is not allowed by POSIX");
2589 }
2590 yylval.nodetypeval = Node_assign_exp;
2591 return ASSIGNOP;
2592 } else {
2593 pushback();
2594 if (do_lint && ! did_warn_op) {
2595 did_warn_op = 1;
2596 warning("** is not allowed by POSIX");
2597 }
2598 return '^';
2599 }
2600 }
2601 pushback();
2602 return '*';
2603
2604 case '/':
2605 if (want_assign) {
2606 if (nextc() == '=') {
2607 yylval.nodetypeval = Node_assign_quotient;
2608 return ASSIGNOP;
2609 }
2610 pushback();
2611 }
2612 return '/';
2613
2614 case '%':
2615 if (nextc() == '=') {
2616 yylval.nodetypeval = Node_assign_mod;
2617 return ASSIGNOP;
2618 }
2619 pushback();
2620 return '%';
2621
2622 case '^':
2623 {
2624 static int did_warn_op = 0, did_warn_assgn = 0;
2625
2626 if (nextc() == '=') {
2627
2628 if (do_lint && ! did_warn_assgn) {
2629 did_warn_assgn = 1;
2630 warning("operator `^=' is not supported in old awk");
2631 }
2632 yylval.nodetypeval = Node_assign_exp;
2633 return ASSIGNOP;
2634 }
2635 pushback();
2636 if (do_lint && ! did_warn_op) {
2637 did_warn_op = 1;
2638 warning("operator `^' is not supported in old awk");
2639 }
2640 return '^';
2641 }
2642
2643 case '+':
2644 if ((c = nextc()) == '=') {
2645 yylval.nodetypeval = Node_assign_plus;
2646 return ASSIGNOP;
2647 }
2648 if (c == '+')
2649 return INCREMENT;
2650 pushback();
2651 return '+';
2652
2653 case '!':
2654 if ((c = nextc()) == '=') {
2655 yylval.nodetypeval = Node_notequal;
2656 return RELOP;
2657 }
2658 if (c == '~') {
2659 yylval.nodetypeval = Node_nomatch;
2660 want_assign = 0;
2661 return MATCHOP;
2662 }
2663 pushback();
2664 return '!';
2665
2666 case '<':
2667 if (nextc() == '=') {
2668 yylval.nodetypeval = Node_leq;
2669 return RELOP;
2670 }
2671 yylval.nodetypeval = Node_less;
2672 pushback();
2673 return '<';
2674
2675 case '=':
2676 if (nextc() == '=') {
2677 yylval.nodetypeval = Node_equal;
2678 return RELOP;
2679 }
2680 yylval.nodetypeval = Node_assign;
2681 pushback();
2682 return ASSIGNOP;
2683
2684 case '>':
2685 if ((c = nextc()) == '=') {
2686 yylval.nodetypeval = Node_geq;
2687 return RELOP;
2688 } else if (c == '>') {
2689 yylval.nodetypeval = Node_redirect_append;
2690 return APPEND_OP;
2691 }
2692 yylval.nodetypeval = Node_greater;
2693 pushback();
2694 return '>';
2695
2696 case '~':
2697 yylval.nodetypeval = Node_match;
2698 want_assign = 0;
2699 return MATCHOP;
2700
2701 case '}':
2702 /*
2703 * Added did newline stuff. Easier than
2704 * hacking the grammar
2705 */
2706 if (did_newline) {
2707 did_newline = 0;
2708 return c;
2709 }
2710 did_newline++;
2711 --lexptr; /* pick up } next time */
2712 return NEWLINE;
2713
2714 case '"':
2715 esc_seen = 0;
2716 while ((c = nextc()) != '"') {
2717 if (c == '\n') {
2718 pushback();
2719 yyerror("unterminated string");
2720 }
2721 if (c == '\\') {
2722 c = nextc();
2723 if (c == '\n') {
2724 sourceline++;
2725 continue;
2726 }
2727 esc_seen = 1;
2728 tokadd('\\');
2729 }
2730 if (c == '\0') {
2731 pushback();
2732 yyerror("unterminated string");
2733 }
2734 tokadd(c);
2735 }
2736 yylval.nodeval = make_str_node(tokstart,
2737 token - tokstart, esc_seen ? SCAN : 0);
2738 yylval.nodeval->flags |= PERM;
2739 return YSTRING;
2740
2741 case '-':
2742 if ((c = nextc()) == '=') {
2743 yylval.nodetypeval = Node_assign_minus;
2744 return ASSIGNOP;
2745 }
2746 if (c == '-')
2747 return DECREMENT;
2748 pushback();
2749 return '-';
2750
2751 case '.':
2752 c = nextc();
2753 pushback();
2754 if (!isdigit(c))
2755 return '.';
2756 else
2757 c = '.'; /* FALL THROUGH */
2758 case '0':
2759 case '1':
2760 case '2':
2761 case '3':
2762 case '4':
2763 case '5':
2764 case '6':
2765 case '7':
2766 case '8':
2767 case '9':
2768 /* It's a number */
2769 for (;;) {
2770 int gotnumber = 0;
2771
2772 tokadd(c);
2773 switch (c) {
2774 case '.':
2775 if (seen_point) {
2776 gotnumber++;
2777 break;
2778 }
2779 ++seen_point;
2780 break;
2781 case 'e':
2782 case 'E':
2783 if (seen_e) {
2784 gotnumber++;
2785 break;
2786 }
2787 ++seen_e;
2788 if ((c = nextc()) == '-' || c == '+')
2789 tokadd(c);
2790 else
2791 pushback();
2792 break;
2793 case '0':
2794 case '1':
2795 case '2':
2796 case '3':
2797 case '4':
2798 case '5':
2799 case '6':
2800 case '7':
2801 case '8':
2802 case '9':
2803 break;
2804 default:
2805 gotnumber++;
2806 }
2807 if (gotnumber)
2808 break;
2809 c = nextc();
2810 }
2811 pushback();
2812 yylval.nodeval = make_number(atof(tokstart));
2813 yylval.nodeval->flags |= PERM;
2814 return YNUMBER;
2815
2816 case '&':
2817 if ((c = nextc()) == '&') {
2818 yylval.nodetypeval = Node_and;
2819 for (;;) {
2820 c = nextc();
2821 if (c == '\0')
2822 break;
2823 if (c == '#') {
2824 while ((c = nextc()) != '\n' && c != '\0')
2825 ;
2826 if (c == '\0')
2827 break;
2828 }
2829 if (c == '\n')
2830 sourceline++;
2831 if (! isspace(c)) {
2832 pushback();
2833 break;
2834 }
2835 }
2836 want_assign = 0;
2837 return LEX_AND;
2838 }
2839 pushback();
2840 return '&';
2841
2842 case '|':
2843 if ((c = nextc()) == '|') {
2844 yylval.nodetypeval = Node_or;
2845 for (;;) {
2846 c = nextc();
2847 if (c == '\0')
2848 break;
2849 if (c == '#') {
2850 while ((c = nextc()) != '\n' && c != '\0')
2851 ;
2852 if (c == '\0')
2853 break;
2854 }
2855 if (c == '\n')
2856 sourceline++;
2857 if (! isspace(c)) {
2858 pushback();
2859 break;
2860 }
2861 }
2862 want_assign = 0;
2863 return LEX_OR;
2864 }
2865 pushback();
2866 return '|';
2867 }
2868
2869 if (c != '_' && ! isalpha(c))
2870 yyerror("Invalid char '%c' in expression\n", c);
2871
2872 /* it's some type of name-type-thing. Find its length */
2873 token = tokstart;
2874 while (is_identchar(c)) {
2875 tokadd(c);
2876 c = nextc();
2877 }
2878 tokadd('\0');
2879 emalloc(tokkey, char *, token - tokstart, "yylex");
2880 memcpy(tokkey, tokstart, token - tokstart);
2881 pushback();
2882
2883 /* See if it is a special token. */
2884 low = 0;
2885 high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
2886 while (low <= high) {
2887 int i/* , c */;
2888
2889 mid = (low + high) / 2;
2890 c = *tokstart - tokentab[mid].operator[0];
2891 i = c ? c : strcmp (tokstart, tokentab[mid].operator);
2892
2893 if (i < 0) { /* token < mid */
2894 high = mid - 1;
2895 } else if (i > 0) { /* token > mid */
2896 low = mid + 1;
2897 } else {
2898 if (do_lint) {
2899 if (tokentab[mid].flags & GAWKX)
2900 warning("%s() is a gawk extension",
2901 tokentab[mid].operator);
2902 if (tokentab[mid].flags & NOT_POSIX)
2903 warning("POSIX does not allow %s",
2904 tokentab[mid].operator);
2905 if (tokentab[mid].flags & NOT_OLD)
2906 warning("%s is not supported in old awk",
2907 tokentab[mid].operator);
2908 }
2909 if ((do_unix && (tokentab[mid].flags & GAWKX))
2910 || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
2911 break;
2912 if (tokentab[mid].class == LEX_BUILTIN
2913 || tokentab[mid].class == LEX_LENGTH
2914 )
2915 yylval.lval = mid;
2916 else
2917 yylval.nodetypeval = tokentab[mid].value;
2918
2919 return tokentab[mid].class;
2920 }
2921 }
2922
2923 yylval.sval = tokkey;
2924 if (*lexptr == '(')
2925 return FUNC_CALL;
2926 else {
2927 want_assign = 1;
2928 return NAME;
2929 }
2930}
2931
2932static NODE *
2933node_common(op)
2934NODETYPE op;
2935{
2936 register NODE *r;
2937
2938 getnode(r);
2939 r->type = op;
2940 r->flags = MALLOC;
2941 /* if lookahead is NL, lineno is 1 too high */
2942 if (lexeme && *lexeme == '\n')
2943 r->source_line = sourceline - 1;
2944 else
2945 r->source_line = sourceline;
2946 r->source_file = source;
2947 return r;
2948}
2949
2950/*
2951 * This allocates a node with defined lnode and rnode.
2952 */
2953NODE *
2954node(left, op, right)
2955NODE *left, *right;
2956NODETYPE op;
2957{
2958 register NODE *r;
2959
2960 r = node_common(op);
2961 r->lnode = left;
2962 r->rnode = right;
2963 return r;
2964}
2965
2966/*
2967 * This allocates a node with defined subnode and proc for builtin functions
2968 * Checks for arg. count and supplies defaults where possible.
2969 */
2970static NODE *
2971snode(subn, op, idx)
2972NODETYPE op;
2973int idx;
2974NODE *subn;
2975{
2976 register NODE *r;
2977 register NODE *n;
2978 int nexp = 0;
2979 int args_allowed;
2980
2981 r = node_common(op);
2982
2983 /* traverse expression list to see how many args. given */
2984 for (n= subn; n; n= n->rnode) {
2985 nexp++;
2986 if (nexp > 3)
2987 break;
2988 }
2989
2990 /* check against how many args. are allowed for this builtin */
2991 args_allowed = tokentab[idx].flags & ARGS;
2992 if (args_allowed && !(args_allowed & A(nexp)))
2993 fatal("%s() cannot have %d argument%c",
2994 tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
2995
2996 r->proc = tokentab[idx].ptr;
2997
2998 /* special case processing for a few builtins */
2999 if (nexp == 0 && r->proc == do_length) {
3000 subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
3001 Node_expression_list,
3002 (NODE *) NULL);
3003 } else if (r->proc == do_match) {
3004 if (subn->rnode->lnode->type != Node_regex)
3005 subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
3006 } else if (r->proc == do_sub || r->proc == do_gsub) {
3007 if (subn->lnode->type != Node_regex)
3008 subn->lnode = mk_rexp(subn->lnode);
3009 if (nexp == 2)
3010 append_right(subn, node(node(make_number(0.0),
3011 Node_field_spec,
3012 (NODE *) NULL),
3013 Node_expression_list,
3014 (NODE *) NULL));
3015 else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
3016 warning("string literal as last arg of substitute");
3017 } else if (r->proc == do_split) {
3018 if (nexp == 2)
3019 append_right(subn,
3020 node(FS_node, Node_expression_list, (NODE *) NULL));
3021 n = subn->rnode->rnode->lnode;
3022 if (n->type != Node_regex)
3023 subn->rnode->rnode->lnode = mk_rexp(n);
3024 if (nexp == 2)
3025 subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
3026 }
3027
3028 r->subnode = subn;
3029 return r;
3030}
3031
3032/*
3033 * This allocates a Node_line_range node with defined condpair and
3034 * zeroes the trigger word to avoid the temptation of assuming that calling
3035 * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'.
3036 */
3037/* Otherwise like node() */
3038static NODE *
3039mkrangenode(cpair)
3040NODE *cpair;
3041{
3042 register NODE *r;
3043
3044 getnode(r);
3045 r->type = Node_line_range;
3046 r->condpair = cpair;
3047 r->triggered = 0;
3048 return r;
3049}
3050
3051/* Build a for loop */
3052static NODE *
3053make_for_loop(init, cond, incr)
3054NODE *init, *cond, *incr;
3055{
3056 register FOR_LOOP_HEADER *r;
3057 NODE *n;
3058
3059 emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
3060 getnode(n);
3061 n->type = Node_illegal;
3062 r->init = init;
3063 r->cond = cond;
3064 r->incr = incr;
3065 n->sub.nodep.r.hd = r;
3066 return n;
3067}
3068
3069/*
3070 * Install a name in the symbol table, even if it is already there.
3071 * Caller must check against redefinition if that is desired.
3072 */
3073NODE *
3074install(name, value)
3075char *name;
3076NODE *value;
3077{
3078 register NODE *hp;
3079 register int len, bucket;
3080
3081 len = strlen(name);
3082 bucket = hash(name, len);
3083 getnode(hp);
3084 hp->type = Node_hashnode;
3085 hp->hnext = variables[bucket];
3086 variables[bucket] = hp;
3087 hp->hlength = len;
3088 hp->hvalue = value;
3089 hp->hname = name;
3090 hp->hvalue->vname = name;
3091 return hp->hvalue;
3092}
3093
3094/* find the most recent hash node for name installed by install */
3095NODE *
3096lookup(name)
3097char *name;
3098{
3099 register NODE *bucket;
3100 register int len;
3101
3102 len = strlen(name);
3103 bucket = variables[hash(name, len)];
3104 while (bucket) {
3105 if (bucket->hlength == len && STREQN(bucket->hname, name, len))
3106 return bucket->hvalue;
3107 bucket = bucket->hnext;
3108 }
3109 return NULL;
3110}
3111
3112/*
3113 * Add new to the rightmost branch of LIST. This uses n^2 time, so we make
3114 * a simple attempt at optimizing it.
3115 */
3116static NODE *
3117append_right(list, new)
3118NODE *list, *new;
3119{
3120 register NODE *oldlist;
3121 static NODE *savefront = NULL, *savetail = NULL;
3122
3123 oldlist = list;
3124 if (savefront == oldlist) {
3125 savetail = savetail->rnode = new;
3126 return oldlist;
3127 } else
3128 savefront = oldlist;
3129 while (list->rnode != NULL)
3130 list = list->rnode;
3131 savetail = list->rnode = new;
3132 return oldlist;
3133}
3134
3135/*
3136 * check if name is already installed; if so, it had better have Null value,
3137 * in which case def is added as the value. Otherwise, install name with def
3138 * as value.
3139 */
3140static void
3141func_install(params, def)
3142NODE *params;
3143NODE *def;
3144{
3145 NODE *r;
3146
3147 pop_params(params->rnode);
3148 pop_var(params, 0);
3149 r = lookup(params->param);
3150 if (r != NULL) {
3151 fatal("function name `%s' previously defined", params->param);
3152 } else
3153 (void) install(params->param, node(params, Node_func, def));
3154}
3155
3156static void
3157pop_var(np, freeit)
3158NODE *np;
3159int freeit;
3160{
3161 register NODE *bucket, **save;
3162 register int len;
3163 char *name;
3164
3165 name = np->param;
3166 len = strlen(name);
3167 save = &(variables[hash(name, len)]);
3168 for (bucket = *save; bucket; bucket = bucket->hnext) {
3169 if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
3170 *save = bucket->hnext;
3171 freenode(bucket);
3172 if (freeit)
3173 free(np->param);
3174 return;
3175 }
3176 save = &(bucket->hnext);
3177 }
3178}
3179
3180static void
3181pop_params(params)
3182NODE *params;
3183{
3184 register NODE *np;
3185
3186 for (np = params; np != NULL; np = np->rnode)
3187 pop_var(np, 1);
3188}
3189
3190static NODE *
3191make_param(name)
3192char *name;
3193{
3194 NODE *r;
3195
3196 getnode(r);
3197 r->type = Node_param_list;
3198 r->rnode = NULL;
3199 r->param = name;
3200 r->param_cnt = param_counter++;
3201 return (install(name, r));
3202}
3203
3204/* Name points to a variable name. Make sure its in the symbol table */
3205NODE *
3206variable(name, can_free)
3207char *name;
3208int can_free;
3209{
3210 register NODE *r;
3211 static int env_loaded = 0;
3212
3213 if (!env_loaded && STREQ(name, "ENVIRON")) {
3214 load_environ();
3215 env_loaded = 1;
3216 }
3217 if ((r = lookup(name)) == NULL)
3218 r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
3219 else if (can_free)
3220 free(name);
3221 return r;
3222}
3223
3224static NODE *
3225mk_rexp(exp)
3226NODE *exp;
3227{
3228 if (exp->type == Node_regex)
3229 return exp;
3230 else {
3231 NODE *n;
3232
3233 getnode(n);
3234 n->type = Node_regex;
3235 n->re_exp = exp;
3236 n->re_text = NULL;
3237 n->re_reg = NULL;
3238 n->re_flags = 0;
3239 n->re_cnt = 1;
3240 return n;
3241 }
3242}