1 2 # line 2 "awk.y" 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 12 * or http://www.opensolaris.org/os/licensing. 13 * See the License for the specific language governing permissions 14 * and limitations under the License. 15 * 16 * When distributing Covered Code, include this CDDL HEADER in each 17 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 18 * If applicable, add the following below this CDDL HEADER, with the 19 * fields enclosed by brackets "[]" replaced with your own identifying 20 * information: Portions Copyright [yyyy] [name of copyright owner] 21 * 22 * CDDL HEADER END 23 */ 24 /* 25 * awk -- YACC grammar 26 * 27 * Copyright (c) 1995 by Sun Microsystems, Inc. 28 * 29 * Copyright 1986, 1992 by Mortice Kern Systems Inc. All rights reserved. 30 * 31 * This Software is unpublished, valuable, confidential property of 32 * Mortice Kern Systems Inc. Use is authorized only in accordance 33 * with the terms and conditions of the source licence agreement 34 * protecting this Software. Any unauthorized use or disclosure of 35 * this Software is strictly prohibited and will result in the 36 * termination of the licence agreement. 37 * 38 * NOTE: this grammar correctly produces NO shift/reduce conflicts from YACC. 39 * 40 */ 41 42 /* 43 * Do not use any character constants as tokens, so the resulting C file 44 * is codeset independent. 45 */ 46 47 #ident "%Z%%M% %I% %E% SMI" 48 #include "awk.h" 49 static NODE * fliplist ANSI((NODE *np)); 50 51 # line 51 "awk.y" 52 typedef union 53 #ifdef __cplusplus 54 YYSTYPE 55 #endif 56 { 57 NODE *node; 58 } YYSTYPE; 59 # define PARM 257 60 # define ARRAY 258 61 # define UFUNC 259 62 # define FIELD 260 63 # define IN 261 64 # define INDEX 262 65 # define CONCAT 263 66 # define NOT 264 67 # define AND 265 68 # define OR 266 69 # define EXP 267 70 # define QUEST 268 71 # define EQ 269 72 # define NE 270 73 # define GE 271 74 # define LE 272 75 # define GT 273 76 # define LT 274 77 # define ADD 275 78 # define SUB 276 79 # define MUL 277 80 # define DIV 278 81 # define REM 279 82 # define INC 280 83 # define DEC 281 84 # define PRE_INC 282 85 # define PRE_DEC 283 86 # define GETLINE 284 87 # define CALLFUNC 285 88 # define RE 286 89 # define TILDE 287 90 # define NRE 288 91 # define ASG 289 92 # define PRINT 290 93 # define PRINTF 291 94 # define EXIT 292 95 # define RETURN 293 96 # define BREAK 294 97 # define CONTINUE 295 98 # define NEXT 296 99 # define DELETE 297 100 # define WHILE 298 101 # define DO 299 102 # define FOR 300 103 # define FORIN 301 104 # define IF 302 105 # define CONSTANT 303 106 # define VAR 304 107 # define FUNC 305 108 # define DEFFUNC 306 109 # define BEGIN 307 110 # define END 308 111 # define CLOSE 309 112 # define ELSE 310 113 # define PACT 311 114 # define DOT 312 115 # define CALLUFUNC 313 116 # define KEYWORD 314 117 # define SVAR 315 118 # define PIPESYM 316 119 # define BAR 317 120 # define CARAT 318 121 # define LANGLE 319 122 # define RANGLE 320 123 # define PLUSC 321 124 # define HYPHEN 322 125 # define STAR 323 126 # define SLASH 324 127 # define PERCENT 325 128 # define EXCLAMATION 326 129 # define DOLLAR 327 130 # define LSQUARE 328 131 # define RSQUARE 329 132 # define LPAREN 330 133 # define RPAREN 331 134 # define SEMI 332 135 # define LBRACE 333 136 # define RBRACE 334 137 # define COMMA 335 138 # define PIPE 336 139 # define WRITE 337 140 # define APPEND 338 141 # define AADD 339 142 # define ASUB 340 143 # define AMUL 341 144 # define ADIV 342 145 # define AREM 343 146 # define AEXP 344 147 # define COLON 345 148 # define UPLUS 346 149 # define UMINUS 347 150 # define URE 348 151 152 #include <inttypes.h> 153 154 #ifdef __STDC__ 155 #include <stdlib.h> 156 #include <string.h> 157 #define YYCONST const 158 #else 159 #include <malloc.h> 160 #include <memory.h> 161 #define YYCONST 162 #endif 163 164 #include <values.h> 165 166 #if defined(__cplusplus) || defined(__STDC__) 167 168 #if defined(__cplusplus) && defined(__EXTERN_C__) 169 extern "C" { 170 #endif 171 #ifndef yyerror 172 #if defined(__cplusplus) 173 void yyerror(YYCONST char *); 174 #endif 175 #endif 176 #ifndef yylex 177 int yylex(void); 178 #endif 179 int yyparse(void); 180 #if defined(__cplusplus) && defined(__EXTERN_C__) 181 } 182 #endif 183 184 #endif 185 186 #define yyclearin yychar = -1 187 #define yyerrok yyerrflag = 0 188 extern int yychar; 189 extern int yyerrflag; 190 YYSTYPE yylval; 191 YYSTYPE yyval; 192 typedef int yytabelem; 193 #ifndef YYMAXDEPTH 194 #define YYMAXDEPTH 150 195 #endif 196 #if YYMAXDEPTH > 0 197 int yy_yys[YYMAXDEPTH], *yys = yy_yys; 198 YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; 199 #else /* user does initial allocation */ 200 int *yys; 201 YYSTYPE *yyv; 202 #endif 203 static int yymaxdepth = YYMAXDEPTH; 204 # define YYERRCODE 256 205 206 # line 530 "awk.y" 207 208 /* 209 * Flip a left-recursively generated list 210 * so that it can easily be traversed from left 211 * to right without recursion. 212 */ 213 static NODE * 214 fliplist(np) 215 register NODE *np; 216 { 217 int type; 218 219 if (np!=NNULL && !isleaf(np->n_flags) 220 #if 0 221 && (type = np->n_type)!=FUNC && type!=UFUNC 222 #endif 223 ) { 224 np->n_right = fliplist(np->n_right); 225 if ((type=np->n_type)==COMMA) { 226 register NODE *lp; 227 228 while ((lp = np->n_left)!=NNULL && lp->n_type==COMMA) { 229 register NODE* *spp; 230 231 lp->n_right = fliplist(lp->n_right); 232 for (spp = &lp->n_right; 233 *spp != NNULL && (*spp)->n_type==COMMA; 234 spp = &(*spp)->n_right) 235 ; 236 np->n_left = *spp; 237 *spp = np; 238 np = lp; 239 } 240 } 241 if (np->n_left != NULL && 242 (type = np->n_left->n_type)!= FUNC && type!=UFUNC) 243 np->n_left = fliplist(np->n_left); 244 } 245 return (np); 246 } 247 static YYCONST yytabelem yyexca[] ={ 248 -1, 1, 249 0, -1, 250 -2, 0, 251 }; 252 # define YYNPROD 109 253 # define YYLAST 943 254 static YYCONST yytabelem yyact[]={ 255 256 68, 28, 69, 25, 57, 58, 56, 59, 60, 61, 257 64, 65, 159, 150, 172, 170, 171, 172, 170, 171, 258 181, 217, 150, 234, 23, 22, 66, 67, 17, 200, 259 229, 230, 30, 150, 43, 44, 42, 41, 38, 37, 260 39, 40, 34, 35, 33, 183, 36, 18, 26, 24, 261 198, 150, 223, 151, 150, 222, 70, 150, 63, 62, 262 51, 52, 53, 54, 55, 21, 20, 28, 27, 25, 263 19, 15, 218, 199, 12, 194, 46, 47, 176, 189, 264 168, 167, 166, 108, 178, 107, 106, 29, 219, 216, 265 23, 22, 187, 186, 17, 172, 170, 171, 185, 192, 266 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 267 33, 177, 36, 18, 26, 24, 105, 56, 103, 102, 268 96, 95, 28, 69, 25, 94, 85, 56, 188, 190, 269 155, 21, 20, 28, 27, 221, 19, 15, 164, 142, 270 12, 28, 46, 47, 160, 23, 22, 56, 49, 17, 271 56, 181, 86, 169, 97, 43, 44, 42, 41, 38, 272 37, 39, 40, 34, 35, 33, 233, 36, 18, 26, 273 24, 51, 52, 53, 54, 55, 224, 28, 113, 25, 274 88, 51, 52, 53, 54, 55, 21, 20, 88, 27, 275 121, 19, 15, 48, 202, 12, 85, 46, 47, 100, 276 23, 22, 1, 15, 17, 13, 53, 54, 55, 7, 277 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 278 33, 2, 36, 18, 26, 24, 201, 182, 68, 4, 279 69, 3, 57, 58, 56, 59, 60, 61, 64, 65, 280 0, 21, 20, 14, 27, 31, 19, 15, 0, 0, 281 12, 98, 46, 47, 66, 67, 68, 0, 69, 82, 282 57, 58, 56, 59, 60, 61, 64, 65, 0, 78, 283 79, 174, 0, 156, 157, 158, 99, 0, 71, 0, 284 0, 0, 66, 67, 70, 0, 63, 62, 51, 52, 285 53, 54, 55, 120, 0, 179, 0, 0, 0, 68, 286 0, 69, 50, 57, 58, 56, 59, 60, 61, 64, 287 65, 0, 70, 0, 63, 62, 51, 52, 53, 54, 288 55, 0, 0, 0, 0, 66, 67, 119, 72, 73, 289 74, 75, 76, 77, 0, 0, 0, 0, 68, 0, 290 69, 0, 57, 58, 56, 59, 60, 61, 64, 65, 291 0, 0, 214, 0, 215, 70, 0, 63, 62, 51, 292 52, 53, 54, 55, 66, 67, 68, 0, 69, 220, 293 57, 58, 56, 59, 60, 61, 64, 65, 0, 68, 294 0, 69, 0, 57, 58, 56, 59, 60, 61, 64, 295 65, 0, 66, 67, 70, 0, 63, 62, 51, 52, 296 53, 54, 55, 0, 0, 66, 67, 0, 193, 0, 297 0, 0, 225, 206, 207, 208, 0, 0, 0, 0, 298 110, 28, 70, 25, 63, 62, 51, 52, 53, 54, 299 55, 0, 0, 0, 0, 70, 191, 63, 62, 51, 300 52, 53, 54, 55, 23, 22, 0, 0, 17, 152, 301 68, 0, 69, 0, 57, 58, 56, 59, 60, 61, 302 64, 65, 0, 112, 0, 0, 0, 18, 26, 24, 303 6, 9, 10, 0, 0, 231, 66, 67, 28, 0, 304 25, 0, 0, 0, 0, 21, 20, 0, 27, 0, 305 19, 15, 0, 28, 12, 25, 0, 5, 0, 0, 306 0, 23, 22, 0, 0, 17, 70, 0, 63, 62, 307 51, 52, 53, 54, 55, 0, 23, 22, 0, 0, 308 17, 0, 0, 161, 18, 26, 24, 68, 0, 69, 309 0, 57, 58, 56, 59, 60, 61, 64, 65, 18, 310 26, 24, 21, 20, 0, 27, 0, 19, 15, 0, 311 28, 12, 25, 66, 67, 0, 0, 21, 20, 0, 312 27, 0, 19, 15, 0, 0, 118, 0, 0, 0, 313 0, 0, 0, 23, 22, 0, 0, 17, 28, 0, 314 25, 0, 0, 0, 0, 63, 62, 51, 52, 53, 315 54, 55, 0, 0, 0, 0, 18, 26, 24, 0, 316 0, 23, 22, 0, 0, 0, 0, 0, 0, 0, 317 209, 0, 0, 0, 21, 20, 0, 27, 0, 19, 318 15, 0, 0, 114, 18, 26, 24, 68, 0, 69, 319 0, 57, 0, 56, 0, 60, 61, 64, 65, 226, 320 0, 0, 21, 20, 0, 27, 0, 19, 15, 0, 321 68, 84, 69, 66, 67, 0, 56, 0, 60, 61, 322 64, 65, 69, 0, 0, 0, 56, 0, 60, 61, 323 64, 65, 0, 0, 0, 0, 66, 67, 0, 0, 324 0, 16, 0, 0, 0, 63, 62, 51, 52, 53, 325 54, 55, 0, 0, 0, 0, 0, 0, 0, 0, 326 0, 0, 0, 0, 0, 0, 32, 0, 63, 62, 327 51, 52, 53, 54, 55, 45, 8, 115, 63, 62, 328 51, 52, 53, 54, 55, 0, 0, 0, 81, 0, 329 80, 0, 0, 0, 0, 89, 90, 91, 101, 0, 330 0, 0, 104, 0, 0, 8, 0, 0, 0, 0, 331 140, 0, 0, 0, 0, 0, 0, 111, 111, 116, 332 116, 0, 117, 0, 0, 0, 122, 123, 124, 125, 333 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 334 136, 137, 138, 139, 162, 141, 0, 143, 144, 145, 335 146, 147, 148, 149, 0, 0, 0, 0, 0, 11, 336 153, 116, 0, 154, 0, 0, 101, 0, 0, 0, 337 116, 116, 116, 0, 0, 83, 0, 87, 111, 163, 338 0, 165, 92, 93, 0, 0, 0, 101, 0, 0, 339 81, 0, 173, 0, 81, 0, 175, 0, 0, 0, 340 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 341 0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 342 0, 0, 0, 205, 0, 0, 180, 0, 0, 0, 343 0, 184, 210, 0, 0, 0, 0, 0, 0, 0, 344 0, 0, 0, 0, 0, 0, 195, 196, 197, 0, 345 0, 0, 0, 0, 204, 0, 0, 0, 211, 203, 346 213, 0, 0, 0, 0, 111, 0, 0, 212, 0, 347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 348 0, 0, 0, 0, 0, 0, 227, 0, 228, 0, 349 0, 0, 0, 0, 111, 0, 0, 232, 101, 0, 350 0, 0, 87 }; 351 static YYCONST yytabelem yypact[]={ 352 353 164,-10000000,-10000000, -245, -301, -80, -111,-10000000, -33,-10000000, 354 -10000000, -11, 221,-10000000,-10000000, 321, -202, -124,-10000000, 221, 355 221, 221, -124, -124, -205, -209, -210,-10000000,-10000000, 164, 356 -80, -135,-10000000, -211, -212, -80, -214, -246, -247, -249, 357 -124, 221, 221, 293, 236, -5,-10000000, -80,-10000000,-10000000, 358 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 359 221, 221, 221, 221, 221, 221, 221, 221, -116, 221, 360 -145, 221, 221, 221, 221, 221, 221, 221,-10000000,-10000000, 361 -278, 118,-10000000,-10000000, 221, 221, -189,-10000000,-10000000, -120, 362 -120, -120,-10000000,-10000000, 221, 221, 221, -336,-10000000, -190, 363 -10000000,-10000000, 221, 221, -160, 221,-10000000,-10000000,-10000000, -250, 364 -251, 189, -252, -319, 221, -313, 189, -322, 221,-10000000, 365 -256, -219, 189, -117, -117, -120, -120, -120, -120, 389, 366 366, -261, -140, -140, -140, -140, -140, -140, 399, 399, 367 -10000000, -150, -124, 266, 266, 266, 266, 266, 266, 266, 368 221, -110,-10000000, 118, -284, 221, -233, -238, -239, -196, 369 -10000000, -253, -132, 105, -231, 77,-10000000,-10000000,-10000000, -257, 370 221, 221, 221, -281, -259, -302,-10000000, -116, 221,-10000000, 371 189, -116,-10000000,-10000000, -140,-10000000,-10000000,-10000000,-10000000, 221, 372 -116, -80, 221, -80,-10000000, 189, 189, 189, -241,-10000000, 373 -241, -242,-10000000, -314, 266,-10000000,-10000000,-10000000,-10000000, -260, 374 -243,-10000000, 38, -175, -277, -280,-10000000, -116, 221, -80, 375 -10000000, -80,-10000000,-10000000, -303,-10000000, -300,-10000000,-10000000, -80, 376 -80, -80,-10000000, -311,-10000000 }; 377 static YYCONST yytabelem yypgo[]={ 378 379 0, 221, 231, 229, 715, 243, 799, 420, 226, 194, 380 706, 245, 153, 717, 178, 209, 205, 152, 681, 202, 381 190, 176, 166, 227, 154 }; 382 static YYCONST yytabelem yyr1[]={ 383 384 0, 19, 1, 1, 2, 2, 2, 20, 21, 22, 385 2, 2, 2, 3, 3, 15, 15, 15, 14, 14, 386 13, 13, 8, 8, 9, 9, 7, 7, 4, 4, 387 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 388 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 389 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 390 6, 6, 18, 18, 5, 5, 5, 5, 5, 5, 391 5, 5, 5, 5, 5, 5, 24, 5, 10, 10, 392 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 393 10, 10, 10, 10, 10, 10, 10, 11, 11, 12, 394 12, 12, 12, 16, 16, 16, 17, 17, 23 }; 395 static YYCONST yytabelem yyr2[]={ 396 397 0, 3, 3, 7, 9, 7, 3, 1, 1, 1, 398 23, 5, 1, 2, 7, 3, 3, 3, 2, 1, 399 2, 7, 1, 2, 2, 7, 2, 1, 7, 7, 400 7, 7, 7, 7, 7, 7, 11, 7, 7, 7, 401 7, 7, 7, 7, 5, 5, 7, 7, 7, 7, 402 7, 7, 7, 7, 7, 11, 2, 2, 7, 5, 403 2, 9, 2, 2, 2, 2, 9, 5, 5, 5, 404 5, 5, 3, 11, 11, 11, 1, 9, 19, 15, 405 11, 13, 15, 11, 5, 5, 5, 7, 7, 7, 406 9, 13, 9, 13, 5, 3, 7, 2, 5, 5, 407 5, 5, 1, 5, 9, 9, 2, 1, 1 }; 408 static YYCONST yytabelem yychk[]={ 409 410 -10000000, -19, -1, -2, -3, 333, 306, -15, -4, 307, 411 308, -6, 330, -16, -5, 327, -18, 284, 303, 326, 412 322, 321, 281, 280, 305, 259, 304, 324, 257, 332, 413 333, -11, -10, 300, 298, 299, 302, 295, 294, 296, 414 297, 293, 292, 290, 291, -4, 332, 333, 304, 259, 415 335, 321, 322, 323, 324, 325, 267, 265, 266, 268, 416 269, 270, 320, 319, 271, 272, 287, 288, 261, 263, 417 317, 289, 339, 340, 341, 342, 343, 344, 280, 281, 418 -13, -4, -5, -6, 330, 328, -17, -6, 304, -4, 419 -4, -4, -6, -6, 330, 330, 330, -24, -1, -11, 420 334, -10, 330, 330, -10, 330, 332, 332, 332, -6, 421 -7, -4, -7, -14, 330, -13, -4, -13, 330, 332, 422 -11, -20, -4, -4, -4, -4, -4, -4, -4, -4, 423 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 424 -18, -4, 284, -4, -4, -4, -4, -4, -4, -4, 425 335, 331, 331, -4, -13, 319, -14, -14, -14, 348, 426 334, -7, -18, -4, 298, -4, 332, 332, 332, -12, 427 337, 338, 336, -13, -12, -13, 334, 330, 345, -17, 428 -4, 261, -23, 329, -4, 331, 331, 331, 324, 332, 429 261, 331, 330, 331, 332, -4, -4, -4, 331, 332, 430 331, -8, -9, -18, -4, -18, -23, -23, -23, -7, 431 -18, -10, -4, -10, -12, -12, 331, 335, 332, 331, 432 331, 310, 332, 332, -21, -9, -7, -10, -10, 333, 433 331, -11, -10, -22, 334 }; 434 static YYCONST yytabelem yydef[]={ 435 436 12, -2, 1, 2, 6, 0, 0, 13, 17, 15, 437 16, 64, 0, 56, 57, 0, 60, 107, 65, 0, 438 0, 0, 0, 0, 72, 0, 62, 76, 63, 12, 439 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, 440 0, 27, 27, 19, 0, 0, 95, 0, 7, 11, 441 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 443 0, 0, 0, 0, 0, 0, 0, 0, 44, 45, 444 0, 20, 59, 64, 0, 0, 103, 106, 62, 67, 445 68, 69, 70, 71, 19, 19, 19, 0, 3, 0, 446 5, 98, 27, 0, 0, 0, 84, 85, 86, 0, 447 0, 26, 0, 102, 0, 18, 20, 102, 0, 94, 448 0, 0, 14, 28, 29, 30, 31, 32, 33, 34, 449 35, 0, 46, 47, 48, 49, 50, 51, 52, 53, 450 54, 58, 107, 37, 38, 39, 40, 41, 42, 43, 451 0, 0, 108, 0, 0, 0, 0, 0, 0, 0, 452 4, 0, 60, 0, 0, 0, 87, 88, 89, 0, 453 0, 0, 0, 0, 0, 0, 96, 22, 0, 104, 454 21, 0, 66, 61, 105, 108, 108, 108, 77, 27, 455 0, 0, 0, 0, 90, 99, 100, 101, 102, 92, 456 102, 0, 23, 24, 36, 55, 73, 74, 75, 0, 457 0, 80, 0, 83, 0, 0, 8, 0, 27, 0, 458 81, 0, 91, 93, 0, 25, 0, 79, 82, 0, 459 0, 9, 78, 0, 10 }; 460 typedef struct 461 #ifdef __cplusplus 462 yytoktype 463 #endif 464 { 465 #ifdef __cplusplus 466 const 467 #endif 468 char *t_name; int t_val; } yytoktype; 469 #ifndef YYDEBUG 470 # define YYDEBUG 0 /* don't allow debugging */ 471 #endif 472 473 #if YYDEBUG 474 475 yytoktype yytoks[] = 476 { 477 "PARM", 257, 478 "ARRAY", 258, 479 "UFUNC", 259, 480 "FIELD", 260, 481 "IN", 261, 482 "INDEX", 262, 483 "CONCAT", 263, 484 "NOT", 264, 485 "AND", 265, 486 "OR", 266, 487 "EXP", 267, 488 "QUEST", 268, 489 "EQ", 269, 490 "NE", 270, 491 "GE", 271, 492 "LE", 272, 493 "GT", 273, 494 "LT", 274, 495 "ADD", 275, 496 "SUB", 276, 497 "MUL", 277, 498 "DIV", 278, 499 "REM", 279, 500 "INC", 280, 501 "DEC", 281, 502 "PRE_INC", 282, 503 "PRE_DEC", 283, 504 "GETLINE", 284, 505 "CALLFUNC", 285, 506 "RE", 286, 507 "TILDE", 287, 508 "NRE", 288, 509 "ASG", 289, 510 "PRINT", 290, 511 "PRINTF", 291, 512 "EXIT", 292, 513 "RETURN", 293, 514 "BREAK", 294, 515 "CONTINUE", 295, 516 "NEXT", 296, 517 "DELETE", 297, 518 "WHILE", 298, 519 "DO", 299, 520 "FOR", 300, 521 "FORIN", 301, 522 "IF", 302, 523 "CONSTANT", 303, 524 "VAR", 304, 525 "FUNC", 305, 526 "DEFFUNC", 306, 527 "BEGIN", 307, 528 "END", 308, 529 "CLOSE", 309, 530 "ELSE", 310, 531 "PACT", 311, 532 "DOT", 312, 533 "CALLUFUNC", 313, 534 "KEYWORD", 314, 535 "SVAR", 315, 536 "PIPESYM", 316, 537 "BAR", 317, 538 "CARAT", 318, 539 "LANGLE", 319, 540 "RANGLE", 320, 541 "PLUSC", 321, 542 "HYPHEN", 322, 543 "STAR", 323, 544 "SLASH", 324, 545 "PERCENT", 325, 546 "EXCLAMATION", 326, 547 "DOLLAR", 327, 548 "LSQUARE", 328, 549 "RSQUARE", 329, 550 "LPAREN", 330, 551 "RPAREN", 331, 552 "SEMI", 332, 553 "LBRACE", 333, 554 "RBRACE", 334, 555 "COMMA", 335, 556 "PIPE", 336, 557 "WRITE", 337, 558 "APPEND", 338, 559 "AADD", 339, 560 "ASUB", 340, 561 "AMUL", 341, 562 "ADIV", 342, 563 "AREM", 343, 564 "AEXP", 344, 565 "COLON", 345, 566 "UPLUS", 346, 567 "UMINUS", 347, 568 "URE", 348, 569 "-unknown-", -1 /* ends search */ 570 }; 571 572 #ifdef __cplusplus 573 const 574 #endif 575 char * yyreds[] = 576 { 577 "-no such reduction-", 578 "dummy : prog", 579 "prog : rule", 580 "prog : rule SEMI prog", 581 "rule : pattern LBRACE statlist RBRACE", 582 "rule : LBRACE statlist RBRACE", 583 "rule : pattern", 584 "rule : DEFFUNC VAR", 585 "rule : DEFFUNC VAR LPAREN varlist RPAREN", 586 "rule : DEFFUNC VAR LPAREN varlist RPAREN LBRACE statlist", 587 "rule : DEFFUNC VAR LPAREN varlist RPAREN LBRACE statlist RBRACE", 588 "rule : DEFFUNC UFUNC", 589 "rule : /* empty */", 590 "pattern : simplepattern", 591 "pattern : expr COMMA expr", 592 "simplepattern : BEGIN", 593 "simplepattern : END", 594 "simplepattern : expr", 595 "eexprlist : exprlist", 596 "eexprlist : /* empty */", 597 "exprlist : expr", 598 "exprlist : exprlist COMMA expr", 599 "varlist : /* empty */", 600 "varlist : varlist2", 601 "varlist2 : var", 602 "varlist2 : var COMMA varlist2", 603 "fexpr : expr", 604 "fexpr : /* empty */", 605 "expr : expr PLUSC expr", 606 "expr : expr HYPHEN expr", 607 "expr : expr STAR expr", 608 "expr : expr SLASH expr", 609 "expr : expr PERCENT expr", 610 "expr : expr EXP expr", 611 "expr : expr AND expr", 612 "expr : expr OR expr", 613 "expr : expr QUEST expr COLON expr", 614 "expr : lvalue ASG expr", 615 "expr : lvalue AADD expr", 616 "expr : lvalue ASUB expr", 617 "expr : lvalue AMUL expr", 618 "expr : lvalue ADIV expr", 619 "expr : lvalue AREM expr", 620 "expr : lvalue AEXP expr", 621 "expr : lvalue INC", 622 "expr : lvalue DEC", 623 "expr : expr EQ expr", 624 "expr : expr NE expr", 625 "expr : expr RANGLE expr", 626 "expr : expr LANGLE expr", 627 "expr : expr GE expr", 628 "expr : expr LE expr", 629 "expr : expr TILDE expr", 630 "expr : expr NRE expr", 631 "expr : expr IN var", 632 "expr : LPAREN exprlist RPAREN IN var", 633 "expr : getline", 634 "expr : rvalue", 635 "expr : expr CONCAT expr", 636 "lvalue : DOLLAR rvalue", 637 "lvalue : var", 638 "lvalue : var LSQUARE exprlist RSQUARE", 639 "var : VAR", 640 "var : PARM", 641 "rvalue : lvalue", 642 "rvalue : CONSTANT", 643 "rvalue : LPAREN expr RPAREN term", 644 "rvalue : EXCLAMATION expr", 645 "rvalue : HYPHEN expr", 646 "rvalue : PLUSC expr", 647 "rvalue : DEC lvalue", 648 "rvalue : INC lvalue", 649 "rvalue : FUNC", 650 "rvalue : FUNC LPAREN eexprlist RPAREN term", 651 "rvalue : UFUNC LPAREN eexprlist RPAREN term", 652 "rvalue : VAR LPAREN eexprlist RPAREN term", 653 "rvalue : SLASH", 654 "rvalue : SLASH URE SLASH", 655 "statement : FOR LPAREN fexpr SEMI fexpr SEMI fexpr RPAREN statement", 656 "statement : FOR LPAREN var IN var RPAREN statement", 657 "statement : WHILE LPAREN expr RPAREN statement", 658 "statement : DO statement WHILE LPAREN expr RPAREN", 659 "statement : IF LPAREN expr RPAREN statement ELSE statement", 660 "statement : IF LPAREN expr RPAREN statement", 661 "statement : CONTINUE SEMI", 662 "statement : BREAK SEMI", 663 "statement : NEXT SEMI", 664 "statement : DELETE lvalue SEMI", 665 "statement : RETURN fexpr SEMI", 666 "statement : EXIT fexpr SEMI", 667 "statement : PRINT eexprlist fileout SEMI", 668 "statement : PRINT LPAREN exprlist RPAREN fileout SEMI", 669 "statement : PRINTF exprlist fileout SEMI", 670 "statement : PRINTF LPAREN exprlist RPAREN fileout SEMI", 671 "statement : expr SEMI", 672 "statement : SEMI", 673 "statement : LBRACE statlist RBRACE", 674 "statlist : statement", 675 "statlist : statlist statement", 676 "fileout : WRITE expr", 677 "fileout : APPEND expr", 678 "fileout : PIPE expr", 679 "fileout : /* empty */", 680 "getline : GETLINE optvar", 681 "getline : expr BAR GETLINE optvar", 682 "getline : GETLINE optvar LANGLE expr", 683 "optvar : lvalue", 684 "optvar : /* empty */", 685 "term : /* empty */", 686 }; 687 #endif /* YYDEBUG */ 688 # line 1 "/usr/share/lib/ccs/yaccpar" 689 /* 690 * CDDL HEADER START 691 * 692 * The contents of this file are subject to the terms of the 693 * Common Development and Distribution License, Version 1.0 only 694 * (the "License"). You may not use this file except in compliance 695 * with the License. 696 * 697 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 698 * or http://www.opensolaris.org/os/licensing. 699 * See the License for the specific language governing permissions 700 * and limitations under the License. 701 * 702 * When distributing Covered Code, include this CDDL HEADER in each 703 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 704 * If applicable, add the following below this CDDL HEADER, with the 705 * fields enclosed by brackets "[]" replaced with your own identifying 706 * information: Portions Copyright [yyyy] [name of copyright owner] 707 * 708 * CDDL HEADER END 709 */ 710 /* 711 * Copyright 1993 Sun Microsystems, Inc. All rights reserved. 712 * Use is subject to license terms. 713 */ 714 715 /* Copyright (c) 1988 AT&T */ 716 /* All Rights Reserved */ 717 718 #pragma ident "%Z%%M% %I% %E% SMI" 719 720 /* 721 ** Skeleton parser driver for yacc output 722 */ 723 724 /* 725 ** yacc user known macros and defines 726 */ 727 #define YYERROR goto yyerrlab 728 #define YYACCEPT return(0) 729 #define YYABORT return(1) 730 #define YYBACKUP( newtoken, newvalue )\ 731 {\ 732 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ 733 {\ 734 yyerror( "syntax error - cannot backup" );\ 735 goto yyerrlab;\ 736 }\ 737 yychar = newtoken;\ 738 yystate = *yyps;\ 739 yylval = newvalue;\ 740 goto yynewstate;\ 741 } 742 #define YYRECOVERING() (!!yyerrflag) 743 #define YYNEW(type) malloc(sizeof(type) * yynewmax) 744 #define YYCOPY(to, from, type) \ 745 (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) 746 #define YYENLARGE( from, type) \ 747 (type *) realloc((char *) from, yynewmax * sizeof(type)) 748 #ifndef YYDEBUG 749 # define YYDEBUG 1 /* make debugging available */ 750 #endif 751 752 /* 753 ** user known globals 754 */ 755 int yydebug; /* set to 1 to get debugging */ 756 757 /* 758 ** driver internal defines 759 */ 760 #define YYFLAG (-10000000) 761 762 /* 763 ** global variables used by the parser 764 */ 765 YYSTYPE *yypv; /* top of value stack */ 766 int *yyps; /* top of state stack */ 767 768 int yystate; /* current state */ 769 int yytmp; /* extra var (lasts between blocks) */ 770 771 int yynerrs; /* number of errors */ 772 int yyerrflag; /* error recovery flag */ 773 int yychar; /* current input token number */ 774 775 776 777 #ifdef YYNMBCHARS 778 #define YYLEX() yycvtok(yylex()) 779 /* 780 ** yycvtok - return a token if i is a wchar_t value that exceeds 255. 781 ** If i<255, i itself is the token. If i>255 but the neither 782 ** of the 30th or 31st bit is on, i is already a token. 783 */ 784 #if defined(__STDC__) || defined(__cplusplus) 785 int yycvtok(int i) 786 #else 787 int yycvtok(i) int i; 788 #endif 789 { 790 int first = 0; 791 int last = YYNMBCHARS - 1; 792 int mid; 793 wchar_t j; 794 795 if(i&0x60000000){/*Must convert to a token. */ 796 if( yymbchars[last].character < i ){ 797 return i;/*Giving up*/ 798 } 799 while ((last>=first)&&(first>=0)) {/*Binary search loop*/ 800 mid = (first+last)/2; 801 j = yymbchars[mid].character; 802 if( j==i ){/*Found*/ 803 return yymbchars[mid].tvalue; 804 }else if( j<i ){ 805 first = mid + 1; 806 }else{ 807 last = mid -1; 808 } 809 } 810 /*No entry in the table.*/ 811 return i;/* Giving up.*/ 812 }else{/* i is already a token. */ 813 return i; 814 } 815 } 816 #else/*!YYNMBCHARS*/ 817 #define YYLEX() yylex() 818 #endif/*!YYNMBCHARS*/ 819 820 /* 821 ** yyparse - return 0 if worked, 1 if syntax error not recovered from 822 */ 823 #if defined(__STDC__) || defined(__cplusplus) 824 int yyparse(void) 825 #else 826 int yyparse() 827 #endif 828 { 829 register YYSTYPE *yypvt = 0; /* top of value stack for $vars */ 830 831 #if defined(__cplusplus) || defined(lint) 832 /* 833 hacks to please C++ and lint - goto's inside 834 switch should never be executed 835 */ 836 static int __yaccpar_lint_hack__ = 0; 837 switch (__yaccpar_lint_hack__) 838 { 839 case 1: goto yyerrlab; 840 case 2: goto yynewstate; 841 } 842 #endif 843 844 /* 845 ** Initialize externals - yyparse may be called more than once 846 */ 847 yypv = &yyv[-1]; 848 yyps = &yys[-1]; 849 yystate = 0; 850 yytmp = 0; 851 yynerrs = 0; 852 yyerrflag = 0; 853 yychar = -1; 854 855 #if YYMAXDEPTH <= 0 856 if (yymaxdepth <= 0) 857 { 858 if ((yymaxdepth = YYEXPAND(0)) <= 0) 859 { 860 yyerror("yacc initialization error"); 861 YYABORT; 862 } 863 } 864 #endif 865 866 { 867 register YYSTYPE *yy_pv; /* top of value stack */ 868 register int *yy_ps; /* top of state stack */ 869 register int yy_state; /* current state */ 870 register int yy_n; /* internal state number info */ 871 goto yystack; /* moved from 6 lines above to here to please C++ */ 872 873 /* 874 ** get globals into registers. 875 ** branch to here only if YYBACKUP was called. 876 */ 877 yynewstate: 878 yy_pv = yypv; 879 yy_ps = yyps; 880 yy_state = yystate; 881 goto yy_newstate; 882 883 /* 884 ** get globals into registers. 885 ** either we just started, or we just finished a reduction 886 */ 887 yystack: 888 yy_pv = yypv; 889 yy_ps = yyps; 890 yy_state = yystate; 891 892 /* 893 ** top of for (;;) loop while no reductions done 894 */ 895 yy_stack: 896 /* 897 ** put a state and value onto the stacks 898 */ 899 #if YYDEBUG 900 /* 901 ** if debugging, look up token value in list of value vs. 902 ** name pairs. 0 and negative (-1) are special values. 903 ** Note: linear search is used since time is not a real 904 ** consideration while debugging. 905 */ 906 if ( yydebug ) 907 { 908 register int yy_i; 909 910 printf( "State %d, token ", yy_state ); 911 if ( yychar == 0 ) 912 printf( "end-of-file\n" ); 913 else if ( yychar < 0 ) 914 printf( "-none-\n" ); 915 else 916 { 917 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 918 yy_i++ ) 919 { 920 if ( yytoks[yy_i].t_val == yychar ) 921 break; 922 } 923 printf( "%s\n", yytoks[yy_i].t_name ); 924 } 925 } 926 #endif /* YYDEBUG */ 927 if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ 928 { 929 /* 930 ** reallocate and recover. Note that pointers 931 ** have to be reset, or bad things will happen 932 */ 933 long yyps_index = (yy_ps - yys); 934 long yypv_index = (yy_pv - yyv); 935 long yypvt_index = (yypvt - yyv); 936 int yynewmax; 937 #ifdef YYEXPAND 938 yynewmax = YYEXPAND(yymaxdepth); 939 #else 940 yynewmax = 2 * yymaxdepth; /* double table size */ 941 if (yymaxdepth == YYMAXDEPTH) /* first time growth */ 942 { 943 char *newyys = (char *)YYNEW(int); 944 char *newyyv = (char *)YYNEW(YYSTYPE); 945 if (newyys != 0 && newyyv != 0) 946 { 947 yys = YYCOPY(newyys, yys, int); 948 yyv = YYCOPY(newyyv, yyv, YYSTYPE); 949 } 950 else 951 yynewmax = 0; /* failed */ 952 } 953 else /* not first time */ 954 { 955 yys = YYENLARGE(yys, int); 956 yyv = YYENLARGE(yyv, YYSTYPE); 957 if (yys == 0 || yyv == 0) 958 yynewmax = 0; /* failed */ 959 } 960 #endif 961 if (yynewmax <= yymaxdepth) /* tables not expanded */ 962 { 963 yyerror( "yacc stack overflow" ); 964 YYABORT; 965 } 966 yymaxdepth = yynewmax; 967 968 yy_ps = yys + yyps_index; 969 yy_pv = yyv + yypv_index; 970 yypvt = yyv + yypvt_index; 971 } 972 *yy_ps = yy_state; 973 *++yy_pv = yyval; 974 975 /* 976 ** we have a new state - find out what to do 977 */ 978 yy_newstate: 979 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) 980 goto yydefault; /* simple state */ 981 #if YYDEBUG 982 /* 983 ** if debugging, need to mark whether new token grabbed 984 */ 985 yytmp = yychar < 0; 986 #endif 987 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 988 yychar = 0; /* reached EOF */ 989 #if YYDEBUG 990 if ( yydebug && yytmp ) 991 { 992 register int yy_i; 993 994 printf( "Received token " ); 995 if ( yychar == 0 ) 996 printf( "end-of-file\n" ); 997 else if ( yychar < 0 ) 998 printf( "-none-\n" ); 999 else 1000 { 1001 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 1002 yy_i++ ) 1003 { 1004 if ( yytoks[yy_i].t_val == yychar ) 1005 break; 1006 } 1007 printf( "%s\n", yytoks[yy_i].t_name ); 1008 } 1009 } 1010 #endif /* YYDEBUG */ 1011 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) 1012 goto yydefault; 1013 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ 1014 { 1015 yychar = -1; 1016 yyval = yylval; 1017 yy_state = yy_n; 1018 if ( yyerrflag > 0 ) 1019 yyerrflag--; 1020 goto yy_stack; 1021 } 1022 1023 yydefault: 1024 if ( ( yy_n = yydef[ yy_state ] ) == -2 ) 1025 { 1026 #if YYDEBUG 1027 yytmp = yychar < 0; 1028 #endif 1029 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 1030 yychar = 0; /* reached EOF */ 1031 #if YYDEBUG 1032 if ( yydebug && yytmp ) 1033 { 1034 register int yy_i; 1035 1036 printf( "Received token " ); 1037 if ( yychar == 0 ) 1038 printf( "end-of-file\n" ); 1039 else if ( yychar < 0 ) 1040 printf( "-none-\n" ); 1041 else 1042 { 1043 for ( yy_i = 0; 1044 yytoks[yy_i].t_val >= 0; 1045 yy_i++ ) 1046 { 1047 if ( yytoks[yy_i].t_val 1048 == yychar ) 1049 { 1050 break; 1051 } 1052 } 1053 printf( "%s\n", yytoks[yy_i].t_name ); 1054 } 1055 } 1056 #endif /* YYDEBUG */ 1057 /* 1058 ** look through exception table 1059 */ 1060 { 1061 register YYCONST int *yyxi = yyexca; 1062 1063 while ( ( *yyxi != -1 ) || 1064 ( yyxi[1] != yy_state ) ) 1065 { 1066 yyxi += 2; 1067 } 1068 while ( ( *(yyxi += 2) >= 0 ) && 1069 ( *yyxi != yychar ) ) 1070 ; 1071 if ( ( yy_n = yyxi[1] ) < 0 ) 1072 YYACCEPT; 1073 } 1074 } 1075 1076 /* 1077 ** check for syntax error 1078 */ 1079 if ( yy_n == 0 ) /* have an error */ 1080 { 1081 /* no worry about speed here! */ 1082 switch ( yyerrflag ) 1083 { 1084 case 0: /* new error */ 1085 yyerror( "syntax error" ); 1086 goto skip_init; 1087 yyerrlab: 1088 /* 1089 ** get globals into registers. 1090 ** we have a user generated syntax type error 1091 */ 1092 yy_pv = yypv; 1093 yy_ps = yyps; 1094 yy_state = yystate; 1095 skip_init: 1096 yynerrs++; 1097 /* FALLTHRU */ 1098 case 1: 1099 case 2: /* incompletely recovered error */ 1100 /* try again... */ 1101 yyerrflag = 3; 1102 /* 1103 ** find state where "error" is a legal 1104 ** shift action 1105 */ 1106 while ( yy_ps >= yys ) 1107 { 1108 yy_n = yypact[ *yy_ps ] + YYERRCODE; 1109 if ( yy_n >= 0 && yy_n < YYLAST && 1110 yychk[yyact[yy_n]] == YYERRCODE) { 1111 /* 1112 ** simulate shift of "error" 1113 */ 1114 yy_state = yyact[ yy_n ]; 1115 goto yy_stack; 1116 } 1117 /* 1118 ** current state has no shift on 1119 ** "error", pop stack 1120 */ 1121 #if YYDEBUG 1122 # define _POP_ "Error recovery pops state %d, uncovers state %d\n" 1123 if ( yydebug ) 1124 printf( _POP_, *yy_ps, 1125 yy_ps[-1] ); 1126 # undef _POP_ 1127 #endif 1128 yy_ps--; 1129 yy_pv--; 1130 } 1131 /* 1132 ** there is no state on stack with "error" as 1133 ** a valid shift. give up. 1134 */ 1135 YYABORT; 1136 case 3: /* no shift yet; eat a token */ 1137 #if YYDEBUG 1138 /* 1139 ** if debugging, look up token in list of 1140 ** pairs. 0 and negative shouldn't occur, 1141 ** but since timing doesn't matter when 1142 ** debugging, it doesn't hurt to leave the 1143 ** tests here. 1144 */ 1145 if ( yydebug ) 1146 { 1147 register int yy_i; 1148 1149 printf( "Error recovery discards " ); 1150 if ( yychar == 0 ) 1151 printf( "token end-of-file\n" ); 1152 else if ( yychar < 0 ) 1153 printf( "token -none-\n" ); 1154 else 1155 { 1156 for ( yy_i = 0; 1157 yytoks[yy_i].t_val >= 0; 1158 yy_i++ ) 1159 { 1160 if ( yytoks[yy_i].t_val 1161 == yychar ) 1162 { 1163 break; 1164 } 1165 } 1166 printf( "token %s\n", 1167 yytoks[yy_i].t_name ); 1168 } 1169 } 1170 #endif /* YYDEBUG */ 1171 if ( yychar == 0 ) /* reached EOF. quit */ 1172 YYABORT; 1173 yychar = -1; 1174 goto yy_newstate; 1175 } 1176 }/* end if ( yy_n == 0 ) */ 1177 /* 1178 ** reduction by production yy_n 1179 ** put stack tops, etc. so things right after switch 1180 */ 1181 #if YYDEBUG 1182 /* 1183 ** if debugging, print the string that is the user's 1184 ** specification of the reduction which is just about 1185 ** to be done. 1186 */ 1187 if ( yydebug ) 1188 printf( "Reduce by (%d) \"%s\"\n", 1189 yy_n, yyreds[ yy_n ] ); 1190 #endif 1191 yytmp = yy_n; /* value to switch over */ 1192 yypvt = yy_pv; /* $vars top of value stack */ 1193 /* 1194 ** Look in goto table for next state 1195 ** Sorry about using yy_state here as temporary 1196 ** register variable, but why not, if it works... 1197 ** If yyr2[ yy_n ] doesn't have the low order bit 1198 ** set, then there is no action to be done for 1199 ** this reduction. So, no saving & unsaving of 1200 ** registers done. The only difference between the 1201 ** code just after the if and the body of the if is 1202 ** the goto yy_stack in the body. This way the test 1203 ** can be made before the choice of what to do is needed. 1204 */ 1205 { 1206 /* length of production doubled with extra bit */ 1207 register int yy_len = yyr2[ yy_n ]; 1208 1209 if ( !( yy_len & 01 ) ) 1210 { 1211 yy_len >>= 1; 1212 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 1213 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 1214 *( yy_ps -= yy_len ) + 1; 1215 if ( yy_state >= YYLAST || 1216 yychk[ yy_state = 1217 yyact[ yy_state ] ] != -yy_n ) 1218 { 1219 yy_state = yyact[ yypgo[ yy_n ] ]; 1220 } 1221 goto yy_stack; 1222 } 1223 yy_len >>= 1; 1224 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 1225 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 1226 *( yy_ps -= yy_len ) + 1; 1227 if ( yy_state >= YYLAST || 1228 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) 1229 { 1230 yy_state = yyact[ yypgo[ yy_n ] ]; 1231 } 1232 } 1233 /* save until reenter driver code */ 1234 yystate = yy_state; 1235 yyps = yy_ps; 1236 yypv = yy_pv; 1237 } 1238 /* 1239 ** code supplied by user is placed in this switch 1240 */ 1241 switch( yytmp ) 1242 { 1243 1244 case 1: 1245 # line 149 "awk.y" 1246 { 1247 yytree = fliplist(yytree); 1248 } break; 1249 case 2: 1250 # line 154 "awk.y" 1251 { 1252 yytree = yypvt[-0].node; 1253 } break; 1254 case 3: 1255 # line 157 "awk.y" 1256 { 1257 if (yypvt[-2].node != NNULL) { 1258 if (yytree != NNULL) 1259 yytree = node(COMMA, yypvt[-2].node, yytree); else 1260 yytree = yypvt[-2].node; 1261 } 1262 } break; 1263 case 4: 1264 # line 166 "awk.y" 1265 { 1266 yyval.node = node(PACT, yypvt[-3].node, yypvt[-1].node); 1267 doing_begin = 0; 1268 } break; 1269 case 5: 1270 # line 170 "awk.y" 1271 { 1272 npattern++; 1273 yyval.node = node(PACT, NNULL, yypvt[-1].node); 1274 } break; 1275 case 6: 1276 # line 174 "awk.y" 1277 { 1278 yyval.node = node(PACT, yypvt[-0].node, node(PRINT, NNULL, NNULL)); 1279 doing_begin = 0; 1280 } break; 1281 case 7: 1282 # line 179 "awk.y" 1283 { yypvt[-0].node->n_type = UFUNC; funparm = 1; } break; 1284 case 8: 1285 # line 181 "awk.y" 1286 { funparm = 0; } break; 1287 case 9: 1288 # line 182 "awk.y" 1289 { uexit(yypvt[-4].node); } break; 1290 case 10: 1291 # line 182 "awk.y" 1292 { 1293 yypvt[-9].node->n_ufunc = node(DEFFUNC, yypvt[-6].node, fliplist(yypvt[-2].node)); 1294 yyval.node = NNULL; 1295 } break; 1296 case 11: 1297 # line 186 "awk.y" 1298 { 1299 awkerr((char *) gettext("function \"%S\" redefined"), yypvt[-0].node->n_name); 1300 /* NOTREACHED */ 1301 } break; 1302 case 12: 1303 # line 190 "awk.y" 1304 { 1305 yyval.node = NNULL; 1306 } break; 1307 case 14: 1308 # line 197 "awk.y" 1309 { 1310 ++npattern; 1311 yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); 1312 } break; 1313 case 15: 1314 # line 204 "awk.y" 1315 { 1316 yyval.node = node(BEGIN, NNULL, NNULL); 1317 doing_begin++; 1318 } break; 1319 case 16: 1320 # line 208 "awk.y" 1321 { 1322 ++npattern; 1323 yyval.node = node(END, NNULL, NNULL); 1324 } break; 1325 case 17: 1326 # line 212 "awk.y" 1327 { 1328 ++npattern; 1329 yyval.node = yypvt[-0].node; 1330 } break; 1331 case 19: 1332 # line 220 "awk.y" 1333 { 1334 yyval.node = NNULL; 1335 } break; 1336 case 21: 1337 # line 227 "awk.y" 1338 { 1339 yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); 1340 } break; 1341 case 22: 1342 # line 233 "awk.y" 1343 { 1344 yyval.node = NNULL; 1345 } break; 1346 case 25: 1347 # line 241 "awk.y" 1348 { 1349 yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); 1350 } break; 1351 case 27: 1352 # line 248 "awk.y" 1353 { 1354 yyval.node = NNULL; 1355 } break; 1356 case 28: 1357 # line 257 "awk.y" 1358 { 1359 yyval.node = node(ADD, yypvt[-2].node, yypvt[-0].node); 1360 } break; 1361 case 29: 1362 # line 260 "awk.y" 1363 { 1364 yyval.node = node(SUB, yypvt[-2].node, yypvt[-0].node); 1365 } break; 1366 case 30: 1367 # line 263 "awk.y" 1368 { 1369 yyval.node = node(MUL, yypvt[-2].node, yypvt[-0].node); 1370 } break; 1371 case 31: 1372 # line 266 "awk.y" 1373 { 1374 yyval.node = node(DIV, yypvt[-2].node, yypvt[-0].node); 1375 } break; 1376 case 32: 1377 # line 269 "awk.y" 1378 { 1379 yyval.node = node(REM, yypvt[-2].node, yypvt[-0].node); 1380 } break; 1381 case 33: 1382 # line 272 "awk.y" 1383 { 1384 yyval.node = node(EXP, yypvt[-2].node, yypvt[-0].node); 1385 } break; 1386 case 34: 1387 # line 275 "awk.y" 1388 { 1389 yyval.node = node(AND, yypvt[-2].node, yypvt[-0].node); 1390 } break; 1391 case 35: 1392 # line 278 "awk.y" 1393 { 1394 yyval.node = node(OR, yypvt[-2].node, yypvt[-0].node); 1395 } break; 1396 case 36: 1397 # line 281 "awk.y" 1398 { 1399 yyval.node = node(QUEST, yypvt[-4].node, node(COLON, yypvt[-2].node, yypvt[-0].node)); 1400 } break; 1401 case 37: 1402 # line 284 "awk.y" 1403 { 1404 yyval.node = node(ASG, yypvt[-2].node, yypvt[-0].node); 1405 } break; 1406 case 38: 1407 # line 287 "awk.y" 1408 { 1409 yyval.node = node(AADD, yypvt[-2].node, yypvt[-0].node); 1410 } break; 1411 case 39: 1412 # line 290 "awk.y" 1413 { 1414 yyval.node = node(ASUB, yypvt[-2].node, yypvt[-0].node); 1415 } break; 1416 case 40: 1417 # line 293 "awk.y" 1418 { 1419 yyval.node = node(AMUL, yypvt[-2].node, yypvt[-0].node); 1420 } break; 1421 case 41: 1422 # line 296 "awk.y" 1423 { 1424 yyval.node = node(ADIV, yypvt[-2].node, yypvt[-0].node); 1425 } break; 1426 case 42: 1427 # line 299 "awk.y" 1428 { 1429 yyval.node = node(AREM, yypvt[-2].node, yypvt[-0].node); 1430 } break; 1431 case 43: 1432 # line 302 "awk.y" 1433 { 1434 yyval.node = node(AEXP, yypvt[-2].node, yypvt[-0].node); 1435 } break; 1436 case 44: 1437 # line 305 "awk.y" 1438 { 1439 yyval.node = node(INC, yypvt[-1].node, NNULL); 1440 } break; 1441 case 45: 1442 # line 308 "awk.y" 1443 { 1444 yyval.node = node(DEC, yypvt[-1].node, NNULL); 1445 } break; 1446 case 46: 1447 # line 311 "awk.y" 1448 { 1449 yyval.node = node(EQ, yypvt[-2].node, yypvt[-0].node); 1450 } break; 1451 case 47: 1452 # line 314 "awk.y" 1453 { 1454 yyval.node = node(NE, yypvt[-2].node, yypvt[-0].node); 1455 } break; 1456 case 48: 1457 # line 317 "awk.y" 1458 { 1459 yyval.node = node(GT, yypvt[-2].node, yypvt[-0].node); 1460 } break; 1461 case 49: 1462 # line 320 "awk.y" 1463 { 1464 yyval.node = node(LT, yypvt[-2].node, yypvt[-0].node); 1465 } break; 1466 case 50: 1467 # line 323 "awk.y" 1468 { 1469 yyval.node = node(GE, yypvt[-2].node, yypvt[-0].node); 1470 } break; 1471 case 51: 1472 # line 326 "awk.y" 1473 { 1474 yyval.node = node(LE, yypvt[-2].node, yypvt[-0].node); 1475 } break; 1476 case 52: 1477 # line 329 "awk.y" 1478 { 1479 yyval.node = node(TILDE, yypvt[-2].node, yypvt[-0].node); 1480 } break; 1481 case 53: 1482 # line 332 "awk.y" 1483 { 1484 yyval.node = node(NRE, yypvt[-2].node, yypvt[-0].node); 1485 } break; 1486 case 54: 1487 # line 335 "awk.y" 1488 { 1489 yyval.node = node(IN, yypvt[-0].node, yypvt[-2].node); 1490 } break; 1491 case 55: 1492 # line 338 "awk.y" 1493 { 1494 yyval.node = node(IN, yypvt[-0].node, yypvt[-3].node); 1495 } break; 1496 case 58: 1497 # line 343 "awk.y" 1498 { 1499 yyval.node = node(CONCAT, yypvt[-2].node, yypvt[-0].node); 1500 } break; 1501 case 59: 1502 # line 349 "awk.y" 1503 { 1504 yyval.node = node(FIELD, yypvt[-0].node, NNULL); 1505 } break; 1506 case 61: 1507 # line 356 "awk.y" 1508 { 1509 yyval.node = node(INDEX, yypvt[-3].node, yypvt[-1].node); 1510 } break; 1511 case 66: 1512 # line 369 "awk.y" 1513 { 1514 yyval.node = yypvt[-2].node; 1515 } break; 1516 case 67: 1517 # line 372 "awk.y" 1518 { 1519 yyval.node = node(NOT, yypvt[-0].node, NNULL); 1520 } break; 1521 case 68: 1522 # line 375 "awk.y" 1523 { 1524 yyval.node = node(SUB, const0, yypvt[-0].node); 1525 } break; 1526 case 69: 1527 # line 378 "awk.y" 1528 { 1529 yyval.node = yypvt[-0].node; 1530 } break; 1531 case 70: 1532 # line 381 "awk.y" 1533 { 1534 yyval.node = node(PRE_DEC, yypvt[-0].node, NNULL); 1535 } break; 1536 case 71: 1537 # line 384 "awk.y" 1538 { 1539 yyval.node = node(PRE_INC, yypvt[-0].node, NNULL); 1540 } break; 1541 case 72: 1542 # line 387 "awk.y" 1543 { 1544 yyval.node = node(CALLFUNC, yypvt[-0].node, NNULL); 1545 } break; 1546 case 73: 1547 # line 390 "awk.y" 1548 { 1549 yyval.node = node(CALLFUNC, yypvt[-4].node, yypvt[-2].node); 1550 } break; 1551 case 74: 1552 # line 393 "awk.y" 1553 { 1554 yyval.node = node(CALLUFUNC, yypvt[-4].node, yypvt[-2].node); 1555 } break; 1556 case 75: 1557 # line 396 "awk.y" 1558 { 1559 yyval.node = node(CALLUFUNC, yypvt[-4].node, yypvt[-2].node); 1560 } break; 1561 case 76: 1562 # line 399 "awk.y" 1563 {redelim='/';} break; 1564 case 77: 1565 # line 399 "awk.y" 1566 { 1567 yyval.node = yypvt[-1].node; 1568 } break; 1569 case 78: 1570 # line 405 "awk.y" 1571 { 1572 yyval.node = node(FOR, node(COMMA, yypvt[-6].node, node(COMMA, yypvt[-4].node, yypvt[-2].node)), yypvt[-0].node); 1573 } break; 1574 case 79: 1575 # line 408 "awk.y" 1576 { 1577 register NODE *np; 1578 1579 /* 1580 * attempt to optimize statements for the form 1581 * for (i in x) delete x[i] 1582 * to 1583 * delete x 1584 */ 1585 np = yypvt[-0].node; 1586 if (np != NNULL 1587 && np->n_type == DELETE 1588 && (np = np->n_left)->n_type == INDEX 1589 && np->n_left == yypvt[-2].node 1590 && np->n_right == yypvt[-4].node) 1591 yyval.node = node(DELETE, yypvt[-2].node, NNULL); 1592 else 1593 yyval.node = node(FORIN, node(IN, yypvt[-4].node, yypvt[-2].node), yypvt[-0].node); 1594 } break; 1595 case 80: 1596 # line 427 "awk.y" 1597 { 1598 yyval.node = node(WHILE, yypvt[-2].node, yypvt[-0].node); 1599 } break; 1600 case 81: 1601 # line 430 "awk.y" 1602 { 1603 yyval.node = node(DO, yypvt[-1].node, yypvt[-4].node); 1604 } break; 1605 case 82: 1606 # line 433 "awk.y" 1607 { 1608 yyval.node = node(IF, yypvt[-4].node, node(ELSE, yypvt[-2].node, yypvt[-0].node)); 1609 } break; 1610 case 83: 1611 # line 436 "awk.y" 1612 { 1613 yyval.node = node(IF, yypvt[-2].node, node(ELSE, yypvt[-0].node, NNULL)); 1614 } break; 1615 case 84: 1616 # line 439 "awk.y" 1617 { 1618 yyval.node = node(CONTINUE, NNULL, NNULL); 1619 } break; 1620 case 85: 1621 # line 442 "awk.y" 1622 { 1623 yyval.node = node(BREAK, NNULL, NNULL); 1624 } break; 1625 case 86: 1626 # line 445 "awk.y" 1627 { 1628 yyval.node = node(NEXT, NNULL, NNULL); 1629 } break; 1630 case 87: 1631 # line 448 "awk.y" 1632 { 1633 yyval.node = node(DELETE, yypvt[-1].node, NNULL); 1634 } break; 1635 case 88: 1636 # line 451 "awk.y" 1637 { 1638 yyval.node = node(RETURN, yypvt[-1].node, NNULL); 1639 } break; 1640 case 89: 1641 # line 454 "awk.y" 1642 { 1643 yyval.node = node(EXIT, yypvt[-1].node, NNULL); 1644 } break; 1645 case 90: 1646 # line 457 "awk.y" 1647 { 1648 yyval.node = node(PRINT, yypvt[-2].node, yypvt[-1].node); 1649 } break; 1650 case 91: 1651 # line 460 "awk.y" 1652 { 1653 yyval.node = node(PRINT, yypvt[-3].node, yypvt[-1].node); 1654 } break; 1655 case 92: 1656 # line 463 "awk.y" 1657 { 1658 yyval.node = node(PRINTF, yypvt[-2].node, yypvt[-1].node); 1659 } break; 1660 case 93: 1661 # line 466 "awk.y" 1662 { 1663 yyval.node = node(PRINTF, yypvt[-3].node, yypvt[-1].node); 1664 } break; 1665 case 94: 1666 # line 469 "awk.y" 1667 { 1668 yyval.node = yypvt[-1].node; 1669 } break; 1670 case 95: 1671 # line 472 "awk.y" 1672 { 1673 yyval.node = NNULL; 1674 } break; 1675 case 96: 1676 # line 475 "awk.y" 1677 { 1678 yyval.node = yypvt[-1].node; 1679 } break; 1680 case 98: 1681 # line 483 "awk.y" 1682 { 1683 if (yypvt[-1].node == NNULL) 1684 yyval.node = yypvt[-0].node; 1685 else if (yypvt[-0].node == NNULL) 1686 yyval.node = yypvt[-1].node; 1687 else 1688 yyval.node = node(COMMA, yypvt[-1].node, yypvt[-0].node); 1689 } break; 1690 case 99: 1691 # line 494 "awk.y" 1692 { 1693 yyval.node = node(WRITE, yypvt[-0].node, NNULL); 1694 } break; 1695 case 100: 1696 # line 497 "awk.y" 1697 { 1698 yyval.node = node(APPEND, yypvt[-0].node, NNULL); 1699 } break; 1700 case 101: 1701 # line 500 "awk.y" 1702 { 1703 yyval.node = node(PIPE, yypvt[-0].node, NNULL); 1704 } break; 1705 case 102: 1706 # line 503 "awk.y" 1707 { 1708 yyval.node = NNULL; 1709 } break; 1710 case 103: 1711 # line 509 "awk.y" 1712 { 1713 yyval.node = node(GETLINE, yypvt[-0].node, NNULL); 1714 } break; 1715 case 104: 1716 # line 512 "awk.y" 1717 { 1718 yyval.node = node(GETLINE, yypvt[-0].node, node(PIPESYM, yypvt[-3].node, NNULL)); 1719 } break; 1720 case 105: 1721 # line 515 "awk.y" 1722 { 1723 yyval.node = node(GETLINE, yypvt[-2].node, node(LT, yypvt[-0].node, NNULL)); 1724 } break; 1725 case 107: 1726 # line 522 "awk.y" 1727 { 1728 yyval.node = NNULL; 1729 } break; 1730 case 108: 1731 # line 528 "awk.y" 1732 {catterm = 1;} break; 1733 # line 556 "/usr/share/lib/ccs/yaccpar" 1734 } 1735 goto yystack; /* reset registers in driver code */ 1736 } 1737 1738