# line 2 "awk.y" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * awk -- YACC grammar * * Copyright (c) 1995 by Sun Microsystems, Inc. * * Copyright 1986, 1992 by Mortice Kern Systems Inc. All rights reserved. * * This Software is unpublished, valuable, confidential property of * Mortice Kern Systems Inc. Use is authorized only in accordance * with the terms and conditions of the source licence agreement * protecting this Software. Any unauthorized use or disclosure of * this Software is strictly prohibited and will result in the * termination of the licence agreement. * * NOTE: this grammar correctly produces NO shift/reduce conflicts from YACC. * */ /* * Do not use any character constants as tokens, so the resulting C file * is codeset independent. */ #ident "%Z%%M% %I% %E% SMI" #include "awk.h" static NODE * fliplist ANSI((NODE *np)); # line 51 "awk.y" typedef union #ifdef __cplusplus YYSTYPE #endif { NODE *node; } YYSTYPE; # define PARM 257 # define ARRAY 258 # define UFUNC 259 # define FIELD 260 # define IN 261 # define INDEX 262 # define CONCAT 263 # define NOT 264 # define AND 265 # define OR 266 # define EXP 267 # define QUEST 268 # define EQ 269 # define NE 270 # define GE 271 # define LE 272 # define GT 273 # define LT 274 # define ADD 275 # define SUB 276 # define MUL 277 # define DIV 278 # define REM 279 # define INC 280 # define DEC 281 # define PRE_INC 282 # define PRE_DEC 283 # define GETLINE 284 # define CALLFUNC 285 # define RE 286 # define TILDE 287 # define NRE 288 # define ASG 289 # define PRINT 290 # define PRINTF 291 # define EXIT 292 # define RETURN 293 # define BREAK 294 # define CONTINUE 295 # define NEXT 296 # define DELETE 297 # define WHILE 298 # define DO 299 # define FOR 300 # define FORIN 301 # define IF 302 # define CONSTANT 303 # define VAR 304 # define FUNC 305 # define DEFFUNC 306 # define BEGIN 307 # define END 308 # define CLOSE 309 # define ELSE 310 # define PACT 311 # define DOT 312 # define CALLUFUNC 313 # define KEYWORD 314 # define SVAR 315 # define PIPESYM 316 # define BAR 317 # define CARAT 318 # define LANGLE 319 # define RANGLE 320 # define PLUSC 321 # define HYPHEN 322 # define STAR 323 # define SLASH 324 # define PERCENT 325 # define EXCLAMATION 326 # define DOLLAR 327 # define LSQUARE 328 # define RSQUARE 329 # define LPAREN 330 # define RPAREN 331 # define SEMI 332 # define LBRACE 333 # define RBRACE 334 # define COMMA 335 # define PIPE 336 # define WRITE 337 # define APPEND 338 # define AADD 339 # define ASUB 340 # define AMUL 341 # define ADIV 342 # define AREM 343 # define AEXP 344 # define COLON 345 # define UPLUS 346 # define UMINUS 347 # define URE 348 #include #ifdef __STDC__ #include #include #define YYCONST const #else #include #include #define YYCONST #endif #include #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #ifndef yyerror #if defined(__cplusplus) void yyerror(YYCONST char *); #endif #endif #ifndef yylex int yylex(void); #endif int yyparse(void); #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 extern int yychar; extern int yyerrflag; YYSTYPE yylval; YYSTYPE yyval; typedef int yytabelem; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif #if YYMAXDEPTH > 0 int yy_yys[YYMAXDEPTH], *yys = yy_yys; YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; #else /* user does initial allocation */ int *yys; YYSTYPE *yyv; #endif static int yymaxdepth = YYMAXDEPTH; # define YYERRCODE 256 # line 530 "awk.y" /* * Flip a left-recursively generated list * so that it can easily be traversed from left * to right without recursion. */ static NODE * fliplist(np) register NODE *np; { int type; if (np!=NNULL && !isleaf(np->n_flags) #if 0 && (type = np->n_type)!=FUNC && type!=UFUNC #endif ) { np->n_right = fliplist(np->n_right); if ((type=np->n_type)==COMMA) { register NODE *lp; while ((lp = np->n_left)!=NNULL && lp->n_type==COMMA) { register NODE* *spp; lp->n_right = fliplist(lp->n_right); for (spp = &lp->n_right; *spp != NNULL && (*spp)->n_type==COMMA; spp = &(*spp)->n_right) ; np->n_left = *spp; *spp = np; np = lp; } } if (np->n_left != NULL && (type = np->n_left->n_type)!= FUNC && type!=UFUNC) np->n_left = fliplist(np->n_left); } return (np); } static YYCONST yytabelem yyexca[] ={ -1, 1, 0, -1, -2, 0, }; # define YYNPROD 109 # define YYLAST 943 static YYCONST yytabelem yyact[]={ 68, 28, 69, 25, 57, 58, 56, 59, 60, 61, 64, 65, 159, 150, 172, 170, 171, 172, 170, 171, 181, 217, 150, 234, 23, 22, 66, 67, 17, 200, 229, 230, 30, 150, 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 33, 183, 36, 18, 26, 24, 198, 150, 223, 151, 150, 222, 70, 150, 63, 62, 51, 52, 53, 54, 55, 21, 20, 28, 27, 25, 19, 15, 218, 199, 12, 194, 46, 47, 176, 189, 168, 167, 166, 108, 178, 107, 106, 29, 219, 216, 23, 22, 187, 186, 17, 172, 170, 171, 185, 192, 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 33, 177, 36, 18, 26, 24, 105, 56, 103, 102, 96, 95, 28, 69, 25, 94, 85, 56, 188, 190, 155, 21, 20, 28, 27, 221, 19, 15, 164, 142, 12, 28, 46, 47, 160, 23, 22, 56, 49, 17, 56, 181, 86, 169, 97, 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 33, 233, 36, 18, 26, 24, 51, 52, 53, 54, 55, 224, 28, 113, 25, 88, 51, 52, 53, 54, 55, 21, 20, 88, 27, 121, 19, 15, 48, 202, 12, 85, 46, 47, 100, 23, 22, 1, 15, 17, 13, 53, 54, 55, 7, 43, 44, 42, 41, 38, 37, 39, 40, 34, 35, 33, 2, 36, 18, 26, 24, 201, 182, 68, 4, 69, 3, 57, 58, 56, 59, 60, 61, 64, 65, 0, 21, 20, 14, 27, 31, 19, 15, 0, 0, 12, 98, 46, 47, 66, 67, 68, 0, 69, 82, 57, 58, 56, 59, 60, 61, 64, 65, 0, 78, 79, 174, 0, 156, 157, 158, 99, 0, 71, 0, 0, 0, 66, 67, 70, 0, 63, 62, 51, 52, 53, 54, 55, 120, 0, 179, 0, 0, 0, 68, 0, 69, 50, 57, 58, 56, 59, 60, 61, 64, 65, 0, 70, 0, 63, 62, 51, 52, 53, 54, 55, 0, 0, 0, 0, 66, 67, 119, 72, 73, 74, 75, 76, 77, 0, 0, 0, 0, 68, 0, 69, 0, 57, 58, 56, 59, 60, 61, 64, 65, 0, 0, 214, 0, 215, 70, 0, 63, 62, 51, 52, 53, 54, 55, 66, 67, 68, 0, 69, 220, 57, 58, 56, 59, 60, 61, 64, 65, 0, 68, 0, 69, 0, 57, 58, 56, 59, 60, 61, 64, 65, 0, 66, 67, 70, 0, 63, 62, 51, 52, 53, 54, 55, 0, 0, 66, 67, 0, 193, 0, 0, 0, 225, 206, 207, 208, 0, 0, 0, 0, 110, 28, 70, 25, 63, 62, 51, 52, 53, 54, 55, 0, 0, 0, 0, 70, 191, 63, 62, 51, 52, 53, 54, 55, 23, 22, 0, 0, 17, 152, 68, 0, 69, 0, 57, 58, 56, 59, 60, 61, 64, 65, 0, 112, 0, 0, 0, 18, 26, 24, 6, 9, 10, 0, 0, 231, 66, 67, 28, 0, 25, 0, 0, 0, 0, 21, 20, 0, 27, 0, 19, 15, 0, 28, 12, 25, 0, 5, 0, 0, 0, 23, 22, 0, 0, 17, 70, 0, 63, 62, 51, 52, 53, 54, 55, 0, 23, 22, 0, 0, 17, 0, 0, 161, 18, 26, 24, 68, 0, 69, 0, 57, 58, 56, 59, 60, 61, 64, 65, 18, 26, 24, 21, 20, 0, 27, 0, 19, 15, 0, 28, 12, 25, 66, 67, 0, 0, 21, 20, 0, 27, 0, 19, 15, 0, 0, 118, 0, 0, 0, 0, 0, 0, 23, 22, 0, 0, 17, 28, 0, 25, 0, 0, 0, 0, 63, 62, 51, 52, 53, 54, 55, 0, 0, 0, 0, 18, 26, 24, 0, 0, 23, 22, 0, 0, 0, 0, 0, 0, 0, 209, 0, 0, 0, 21, 20, 0, 27, 0, 19, 15, 0, 0, 114, 18, 26, 24, 68, 0, 69, 0, 57, 0, 56, 0, 60, 61, 64, 65, 226, 0, 0, 21, 20, 0, 27, 0, 19, 15, 0, 68, 84, 69, 66, 67, 0, 56, 0, 60, 61, 64, 65, 69, 0, 0, 0, 56, 0, 60, 61, 64, 65, 0, 0, 0, 0, 66, 67, 0, 0, 0, 16, 0, 0, 0, 63, 62, 51, 52, 53, 54, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 63, 62, 51, 52, 53, 54, 55, 45, 8, 115, 63, 62, 51, 52, 53, 54, 55, 0, 0, 0, 81, 0, 80, 0, 0, 0, 0, 89, 90, 91, 101, 0, 0, 0, 104, 0, 0, 8, 0, 0, 0, 0, 140, 0, 0, 0, 0, 0, 0, 111, 111, 116, 116, 0, 117, 0, 0, 0, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 162, 141, 0, 143, 144, 145, 146, 147, 148, 149, 0, 0, 0, 0, 0, 11, 153, 116, 0, 154, 0, 0, 101, 0, 0, 0, 116, 116, 116, 0, 0, 83, 0, 87, 111, 163, 0, 165, 92, 93, 0, 0, 0, 101, 0, 0, 81, 0, 173, 0, 81, 0, 175, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 0, 0, 0, 205, 0, 0, 180, 0, 0, 0, 0, 184, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 195, 196, 197, 0, 0, 0, 0, 0, 204, 0, 0, 0, 211, 203, 213, 0, 0, 0, 0, 111, 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, 0, 228, 0, 0, 0, 0, 0, 111, 0, 0, 232, 101, 0, 0, 0, 87 }; static YYCONST yytabelem yypact[]={ 164,-10000000,-10000000, -245, -301, -80, -111,-10000000, -33,-10000000, -10000000, -11, 221,-10000000,-10000000, 321, -202, -124,-10000000, 221, 221, 221, -124, -124, -205, -209, -210,-10000000,-10000000, 164, -80, -135,-10000000, -211, -212, -80, -214, -246, -247, -249, -124, 221, 221, 293, 236, -5,-10000000, -80,-10000000,-10000000, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, -116, 221, -145, 221, 221, 221, 221, 221, 221, 221,-10000000,-10000000, -278, 118,-10000000,-10000000, 221, 221, -189,-10000000,-10000000, -120, -120, -120,-10000000,-10000000, 221, 221, 221, -336,-10000000, -190, -10000000,-10000000, 221, 221, -160, 221,-10000000,-10000000,-10000000, -250, -251, 189, -252, -319, 221, -313, 189, -322, 221,-10000000, -256, -219, 189, -117, -117, -120, -120, -120, -120, 389, 366, -261, -140, -140, -140, -140, -140, -140, 399, 399, -10000000, -150, -124, 266, 266, 266, 266, 266, 266, 266, 221, -110,-10000000, 118, -284, 221, -233, -238, -239, -196, -10000000, -253, -132, 105, -231, 77,-10000000,-10000000,-10000000, -257, 221, 221, 221, -281, -259, -302,-10000000, -116, 221,-10000000, 189, -116,-10000000,-10000000, -140,-10000000,-10000000,-10000000,-10000000, 221, -116, -80, 221, -80,-10000000, 189, 189, 189, -241,-10000000, -241, -242,-10000000, -314, 266,-10000000,-10000000,-10000000,-10000000, -260, -243,-10000000, 38, -175, -277, -280,-10000000, -116, 221, -80, -10000000, -80,-10000000,-10000000, -303,-10000000, -300,-10000000,-10000000, -80, -80, -80,-10000000, -311,-10000000 }; static YYCONST yytabelem yypgo[]={ 0, 221, 231, 229, 715, 243, 799, 420, 226, 194, 706, 245, 153, 717, 178, 209, 205, 152, 681, 202, 190, 176, 166, 227, 154 }; static YYCONST yytabelem yyr1[]={ 0, 19, 1, 1, 2, 2, 2, 20, 21, 22, 2, 2, 2, 3, 3, 15, 15, 15, 14, 14, 13, 13, 8, 8, 9, 9, 7, 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 18, 18, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 16, 16, 16, 17, 17, 23 }; static YYCONST yytabelem yyr2[]={ 0, 3, 3, 7, 9, 7, 3, 1, 1, 1, 23, 5, 1, 2, 7, 3, 3, 3, 2, 1, 2, 7, 1, 2, 2, 7, 2, 1, 7, 7, 7, 7, 7, 7, 7, 7, 11, 7, 7, 7, 7, 7, 7, 7, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 11, 2, 2, 7, 5, 2, 9, 2, 2, 2, 2, 9, 5, 5, 5, 5, 5, 3, 11, 11, 11, 1, 9, 19, 15, 11, 13, 15, 11, 5, 5, 5, 7, 7, 7, 9, 13, 9, 13, 5, 3, 7, 2, 5, 5, 5, 5, 1, 5, 9, 9, 2, 1, 1 }; static YYCONST yytabelem yychk[]={ -10000000, -19, -1, -2, -3, 333, 306, -15, -4, 307, 308, -6, 330, -16, -5, 327, -18, 284, 303, 326, 322, 321, 281, 280, 305, 259, 304, 324, 257, 332, 333, -11, -10, 300, 298, 299, 302, 295, 294, 296, 297, 293, 292, 290, 291, -4, 332, 333, 304, 259, 335, 321, 322, 323, 324, 325, 267, 265, 266, 268, 269, 270, 320, 319, 271, 272, 287, 288, 261, 263, 317, 289, 339, 340, 341, 342, 343, 344, 280, 281, -13, -4, -5, -6, 330, 328, -17, -6, 304, -4, -4, -4, -6, -6, 330, 330, 330, -24, -1, -11, 334, -10, 330, 330, -10, 330, 332, 332, 332, -6, -7, -4, -7, -14, 330, -13, -4, -13, 330, 332, -11, -20, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -18, -4, 284, -4, -4, -4, -4, -4, -4, -4, 335, 331, 331, -4, -13, 319, -14, -14, -14, 348, 334, -7, -18, -4, 298, -4, 332, 332, 332, -12, 337, 338, 336, -13, -12, -13, 334, 330, 345, -17, -4, 261, -23, 329, -4, 331, 331, 331, 324, 332, 261, 331, 330, 331, 332, -4, -4, -4, 331, 332, 331, -8, -9, -18, -4, -18, -23, -23, -23, -7, -18, -10, -4, -10, -12, -12, 331, 335, 332, 331, 331, 310, 332, 332, -21, -9, -7, -10, -10, 333, 331, -11, -10, -22, 334 }; static YYCONST yytabelem yydef[]={ 12, -2, 1, 2, 6, 0, 0, 13, 17, 15, 16, 64, 0, 56, 57, 0, 60, 107, 65, 0, 0, 0, 0, 0, 72, 0, 62, 76, 63, 12, 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, 0, 27, 27, 19, 0, 0, 95, 0, 7, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 45, 0, 20, 59, 64, 0, 0, 103, 106, 62, 67, 68, 69, 70, 71, 19, 19, 19, 0, 3, 0, 5, 98, 27, 0, 0, 0, 84, 85, 86, 0, 0, 26, 0, 102, 0, 18, 20, 102, 0, 94, 0, 0, 14, 28, 29, 30, 31, 32, 33, 34, 35, 0, 46, 47, 48, 49, 50, 51, 52, 53, 54, 58, 107, 37, 38, 39, 40, 41, 42, 43, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0, 4, 0, 60, 0, 0, 0, 87, 88, 89, 0, 0, 0, 0, 0, 0, 0, 96, 22, 0, 104, 21, 0, 66, 61, 105, 108, 108, 108, 77, 27, 0, 0, 0, 0, 90, 99, 100, 101, 102, 92, 102, 0, 23, 24, 36, 55, 73, 74, 75, 0, 0, 80, 0, 83, 0, 0, 8, 0, 27, 0, 81, 0, 91, 93, 0, 25, 0, 79, 82, 0, 0, 9, 78, 0, 10 }; typedef struct #ifdef __cplusplus yytoktype #endif { #ifdef __cplusplus const #endif char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG yytoktype yytoks[] = { "PARM", 257, "ARRAY", 258, "UFUNC", 259, "FIELD", 260, "IN", 261, "INDEX", 262, "CONCAT", 263, "NOT", 264, "AND", 265, "OR", 266, "EXP", 267, "QUEST", 268, "EQ", 269, "NE", 270, "GE", 271, "LE", 272, "GT", 273, "LT", 274, "ADD", 275, "SUB", 276, "MUL", 277, "DIV", 278, "REM", 279, "INC", 280, "DEC", 281, "PRE_INC", 282, "PRE_DEC", 283, "GETLINE", 284, "CALLFUNC", 285, "RE", 286, "TILDE", 287, "NRE", 288, "ASG", 289, "PRINT", 290, "PRINTF", 291, "EXIT", 292, "RETURN", 293, "BREAK", 294, "CONTINUE", 295, "NEXT", 296, "DELETE", 297, "WHILE", 298, "DO", 299, "FOR", 300, "FORIN", 301, "IF", 302, "CONSTANT", 303, "VAR", 304, "FUNC", 305, "DEFFUNC", 306, "BEGIN", 307, "END", 308, "CLOSE", 309, "ELSE", 310, "PACT", 311, "DOT", 312, "CALLUFUNC", 313, "KEYWORD", 314, "SVAR", 315, "PIPESYM", 316, "BAR", 317, "CARAT", 318, "LANGLE", 319, "RANGLE", 320, "PLUSC", 321, "HYPHEN", 322, "STAR", 323, "SLASH", 324, "PERCENT", 325, "EXCLAMATION", 326, "DOLLAR", 327, "LSQUARE", 328, "RSQUARE", 329, "LPAREN", 330, "RPAREN", 331, "SEMI", 332, "LBRACE", 333, "RBRACE", 334, "COMMA", 335, "PIPE", 336, "WRITE", 337, "APPEND", 338, "AADD", 339, "ASUB", 340, "AMUL", 341, "ADIV", 342, "AREM", 343, "AEXP", 344, "COLON", 345, "UPLUS", 346, "UMINUS", 347, "URE", 348, "-unknown-", -1 /* ends search */ }; #ifdef __cplusplus const #endif char * yyreds[] = { "-no such reduction-", "dummy : prog", "prog : rule", "prog : rule SEMI prog", "rule : pattern LBRACE statlist RBRACE", "rule : LBRACE statlist RBRACE", "rule : pattern", "rule : DEFFUNC VAR", "rule : DEFFUNC VAR LPAREN varlist RPAREN", "rule : DEFFUNC VAR LPAREN varlist RPAREN LBRACE statlist", "rule : DEFFUNC VAR LPAREN varlist RPAREN LBRACE statlist RBRACE", "rule : DEFFUNC UFUNC", "rule : /* empty */", "pattern : simplepattern", "pattern : expr COMMA expr", "simplepattern : BEGIN", "simplepattern : END", "simplepattern : expr", "eexprlist : exprlist", "eexprlist : /* empty */", "exprlist : expr", "exprlist : exprlist COMMA expr", "varlist : /* empty */", "varlist : varlist2", "varlist2 : var", "varlist2 : var COMMA varlist2", "fexpr : expr", "fexpr : /* empty */", "expr : expr PLUSC expr", "expr : expr HYPHEN expr", "expr : expr STAR expr", "expr : expr SLASH expr", "expr : expr PERCENT expr", "expr : expr EXP expr", "expr : expr AND expr", "expr : expr OR expr", "expr : expr QUEST expr COLON expr", "expr : lvalue ASG expr", "expr : lvalue AADD expr", "expr : lvalue ASUB expr", "expr : lvalue AMUL expr", "expr : lvalue ADIV expr", "expr : lvalue AREM expr", "expr : lvalue AEXP expr", "expr : lvalue INC", "expr : lvalue DEC", "expr : expr EQ expr", "expr : expr NE expr", "expr : expr RANGLE expr", "expr : expr LANGLE expr", "expr : expr GE expr", "expr : expr LE expr", "expr : expr TILDE expr", "expr : expr NRE expr", "expr : expr IN var", "expr : LPAREN exprlist RPAREN IN var", "expr : getline", "expr : rvalue", "expr : expr CONCAT expr", "lvalue : DOLLAR rvalue", "lvalue : var", "lvalue : var LSQUARE exprlist RSQUARE", "var : VAR", "var : PARM", "rvalue : lvalue", "rvalue : CONSTANT", "rvalue : LPAREN expr RPAREN term", "rvalue : EXCLAMATION expr", "rvalue : HYPHEN expr", "rvalue : PLUSC expr", "rvalue : DEC lvalue", "rvalue : INC lvalue", "rvalue : FUNC", "rvalue : FUNC LPAREN eexprlist RPAREN term", "rvalue : UFUNC LPAREN eexprlist RPAREN term", "rvalue : VAR LPAREN eexprlist RPAREN term", "rvalue : SLASH", "rvalue : SLASH URE SLASH", "statement : FOR LPAREN fexpr SEMI fexpr SEMI fexpr RPAREN statement", "statement : FOR LPAREN var IN var RPAREN statement", "statement : WHILE LPAREN expr RPAREN statement", "statement : DO statement WHILE LPAREN expr RPAREN", "statement : IF LPAREN expr RPAREN statement ELSE statement", "statement : IF LPAREN expr RPAREN statement", "statement : CONTINUE SEMI", "statement : BREAK SEMI", "statement : NEXT SEMI", "statement : DELETE lvalue SEMI", "statement : RETURN fexpr SEMI", "statement : EXIT fexpr SEMI", "statement : PRINT eexprlist fileout SEMI", "statement : PRINT LPAREN exprlist RPAREN fileout SEMI", "statement : PRINTF exprlist fileout SEMI", "statement : PRINTF LPAREN exprlist RPAREN fileout SEMI", "statement : expr SEMI", "statement : SEMI", "statement : LBRACE statlist RBRACE", "statlist : statement", "statlist : statlist statement", "fileout : WRITE expr", "fileout : APPEND expr", "fileout : PIPE expr", "fileout : /* empty */", "getline : GETLINE optvar", "getline : expr BAR GETLINE optvar", "getline : GETLINE optvar LANGLE expr", "optvar : lvalue", "optvar : /* empty */", "term : /* empty */", }; #endif /* YYDEBUG */ # line 1 "/usr/share/lib/ccs/yaccpar" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1993 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" /* ** Skeleton parser driver for yacc output */ /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #define YYACCEPT return(0) #define YYABORT return(1) #define YYBACKUP( newtoken, newvalue )\ {\ if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #define YYNEW(type) malloc(sizeof(type) * yynewmax) #define YYCOPY(to, from, type) \ (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) #define YYENLARGE( from, type) \ (type *) realloc((char *) from, yynewmax * sizeof(type)) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-10000000) /* ** global variables used by the parser */ YYSTYPE *yypv; /* top of value stack */ int *yyps; /* top of state stack */ int yystate; /* current state */ int yytmp; /* extra var (lasts between blocks) */ int yynerrs; /* number of errors */ int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ #ifdef YYNMBCHARS #define YYLEX() yycvtok(yylex()) /* ** yycvtok - return a token if i is a wchar_t value that exceeds 255. ** If i<255, i itself is the token. If i>255 but the neither ** of the 30th or 31st bit is on, i is already a token. */ #if defined(__STDC__) || defined(__cplusplus) int yycvtok(int i) #else int yycvtok(i) int i; #endif { int first = 0; int last = YYNMBCHARS - 1; int mid; wchar_t j; if(i&0x60000000){/*Must convert to a token. */ if( yymbchars[last].character < i ){ return i;/*Giving up*/ } while ((last>=first)&&(first>=0)) {/*Binary search loop*/ mid = (first+last)/2; j = yymbchars[mid].character; if( j==i ){/*Found*/ return yymbchars[mid].tvalue; }else if( j= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ long yyps_index = (yy_ps - yys); long yypv_index = (yy_pv - yyv); long yypvt_index = (yypvt - yyv); int yynewmax; #ifdef YYEXPAND yynewmax = YYEXPAND(yymaxdepth); #else yynewmax = 2 * yymaxdepth; /* double table size */ if (yymaxdepth == YYMAXDEPTH) /* first time growth */ { char *newyys = (char *)YYNEW(int); char *newyyv = (char *)YYNEW(YYSTYPE); if (newyys != 0 && newyyv != 0) { yys = YYCOPY(newyys, yys, int); yyv = YYCOPY(newyyv, yyv, YYSTYPE); } else yynewmax = 0; /* failed */ } else /* not first time */ { yys = YYENLARGE(yys, int); yyv = YYENLARGE(yyv, YYSTYPE); if (yys == 0 || yyv == 0) yynewmax = 0; /* failed */ } #endif if (yynewmax <= yymaxdepth) /* tables not expanded */ { yyerror( "yacc stack overflow" ); YYABORT; } yymaxdepth = yynewmax; yy_ps = yys + yyps_index; yy_pv = yyv + yypv_index; yypvt = yyv + yypvt_index; } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register YYCONST int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; skip_init: yynerrs++; /* FALLTHRU */ case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; printf( "Error recovery discards " ); if ( yychar == 0 ) printf( "token end-of-file\n" ); else if ( yychar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 1: # line 149 "awk.y" { yytree = fliplist(yytree); } break; case 2: # line 154 "awk.y" { yytree = yypvt[-0].node; } break; case 3: # line 157 "awk.y" { if (yypvt[-2].node != NNULL) { if (yytree != NNULL) yytree = node(COMMA, yypvt[-2].node, yytree); else yytree = yypvt[-2].node; } } break; case 4: # line 166 "awk.y" { yyval.node = node(PACT, yypvt[-3].node, yypvt[-1].node); doing_begin = 0; } break; case 5: # line 170 "awk.y" { npattern++; yyval.node = node(PACT, NNULL, yypvt[-1].node); } break; case 6: # line 174 "awk.y" { yyval.node = node(PACT, yypvt[-0].node, node(PRINT, NNULL, NNULL)); doing_begin = 0; } break; case 7: # line 179 "awk.y" { yypvt[-0].node->n_type = UFUNC; funparm = 1; } break; case 8: # line 181 "awk.y" { funparm = 0; } break; case 9: # line 182 "awk.y" { uexit(yypvt[-4].node); } break; case 10: # line 182 "awk.y" { yypvt[-9].node->n_ufunc = node(DEFFUNC, yypvt[-6].node, fliplist(yypvt[-2].node)); yyval.node = NNULL; } break; case 11: # line 186 "awk.y" { awkerr((char *) gettext("function \"%S\" redefined"), yypvt[-0].node->n_name); /* NOTREACHED */ } break; case 12: # line 190 "awk.y" { yyval.node = NNULL; } break; case 14: # line 197 "awk.y" { ++npattern; yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); } break; case 15: # line 204 "awk.y" { yyval.node = node(BEGIN, NNULL, NNULL); doing_begin++; } break; case 16: # line 208 "awk.y" { ++npattern; yyval.node = node(END, NNULL, NNULL); } break; case 17: # line 212 "awk.y" { ++npattern; yyval.node = yypvt[-0].node; } break; case 19: # line 220 "awk.y" { yyval.node = NNULL; } break; case 21: # line 227 "awk.y" { yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); } break; case 22: # line 233 "awk.y" { yyval.node = NNULL; } break; case 25: # line 241 "awk.y" { yyval.node = node(COMMA, yypvt[-2].node, yypvt[-0].node); } break; case 27: # line 248 "awk.y" { yyval.node = NNULL; } break; case 28: # line 257 "awk.y" { yyval.node = node(ADD, yypvt[-2].node, yypvt[-0].node); } break; case 29: # line 260 "awk.y" { yyval.node = node(SUB, yypvt[-2].node, yypvt[-0].node); } break; case 30: # line 263 "awk.y" { yyval.node = node(MUL, yypvt[-2].node, yypvt[-0].node); } break; case 31: # line 266 "awk.y" { yyval.node = node(DIV, yypvt[-2].node, yypvt[-0].node); } break; case 32: # line 269 "awk.y" { yyval.node = node(REM, yypvt[-2].node, yypvt[-0].node); } break; case 33: # line 272 "awk.y" { yyval.node = node(EXP, yypvt[-2].node, yypvt[-0].node); } break; case 34: # line 275 "awk.y" { yyval.node = node(AND, yypvt[-2].node, yypvt[-0].node); } break; case 35: # line 278 "awk.y" { yyval.node = node(OR, yypvt[-2].node, yypvt[-0].node); } break; case 36: # line 281 "awk.y" { yyval.node = node(QUEST, yypvt[-4].node, node(COLON, yypvt[-2].node, yypvt[-0].node)); } break; case 37: # line 284 "awk.y" { yyval.node = node(ASG, yypvt[-2].node, yypvt[-0].node); } break; case 38: # line 287 "awk.y" { yyval.node = node(AADD, yypvt[-2].node, yypvt[-0].node); } break; case 39: # line 290 "awk.y" { yyval.node = node(ASUB, yypvt[-2].node, yypvt[-0].node); } break; case 40: # line 293 "awk.y" { yyval.node = node(AMUL, yypvt[-2].node, yypvt[-0].node); } break; case 41: # line 296 "awk.y" { yyval.node = node(ADIV, yypvt[-2].node, yypvt[-0].node); } break; case 42: # line 299 "awk.y" { yyval.node = node(AREM, yypvt[-2].node, yypvt[-0].node); } break; case 43: # line 302 "awk.y" { yyval.node = node(AEXP, yypvt[-2].node, yypvt[-0].node); } break; case 44: # line 305 "awk.y" { yyval.node = node(INC, yypvt[-1].node, NNULL); } break; case 45: # line 308 "awk.y" { yyval.node = node(DEC, yypvt[-1].node, NNULL); } break; case 46: # line 311 "awk.y" { yyval.node = node(EQ, yypvt[-2].node, yypvt[-0].node); } break; case 47: # line 314 "awk.y" { yyval.node = node(NE, yypvt[-2].node, yypvt[-0].node); } break; case 48: # line 317 "awk.y" { yyval.node = node(GT, yypvt[-2].node, yypvt[-0].node); } break; case 49: # line 320 "awk.y" { yyval.node = node(LT, yypvt[-2].node, yypvt[-0].node); } break; case 50: # line 323 "awk.y" { yyval.node = node(GE, yypvt[-2].node, yypvt[-0].node); } break; case 51: # line 326 "awk.y" { yyval.node = node(LE, yypvt[-2].node, yypvt[-0].node); } break; case 52: # line 329 "awk.y" { yyval.node = node(TILDE, yypvt[-2].node, yypvt[-0].node); } break; case 53: # line 332 "awk.y" { yyval.node = node(NRE, yypvt[-2].node, yypvt[-0].node); } break; case 54: # line 335 "awk.y" { yyval.node = node(IN, yypvt[-0].node, yypvt[-2].node); } break; case 55: # line 338 "awk.y" { yyval.node = node(IN, yypvt[-0].node, yypvt[-3].node); } break; case 58: # line 343 "awk.y" { yyval.node = node(CONCAT, yypvt[-2].node, yypvt[-0].node); } break; case 59: # line 349 "awk.y" { yyval.node = node(FIELD, yypvt[-0].node, NNULL); } break; case 61: # line 356 "awk.y" { yyval.node = node(INDEX, yypvt[-3].node, yypvt[-1].node); } break; case 66: # line 369 "awk.y" { yyval.node = yypvt[-2].node; } break; case 67: # line 372 "awk.y" { yyval.node = node(NOT, yypvt[-0].node, NNULL); } break; case 68: # line 375 "awk.y" { yyval.node = node(SUB, const0, yypvt[-0].node); } break; case 69: # line 378 "awk.y" { yyval.node = yypvt[-0].node; } break; case 70: # line 381 "awk.y" { yyval.node = node(PRE_DEC, yypvt[-0].node, NNULL); } break; case 71: # line 384 "awk.y" { yyval.node = node(PRE_INC, yypvt[-0].node, NNULL); } break; case 72: # line 387 "awk.y" { yyval.node = node(CALLFUNC, yypvt[-0].node, NNULL); } break; case 73: # line 390 "awk.y" { yyval.node = node(CALLFUNC, yypvt[-4].node, yypvt[-2].node); } break; case 74: # line 393 "awk.y" { yyval.node = node(CALLUFUNC, yypvt[-4].node, yypvt[-2].node); } break; case 75: # line 396 "awk.y" { yyval.node = node(CALLUFUNC, yypvt[-4].node, yypvt[-2].node); } break; case 76: # line 399 "awk.y" {redelim='/';} break; case 77: # line 399 "awk.y" { yyval.node = yypvt[-1].node; } break; case 78: # line 405 "awk.y" { yyval.node = node(FOR, node(COMMA, yypvt[-6].node, node(COMMA, yypvt[-4].node, yypvt[-2].node)), yypvt[-0].node); } break; case 79: # line 408 "awk.y" { register NODE *np; /* * attempt to optimize statements for the form * for (i in x) delete x[i] * to * delete x */ np = yypvt[-0].node; if (np != NNULL && np->n_type == DELETE && (np = np->n_left)->n_type == INDEX && np->n_left == yypvt[-2].node && np->n_right == yypvt[-4].node) yyval.node = node(DELETE, yypvt[-2].node, NNULL); else yyval.node = node(FORIN, node(IN, yypvt[-4].node, yypvt[-2].node), yypvt[-0].node); } break; case 80: # line 427 "awk.y" { yyval.node = node(WHILE, yypvt[-2].node, yypvt[-0].node); } break; case 81: # line 430 "awk.y" { yyval.node = node(DO, yypvt[-1].node, yypvt[-4].node); } break; case 82: # line 433 "awk.y" { yyval.node = node(IF, yypvt[-4].node, node(ELSE, yypvt[-2].node, yypvt[-0].node)); } break; case 83: # line 436 "awk.y" { yyval.node = node(IF, yypvt[-2].node, node(ELSE, yypvt[-0].node, NNULL)); } break; case 84: # line 439 "awk.y" { yyval.node = node(CONTINUE, NNULL, NNULL); } break; case 85: # line 442 "awk.y" { yyval.node = node(BREAK, NNULL, NNULL); } break; case 86: # line 445 "awk.y" { yyval.node = node(NEXT, NNULL, NNULL); } break; case 87: # line 448 "awk.y" { yyval.node = node(DELETE, yypvt[-1].node, NNULL); } break; case 88: # line 451 "awk.y" { yyval.node = node(RETURN, yypvt[-1].node, NNULL); } break; case 89: # line 454 "awk.y" { yyval.node = node(EXIT, yypvt[-1].node, NNULL); } break; case 90: # line 457 "awk.y" { yyval.node = node(PRINT, yypvt[-2].node, yypvt[-1].node); } break; case 91: # line 460 "awk.y" { yyval.node = node(PRINT, yypvt[-3].node, yypvt[-1].node); } break; case 92: # line 463 "awk.y" { yyval.node = node(PRINTF, yypvt[-2].node, yypvt[-1].node); } break; case 93: # line 466 "awk.y" { yyval.node = node(PRINTF, yypvt[-3].node, yypvt[-1].node); } break; case 94: # line 469 "awk.y" { yyval.node = yypvt[-1].node; } break; case 95: # line 472 "awk.y" { yyval.node = NNULL; } break; case 96: # line 475 "awk.y" { yyval.node = yypvt[-1].node; } break; case 98: # line 483 "awk.y" { if (yypvt[-1].node == NNULL) yyval.node = yypvt[-0].node; else if (yypvt[-0].node == NNULL) yyval.node = yypvt[-1].node; else yyval.node = node(COMMA, yypvt[-1].node, yypvt[-0].node); } break; case 99: # line 494 "awk.y" { yyval.node = node(WRITE, yypvt[-0].node, NNULL); } break; case 100: # line 497 "awk.y" { yyval.node = node(APPEND, yypvt[-0].node, NNULL); } break; case 101: # line 500 "awk.y" { yyval.node = node(PIPE, yypvt[-0].node, NNULL); } break; case 102: # line 503 "awk.y" { yyval.node = NNULL; } break; case 103: # line 509 "awk.y" { yyval.node = node(GETLINE, yypvt[-0].node, NNULL); } break; case 104: # line 512 "awk.y" { yyval.node = node(GETLINE, yypvt[-0].node, node(PIPESYM, yypvt[-3].node, NNULL)); } break; case 105: # line 515 "awk.y" { yyval.node = node(GETLINE, yypvt[-2].node, node(LT, yypvt[-0].node, NNULL)); } break; case 107: # line 522 "awk.y" { yyval.node = NNULL; } break; case 108: # line 528 "awk.y" {catterm = 1;} break; # line 556 "/usr/share/lib/ccs/yaccpar" } goto yystack; /* reset registers in driver code */ }