2 /* A Bison parser, made from ./awk.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
24 #define LEX_RETURN 274
25 #define LEX_DELETE 275
30 #define LEX_CONTINUE 280
32 #define LEX_PRINTF 282
35 #define LEX_FUNCTION 285
36 #define LEX_GETLINE 286
37 #define LEX_NEXTFILE 287
43 #define LEX_BUILTIN 293
44 #define LEX_LENGTH 294
56 #define DONT_FREE FALSE
58 #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
59 static void yyerror(const char *m, ...) ;
61 static void yyerror(); /* va_alist */
63 static char *get_src_buf P((void));
64 static int yylex P((void));
65 static NODE *node_common P((NODETYPE op));
66 static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
67 static NODE *mkrangenode P((NODE *cpair));
68 static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
69 static NODE *append_right P((NODE *list, NODE *new));
70 static void func_install P((NODE *params, NODE *def));
71 static void pop_var P((NODE *np, int freeit));
72 static void pop_params P((NODE *params));
73 static NODE *make_param P((char *name));
74 static NODE *mk_rexp P((NODE *exp));
75 static int dup_parms P((NODE *func));
76 static void param_sanity P((NODE *arglist));
77 static int isnoeffect P((NODETYPE t));
78 static int isassignable P((NODE *n));
80 enum defref { FUNC_DEFINE, FUNC_USE };
81 static void func_use P((char *name, enum defref how));
82 static void check_funcs P((void));
84 static int want_assign; /* lexical scanning kludge */
85 static int want_regexp; /* lexical scanning kludge */
86 static int can_return; /* lexical scanning kludge */
87 static int io_allowed = TRUE; /* lexical scanning kludge */
88 static char *lexptr; /* pointer to next char during parsing */
90 static char *lexptr_begin; /* keep track of where we were for error msgs */
91 static char *lexeme; /* beginning of lexeme for debugging */
92 static char *thisline = NULL;
93 #define YYDEBUG_LEXER_TEXT (lexeme)
94 static int param_counter;
95 static char *tokstart = NULL;
96 static char *tok = NULL;
99 #define HASHSIZE 1021 /* this constant only used here */
100 NODE *variables[HASHSIZE];
103 extern int sourceline;
104 extern struct src *srcfiles;
107 extern NODE *begin_block;
108 extern NODE *end_block;
115 NODETYPE nodetypeval;
130 #define YYFLAG -32768
133 #define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 107)
135 static const char yytranslate[] = { 0,
136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 51, 2, 2, 54, 50, 2, 2, 55,
140 56, 48, 46, 42, 47, 2, 49, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 41, 61, 43,
142 2, 44, 40, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
145 57, 2, 58, 53, 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, 59, 45, 60, 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, 2, 2, 2, 2, 2,
158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
161 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
162 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
163 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
164 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
169 static const short yyprhs[] = { 0,
170 0, 4, 6, 9, 11, 14, 15, 16, 20, 21,
171 25, 28, 31, 34, 36, 39, 42, 44, 46, 48,
172 50, 52, 53, 61, 66, 71, 73, 77, 78, 83,
173 89, 94, 96, 99, 101, 104, 106, 109, 112, 115,
174 119, 121, 128, 137, 146, 157, 167, 170, 173, 180,
175 185, 189, 192, 196, 197, 202, 209, 213, 216, 218,
176 220, 227, 237, 239, 242, 243, 245, 246, 249, 250,
177 253, 256, 259, 260, 262, 264, 268, 270, 273, 277,
178 278, 280, 281, 283, 285, 289, 291, 294, 298, 302,
179 303, 305, 307, 311, 313, 316, 320, 324, 325, 330,
180 336, 341, 345, 349, 353, 357, 359, 362, 366, 370,
181 374, 378, 384, 386, 389, 390, 395, 399, 403, 407,
182 409, 412, 416, 420, 424, 430, 432, 435, 437, 441,
183 445, 449, 453, 457, 461, 464, 467, 470, 474, 479,
184 484, 486, 491, 493, 496, 499, 501, 503, 506, 509,
185 510, 512, 514, 519, 522, 525, 528, 530, 531, 533,
189 static const short yyrhs[] = { 83,
190 63, 83, 0, 64, 0, 63, 64, 0, 1, 0,
191 63, 1, 0, 0, 0, 15, 65, 75, 0, 0,
192 16, 66, 75, 0, 15, 77, 0, 16, 77, 0,
193 72, 75, 0, 75, 0, 72, 77, 0, 69, 71,
194 0, 4, 0, 3, 0, 68, 0, 38, 0, 39,
195 0, 0, 30, 70, 67, 55, 86, 103, 83, 0,
196 101, 76, 102, 104, 0, 101, 102, 104, 83, 0,
197 93, 0, 93, 42, 93, 0, 0, 49, 74, 5,
198 49, 0, 101, 76, 102, 104, 83, 0, 101, 102,
199 104, 83, 0, 78, 0, 76, 78, 0, 1, 0,
200 76, 1, 0, 82, 0, 105, 83, 0, 105, 83,
201 0, 101, 102, 0, 101, 76, 102, 0, 81, 0,
202 21, 55, 93, 103, 83, 78, 0, 22, 83, 78,
203 21, 55, 93, 103, 83, 0, 23, 55, 4, 33,
204 4, 103, 83, 78, 0, 23, 55, 88, 105, 93,
205 105, 88, 103, 83, 78, 0, 23, 55, 88, 105,
206 105, 88, 103, 83, 78, 0, 24, 77, 0, 25,
207 77, 0, 80, 55, 92, 103, 85, 77, 0, 80,
208 89, 85, 77, 0, 28, 88, 77, 0, 32, 77,
209 0, 29, 88, 77, 0, 0, 19, 79, 88, 77,
210 0, 20, 4, 57, 92, 58, 77, 0, 20, 4,
211 77, 0, 93, 77, 0, 26, 0, 27, 0, 17,
212 55, 93, 103, 83, 78, 0, 17, 55, 93, 103,
213 83, 78, 18, 83, 78, 0, 13, 0, 82, 13,
214 0, 0, 82, 0, 0, 43, 97, 0, 0, 44,
215 93, 0, 10, 93, 0, 45, 93, 0, 0, 87,
216 0, 4, 0, 87, 106, 4, 0, 1, 0, 87,
217 1, 0, 87, 106, 1, 0, 0, 93, 0, 0,
218 90, 0, 95, 0, 90, 106, 95, 0, 1, 0,
219 90, 1, 0, 90, 1, 95, 0, 90, 106, 1,
220 0, 0, 92, 0, 93, 0, 92, 106, 93, 0,
221 1, 0, 92, 1, 0, 92, 1, 93, 0, 92,
222 106, 1, 0, 0, 100, 11, 94, 93, 0, 55,
223 92, 103, 33, 4, 0, 93, 45, 31, 99, 0,
224 31, 99, 84, 0, 93, 34, 93, 0, 93, 35,
225 93, 0, 93, 12, 93, 0, 73, 0, 51, 73,
226 0, 93, 33, 4, 0, 93, 9, 93, 0, 93,
227 43, 93, 0, 93, 44, 93, 0, 93, 40, 93,
228 41, 93, 0, 97, 0, 93, 97, 0, 0, 100,
229 11, 96, 95, 0, 95, 34, 95, 0, 95, 35,
230 95, 0, 31, 99, 84, 0, 73, 0, 51, 73,
231 0, 95, 12, 95, 0, 95, 33, 4, 0, 95,
232 9, 95, 0, 95, 40, 95, 41, 95, 0, 97,
233 0, 95, 97, 0, 98, 0, 97, 53, 97, 0,
234 97, 48, 97, 0, 97, 49, 97, 0, 97, 50,
235 97, 0, 97, 46, 97, 0, 97, 47, 97, 0,
236 100, 36, 0, 100, 37, 0, 51, 97, 0, 55,
237 93, 103, 0, 38, 55, 91, 103, 0, 39, 55,
238 91, 103, 0, 39, 0, 3, 55, 91, 103, 0,
239 100, 0, 36, 100, 0, 37, 100, 0, 7, 0,
240 8, 0, 47, 97, 0, 46, 97, 0, 0, 100,
241 0, 4, 0, 4, 57, 92, 58, 0, 54, 98,
242 0, 59, 83, 0, 60, 83, 0, 56, 0, 0,
243 105, 0, 61, 0, 42, 83, 0
249 static const short yyrline[] = { 0,
250 150, 158, 166, 182, 183, 184, 188, 190, 204, 206,
251 220, 226, 232, 234, 236, 249, 258, 260, 262, 272,
252 273, 277, 281, 296, 301, 310, 312, 321, 323, 341,
253 343, 348, 354, 362, 364, 369, 370, 374, 376, 378,
254 380, 382, 384, 386, 413, 417, 422, 425, 428, 430,
255 450, 489, 508, 510, 515, 517, 519, 533, 538, 540,
256 545, 550, 557, 559, 563, 564, 568, 570, 575, 577,
257 579, 581, 586, 588, 593, 595, 597, 599, 601, 607,
258 609, 614, 616, 621, 623, 629, 631, 633, 635, 640,
259 642, 647, 649, 655, 657, 659, 661, 666, 669, 674,
260 676, 681, 687, 689, 691, 697, 707, 715, 717, 723,
261 725, 727, 729, 731, 736, 739, 740, 742, 744, 750,
262 752, 754, 756, 758, 760, 762, 764, 769, 771, 773,
263 775, 777, 779, 781, 783, 785, 790, 792, 794, 797,
264 799, 807, 814, 815, 817, 819, 821, 824, 832, 843,
265 845, 850, 852, 862, 867, 871, 875, 879, 880, 884,
271 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
273 static const char * const yytname[] = { "$","error","$undefined.","FUNC_CALL",
274 "NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
275 "NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
276 "LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
277 "LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_NEXTFILE",
278 "LEX_IN","LEX_AND","LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH",
279 "'?'","':'","','","'<'","'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY",
280 "'^'","'$'","'('","')'","'['","']'","'{'","'}'","';'","start","program","rule",
281 "@1","@2","func_name","lex_builtin","function_prologue","@3","function_body",
282 "pattern","regexp","@4","action","statements","statement_term","statement","@5",
283 "print","if_statement","nls","opt_nls","input_redir","output_redir","opt_param_list",
284 "param_list","opt_exp","opt_rexpression_list","rexpression_list","opt_expression_list",
285 "expression_list","exp","@6","rexp","@7","simp_exp","non_post_simp_exp","opt_variable",
286 "variable","l_brace","r_brace","r_paren","opt_semi","semi","comma", NULL
290 static const short yyr1[] = { 0,
291 62, 63, 63, 63, 63, 63, 65, 64, 66, 64,
292 64, 64, 64, 64, 64, 64, 67, 67, 67, 68,
293 68, 70, 69, 71, 71, 72, 72, 74, 73, 75,
294 75, 76, 76, 76, 76, 77, 77, 78, 78, 78,
295 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
296 78, 78, 78, 79, 78, 78, 78, 78, 80, 80,
297 81, 81, 82, 82, 83, 83, 84, 84, 85, 85,
298 85, 85, 86, 86, 87, 87, 87, 87, 87, 88,
299 88, 89, 89, 90, 90, 90, 90, 90, 90, 91,
300 91, 92, 92, 92, 92, 92, 92, 94, 93, 93,
301 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
302 93, 93, 93, 93, 96, 95, 95, 95, 95, 95,
303 95, 95, 95, 95, 95, 95, 95, 97, 97, 97,
304 97, 97, 97, 97, 97, 97, 98, 98, 98, 98,
305 98, 98, 98, 98, 98, 98, 98, 98, 98, 99,
306 99, 100, 100, 100, 101, 102, 103, 104, 104, 105,
310 static const short yyr2[] = { 0,
311 3, 1, 2, 1, 2, 0, 0, 3, 0, 3,
312 2, 2, 2, 1, 2, 2, 1, 1, 1, 1,
313 1, 0, 7, 4, 4, 1, 3, 0, 4, 5,
314 4, 1, 2, 1, 2, 1, 2, 2, 2, 3,
315 1, 6, 8, 8, 10, 9, 2, 2, 6, 4,
316 3, 2, 3, 0, 4, 6, 3, 2, 1, 1,
317 6, 9, 1, 2, 0, 1, 0, 2, 0, 2,
318 2, 2, 0, 1, 1, 3, 1, 2, 3, 0,
319 1, 0, 1, 1, 3, 1, 2, 3, 3, 0,
320 1, 1, 3, 1, 2, 3, 3, 0, 4, 5,
321 4, 3, 3, 3, 3, 1, 2, 3, 3, 3,
322 3, 5, 1, 2, 0, 4, 3, 3, 3, 1,
323 2, 3, 3, 3, 5, 1, 2, 1, 3, 3,
324 3, 3, 3, 3, 2, 2, 2, 3, 4, 4,
325 1, 4, 1, 2, 2, 1, 1, 2, 2, 0,
326 1, 1, 4, 2, 2, 2, 1, 0, 1, 1,
330 static const short yydefact[] = { 65,
331 63, 66, 0, 64, 4, 0, 152, 146, 147, 7,
332 9, 22, 150, 0, 0, 0, 141, 0, 0, 28,
333 0, 0, 0, 65, 0, 2, 0, 0, 106, 14,
334 26, 113, 128, 143, 0, 0, 0, 160, 0, 11,
335 36, 65, 0, 12, 0, 67, 151, 144, 145, 0,
336 0, 0, 0, 149, 143, 148, 0, 107, 137, 154,
337 143, 94, 0, 92, 155, 5, 3, 1, 16, 0,
338 13, 15, 0, 0, 0, 0, 0, 0, 0, 0,
339 0, 0, 114, 0, 0, 0, 0, 0, 0, 98,
340 135, 136, 34, 0, 54, 0, 0, 65, 0, 0,
341 0, 59, 60, 80, 80, 0, 65, 0, 32, 0,
342 41, 0, 0, 158, 65, 0, 0, 92, 0, 8,
343 37, 10, 18, 17, 20, 21, 0, 19, 0, 102,
344 0, 0, 0, 0, 95, 65, 157, 0, 0, 138,
345 0, 158, 109, 105, 108, 103, 104, 0, 27, 110,
346 111, 150, 133, 134, 130, 131, 132, 129, 0, 0,
347 80, 0, 0, 0, 80, 47, 48, 0, 81, 0,
348 52, 156, 35, 33, 158, 86, 150, 0, 0, 120,
349 69, 0, 84, 126, 143, 58, 0, 39, 65, 159,
350 38, 142, 153, 0, 68, 139, 140, 29, 96, 161,
351 0, 97, 93, 158, 65, 0, 101, 99, 0, 0,
352 0, 57, 0, 0, 152, 0, 51, 53, 65, 67,
353 121, 0, 0, 0, 0, 0, 87, 0, 0, 0,
354 0, 0, 0, 0, 127, 115, 40, 31, 77, 75,
355 0, 0, 100, 24, 25, 112, 65, 55, 0, 65,
356 0, 0, 0, 30, 119, 69, 71, 70, 72, 50,
357 88, 89, 85, 124, 122, 123, 117, 118, 0, 0,
358 65, 78, 0, 0, 0, 0, 0, 0, 0, 80,
359 0, 0, 116, 23, 79, 76, 61, 56, 42, 0,
360 65, 80, 0, 49, 125, 65, 65, 0, 0, 65,
361 0, 43, 44, 65, 0, 62, 0, 46, 45, 0,
365 static const short yydefgoto[] = { 310,
366 25, 26, 39, 43, 127, 128, 27, 45, 69, 28,
367 29, 57, 30, 108, 40, 109, 161, 110, 111, 2,
368 3, 130, 226, 241, 242, 168, 181, 182, 116, 117,
369 112, 159, 183, 270, 32, 33, 46, 34, 113, 114,
373 static const short yypact[] = { -6,
374 -32768, 0, 875,-32768,-32768, -40, -38,-32768,-32768, -7,
375 -7,-32768, 10, 10, 10, -31, -26, 1735, 1735,-32768,
376 1715, 1735, 1131, -6, 932,-32768, -24, 72,-32768,-32768,
377 1304, 205,-32768, 5, 709, 1110, 1131,-32768, -24,-32768,
378 0, -6, -24,-32768, 85, 3,-32768,-32768,-32768, 1110,
379 1110, 1735, 1620, 8, 106, 8, 81,-32768, 8,-32768,
380 -32768,-32768, 37, 1250,-32768,-32768,-32768,-32768,-32768, 709,
381 -32768,-32768, 1620, 1620, 90, 1620, 1620, 1620, 1620, 1620,
382 1620, 65, 205, 1735, 1735, 1735, 1735, 1735, 1735,-32768,
383 -32768,-32768,-32768, 50,-32768, 111, 70, -6, 93, -7,
384 -7,-32768,-32768, 1620, 1620, -7, -6, 758,-32768, 819,
385 -32768, 1040, 709, 100, -6, 99, 55, 1402, 9,-32768,
386 -32768,-32768,-32768,-32768,-32768,-32768, 109,-32768, 1735,-32768,
387 99, 99, 1250, 119, 1620, -6,-32768, 133, 1180,-32768,
388 758, 100, 1327, 794,-32768, 1515, 1451, 1353, 1402, 1327,
389 1327, 10, 125, 125, 8, 8, 8, 8, 1620, 1620,
390 1620, 42, 1620, 981, 1657,-32768,-32768, -7, 1402, -7,
391 -32768,-32768,-32768,-32768, 100,-32768, 10, 1715, 1131,-32768,
392 96, 39, 1538, 205, 117,-32768, 758,-32768, -6,-32768,
393 -32768,-32768,-32768, 7, 205,-32768,-32768,-32768, 1402,-32768,
394 166,-32768, 1402, 100, -6, 1620,-32768, 1402, 1250, -7,
395 1131,-32768, 1250, 151, -12, 100,-32768,-32768, -6, 3,
396 -32768, 37, 1620, 1620, 1620, -7, 1678, 1201, 1678, 1678,
397 181, 1678, 1678, 1678, 205,-32768,-32768,-32768,-32768,-32768,
398 99, 56,-32768,-32768,-32768, 1402, -6,-32768, 11, -6,
399 131, 183, 1061,-32768,-32768, 96, 1402, 1402, 1402,-32768,
400 1538,-32768, 1538, 635, 83,-32768, 1599, 1579, 1474, 1678,
401 -6,-32768, 103, 981, -7, 981, 1620, 99, 623, 1620,
402 -7, 1678, 1538,-32768,-32768,-32768, 170,-32768,-32768, 1250,
403 -6, 1620, 99,-32768, 1538, -6, -6, 981, 99, -6,
404 981,-32768,-32768, -6, 981,-32768, 981,-32768,-32768, 190,
408 static const short yypgoto[] = {-32768,
409 -32768, 167,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
410 211,-32768, 107, -53, 315, -105,-32768,-32768,-32768, 199,
411 97, -22, -62,-32768,-32768, -103,-32768,-32768, 94, -14,
412 -3,-32768, -202,-32768, 318, 177, -134, 95, 124, -69,
420 static const short yytable[] = { 31,
421 142, 170, 174, 205, 228, 1, 1, 239, 63, 135,
422 240, 135, 4, 7, 36, 90, 141, 207, 37, 64,
423 252, 31, 119, 50, 261, 263, 264, 265, 51, 267,
424 268, 269, 118, 118, 24, 174, 219, 135, 175, 227,
425 91, 92, 220, 188, 37, 129, 118, 118, -83, 133,
426 136, -83, 136, 38, 1, 135, 272, 210, 214, 187,
427 89, 216, -73, 22, 273, 244, 193, 283, 275, 143,
428 144, 204, 146, 147, 148, 149, 150, 151, 136, 295,
429 136, 174, -83, -83, 1, 134, 7, 123, 124, 8,
430 9, 229, 137, 145,-32768, 152, 136, 136, 211, -83,
431 169, 169, 38, 285, 160, 223, 286, 47, 48, 49,
432 -91, -74, 55, 55, 162, 55, 61, 237, 14, 15,
433 65, 68, 125, 126, 163, 55, 35, 236, 18, 19,
434 24, 199, 38, 52, 71, 203, 22, 53, 121, 224,
435 225, 91, 92, 131, 132, 120, 55, 165, 35, 122,
436 70, 35, 91, 92, 137, 208, 209, 169, 55, 213,
437 38, 169, 35, 194, 222, 201, 35, 198, 287, 243,
438 289, 251, 86, 87, 88, 64, 293, 89, 55, 55,
439 55, 55, 55, 55, 266, 277, 278, 296, 299, 311,
440 312, 67, 303, 281, 164, 306, 249, 255, 60, 308,
441 0, 309, 246, 172, 185, 0, 55, 118, 41, 41,
442 0, 191, 55, 0, 0, 0, 0, 0, 0, 257,
443 258, 259, 0, 55, 0, 0, 41, 55, 0, 0,
444 0, 58, 200, 0, 0, 0, 0, 55, 55, 0,
445 55, 55, 55, 55, 55, 55, 47, 0, 0, 279,
446 84, 85, 86, 87, 88, 0, 0, 89, 0, 0,
447 0, 0, 0, 55, 0, 0, 0, 0, 0, 0,
448 0, 47, 55, 290, 0, 0, 169, 55, 0, 0,
449 0, 0, 0, 0, 0, 238, 0, 0, 169, 0,
450 0, 0, 0, 55, 0, 0, 0, 55, 41, 41,
451 0, 245, 55, 55, 41, 0, 0, 55, 0, 0,
452 41, 0, 0, 0, 0, 254, 0, 0, 0, 0,
453 180, 185, 185, 185, 185, 44, 185, 185, 185, 0,
454 0, 0, 0, 0, 0, 54, 56, 0, 59, 0,
455 55, 0, 72, 274, 0, 0, 276, 0, 83, 0,
456 0, 55, 55, 55, 0, 55, 0, 55, 55, 55,
457 41, 55, 55, 55, 185, 0, 41, 284, 41, 59,
458 0, 0, 0, 55, 0, 0, 185, 55, 0, 0,
459 0, 83, 0, 0, 55, 0, 0, 298, 221, 55,
460 0, 0, 301, 302, 0, 0, 305, 0, 0, 0,
461 307, 153, 154, 155, 156, 157, 158, 0, 41, 0,
462 0, 0, 0, 0, 166, 167, 0, 0, 0, 0,
463 171, 0, 0, 0, 41, 0, 186, 184, 0, 83,
464 0, 0, 0, 0, 0, 83, 0, 180, 180, 180,
465 180, 0, 180, 180, 180, 0, 195, 0, 0, 0,
466 83, 0, 0, 0, 115, 0, 0, 0, 0, 0,
467 83, 83, 0, 83, 83, 83, 83, 83, 83, 138,
468 0, 0, 0, 41, 0, 0, 212, 0, 0, 41,
469 180, 0, 217, 0, 218, 0, 83, 0, 0, 115,
470 0, 0, 180, 0, 0, 59, 0, 0, 0, 0,
471 235, 0, 0, 0, 0, 0, 0, 0, 0, 0,
472 0, 0, 0, 0, 0, 0, 83, 0, 0, 0,
473 83, 0, 192, 0, 248, 83, 83, 115, 0, 0,
474 83, 0, 115, 190, 0, 0, 0, 196, 197, 0,
475 260, 0, 0, 0, 184, 184, 184, 184, 0, 184,
476 184, 184, 0, 0, 0, 0, 0, 0, 0, 0,
477 115, 190, 0, 83, 0, 0, 0, 0, 0, 0,
478 0, 0, 0, 0, 83, 83, 83, 0, 235, 0,
479 235, 235, 235, 115, 235, 235, 235, 184, 0, 288,
480 0, 0, 0, 0, 190, 294, 83, 0, 0, 184,
481 235, 0, 0, 0, 0, 0, 115, 83, 0, 0,
482 0, 0, 235, 0, 0, 247, 0, 0, 0, 250,
483 0, 0, 0, 190, 0, 6, 7, 0, 256, 8,
484 9, 73, 0, 0, 74, 253, 0, 0, 7, 0,
485 0, 8, 9,-32768, 0, 0, 0, 271, 0, 0,
486 0, 0, 0, 0, 0, 75, 76, 77, 14, 15,
487 16, 17, 78, 0, 0, 80, 81, 82, 18, 19,
488 14, 15, 280, 52, 0, 0, 22, 53, 0, 0,
489 18, 19, 0, 38, 291, 52, 0, 0, 22, 53,
490 0, 0, 0, 115, 0, 115, 297, 0, 292, 300,
491 0, 0, 0, 0, 0, 304, 0, 0, 0, 93,
492 0, 6, 7, 0, 0, 8, 9, 115, 0, 0,
493 115, 0, 0, 0, 115, 94, 115, 95, 96, 97,
494 98, 99, 100, 101, 102, 103, 104, 105, 0, 13,
495 106, 0, 0, 0, 14, 15, 16, 17, 0, 0,
496 0, 0, 0, 0, 18, 19, 0, 20, 173, 21,
497 6, 7, 22, 23, 8, 9, 0, 24, 107, 38,
498 0, 0, 0, 0, 94, 0, 95, 96, 97, 98,
499 99, 100, 101, 102, 103, 104, 105, 0, 13, 106,
500 0, 0, 0, 14, 15, 16, 17, 7, 0, 0,
501 8, 9, 73, 18, 19,-32768, 20, 0, 21, 0,
502 0, 22, 23, 0, 0, 0, 24, 107, 38, 176,
503 0, 6, 7, 0, 0, 8, 9, 0, -82, 14,
504 15, -82, 0, 0, 0, 0, 80, 81, 82, 18,
505 19, 0, 0, 0, 52, 0, 0, 22, 53, 177,
506 0, 0, 0, 0, 14, 15, 16, 17, 0, 0,
507 0, 0, -82, -82, 18, 19, 0, 20, 0, 178,
508 0, 0, 22, 179, -6, 5, 0, 6, 7, -82,
509 0, 8, 9, 0, 0, 0, 0, -6, 0, 10,
510 11, 0, 0, 0, 0, 0, 0, 0, 0, 0,
511 0, 0, 0, 0, 12, 13, 0, 0, 0, 0,
512 14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
513 18, 19, 0, 20, 0, 21, 0, 0, 22, 23,
514 0, -65, 66, 24, 6, 7, 0, 0, 8, 9,
515 0, 0, 0, 0, 1, 0, 10, 11, 0, 0,
516 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
517 0, 12, 13, 0, 0, 0, 0, 14, 15, 16,
518 17, 0, 0, 0, 0, 0, 0, 18, 19, 0,
519 20, 0, 21, 6, 7, 22, 23, 8, 9, 0,
520 24, 0, 0, 0, 0, 0, 0, 94, 0, 95,
521 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
522 0, 13, 106, 0, 0, 0, 14, 15, 16, 17,
523 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
524 0, 21, 0, 0, 22, 23, 0, 0, 0, 24,
525 0, 38, 6, 7, 0, 0, 8, 9, 73, 0,
526 0, 74, 1, 0, 0, 0, 0, 0, 0, 0,
527 0, 0, 0, 6, 7, 0, 0, 8, 9, 0,
528 0, 0, 75, 76, 77, 14, 15, 16, 17, 78,
529 0, 0, 80, 81, 82, 18, 19, 0, 0, 0,
530 52, 13, 0, 22, 53, 0, 14, 15, 16, 17,
531 38, 0, 0, 0, 0, 0, 18, 19, 0, 20,
532 62, 21, 6, 7, 22, 23, 8, 9, 0, 0,
533 0, 38, 0, 0, 0, 0, 0, 0, 0, 0,
534 0, 62, 0, 6, 7, 0, 0, 8, 9, 0,
535 13, 0, 0, 0, 0, 14, 15, 16, 17, 0,
536 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
537 21, 13, 0, 22, 23, -90, 14, 15, 16, 17,
538 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
539 202, 21, 6, 7, 22, 23, 8, 9, 0, 0,
540 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
541 0, 262, 0, 6, 7, 0, 0, 8, 9, 0,
542 13, 0, 0, 0, 0, 14, 15, 16, 17, 0,
543 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
544 21, 177, 0, 22, 23, 0, 14, 15, 16, 17,
545 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
546 0, 178, 6, 7, 22, 53, 8, 9, 73, 0,
547 0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
548 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
549 0, 0, 75, 76, 77, 14, 15, 16, 17, 78,
550 0, 0, 80, 81, 82, 18, 19, 0, 0, 0,
551 52, 0, 0, 22, 53, 137, 6, 7, 0, 0,
552 8, 9, 73, 0, 0, 74, 0, 0, 0, 0,
553 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
554 7, 0, 0, 8, 9,-32768, 75, 76, 77, 14,
555 15, 16, 17, 78, 0, 79, 80, 81, 82, 18,
556 19, 0, 0, 0, 52, 6, 7, 22, 53, 8,
557 9, 73, 14, 15, 74, 0, 0, 0, 0,-32768,
558 -32768,-32768, 18, 19, 0, 0, 0, 52, 0, 0,
559 22, 53, 0, 0, 0, 75, 76, 77, 14, 15,
560 16, 17, 78, 206, 0, 80, 81, 82, 18, 19,
561 0, 0, 0, 52, 6, 7, 22, 53, 8, 9,
562 73, 0, 0, 74, 0, 0, 0, 0, 0, 0,
563 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
564 0, 0, 0, 0, 75, 76, 77, 14, 15, 16,
565 17, 78, 0, 0, 80, 81, 82, 18, 19, 0,
566 0, 0, 52, 6, 7, 22, 53, 8, 9, 73,
567 0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
568 0, 0, 0, 0, 0, 0, 6, 7, 0, 0,
569 8, 9, 229, 75, 76, 230, 14, 15, 16, 17,
570 0, 0, 0, 80, 81, 82, 18, 19, 0, 0,
571 0, 52, 0, 0, 22, 53, 231, 232, 233, 14,
572 15, 16, 17, 234, 282, 0, 0, 6, 7, 18,
573 19, 8, 9, 73, 52, 0, 74, 22, 53, 0,
574 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
575 6, 7, 0, 0, 8, 9, 229, 75, 0, 230,
576 14, 15, 16, 17, 0, 0, 0, 80, 81, 82,
577 18, 19, 0, 0, 0, 52, 0, 0, 22, 53,
578 231, 232, 233, 14, 15, 16, 17, 234, 0, 0,
579 0, 6, 7, 18, 19, 8, 9, 229, 52, 0,
580 230, 22, 53, 0, 0, 0, 0, 0, 0, 0,
581 0, 6, 7, 0, 0, 8, 9, 229, 0, 0,
582 230, 231, 232, 0, 14, 15, 16, 17, 0, 0,
583 0, 0, 6, 7, 18, 19, 8, 9, 0, 52,
584 0, 231, 22, 53, 14, 15, 16, 17, 0, 0,
585 0, 0, 0, 0, 18, 19, 0, 0, 0, 52,
586 13, 0, 22, 53, 0, 14, 15, 16, 17, 6,
587 215, 0, 0, 8, 9, 18, 19, 0, 20, 0,
588 21, 0, 0, 22, 23, 0, 0, 0, 0, 0,
589 6, 7, 0, 0, 8, 9, 0, 13, 0, 0,
590 0, 0, 14, 15, 16, 17, 0, 0, 0, 0,
591 0, 0, 18, 19, 0, 20, 0, 21, 177, 0,
592 22, 23, 0, 14, 15, 16, 17, 6, 7, 0,
593 0, 8, 9, 18, 19, 0, 20, 0, 178, 0,
594 0, 22, 53, 0, 0, 0, 0, 6, 7, 0,
595 0, 8, 9, 0, 0, 0, 0, 0, 0, 0,
596 14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
597 18, 19, 0, 20, 0, 52, 0, 0, 22, 53,
598 14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
599 18, 19, 0, 0, 0, 52, 0, 0, 22, 53
602 static const short yycheck[] = { 3,
603 70, 105, 108, 142, 182, 13, 13, 1, 23, 1,
604 4, 1, 13, 4, 55, 11, 70, 152, 57, 23,
605 33, 25, 37, 55, 227, 228, 229, 230, 55, 232,
606 233, 234, 36, 37, 59, 141, 175, 1, 108, 1,
607 36, 37, 177, 113, 57, 43, 50, 51, 10, 53,
608 42, 13, 42, 61, 13, 1, 1, 161, 164, 113,
609 53, 165, 56, 54, 242, 204, 58, 270, 58, 73,
610 74, 141, 76, 77, 78, 79, 80, 81, 42, 282,
611 42, 187, 44, 45, 13, 5, 4, 3, 4, 7,
612 8, 9, 56, 4, 12, 31, 42, 42, 57, 61,
613 104, 105, 61, 1, 55, 10, 4, 13, 14, 15,
614 56, 56, 18, 19, 4, 21, 22, 187, 36, 37,
615 24, 25, 38, 39, 55, 31, 3, 11, 46, 47,
616 59, 135, 61, 51, 28, 139, 54, 55, 42, 44,
617 45, 36, 37, 50, 51, 39, 52, 55, 25, 43,
618 27, 28, 36, 37, 56, 159, 160, 161, 64, 163,
619 61, 165, 39, 55, 179, 33, 43, 49, 274, 4,
620 276, 21, 48, 49, 50, 179, 280, 53, 84, 85,
621 86, 87, 88, 89, 4, 55, 4, 18, 292, 0,
622 0, 25, 298, 256, 98, 301, 211, 220, 22, 305,
623 -1, 307, 206, 107, 110, -1, 112, 211, 10, 11,
624 -1, 115, 118, -1, -1, -1, -1, -1, -1, 223,
625 224, 225, -1, 129, -1, -1, 28, 133, -1, -1,
626 -1, 21, 136, -1, -1, -1, -1, 143, 144, -1,
627 146, 147, 148, 149, 150, 151, 152, -1, -1, 253,
628 46, 47, 48, 49, 50, -1, -1, 53, -1, -1,
629 -1, -1, -1, 169, -1, -1, -1, -1, -1, -1,
630 -1, 177, 178, 277, -1, -1, 280, 183, -1, -1,
631 -1, -1, -1, -1, -1, 189, -1, -1, 292, -1,
632 -1, -1, -1, 199, -1, -1, -1, 203, 100, 101,
633 -1, 205, 208, 209, 106, -1, -1, 213, -1, -1,
634 112, -1, -1, -1, -1, 219, -1, -1, -1, -1,
635 110, 227, 228, 229, 230, 11, 232, 233, 234, -1,
636 -1, -1, -1, -1, -1, 18, 19, -1, 21, -1,
637 246, -1, 28, 247, -1, -1, 250, -1, 31, -1,
638 -1, 257, 258, 259, -1, 261, -1, 263, 264, 265,
639 162, 267, 268, 269, 270, -1, 168, 271, 170, 52,
640 -1, -1, -1, 279, -1, -1, 282, 283, -1, -1,
641 -1, 64, -1, -1, 290, -1, -1, 291, 178, 295,
642 -1, -1, 296, 297, -1, -1, 300, -1, -1, -1,
643 304, 84, 85, 86, 87, 88, 89, -1, 210, -1,
644 -1, -1, -1, -1, 100, 101, -1, -1, -1, -1,
645 106, -1, -1, -1, 226, -1, 112, 110, -1, 112,
646 -1, -1, -1, -1, -1, 118, -1, 227, 228, 229,
647 230, -1, 232, 233, 234, -1, 129, -1, -1, -1,
648 133, -1, -1, -1, 35, -1, -1, -1, -1, -1,
649 143, 144, -1, 146, 147, 148, 149, 150, 151, 63,
650 -1, -1, -1, 275, -1, -1, 162, -1, -1, 281,
651 270, -1, 168, -1, 170, -1, 169, -1, -1, 70,
652 -1, -1, 282, -1, -1, 178, -1, -1, -1, -1,
653 183, -1, -1, -1, -1, -1, -1, -1, -1, -1,
654 -1, -1, -1, -1, -1, -1, 199, -1, -1, -1,
655 203, -1, 116, -1, 210, 208, 209, 108, -1, -1,
656 213, -1, 113, 114, -1, -1, -1, 131, 132, -1,
657 226, -1, -1, -1, 227, 228, 229, 230, -1, 232,
658 233, 234, -1, -1, -1, -1, -1, -1, -1, -1,
659 141, 142, -1, 246, -1, -1, -1, -1, -1, -1,
660 -1, -1, -1, -1, 257, 258, 259, -1, 261, -1,
661 263, 264, 265, 164, 267, 268, 269, 270, -1, 275,
662 -1, -1, -1, -1, 175, 281, 279, -1, -1, 282,
663 283, -1, -1, -1, -1, -1, 187, 290, -1, -1,
664 -1, -1, 295, -1, -1, 209, -1, -1, -1, 213,
665 -1, -1, -1, 204, -1, 3, 4, -1, 222, 7,
666 8, 9, -1, -1, 12, 216, -1, -1, 4, -1,
667 -1, 7, 8, 9, -1, -1, -1, 241, -1, -1,
668 -1, -1, -1, -1, -1, 33, 34, 35, 36, 37,
669 38, 39, 40, -1, -1, 43, 44, 45, 46, 47,
670 36, 37, 253, 51, -1, -1, 54, 55, -1, -1,
671 46, 47, -1, 61, 278, 51, -1, -1, 54, 55,
672 -1, -1, -1, 274, -1, 276, 290, -1, 279, 293,
673 -1, -1, -1, -1, -1, 299, -1, -1, -1, 1,
674 -1, 3, 4, -1, -1, 7, 8, 298, -1, -1,
675 301, -1, -1, -1, 305, 17, 307, 19, 20, 21,
676 22, 23, 24, 25, 26, 27, 28, 29, -1, 31,
677 32, -1, -1, -1, 36, 37, 38, 39, -1, -1,
678 -1, -1, -1, -1, 46, 47, -1, 49, 1, 51,
679 3, 4, 54, 55, 7, 8, -1, 59, 60, 61,
680 -1, -1, -1, -1, 17, -1, 19, 20, 21, 22,
681 23, 24, 25, 26, 27, 28, 29, -1, 31, 32,
682 -1, -1, -1, 36, 37, 38, 39, 4, -1, -1,
683 7, 8, 9, 46, 47, 12, 49, -1, 51, -1,
684 -1, 54, 55, -1, -1, -1, 59, 60, 61, 1,
685 -1, 3, 4, -1, -1, 7, 8, -1, 10, 36,
686 37, 13, -1, -1, -1, -1, 43, 44, 45, 46,
687 47, -1, -1, -1, 51, -1, -1, 54, 55, 31,
688 -1, -1, -1, -1, 36, 37, 38, 39, -1, -1,
689 -1, -1, 44, 45, 46, 47, -1, 49, -1, 51,
690 -1, -1, 54, 55, 0, 1, -1, 3, 4, 61,
691 -1, 7, 8, -1, -1, -1, -1, 13, -1, 15,
692 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
693 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
694 36, 37, 38, 39, -1, -1, -1, -1, -1, -1,
695 46, 47, -1, 49, -1, 51, -1, -1, 54, 55,
696 -1, 0, 1, 59, 3, 4, -1, -1, 7, 8,
697 -1, -1, -1, -1, 13, -1, 15, 16, -1, -1,
698 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
699 -1, 30, 31, -1, -1, -1, -1, 36, 37, 38,
700 39, -1, -1, -1, -1, -1, -1, 46, 47, -1,
701 49, -1, 51, 3, 4, 54, 55, 7, 8, -1,
702 59, -1, -1, -1, -1, -1, -1, 17, -1, 19,
703 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
704 -1, 31, 32, -1, -1, -1, 36, 37, 38, 39,
705 -1, -1, -1, -1, -1, -1, 46, 47, -1, 49,
706 -1, 51, -1, -1, 54, 55, -1, -1, -1, 59,
707 -1, 61, 3, 4, -1, -1, 7, 8, 9, -1,
708 -1, 12, 13, -1, -1, -1, -1, -1, -1, -1,
709 -1, -1, -1, 3, 4, -1, -1, 7, 8, -1,
710 -1, -1, 33, 34, 35, 36, 37, 38, 39, 40,
711 -1, -1, 43, 44, 45, 46, 47, -1, -1, -1,
712 51, 31, -1, 54, 55, -1, 36, 37, 38, 39,
713 61, -1, -1, -1, -1, -1, 46, 47, -1, 49,
714 1, 51, 3, 4, 54, 55, 7, 8, -1, -1,
715 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
716 -1, 1, -1, 3, 4, -1, -1, 7, 8, -1,
717 31, -1, -1, -1, -1, 36, 37, 38, 39, -1,
718 -1, -1, -1, -1, -1, 46, 47, -1, 49, -1,
719 51, 31, -1, 54, 55, 56, 36, 37, 38, 39,
720 -1, -1, -1, -1, -1, -1, 46, 47, -1, 49,
721 1, 51, 3, 4, 54, 55, 7, 8, -1, -1,
722 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
723 -1, 1, -1, 3, 4, -1, -1, 7, 8, -1,
724 31, -1, -1, -1, -1, 36, 37, 38, 39, -1,
725 -1, -1, -1, -1, -1, 46, 47, -1, 49, -1,
726 51, 31, -1, 54, 55, -1, 36, 37, 38, 39,
727 -1, -1, -1, -1, -1, -1, 46, 47, -1, 49,
728 -1, 51, 3, 4, 54, 55, 7, 8, 9, -1,
729 -1, 12, -1, -1, -1, -1, -1, -1, -1, -1,
730 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
731 -1, -1, 33, 34, 35, 36, 37, 38, 39, 40,
732 -1, -1, 43, 44, 45, 46, 47, -1, -1, -1,
733 51, -1, -1, 54, 55, 56, 3, 4, -1, -1,
734 7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
735 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
736 4, -1, -1, 7, 8, 9, 33, 34, 35, 36,
737 37, 38, 39, 40, -1, 42, 43, 44, 45, 46,
738 47, -1, -1, -1, 51, 3, 4, 54, 55, 7,
739 8, 9, 36, 37, 12, -1, -1, -1, -1, 43,
740 44, 45, 46, 47, -1, -1, -1, 51, -1, -1,
741 54, 55, -1, -1, -1, 33, 34, 35, 36, 37,
742 38, 39, 40, 41, -1, 43, 44, 45, 46, 47,
743 -1, -1, -1, 51, 3, 4, 54, 55, 7, 8,
744 9, -1, -1, 12, -1, -1, -1, -1, -1, -1,
745 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
746 -1, -1, -1, -1, 33, 34, 35, 36, 37, 38,
747 39, 40, -1, -1, 43, 44, 45, 46, 47, -1,
748 -1, -1, 51, 3, 4, 54, 55, 7, 8, 9,
749 -1, -1, 12, -1, -1, -1, -1, -1, -1, -1,
750 -1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
751 7, 8, 9, 33, 34, 12, 36, 37, 38, 39,
752 -1, -1, -1, 43, 44, 45, 46, 47, -1, -1,
753 -1, 51, -1, -1, 54, 55, 33, 34, 35, 36,
754 37, 38, 39, 40, 41, -1, -1, 3, 4, 46,
755 47, 7, 8, 9, 51, -1, 12, 54, 55, -1,
756 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
757 3, 4, -1, -1, 7, 8, 9, 33, -1, 12,
758 36, 37, 38, 39, -1, -1, -1, 43, 44, 45,
759 46, 47, -1, -1, -1, 51, -1, -1, 54, 55,
760 33, 34, 35, 36, 37, 38, 39, 40, -1, -1,
761 -1, 3, 4, 46, 47, 7, 8, 9, 51, -1,
762 12, 54, 55, -1, -1, -1, -1, -1, -1, -1,
763 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
764 12, 33, 34, -1, 36, 37, 38, 39, -1, -1,
765 -1, -1, 3, 4, 46, 47, 7, 8, -1, 51,
766 -1, 33, 54, 55, 36, 37, 38, 39, -1, -1,
767 -1, -1, -1, -1, 46, 47, -1, -1, -1, 51,
768 31, -1, 54, 55, -1, 36, 37, 38, 39, 3,
769 4, -1, -1, 7, 8, 46, 47, -1, 49, -1,
770 51, -1, -1, 54, 55, -1, -1, -1, -1, -1,
771 3, 4, -1, -1, 7, 8, -1, 31, -1, -1,
772 -1, -1, 36, 37, 38, 39, -1, -1, -1, -1,
773 -1, -1, 46, 47, -1, 49, -1, 51, 31, -1,
774 54, 55, -1, 36, 37, 38, 39, 3, 4, -1,
775 -1, 7, 8, 46, 47, -1, 49, -1, 51, -1,
776 -1, 54, 55, -1, -1, -1, -1, 3, 4, -1,
777 -1, 7, 8, -1, -1, -1, -1, -1, -1, -1,
778 36, 37, 38, 39, -1, -1, -1, -1, -1, -1,
779 46, 47, -1, 49, -1, 51, -1, -1, 54, 55,
780 36, 37, 38, 39, -1, -1, -1, -1, -1, -1,
781 46, 47, -1, -1, -1, 51, -1, -1, 54, 55
783 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
784 #line 3 "/usr/share/bison.simple"
786 /* Skeleton output parser for bison,
787 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
789 This program is free software; you can redistribute it and/or modify
790 it under the terms of the GNU General Public License as published by
791 the Free Software Foundation; either version 2, or (at your option)
794 This program is distributed in the hope that it will be useful,
795 but WITHOUT ANY WARRANTY; without even the implied warranty of
796 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
797 GNU General Public License for more details.
799 You should have received a copy of the GNU General Public License
800 along with this program; if not, write to the Free Software
801 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
803 /* As a special exception, when this file is copied by Bison into a
804 Bison output file, you may use that output file without restriction.
805 This special exception was added by the Free Software Foundation
806 in version 1.24 of Bison. */
810 #define alloca __builtin_alloca
811 #else /* not GNU C. */
812 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
814 #else /* not sparc */
815 #if defined (MSDOS) && !defined (__TURBOC__)
817 #else /* not MSDOS, or __TURBOC__ */
821 #else /* not MSDOS, __TURBOC__, or _AIX */
825 void *alloca (unsigned int);
827 #else /* not __cplusplus */
829 #endif /* not __cplusplus */
831 #endif /* not _AIX */
832 #endif /* not MSDOS, or __TURBOC__ */
833 #endif /* not sparc. */
834 #endif /* not GNU C. */
835 #endif /* alloca not defined. */
837 /* This is the parser code that is written into each bison parser
838 when the %semantic_parser declaration is not specified in the grammar.
839 It was written by Richard Stallman by simplifying the hairy parser
840 used when %semantic_parser is specified. */
842 /* Note: there must be only one dollar sign in this file.
843 It is replaced by the list of actions, each action
844 as one case of the switch. */
846 #define yyerrok (yyerrstatus = 0)
847 #define yyclearin (yychar = YYEMPTY)
850 #define YYACCEPT return(0)
851 #define YYABORT return(1)
852 #define YYERROR goto yyerrlab1
853 /* Like YYERROR except do call yyerror.
854 This remains here temporarily to ease the
855 transition to the new meaning of YYERROR, for GCC.
856 Once GCC version 2 has supplanted version 1, this can go. */
857 #define YYFAIL goto yyerrlab
858 #define YYRECOVERING() (!!yyerrstatus)
859 #define YYBACKUP(token, value) \
861 if (yychar == YYEMPTY && yylen == 1) \
862 { yychar = (token), yylval = (value); \
863 yychar1 = YYTRANSLATE (yychar); \
868 { yyerror ("syntax error: cannot back up"); YYERROR; } \
872 #define YYERRCODE 256
875 #define YYLEX yylex()
881 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
883 #define YYLEX yylex(&yylval, &yylloc)
885 #else /* not YYLSP_NEEDED */
887 #define YYLEX yylex(&yylval, YYLEX_PARAM)
889 #define YYLEX yylex(&yylval)
891 #endif /* not YYLSP_NEEDED */
894 /* If nonreentrant, generate the variables here */
898 int yychar; /* the lookahead symbol */
899 YYSTYPE yylval; /* the semantic value of the */
900 /* lookahead symbol */
903 YYLTYPE yylloc; /* location data for the lookahead */
907 int yynerrs; /* number of parse errors so far */
908 #endif /* not YYPURE */
911 int yydebug; /* nonzero means print parse trace */
912 /* Since this is uninitialized, it does not stop multiple parsers
916 /* YYINITDEPTH indicates the initial size of the parser's stacks */
919 #define YYINITDEPTH 200
922 /* YYMAXDEPTH is the maximum size the stacks can grow to
923 (effective only if the built-in stack extension method is used). */
930 #define YYMAXDEPTH 10000
933 #ifndef YYPARSE_RETURN_TYPE
934 #define YYPARSE_RETURN_TYPE int
937 /* Prevent warning if -Wstrict-prototypes. */
939 YYPARSE_RETURN_TYPE yyparse (void);
942 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
943 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
944 #else /* not GNU C or C++ */
947 /* This is the most reliable way to avoid incompatibilities
948 in available built-in functions on various systems. */
950 __yy_memcpy (to, from, count)
955 register char *f = from;
956 register char *t = to;
957 register int i = count;
963 #else /* __cplusplus */
965 /* This is the most reliable way to avoid incompatibilities
966 in available built-in functions on various systems. */
968 __yy_memcpy (char *to, char *from, int count)
970 register char *f = from;
971 register char *t = to;
972 register int i = count;
981 #line 196 "/usr/share/bison.simple"
983 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
984 into yyparse. The argument should have type void *.
985 It should actually point to an object.
986 Grammar actions can access the variable by casting it
987 to the proper pointer type. */
991 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
992 #define YYPARSE_PARAM_DECL
993 #else /* not __cplusplus */
994 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
995 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
996 #endif /* not __cplusplus */
997 #else /* not YYPARSE_PARAM */
998 #define YYPARSE_PARAM_ARG
999 #define YYPARSE_PARAM_DECL
1000 #endif /* not YYPARSE_PARAM */
1003 yyparse(YYPARSE_PARAM_ARG)
1006 register int yystate;
1008 register short *yyssp;
1009 register YYSTYPE *yyvsp;
1010 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1011 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
1013 short yyssa[YYINITDEPTH]; /* the state stack */
1014 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
1016 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1017 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
1020 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1021 YYLTYPE *yyls = yylsa;
1024 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1026 #define YYPOPSTACK (yyvsp--, yyssp--)
1029 int yystacksize = YYINITDEPTH;
1040 YYSTYPE yyval; /* the variable used to return */
1041 /* semantic values from the action */
1048 fprintf(stderr, "Starting parse\n");
1054 yychar = YYEMPTY; /* Cause a token to be read. */
1056 /* Initialize stack pointers.
1057 Waste one element of value and location stack
1058 so that they stay on the same level as the state stack.
1059 The wasted elements are never initialized. */
1067 /* Push a new state, which is found in yystate . */
1068 /* In all cases, when you get here, the value and location stacks
1069 have just been pushed. so pushing a state here evens the stacks. */
1074 if (yyssp >= yyss + yystacksize - 1)
1076 /* Give user a chance to reallocate the stack */
1077 /* Use copies of these so that the &'s don't force the real ones into memory. */
1078 YYSTYPE *yyvs1 = yyvs;
1079 short *yyss1 = yyss;
1081 YYLTYPE *yyls1 = yyls;
1084 /* Get the current used size of the three stacks, in elements. */
1085 int size = yyssp - yyss + 1;
1088 /* Each stack pointer address is followed by the size of
1089 the data in use in that stack, in bytes. */
1091 /* This used to be a conditional around just the two extra args,
1092 but that might be undefined if yyoverflow is a macro. */
1093 yyoverflow("parser stack overflow",
1094 &yyss1, size * sizeof (*yyssp),
1095 &yyvs1, size * sizeof (*yyvsp),
1096 &yyls1, size * sizeof (*yylsp),
1099 yyoverflow("parser stack overflow",
1100 &yyss1, size * sizeof (*yyssp),
1101 &yyvs1, size * sizeof (*yyvsp),
1105 yyss = yyss1; yyvs = yyvs1;
1109 #else /* no yyoverflow */
1110 /* Extend the stack our own way. */
1111 if (yystacksize >= YYMAXDEPTH)
1113 yyerror("parser stack overflow");
1117 if (yystacksize > YYMAXDEPTH)
1118 yystacksize = YYMAXDEPTH;
1119 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
1120 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
1121 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
1122 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
1124 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
1125 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
1127 #endif /* no yyoverflow */
1129 yyssp = yyss + size - 1;
1130 yyvsp = yyvs + size - 1;
1132 yylsp = yyls + size - 1;
1137 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1140 if (yyssp >= yyss + yystacksize - 1)
1146 fprintf(stderr, "Entering state %d\n", yystate);
1152 /* Do appropriate processing given the current state. */
1153 /* Read a lookahead token if we need one and don't already have one. */
1156 /* First try to decide what to do without reference to lookahead token. */
1158 yyn = yypact[yystate];
1162 /* Not known => get a lookahead token if don't already have one. */
1164 /* yychar is either YYEMPTY or YYEOF
1165 or a valid token in external form. */
1167 if (yychar == YYEMPTY)
1171 fprintf(stderr, "Reading a token: ");
1176 /* Convert token to internal form (in yychar1) for indexing tables with */
1178 if (yychar <= 0) /* This means end of input. */
1181 yychar = YYEOF; /* Don't call YYLEX any more */
1185 fprintf(stderr, "Now at end of input.\n");
1190 yychar1 = YYTRANSLATE(yychar);
1195 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1196 /* Give the individual parser a way to print the precise meaning
1197 of a token, for further debugging info. */
1199 YYPRINT (stderr, yychar, yylval);
1201 fprintf (stderr, ")\n");
1207 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1212 /* yyn is what to do for this token type in this state.
1213 Negative => reduce, -yyn is rule number.
1214 Positive => shift, yyn is new state.
1215 New state is final state => don't bother to shift,
1216 just return success.
1217 0, or most negative number => error. */
1232 /* Shift the lookahead token. */
1236 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1239 /* Discard the token being shifted unless it is eof. */
1240 if (yychar != YYEOF)
1248 /* count tokens shifted since error; after three, turn off error status. */
1249 if (yyerrstatus) yyerrstatus--;
1254 /* Do the default action for the current state. */
1257 yyn = yydefact[yystate];
1261 /* Do a reduction. yyn is the number of a rule to reduce with. */
1265 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1272 fprintf (stderr, "Reducing via rule %d (line %d), ",
1275 /* Print the symbols being reduced, and their result. */
1276 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1277 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1278 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1288 expression_value = yyvsp[-1].nodeval;
1295 if (yyvsp[0].nodeval != NULL)
1296 yyval.nodeval = yyvsp[0].nodeval;
1298 yyval.nodeval = NULL;
1305 if (yyvsp[0].nodeval == NULL)
1306 yyval.nodeval = yyvsp[-1].nodeval;
1307 else if (yyvsp[-1].nodeval == NULL)
1308 yyval.nodeval = yyvsp[0].nodeval;
1310 if (yyvsp[-1].nodeval->type != Node_rule_list)
1311 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
1313 yyval.nodeval = append_right(yyvsp[-1].nodeval,
1314 node(yyvsp[0].nodeval, Node_rule_list, (NODE *) NULL));
1321 { yyval.nodeval = NULL; ;
1325 { yyval.nodeval = NULL; ;
1329 { yyval.nodeval = NULL; ;
1333 { io_allowed = FALSE; ;
1338 if (begin_block != NULL) {
1339 if (begin_block->type != Node_rule_list)
1340 begin_block = node(begin_block, Node_rule_list,
1342 (void) append_right(begin_block, node(
1343 node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval),
1344 Node_rule_list, (NODE *) NULL) );
1346 begin_block = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval);
1347 yyval.nodeval = NULL;
1354 { io_allowed = FALSE; ;
1359 if (end_block != NULL) {
1360 if (end_block->type != Node_rule_list)
1361 end_block = node(end_block, Node_rule_list,
1363 (void) append_right (end_block, node(
1364 node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval),
1365 Node_rule_list, (NODE *) NULL));
1367 end_block = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval);
1368 yyval.nodeval = NULL;
1376 warning("BEGIN blocks must have an action part");
1384 warning("END blocks must have an action part");
1391 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
1395 { yyval.nodeval = node((NODE *) NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
1400 yyval.nodeval = node(yyvsp[-1].nodeval,
1402 node(node(node(make_number(0.0),
1405 Node_expression_list,
1415 func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
1416 yyval.nodeval = NULL;
1422 { yyval.sval = yyvsp[0].sval; ;
1426 { yyval.sval = yyvsp[0].sval; ;
1431 yyerror("%s() is a built-in function, it cannot be redefined",
1448 t = make_param(yyvsp[-4].sval);
1450 yyval.nodeval = append_right(t, yyvsp[-2].nodeval);
1452 /* check for duplicate parameter names */
1453 if (dup_parms(yyval.nodeval))
1460 yyval.nodeval = yyvsp[-2].nodeval;
1467 yyval.nodeval = node((NODE *) NULL, Node_K_return, (NODE *) NULL);
1473 { yyval.nodeval = yyvsp[0].nodeval; ;
1477 { yyval.nodeval = mkrangenode(node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval)); ;
1490 n->type = Node_regex;
1491 len = strlen(yyvsp[-1].sval);
1492 n->re_exp = make_string(yyvsp[-1].sval, len);
1493 n->re_reg = make_regexp(yyvsp[-1].sval, len, FALSE, TRUE);
1495 n->re_flags = CONST;
1502 { yyval.nodeval = yyvsp[-3].nodeval; ;
1506 { yyval.nodeval = NULL; ;
1511 yyval.nodeval = yyvsp[0].nodeval;
1512 if (do_lint && isnoeffect(yyval.nodeval->type))
1513 warning("statement may have no effect");
1519 if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
1520 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list, (NODE *) NULL);
1521 yyval.nodeval = append_right(yyvsp[-1].nodeval,
1522 node(yyvsp[0].nodeval, Node_statement_list, (NODE *) NULL));
1528 { yyval.nodeval = NULL; ;
1532 { yyval.nodeval = NULL; ;
1536 { yyval.nodeval = NULL; ;
1540 { yyval.nodeval = NULL; ;
1544 { yyval.nodeval = yyvsp[-1].nodeval; ;
1548 { yyval.nodeval = yyvsp[0].nodeval; ;
1552 { yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
1556 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
1562 * Efficiency hack. Recognize the special case of
1567 * and treat it as if it were
1571 * Check that the body is a `delete a[i]' statement,
1572 * and that both the loop var and array names match.
1574 if (yyvsp[0].nodeval->type == Node_K_delete
1575 && yyvsp[0].nodeval->rnode != NULL
1576 && strcmp(yyvsp[-5].sval, yyvsp[0].nodeval->rnode->var_value->vname) == 0
1577 && strcmp(yyvsp[-3].sval, yyvsp[0].nodeval->lnode->vname) == 0) {
1578 yyvsp[0].nodeval->type = Node_K_delete_loop;
1579 yyval.nodeval = yyvsp[0].nodeval;
1581 yyval.nodeval = node(yyvsp[0].nodeval, Node_K_arrayfor,
1582 make_for_loop(variable(yyvsp[-5].sval, CAN_FREE, Node_var),
1583 (NODE *) NULL, variable(yyvsp[-3].sval, CAN_FREE, Node_var_array)));
1590 yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *) make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
1596 yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for,
1597 (NODE *) make_for_loop(yyvsp[-6].nodeval, (NODE *) NULL, yyvsp[-3].nodeval));
1602 { yyval.nodeval = node((NODE *) NULL, Node_K_break, (NODE *) NULL); ;
1606 { yyval.nodeval = node((NODE *) NULL, Node_K_continue, (NODE *) NULL); ;
1610 { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
1615 if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL) {
1616 static int warned = FALSE;
1618 yyvsp[-2].nodeval = node(node(make_number(0.0),
1621 Node_expression_list,
1624 if (do_lint && ! io_allowed && ! warned) {
1627 "plain `print' in BEGIN or END rule should probably be `print \"\"'");
1631 yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
1638 if (yyvsp[-1].nodeval) {
1639 if (yyvsp[-1].nodeval == lookup("file")) {
1640 static int warned = FALSE;
1644 warning("`next file' is obsolete; use `nextfile'");
1647 warning("`next file' is a gawk extension");
1648 if (do_traditional) {
1650 * can't use yyerror, since may have overshot
1654 error("`next file' is a gawk extension");
1659 error("`next file' used in BEGIN or END action");
1661 type = Node_K_nextfile;
1664 error("illegal expression after `next'");
1665 type = Node_K_next; /* sanity */
1669 yyerror("`next' used in BEGIN or END action");
1672 yyval.nodeval = node((NODE *) NULL, type, (NODE *) NULL);
1679 warning("`nextfile' is a gawk extension");
1680 if (do_traditional) {
1682 * can't use yyerror, since may have overshot
1686 error("`nextfile' is a gawk extension");
1691 error("`nextfile' used in BEGIN or END action");
1693 yyval.nodeval = node((NODE *) NULL, Node_K_nextfile, (NODE *) NULL);
1698 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_exit, (NODE *) NULL); ;
1704 yyerror("`return' used outside function context");
1709 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_return, (NODE *) NULL); ;
1713 { yyval.nodeval = node(variable(yyvsp[-4].sval, CAN_FREE, Node_var_array), Node_K_delete, yyvsp[-2].nodeval); ;
1719 warning("`delete array' is a gawk extension");
1720 if (do_traditional) {
1722 * can't use yyerror, since may have overshot
1726 error("`delete array' is a gawk extension");
1728 yyval.nodeval = node(variable(yyvsp[-1].sval, CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
1733 { yyval.nodeval = yyvsp[-1].nodeval; ;
1737 { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
1741 { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
1746 yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if,
1747 node(yyvsp[0].nodeval, Node_if_branches, (NODE *) NULL));
1752 { yyval.nodeval = node(yyvsp[-6].nodeval, Node_K_if,
1753 node(yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
1757 { want_assign = FALSE; ;
1761 { yyval.nodeval = NULL; ;
1765 { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_input, (NODE *) NULL); ;
1769 { yyval.nodeval = NULL; ;
1773 { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_output, (NODE *) NULL); ;
1777 { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_append, (NODE *) NULL); ;
1781 { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_pipe, (NODE *) NULL); ;
1785 { yyval.nodeval = NULL; ;
1789 { yyval.nodeval = yyvsp[0].nodeval; ;
1793 { yyval.nodeval = make_param(yyvsp[0].sval); ;
1797 { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
1801 { yyval.nodeval = NULL; ;
1805 { yyval.nodeval = NULL; ;
1809 { yyval.nodeval = NULL; ;
1813 { yyval.nodeval = NULL; ;
1817 { yyval.nodeval = yyvsp[0].nodeval; ;
1821 { yyval.nodeval = NULL; ;
1825 { yyval.nodeval = yyvsp[0].nodeval; ;
1829 { yyval.nodeval = node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL); ;
1834 yyval.nodeval = append_right(yyvsp[-2].nodeval,
1835 node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL));
1841 { yyval.nodeval = NULL; ;
1845 { yyval.nodeval = NULL; ;
1849 { yyval.nodeval = NULL; ;
1853 { yyval.nodeval = NULL; ;
1857 { yyval.nodeval = NULL; ;
1861 { yyval.nodeval = yyvsp[0].nodeval; ;
1865 { yyval.nodeval = node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL); ;
1870 yyval.nodeval = append_right(yyvsp[-2].nodeval,
1871 node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL));
1877 { yyval.nodeval = NULL; ;
1881 { yyval.nodeval = NULL; ;
1885 { yyval.nodeval = NULL; ;
1889 { yyval.nodeval = NULL; ;
1893 { want_assign = FALSE; ;
1898 if (do_lint && yyvsp[0].nodeval->type == Node_regex)
1899 warning("Regular expression on left of assignment.");
1900 yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
1905 { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-3].nodeval); ;
1910 yyval.nodeval = node(yyvsp[0].nodeval, Node_K_getline,
1911 node(yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *) NULL));
1917 if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
1918 warning("non-redirected getline undefined inside BEGIN or END action");
1919 yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
1924 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
1928 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
1933 if (yyvsp[-2].nodeval->type == Node_regex)
1934 warning("Regular expression on left of MATCH operator.");
1935 yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
1941 yyval.nodeval = yyvsp[0].nodeval;
1942 if (do_lint && tokstart[0] == '*') {
1943 /* possible C comment */
1944 int n = strlen(tokstart) - 1;
1945 if (tokstart[n] == '*')
1946 warning("regexp looks like a C comment, but is not");
1953 yyval.nodeval = node(node(make_number(0.0),
1962 { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-2].nodeval); ;
1967 if (do_lint && yyvsp[0].nodeval->type == Node_regex)
1968 warning("Regular expression on left of comparison.");
1969 yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
1974 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
1978 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
1982 { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
1986 { yyval.nodeval = yyvsp[0].nodeval; ;
1990 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
1994 { want_assign = FALSE; ;
1998 { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
2002 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
2006 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
2011 if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
2012 warning("non-redirected getline undefined inside BEGIN or END action");
2013 yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
2018 { yyval.nodeval = yyvsp[0].nodeval; ;
2022 { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
2026 { yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
2030 { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-2].nodeval); ;
2034 { yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
2038 { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
2042 { yyval.nodeval = yyvsp[0].nodeval; ;
2046 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
2050 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
2054 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
2058 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
2062 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
2066 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
2070 { yyval.nodeval = node(yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
2074 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postincrement, (NODE *) NULL); ;
2078 { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postdecrement, (NODE *) NULL); ;
2082 { yyval.nodeval = node(yyvsp[0].nodeval, Node_not, (NODE *) NULL); ;
2086 { yyval.nodeval = yyvsp[-1].nodeval; ;
2090 { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
2094 { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
2100 warning("call of `length' without parentheses is not portable");
2101 yyval.nodeval = snode((NODE *) NULL, Node_builtin, (int) yyvsp[0].lval);
2103 warning("call of `length' without parentheses is deprecated by POSIX");
2109 yyval.nodeval = node(yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
2110 func_use(yyvsp[-3].sval, FUNC_USE);
2111 param_sanity(yyvsp[-1].nodeval);
2112 free(yyvsp[-3].sval);
2117 { yyval.nodeval = node(yyvsp[0].nodeval, Node_preincrement, (NODE *) NULL); ;
2121 { yyval.nodeval = node(yyvsp[0].nodeval, Node_predecrement, (NODE *) NULL); ;
2125 { yyval.nodeval = yyvsp[0].nodeval; ;
2129 { yyval.nodeval = yyvsp[0].nodeval; ;
2134 if (yyvsp[0].nodeval->type == Node_val) {
2135 yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
2136 yyval.nodeval = yyvsp[0].nodeval;
2138 yyval.nodeval = node(yyvsp[0].nodeval, Node_unary_minus, (NODE *) NULL);
2146 * POSIX semantics: force a conversion to numeric type
2148 yyval.nodeval = node (make_number(0.0), Node_plus, yyvsp[0].nodeval);
2153 { yyval.nodeval = NULL; ;
2157 { yyval.nodeval = yyvsp[0].nodeval; ;
2161 { yyval.nodeval = variable(yyvsp[0].sval, CAN_FREE, Node_var); ;
2166 if (yyvsp[-1].nodeval == NULL) {
2167 fatal("invalid subscript expression");
2168 } else if (yyvsp[-1].nodeval->rnode == NULL) {
2169 yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval->lnode);
2170 freenode(yyvsp[-1].nodeval);
2172 yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval);
2177 { yyval.nodeval = node(yyvsp[0].nodeval, Node_field_spec, (NODE *) NULL); ;
2189 { yyerrok; want_assign = FALSE; ;
2196 /* the action file gets copied in in place of this dollarsign */
2197 #line 498 "/usr/share/bison.simple"
2208 short *ssp1 = yyss - 1;
2209 fprintf (stderr, "state stack now");
2210 while (ssp1 != yyssp)
2211 fprintf (stderr, " %d", *++ssp1);
2212 fprintf (stderr, "\n");
2222 yylsp->first_line = yylloc.first_line;
2223 yylsp->first_column = yylloc.first_column;
2224 yylsp->last_line = (yylsp-1)->last_line;
2225 yylsp->last_column = (yylsp-1)->last_column;
2230 yylsp->last_line = (yylsp+yylen-1)->last_line;
2231 yylsp->last_column = (yylsp+yylen-1)->last_column;
2235 /* Now "shift" the result of the reduction.
2236 Determine what state that goes to,
2237 based on the state we popped back to
2238 and the rule number reduced by. */
2242 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2243 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2244 yystate = yytable[yystate];
2246 yystate = yydefgoto[yyn - YYNTBASE];
2250 yyerrlab: /* here on detecting error */
2253 /* If not already recovering from an error, report this error. */
2257 #ifdef YYERROR_VERBOSE
2258 yyn = yypact[yystate];
2260 if (yyn > YYFLAG && yyn < YYLAST)
2267 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
2268 for (x = (yyn < 0 ? -yyn : 0);
2269 x < (sizeof(yytname) / sizeof(char *)); x++)
2270 if (yycheck[x + yyn] == x)
2271 size += strlen(yytname[x]) + 15, count++;
2272 msg = (char *) malloc(size + 15);
2275 strcpy(msg, "parse error");
2280 for (x = (yyn < 0 ? -yyn : 0);
2281 x < (sizeof(yytname) / sizeof(char *)); x++)
2282 if (yycheck[x + yyn] == x)
2284 strcat(msg, count == 0 ? ", expecting `" : " or `");
2285 strcat(msg, yytname[x]);
2294 yyerror ("parse error; also virtual memory exceeded");
2297 #endif /* YYERROR_VERBOSE */
2298 yyerror("parse error");
2302 yyerrlab1: /* here on error raised explicitly by an action */
2304 if (yyerrstatus == 3)
2306 /* if just tried and failed to reuse lookahead token after an error, discard it. */
2308 /* return failure if at end of input */
2309 if (yychar == YYEOF)
2314 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2320 /* Else will try to reuse lookahead token
2321 after shifting the error token. */
2323 yyerrstatus = 3; /* Each real token shifted decrements this */
2327 yyerrdefault: /* current state does not do anything special for the error token. */
2330 /* This is wrong; only states that explicitly want error tokens
2331 should shift them. */
2332 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
2333 if (yyn) goto yydefault;
2336 yyerrpop: /* pop the current state because it cannot handle the error token */
2338 if (yyssp == yyss) YYABORT;
2348 short *ssp1 = yyss - 1;
2349 fprintf (stderr, "Error: state stack now");
2350 while (ssp1 != yyssp)
2351 fprintf (stderr, " %d", *++ssp1);
2352 fprintf (stderr, "\n");
2358 yyn = yypact[yystate];
2363 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2382 fprintf(stderr, "Shifting error token, ");
2397 const char *operator; /* text to match */
2398 NODETYPE value; /* node type */
2399 int class; /* lexical class */
2400 unsigned flags; /* # of args. allowed and compatability */
2401 # define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
2402 # define A(n) (1<<(n))
2403 # define VERSION 0xFF00 /* old awk is zero */
2404 # define NOT_OLD 0x0100 /* feature not in old awk */
2405 # define NOT_POSIX 0x0200 /* feature not in POSIX */
2406 # define GAWKX 0x0400 /* gawk extension */
2407 # define RESX 0x0800 /* Bell Labs Research extension */
2408 NODE *(*ptr)(); /* function that implements this keyword */
2412 /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
2413 /* Function pointers come from declarations in awk.h. */
2415 static struct token tokentab[] = {
2416 {"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
2417 {"END", Node_illegal, LEX_END, 0, 0},
2419 {"adump", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_adump},
2422 {"and", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_and},
2424 {"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
2425 {"break", Node_K_break, LEX_BREAK, 0, 0},
2426 {"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
2428 {"compl", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_compl},
2430 {"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
2431 {"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
2432 {"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
2433 {"do", Node_K_do, LEX_DO, NOT_OLD, 0},
2434 {"else", Node_illegal, LEX_ELSE, 0, 0},
2435 {"exit", Node_K_exit, LEX_EXIT, 0, 0},
2436 {"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp},
2437 {"fflush", Node_builtin, LEX_BUILTIN, RESX|A(0)|A(1), do_fflush},
2438 {"for", Node_K_for, LEX_FOR, 0, 0},
2439 {"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0},
2440 {"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0},
2441 {"gensub", Node_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), do_gensub},
2442 {"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0},
2443 {"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub},
2444 {"if", Node_K_if, LEX_IF, 0, 0},
2445 {"in", Node_illegal, LEX_IN, 0, 0},
2446 {"index", Node_builtin, LEX_BUILTIN, A(2), do_index},
2447 {"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
2448 {"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
2449 {"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
2451 {"lshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift},
2453 {"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
2454 {"next", Node_K_next, LEX_NEXT, 0, 0},
2455 {"nextfile", Node_K_nextfile, LEX_NEXTFILE, GAWKX, 0},
2457 {"or", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_or},
2459 {"print", Node_K_print, LEX_PRINT, 0, 0},
2460 {"printf", Node_K_printf, LEX_PRINTF, 0, 0},
2461 {"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
2462 {"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
2464 {"rshift", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_rshift},
2466 {"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
2467 {"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
2468 {"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
2469 {"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
2470 {"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
2472 {"stopme", Node_builtin, LEX_BUILTIN, GAWKX|A(0), stopme},
2474 {"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2), do_strftime},
2476 {"strtonum", Node_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum},
2478 {"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
2479 {"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
2480 {"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
2481 {"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime},
2482 {"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
2483 {"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
2484 {"while", Node_K_while, LEX_WHILE, 0, 0},
2486 {"xor", Node_builtin, LEX_BUILTIN, GAWKX|A(2), do_xor},
2490 /* yyerror --- print a syntax error message, show where */
2492 #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
2494 yyerror(const char *m, ...)
2503 const char *mesg = NULL;
2504 register char *bp, *cp;
2507 static char end_of_file_line[] = "(END OF FILE)";
2510 /* Find the current line in the input file */
2511 if (lexptr && lexeme) {
2512 if (thisline == NULL) {
2516 mesg = "unexpected newline";
2518 for (; cp != lexptr_begin && *cp != '\n'; --cp)
2524 /* NL isn't guaranteed */
2526 while (bp < lexend && *bp && *bp != '\n')
2529 thisline = end_of_file_line;
2530 bp = thisline + strlen(thisline);
2532 msg("%.*s", (int) (bp - thisline), thisline);
2534 cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
2535 if (lexptr != NULL) {
2537 while (bp < cp && scan < lexeme)
2538 if (*scan++ == '\t')
2545 #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
2552 mesg = va_arg(args, char *);
2559 /* get_src_buf --- read the next buffer of source program */
2564 static int samefile = FALSE;
2565 static int nextfile = 0;
2566 static char *buf = NULL;
2569 register char *scan;
2571 static int did_newline = FALSE;
2575 # define SLOP 128 /* enough space to hold most source lines */
2579 if (nextfile > numfiles)
2582 if (srcfiles[nextfile].stype == CMDLINE) {
2584 len = strlen(srcfiles[nextfile].val);
2587 * Yet Another Special case:
2588 * gawk '' /path/name
2591 static int warned = FALSE;
2593 if (do_lint && ! warned) {
2595 warning("empty program text on command line");
2601 lexptr = lexptr_begin = srcfiles[nextfile].val;
2602 lexend = lexptr + len;
2603 } else if (! did_newline && *(lexptr-1) != '\n') {
2605 * The following goop is to ensure that the source
2606 * ends with a newline and that the entire current
2607 * line is available for error messages.
2612 offset = lexptr - lexeme;
2613 for (scan = lexeme; scan > lexptr_begin; scan--)
2614 if (*scan == '\n') {
2618 len = lexptr - scan;
2619 emalloc(buf, char *, len+1, "get_src_buf");
2620 memcpy(buf, scan, len);
2624 lexeme = lexptr - offset;
2626 lexend = lexptr + 1;
2629 lexeme = lexptr = lexptr_begin = NULL;
2631 if (lexptr == NULL && ++nextfile <= numfiles)
2636 source = srcfiles[nextfile].val;
2637 if (source == NULL) {
2643 return lexeme = lexptr = lexptr_begin = NULL;
2645 fd = pathopen(source);
2646 if (fd <= INVALID_HANDLE) {
2649 /* suppress file name and line no. in error mesg */
2652 fatal("can't open source file \"%s\" for reading (%s)",
2653 in, strerror(errno));
2655 len = optimal_bufsize(fd, & sbuf);
2659 emalloc(buf, char *, len + SLOP, "get_src_buf");
2660 lexptr_begin = buf + SLOP;
2665 * Here, we retain the current source line (up to length SLOP)
2666 * in the beginning of the buffer that was overallocated above
2671 offset = lexptr - lexeme;
2672 for (scan = lexeme; scan > lexptr_begin; scan--)
2673 if (*scan == '\n') {
2677 linelen = lexptr - scan;
2680 thisline = buf + SLOP - linelen;
2681 memcpy(thisline, scan, linelen);
2682 lexeme = buf + SLOP - offset;
2683 lexptr_begin = thisline;
2685 n = read(fd, buf + SLOP, len);
2687 fatal("can't read sourcefile \"%s\" (%s)",
2688 source, strerror(errno));
2691 static int warned = FALSE;
2693 if (do_lint && ! warned) {
2695 warning("source file `%s' is empty", source);
2698 if (fileno(stdin) != fd) /* safety */
2707 lexptr = buf + SLOP;
2708 lexend = lexptr + n;
2712 /* tokadd --- add a character to the token buffer */
2714 #define tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok)
2716 /* tokexpand --- grow the token buffer */
2721 static int toksize = 60;
2724 tokoffset = tok - tokstart;
2726 if (tokstart != NULL)
2727 erealloc(tokstart, char *, toksize, "tokexpand");
2729 emalloc(tokstart, char *, toksize, "tokexpand");
2730 tokend = tokstart + toksize;
2731 tok = tokstart + tokoffset;
2735 /* nextc --- get the next input character */
2743 if (lexptr && lexptr < lexend)
2744 c = (int) (unsigned char) *lexptr++;
2745 else if (get_src_buf())
2746 c = (int) (unsigned char) *lexptr++;
2753 #define nextc() ((lexptr && lexptr < lexend) ? \
2754 ((int) (unsigned char) *lexptr++) : \
2755 (get_src_buf() ? ((int) (unsigned char) *lexptr++) : EOF) \
2759 /* pushback --- push a character back on the input */
2761 #define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
2763 /* allow_newline --- allow newline after &&, ||, ? and : */
2775 while ((c = nextc()) != '\n' && c != EOF)
2789 /* yylex --- Read the input and turn it into tokens. */
2795 int seen_e = FALSE; /* These are for numbers */
2796 int seen_point = FALSE;
2797 int esc_seen; /* for literal strings */
2799 static int did_newline = FALSE;
2801 static int lasttok = 0, eof_warned = FALSE;
2804 if (nextc() == EOF) {
2805 if (lasttok != NEWLINE) {
2807 if (do_lint && ! eof_warned) {
2808 warning("source file does not end in newline");
2811 return NEWLINE; /* fake it */
2818 * added for OS/2's extproc feature of cmd.exe
2819 * (like #! in BSD sh)
2821 if (strncasecmp(lexptr, "extproc ", 8) == 0) {
2822 while (*lexptr && *lexptr != '\n')
2829 int in_brack = 0; /* count brackets, [[:alnum:]] allowed */
2831 * Counting brackets is non-trivial. [[] is ok,
2832 * and so is [\]], with a point being that /[/]/ as a regexp
2833 * constant has to work.
2835 * Do not count [ or ] if either one is preceded by a \.
2836 * A `[' should be counted if
2837 * a) it is the first one so far (in_brack == 0)
2838 * b) it is the `[' in `[:'
2839 * A ']' should be counted if not preceded by a \, since
2840 * it is either closing `:]' or just a plain list.
2841 * According to POSIX, []] is how you put a ] into a set.
2842 * Try to handle that too.
2844 * The code for \ handles \[ and \].
2847 want_regexp = FALSE;
2853 /* one day check for `.' and `=' too */
2854 if ((c1 = nextc()) == ':' || in_brack == 0)
2859 if (tokstart[0] == '['
2860 && (tok == tokstart + 1
2861 || (tok == tokstart + 2
2862 && tokstart[1] == '^')))
2868 if ((c = nextc()) == EOF) {
2869 yyerror("unterminated regexp ends with \\ at end of file");
2870 return lasttok = REGEXP; /* kludge */
2871 } else if (c == '\n') {
2880 case '/': /* end of the regexp */
2886 yylval.sval = tokstart;
2887 return lasttok = REGEXP;
2890 yyerror("unterminated regexp");
2891 return lasttok = REGEXP; /* kludge */
2893 yyerror("unterminated regexp at end of file");
2894 return lasttok = REGEXP; /* kludge */
2900 while ((c = nextc()) == ' ' || c == '\t')
2903 lexeme = lexptr ? lexptr - 1 : lexptr;
2906 yylval.nodetypeval = Node_illegal;
2910 if (lasttok != NEWLINE) {
2912 if (do_lint && ! eof_warned) {
2913 warning("source file does not end in newline");
2916 return NEWLINE; /* fake it */
2922 return lasttok = NEWLINE;
2924 case '#': /* it's a comment */
2925 while ((c = nextc()) != '\n') {
2927 if (lasttok != NEWLINE) {
2929 if (do_lint && ! eof_warned) {
2931 "source file does not end in newline");
2934 return NEWLINE; /* fake it */
2940 return lasttok = NEWLINE;
2943 #ifdef RELAXED_CONTINUATION
2945 * This code puports to allow comments and/or whitespace
2946 * after the `\' at the end of a line used for continuation.
2947 * Use it at your own risk. We think it's a bad idea, which
2948 * is why it's not on by default.
2950 if (! do_traditional) {
2951 /* strip trailing white-space and/or comment */
2952 while ((c = nextc()) == ' ' || c == '\t')
2957 "use of `\\ #...' line continuation is not portable");
2958 while ((c = nextc()) != '\n')
2964 #endif /* RELAXED_CONTINUATION */
2965 if (nextc() == '\n') {
2969 yyerror("backslash not last character on line");
2976 return lasttok = '$';
2988 want_assign = FALSE;
2995 if ((c = nextc()) == '=') {
2996 yylval.nodetypeval = Node_assign_times;
2997 return lasttok = ASSIGNOP;
2998 } else if (do_posix) {
3000 return lasttok = '*';
3001 } else if (c == '*') {
3002 /* make ** and **= aliases for ^ and ^= */
3003 static int did_warn_op = FALSE, did_warn_assgn = FALSE;
3005 if (nextc() == '=') {
3006 if (do_lint && ! did_warn_assgn) {
3007 did_warn_assgn = TRUE;
3008 warning("**= is not allowed by POSIX");
3009 warning("operator `**=' is not supported in old awk");
3011 yylval.nodetypeval = Node_assign_exp;
3015 if (do_lint && ! did_warn_op) {
3017 warning("** is not allowed by POSIX");
3018 warning("operator `**' is not supported in old awk");
3020 return lasttok = '^';
3024 return lasttok = '*';
3028 if (nextc() == '=') {
3029 yylval.nodetypeval = Node_assign_quotient;
3030 return lasttok = ASSIGNOP;
3034 return lasttok = '/';
3037 if (nextc() == '=') {
3038 yylval.nodetypeval = Node_assign_mod;
3039 return lasttok = ASSIGNOP;
3042 return lasttok = '%';
3046 static int did_warn_op = FALSE, did_warn_assgn = FALSE;
3048 if (nextc() == '=') {
3049 if (do_lint && ! did_warn_assgn) {
3050 did_warn_assgn = TRUE;
3051 warning("operator `^=' is not supported in old awk");
3053 yylval.nodetypeval = Node_assign_exp;
3054 return lasttok = ASSIGNOP;
3057 if (do_lint && ! did_warn_op) {
3059 warning("operator `^' is not supported in old awk");
3061 return lasttok = '^';
3065 if ((c = nextc()) == '=') {
3066 yylval.nodetypeval = Node_assign_plus;
3067 return lasttok = ASSIGNOP;
3070 return lasttok = INCREMENT;
3072 return lasttok = '+';
3075 if ((c = nextc()) == '=') {
3076 yylval.nodetypeval = Node_notequal;
3077 return lasttok = RELOP;
3080 yylval.nodetypeval = Node_nomatch;
3081 want_assign = FALSE;
3082 return lasttok = MATCHOP;
3085 return lasttok = '!';
3088 if (nextc() == '=') {
3089 yylval.nodetypeval = Node_leq;
3090 return lasttok = RELOP;
3092 yylval.nodetypeval = Node_less;
3094 return lasttok = '<';
3097 if (nextc() == '=') {
3098 yylval.nodetypeval = Node_equal;
3099 return lasttok = RELOP;
3101 yylval.nodetypeval = Node_assign;
3103 return lasttok = ASSIGNOP;
3106 if ((c = nextc()) == '=') {
3107 yylval.nodetypeval = Node_geq;
3108 return lasttok = RELOP;
3109 } else if (c == '>') {
3110 yylval.nodetypeval = Node_redirect_append;
3111 return lasttok = APPEND_OP;
3113 yylval.nodetypeval = Node_greater;
3115 return lasttok = '>';
3118 yylval.nodetypeval = Node_match;
3119 want_assign = FALSE;
3120 return lasttok = MATCHOP;
3124 * Added did newline stuff. Easier than
3125 * hacking the grammar.
3128 did_newline = FALSE;
3132 --lexptr; /* pick up } next time */
3133 return lasttok = NEWLINE;
3137 while ((c = nextc()) != '"') {
3140 yyerror("unterminated string");
3154 yyerror("unterminated string");
3159 yylval.nodeval = make_str_node(tokstart,
3160 tok - tokstart, esc_seen ? SCAN : 0);
3161 yylval.nodeval->flags |= PERM;
3162 return lasttok = YSTRING;
3165 if ((c = nextc()) == '=') {
3166 yylval.nodetypeval = Node_assign_minus;
3167 return lasttok = ASSIGNOP;
3170 return lasttok = DECREMENT;
3172 return lasttok = '-';
3178 return lasttok = '.';
3194 int gotnumber = FALSE;
3203 if (tok == tokstart + 2)
3223 if ((c = nextc()) == '-' || c == '+')
3239 if (do_traditional || ! inhex)
3264 else if (do_lint && ! eof_warned) {
3265 warning("source file does not end in newline");
3270 if (! do_traditional && isnondecimal(tokstart))
3271 yylval.nodeval = make_number(nondec2awknum(tokstart, strlen(tokstart)));
3274 yylval.nodeval = make_number(atof(tokstart));
3275 yylval.nodeval->flags |= PERM;
3276 return lasttok = YNUMBER;
3279 if ((c = nextc()) == '&') {
3280 yylval.nodetypeval = Node_and;
3282 want_assign = FALSE;
3283 return lasttok = LEX_AND;
3286 return lasttok = '&';
3289 if ((c = nextc()) == '|') {
3290 yylval.nodetypeval = Node_or;
3292 want_assign = FALSE;
3293 return lasttok = LEX_OR;
3296 return lasttok = '|';
3299 if (c != '_' && ! isalpha(c)) {
3300 yyerror("Invalid char '%c' in expression\n", c);
3304 /* it's some type of name-type-thing. Find its length. */
3306 while (is_identchar(c)) {
3311 emalloc(tokkey, char *, tok - tokstart, "yylex");
3312 memcpy(tokkey, tokstart, tok - tokstart);
3315 else if (do_lint && ! eof_warned) {
3316 warning("source file does not end in newline");
3320 /* See if it is a special token. */
3322 high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
3323 while (low <= high) {
3326 mid = (low + high) / 2;
3327 c = *tokstart - tokentab[mid].operator[0];
3328 i = c ? c : strcmp(tokstart, tokentab[mid].operator);
3330 if (i < 0) /* token < mid */
3332 else if (i > 0) /* token > mid */
3336 if (tokentab[mid].flags & GAWKX)
3337 warning("%s() is a gawk extension",
3338 tokentab[mid].operator);
3339 if (tokentab[mid].flags & RESX)
3340 warning("%s() is a Bell Labs extension",
3341 tokentab[mid].operator);
3342 if (tokentab[mid].flags & NOT_POSIX)
3343 warning("POSIX does not allow %s",
3344 tokentab[mid].operator);
3346 if (do_lint_old && (tokentab[mid].flags & NOT_OLD))
3347 warning("%s is not supported in old awk",
3348 tokentab[mid].operator);
3349 if ((do_traditional && (tokentab[mid].flags & GAWKX))
3350 || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
3352 if (tokentab[mid].class == LEX_BUILTIN
3353 || tokentab[mid].class == LEX_LENGTH
3357 yylval.nodetypeval = tokentab[mid].value;
3360 return lasttok = tokentab[mid].class;
3364 yylval.sval = tokkey;
3366 return lasttok = FUNC_CALL;
3369 return lasttok = NAME;
3373 /* node_common --- common code for allocating a new node */
3384 /* if lookahead is NL, lineno is 1 too high */
3385 if (lexeme && *lexeme == '\n')
3386 r->source_line = sourceline - 1;
3388 r->source_line = sourceline;
3389 r->source_file = source;
3393 /* node --- allocates a node with defined lnode and rnode. */
3396 node(left, op, right)
3402 r = node_common(op);
3408 /* snode --- allocate a node with defined subnode and proc for builtin
3409 functions. Checks for arg. count and supplies defaults where
3413 snode(subn, op, idx)
3423 r = node_common(op);
3425 /* traverse expression list to see how many args. given */
3426 for (n = subn; n != NULL; n = n->rnode) {
3432 /* check against how many args. are allowed for this builtin */
3433 args_allowed = tokentab[idx].flags & ARGS;
3434 if (args_allowed && (args_allowed & A(nexp)) == 0)
3435 fatal("%s() cannot have %d argument%c",
3436 tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
3438 r->proc = tokentab[idx].ptr;
3440 /* special case processing for a few builtins */
3442 * FIXME: go through these to make sure that everything done
3443 * here is really right. Move anything that's not into
3444 * the corresponding routine.
3446 if (nexp == 0 && r->proc == do_length) {
3447 subn = node(node(make_number(0.0), Node_field_spec, (NODE *) NULL),
3448 Node_expression_list,
3450 } else if (r->proc == do_match) {
3451 if (subn->rnode->lnode->type != Node_regex)
3452 subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
3453 } else if (r->proc == do_sub || r->proc == do_gsub) {
3454 if (subn->lnode->type != Node_regex)
3455 subn->lnode = mk_rexp(subn->lnode);
3457 append_right(subn, node(node(make_number(0.0),
3460 Node_expression_list,
3462 else if (subn->rnode->rnode->lnode->type == Node_val) {
3464 warning("string literal as last arg of substitute");
3465 } else if (! isassignable(subn->rnode->rnode->lnode))
3466 yyerror("%s third parameter is not a changeable object",
3467 r->proc == do_sub ? "sub" : "gsub");
3468 } else if (r->proc == do_gensub) {
3469 if (subn->lnode->type != Node_regex)
3470 subn->lnode = mk_rexp(subn->lnode);
3472 append_right(subn, node(node(make_number(0.0),
3475 Node_expression_list,
3477 } else if (r->proc == do_split) {
3480 node(FS_node, Node_expression_list, (NODE *) NULL));
3481 n = subn->rnode->rnode->lnode;
3482 if (n->type != Node_regex)
3483 subn->rnode->rnode->lnode = mk_rexp(n);
3485 subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
3494 * This allocates a Node_line_range node with defined condpair and
3495 * zeroes the trigger word to avoid the temptation of assuming that calling
3496 * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'.
3497 * Otherwise like node().
3507 r->type = Node_line_range;
3508 r->condpair = cpair;
3509 r->triggered = FALSE;
3513 /* make_for_loop --- build a for loop */
3516 make_for_loop(init, cond, incr)
3517 NODE *init, *cond, *incr;
3519 register FOR_LOOP_HEADER *r;
3522 emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
3524 n->type = Node_illegal;
3528 n->sub.nodep.r.hd = r;
3532 /* dup_parms --- return TRUE if there are duplicate parameters */
3539 char *fname, **names;
3540 int count, i, j, dups;
3543 if (func == NULL) /* error earlier */
3546 fname = func->param;
3547 count = func->param_cnt;
3548 params = func->rnode;
3550 if (count == 0) /* no args, no problem */
3553 if (params == NULL) /* error earlier */
3556 emalloc(names, char **, count * sizeof(char *), "dup_parms");
3559 for (np = params; np != NULL; np = np->rnode) {
3560 if (np->param == NULL) { /* error earlier, give up, go home */
3564 names[i++] = np->param;
3568 for (i = 1; i < count; i++) {
3569 for (j = 0; j < i; j++) {
3570 if (strcmp(names[i], names[j]) == 0) {
3573 "function `%s': parameter #%d, `%s', duplicates parameter #%d",
3574 fname, i+1, names[j], j+1);
3580 return (dups > 0 ? TRUE : FALSE);
3585 * Install a name in the symbol table, even if it is already there.
3586 * Caller must check against redefinition if that is desired.
3590 install(name, value)
3595 register size_t len;
3596 register int bucket;
3599 bucket = hash(name, len, (unsigned long) HASHSIZE);
3601 hp->type = Node_hashnode;
3602 hp->hnext = variables[bucket];
3603 variables[bucket] = hp;
3607 hp->hvalue->vname = name;
3611 /* lookup --- find the most recent hash node for name installed by install */
3617 register NODE *bucket;
3618 register size_t len;
3621 for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE)];
3622 bucket != NULL; bucket = bucket->hnext)
3623 if (bucket->hlength == len && STREQN(bucket->hname, name, len))
3624 return bucket->hvalue;
3631 * Add new to the rightmost branch of LIST. This uses n^2 time, so we make
3632 * a simple attempt at optimizing it.
3636 append_right(list, new)
3639 register NODE *oldlist;
3640 static NODE *savefront = NULL, *savetail = NULL;
3642 if (list == NULL || new == NULL)
3646 if (savefront == oldlist) {
3647 savetail = savetail->rnode = new;
3650 savefront = oldlist;
3651 while (list->rnode != NULL)
3653 savetail = list->rnode = new;
3659 * check if name is already installed; if so, it had better have Null value,
3660 * in which case def is added as the value. Otherwise, install name with def
3665 func_install(params, def)
3672 /* check for function foo(foo) { ... }. bleh. */
3673 for (n = params->rnode; n != NULL; n = n->rnode) {
3674 if (strcmp(n->param, params->param) == 0)
3675 fatal("function `%s': can't use function name as parameter name",
3679 pop_params(params->rnode);
3680 pop_var(params, FALSE);
3681 r = lookup(params->param);
3683 fatal("function name `%s' previously defined", params->param);
3685 (void) install(params->param, node(params, Node_func, def));
3687 func_use(params->param, FUNC_DEFINE);
3690 /* pop_var --- remove a variable from the symbol table */
3697 register NODE *bucket, **save;
3698 register size_t len;
3703 save = &(variables[hash(name, len, (unsigned long) HASHSIZE)]);
3704 for (bucket = *save; bucket != NULL; bucket = bucket->hnext) {
3705 if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
3706 *save = bucket->hnext;
3712 save = &(bucket->hnext);
3716 /* pop_params --- remove list of function parameters from symbol table */
3719 * pop parameters out of the symbol table. do this in reverse order to
3720 * avoid reading freed memory if there were duplicated parameters.
3728 pop_params(params->rnode);
3729 pop_var(params, TRUE);
3732 /* make_param --- make NAME into a function parameter */
3741 r->type = Node_param_list;
3744 r->param_cnt = param_counter++;
3745 return (install(name, r));
3748 static struct fdesc {
3753 } *ftable[HASHSIZE];
3755 /* func_use --- track uses and definitions of functions */
3767 ind = hash(name, len, HASHSIZE);
3769 for (fp = ftable[ind]; fp != NULL; fp = fp->next) {
3770 if (strcmp(fp->name, name) == 0) {
3771 if (how == FUNC_DEFINE)
3779 /* not in the table, fall through to allocate a new one */
3781 emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use");
3782 memset(fp, '\0', sizeof(struct fdesc));
3783 emalloc(fp->name, char *, len + 1, "func_use");
3784 strcpy(fp->name, name);
3785 if (how == FUNC_DEFINE)
3789 fp->next = ftable[ind];
3793 /* check_funcs --- verify functions that are called but not defined */
3798 struct fdesc *fp, *next;
3801 for (i = 0; i < HASHSIZE; i++) {
3802 for (fp = ftable[i]; fp != NULL; fp = fp->next) {
3804 /* making this the default breaks old code. sigh. */
3805 if (fp->defined == 0) {
3807 "function `%s' called but never defined", fp->name);
3811 if (do_lint && fp->defined == 0)
3813 "function `%s' called but never defined", fp->name);
3815 if (do_lint && fp->used == 0) {
3816 warning("function `%s' defined but never called",
3822 /* now let's free all the memory */
3823 for (i = 0; i < HASHSIZE; i++) {
3824 for (fp = ftable[i]; fp != NULL; fp = next) {
3832 /* param_sanity --- look for parameters that are regexp constants */
3835 param_sanity(arglist)
3841 for (i = 1, argp = arglist; argp != NULL; argp = argp->rnode, i++) {
3843 if (arg->type == Node_regex)
3844 warning("regexp constant for parameter #%d yields boolean value", i);
3848 /* variable --- make sure NAME is in the symbol table */
3851 variable(name, can_free, type)
3857 static int env_loaded = FALSE;
3859 if (! env_loaded && STREQ(name, "ENVIRON")) {
3863 if ((r = lookup(name)) == NULL)
3864 r = install(name, node(Nnull_string, type, (NODE *) NULL));
3870 /* mk_rexp --- make a regular expression constant */
3878 if (exp->type == Node_regex)
3882 n->type = Node_regex;
3891 /* isnoeffect --- when used as a statement, has no side effects */
3894 * To be completely general, we should recursively walk the parse
3895 * tree, to make sure that all the subexpressions also have no effect.
3896 * Instead, we just weaken the actual warning that's printed, up above
3910 case Node_subscript:
3913 case Node_unary_minus:
3914 case Node_field_spec:
3933 case Node_FIELDWIDTHS:
3934 case Node_IGNORECASE:
3941 break; /* keeps gcc -Wall happy */
3947 /* isassignable --- can this node be assigned to? */
3955 case Node_FIELDWIDTHS:
3961 case Node_IGNORECASE:
3966 case Node_field_spec:
3967 case Node_subscript:
3969 case Node_param_list:
3970 return ((n->flags & FUNC) == 0); /* ok if not func name */
3972 break; /* keeps gcc -Wall happy */
3982 return tmp_number((AWKNUM) 0.0);