home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
GAWKNT.ZIP
/
SRC.ZIP
/
AWKTAB.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-07
|
108KB
|
3,300 lines
/* A Bison parser, made from awk.y */
#define YYBISON 1 /* Identify Bison output. */
#define FUNC_CALL 258
#define NAME 259
#define REGEXP 260
#define ERROR 261
#define YNUMBER 262
#define YSTRING 263
#define RELOP 264
#define APPEND_OP 265
#define ASSIGNOP 266
#define MATCHOP 267
#define NEWLINE 268
#define CONCAT_OP 269
#define LEX_BEGIN 270
#define LEX_END 271
#define LEX_IF 272
#define LEX_ELSE 273
#define LEX_RETURN 274
#define LEX_DELETE 275
#define LEX_WHILE 276
#define LEX_DO 277
#define LEX_FOR 278
#define LEX_BREAK 279
#define LEX_CONTINUE 280
#define LEX_PRINT 281
#define LEX_PRINTF 282
#define LEX_NEXT 283
#define LEX_EXIT 284
#define LEX_FUNCTION 285
#define LEX_GETLINE 286
#define LEX_IN 287
#define LEX_AND 288
#define LEX_OR 289
#define INCREMENT 290
#define DECREMENT 291
#define LEX_BUILTIN 292
#define LEX_LENGTH 293
#define UNARY 294
#line 26 "awk.y"
#ifdef DEBUG
#define YYDEBUG 12
#endif
#include "awk.h"
static void yyerror (); /* va_alist */
static char *get_src_buf P((void));
static int yylex P((void));
static NODE *node_common P((NODETYPE op));
static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
static NODE *mkrangenode P((NODE *cpair));
static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
static NODE *append_right P((NODE *list, NODE *new));
static void func_install P((NODE *params, NODE *def));
static void pop_var P((NODE *np, int freeit));
static void pop_params P((NODE *params));
static NODE *make_param P((char *name));
static NODE *mk_rexp P((NODE *exp));
static int want_assign; /* lexical scanning kludge */
static int want_regexp; /* lexical scanning kludge */
static int can_return; /* lexical scanning kludge */
static int io_allowed = 1; /* lexical scanning kludge */
static char *lexptr; /* pointer to next char during parsing */
static char *lexend;
static char *lexptr_begin; /* keep track of where we were for error msgs */
static char *lexeme; /* beginning of lexeme for debugging */
static char *thisline = NULL;
#define YYDEBUG_LEXER_TEXT (lexeme)
static int param_counter;
static char *tokstart = NULL;
static char *tok = NULL;
static char *tokend;
#define HASHSIZE 1021 /* this constant only used here */
NODE *variables[HASHSIZE];
extern char *source;
extern int sourceline;
extern struct src *srcfiles;
extern int numfiles;
extern int errcount;
extern NODE *begin_block;
extern NODE *end_block;
#line 74 "awk.y"
typedef union {
long lval;
AWKNUM fval;
NODE *nodeval;
NODETYPE nodetypeval;
char *sval;
NODE *(*ptrval)();
} YYSTYPE;
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#include <stdio.h>
#ifndef __STDC__
#define const
#endif
#define YYFINAL 307
#define YYFLAG -32768
#define YYNTBASE 61
#define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 106)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 50, 2, 2, 53, 49, 2, 2, 54,
55, 47, 45, 41, 46, 2, 48, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 40, 60, 42,
2, 43, 39, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
56, 2, 57, 52, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 58, 44, 59, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 51
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 4, 6, 9, 11, 14, 15, 19, 20, 24,
27, 30, 33, 35, 38, 41, 43, 45, 47, 49,
51, 52, 60, 65, 67, 71, 72, 77, 83, 88,
90, 93, 95, 98, 100, 103, 106, 109, 113, 115,
122, 131, 140, 151, 161, 164, 167, 174, 179, 183,
187, 188, 193, 200, 204, 207, 209, 211, 218, 228,
230, 233, 234, 236, 237, 240, 241, 244, 247, 250,
251, 253, 255, 259, 261, 264, 268, 269, 271, 272,
274, 276, 280, 282, 285, 289, 293, 294, 296, 298,
302, 304, 307, 311, 315, 316, 321, 327, 332, 336,
340, 344, 348, 350, 353, 357, 361, 365, 369, 375,
377, 380, 381, 386, 390, 394, 398, 400, 403, 407,
411, 415, 421, 423, 426, 428, 432, 436, 440, 444,
448, 452, 455, 458, 461, 465, 470, 475, 477, 482,
484, 487, 490, 492, 494, 497, 500, 501, 503, 505,
510, 513, 516, 519, 521, 522, 524, 526
};
#endif
static const short yyrhs[] = { 82,
62, 82, 0, 63, 0, 62, 63, 0, 1, 0,
62, 1, 0, 0, 15, 64, 74, 0, 0, 16,
65, 74, 0, 15, 76, 0, 16, 76, 0, 71,
74, 0, 74, 0, 71, 76, 0, 68, 70, 0,
4, 0, 3, 0, 67, 0, 37, 0, 38, 0,
0, 30, 69, 66, 54, 85, 102, 82, 0, 100,
75, 101, 103, 0, 92, 0, 92, 41, 92, 0,
0, 48, 73, 5, 48, 0, 100, 75, 101, 103,
82, 0, 100, 101, 103, 82, 0, 77, 0, 75,
77, 0, 1, 0, 75, 1, 0, 81, 0, 104,
82, 0, 104, 82, 0, 100, 101, 0, 100, 75,
101, 0, 80, 0, 21, 54, 92, 102, 82, 77,
0, 22, 82, 77, 21, 54, 92, 102, 82, 0,
23, 54, 4, 32, 4, 102, 82, 77, 0, 23,
54, 87, 104, 92, 104, 87, 102, 82, 77, 0,
23, 54, 87, 104, 104, 87, 102, 82, 77, 0,
24, 76, 0, 25, 76, 0, 79, 54, 91, 102,
84, 76, 0, 79, 88, 84, 76, 0, 28, 87,
76, 0, 29, 87, 76, 0, 0, 19, 78, 87,
76, 0, 20, 4, 56, 91, 57, 76, 0, 20,
4, 76, 0, 92, 76, 0, 26, 0, 27, 0,
17, 54, 92, 102, 82, 77, 0, 17, 54, 92,
102, 82, 77, 18, 82, 77, 0, 13, 0, 81,
13, 0, 0, 81, 0, 0, 42, 96, 0, 0,
43, 92, 0, 10, 92, 0, 44, 92, 0, 0,
86, 0, 4, 0, 86, 105, 4, 0, 1, 0,
86, 1, 0, 86, 105, 1, 0, 0, 92, 0,
0, 89, 0, 94, 0, 89, 105, 94, 0, 1,
0, 89, 1, 0, 89, 1, 94, 0, 89, 105,
1, 0, 0, 91, 0, 92, 0, 91, 105, 92,
0, 1, 0, 91, 1, 0, 91, 1, 92, 0,
91, 105, 1, 0, 0, 99, 11, 93, 92, 0,
54, 91, 102, 32, 4, 0, 92, 44, 31, 98,
0, 31, 98, 83, 0, 92, 33, 92, 0, 92,
34, 92, 0, 92, 12, 92, 0, 72, 0, 50,
72, 0, 92, 32, 4, 0, 92, 9, 92, 0,
92, 42, 92, 0, 92, 43, 92, 0, 92, 39,
92, 40, 92, 0, 96, 0, 92, 96, 0, 0,
99, 11, 95, 94, 0, 94, 33, 94, 0, 94,
34, 94, 0, 31, 98, 83, 0, 72, 0, 50,
72, 0, 94, 12, 94, 0, 94, 32, 4, 0,
94, 9, 94, 0, 94, 39, 94, 40, 94, 0,
96, 0, 94, 96, 0, 97, 0, 96, 52, 96,
0, 96, 47, 96, 0, 96, 48, 96, 0, 96,
49, 96, 0, 96, 45, 96, 0, 96, 46, 96,
0, 99, 35, 0, 99, 36, 0, 50, 96, 0,
54, 92, 102, 0, 37, 54, 90, 102, 0, 38,
54, 90, 102, 0, 38, 0, 3, 54, 90, 102,
0, 99, 0, 35, 99, 0, 36, 99, 0, 7,
0, 8, 0, 46, 96, 0, 45, 96, 0, 0,
99, 0, 4, 0, 4, 56, 91, 57, 0, 53,
97, 0, 58, 82, 0, 59, 82, 0, 55, 0,
0, 104, 0, 60, 0, 41, 82, 0
};
#if YYDEBUG != 0
static const short yyrline[] = { 0,
135, 140, 148, 164, 165, 169, 171, 185, 187, 201,
207, 213, 215, 217, 230, 239, 241, 243, 253, 254,
258, 262, 270, 279, 281, 290, 292, 310, 312, 317,
319, 327, 329, 334, 335, 339, 341, 343, 345, 347,
349, 351, 356, 360, 365, 368, 371, 373, 384, 411,
413, 415, 417, 419, 433, 438, 440, 445, 450, 457,
459, 463, 464, 468, 470, 475, 477, 479, 481, 486,
488, 493, 495, 497, 499, 501, 507, 509, 514, 516,
521, 523, 529, 531, 533, 535, 540, 542, 547, 549,
555, 557, 559, 561, 566, 569, 574, 576, 581, 587,
589, 591, 597, 599, 607, 609, 615, 617, 619, 621,
623, 628, 631, 632, 634, 636, 642, 644, 646, 648,
650, 652, 654, 656, 661, 663, 665, 667, 669, 671,
673, 675, 677, 682, 684, 686, 689, 691, 699, 703,
704, 706, 708, 710, 713, 720, 725, 727, 732, 734,
742, 747, 751, 755, 759, 760, 764, 767
};
static const char * const yytname[] = { "$","error","$illegal.","FUNC_CALL",
"NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
"NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
"LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
"LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_IN","LEX_AND",
"LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'","','",
"'<'","'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY","'^'","'$'","'('",
"')'","'['","']'","'{'","'}'","';'","start","program","rule","@1","@2","func_name",
"lex_builtin","function_prologue","@3","function_body","pattern","regexp","@4",
"action","statements","statement_term","statement","@5","print","if_statement",
"nls","opt_nls","input_redir","output_redir","opt_param_list","param_list","opt_exp",
"opt_rexpression_list","rexpression_list","opt_expression_list","expression_list",
"exp","@6","rexp","@7","simp_exp","non_post_simp_exp","opt_variable","variable",
"l_brace","r_brace","r_paren","opt_semi","semi","comma",""
};
#endif
static const short yyr1[] = { 0,
61, 62, 62, 62, 62, 64, 63, 65, 63, 63,
63, 63, 63, 63, 63, 66, 66, 66, 67, 67,
69, 68, 70, 71, 71, 73, 72, 74, 74, 75,
75, 75, 75, 76, 76, 77, 77, 77, 77, 77,
77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
78, 77, 77, 77, 77, 79, 79, 80, 80, 81,
81, 82, 82, 83, 83, 84, 84, 84, 84, 85,
85, 86, 86, 86, 86, 86, 87, 87, 88, 88,
89, 89, 89, 89, 89, 89, 90, 90, 91, 91,
91, 91, 91, 91, 93, 92, 92, 92, 92, 92,
92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
92, 95, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 96, 96, 96, 96, 96, 96,
96, 96, 96, 97, 97, 97, 97, 97, 97, 97,
97, 97, 97, 97, 97, 97, 98, 98, 99, 99,
99, 100, 101, 102, 103, 103, 104, 105
};
static const short yyr2[] = { 0,
3, 1, 2, 1, 2, 0, 3, 0, 3, 2,
2, 2, 1, 2, 2, 1, 1, 1, 1, 1,
0, 7, 4, 1, 3, 0, 4, 5, 4, 1,
2, 1, 2, 1, 2, 2, 2, 3, 1, 6,
8, 8, 10, 9, 2, 2, 6, 4, 3, 3,
0, 4, 6, 3, 2, 1, 1, 6, 9, 1,
2, 0, 1, 0, 2, 0, 2, 2, 2, 0,
1, 1, 3, 1, 2, 3, 0, 1, 0, 1,
1, 3, 1, 2, 3, 3, 0, 1, 1, 3,
1, 2, 3, 3, 0, 4, 5, 4, 3, 3,
3, 3, 1, 2, 3, 3, 3, 3, 5, 1,
2, 0, 4, 3, 3, 3, 1, 2, 3, 3,
3, 5, 1, 2, 1, 3, 3, 3, 3, 3,
3, 2, 2, 2, 3, 4, 4, 1, 4, 1,
2, 2, 1, 1, 2, 2, 0, 1, 1, 4,
2, 2, 2, 1, 0, 1, 1, 2
};
static const short yydefact[] = { 62,
60, 63, 0, 61, 4, 0, 149, 143, 144, 6,
8, 21, 147, 0, 0, 0, 138, 0, 0, 26,
0, 0, 0, 62, 0, 2, 0, 0, 103, 13,
24, 110, 125, 140, 0, 0, 0, 157, 0, 10,
34, 62, 0, 11, 0, 64, 148, 141, 142, 0,
0, 0, 0, 146, 140, 145, 0, 104, 134, 151,
140, 91, 0, 89, 152, 5, 3, 1, 15, 0,
12, 14, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 111, 0, 0, 0, 0, 0, 0, 95,
132, 133, 32, 0, 51, 0, 0, 62, 0, 0,
0, 56, 57, 77, 77, 62, 0, 30, 0, 39,
0, 0, 155, 62, 0, 0, 89, 0, 7, 35,
9, 17, 16, 19, 20, 0, 18, 0, 99, 0,
0, 0, 0, 92, 62, 154, 0, 0, 135, 0,
106, 102, 105, 100, 101, 0, 25, 107, 108, 147,
130, 131, 127, 128, 129, 126, 0, 0, 77, 0,
0, 0, 77, 45, 46, 0, 78, 0, 153, 33,
31, 155, 83, 147, 0, 0, 117, 66, 0, 81,
123, 140, 55, 0, 37, 62, 156, 36, 139, 150,
0, 65, 136, 137, 27, 93, 158, 0, 94, 90,
155, 0, 98, 96, 0, 0, 0, 54, 0, 0,
149, 0, 49, 50, 62, 64, 118, 0, 0, 0,
0, 0, 84, 0, 0, 0, 0, 0, 0, 0,
124, 112, 38, 29, 74, 72, 0, 0, 97, 23,
109, 62, 52, 0, 62, 0, 0, 0, 28, 116,
66, 68, 67, 69, 48, 85, 86, 82, 121, 119,
120, 114, 115, 0, 0, 62, 75, 0, 0, 0,
0, 0, 0, 0, 77, 0, 0, 113, 22, 76,
73, 58, 53, 40, 0, 62, 77, 0, 47, 122,
62, 62, 0, 0, 62, 0, 41, 42, 62, 0,
59, 0, 44, 43, 0, 0, 0
};
static const short yydefgoto[] = { 305,
25, 26, 39, 43, 126, 127, 27, 45, 69, 28,
29, 57, 30, 107, 40, 108, 159, 109, 110, 2,
3, 129, 222, 237, 238, 166, 178, 179, 115, 116,
111, 157, 180, 265, 32, 33, 46, 34, 112, 113,
139, 186, 42, 138
};
static const short yypact[] = { 6,
-32768, 10, 1082,-32768,-32768, -33, -16,-32768,-32768, 4,
4,-32768, 31, 31, 31, 14, 44, 1746, 1746,-32768,
1740, 1746, 1155, 6, 874,-32768, 46, 0,-32768,-32768,
1324, 284,-32768, 18, 654, 433, 1155,-32768, 46,-32768,
10, 6, 46,-32768, 88, 65,-32768,-32768,-32768, 433,
433, 1746, 1536, 59, 58, 59, 111,-32768, 59,-32768,
-32768,-32768, 40, 1271,-32768,-32768,-32768,-32768,-32768, 790,
-32768,-32768, 1536, 1536, 117, 1536, 1536, 1536, 1536, 1536,
1536, 99, 284, 1746, 1746, 1746, 1746, 1746, 1746,-32768,
-32768,-32768,-32768, 69,-32768, 132, 79, 6, 83, 4,
4,-32768,-32768, 1536, 1536, 6, 742,-32768, 848,-32768,
980, 654, 80, 6, 84, 42, 1420, 8,-32768,-32768,
-32768,-32768,-32768,-32768,-32768, 90,-32768, 1746,-32768, 84,
84, 1271, 97, 1536, 6,-32768, 106, 1175,-32768, 742,
1807, 1794,-32768, 1556, 1468, 1372, 1420, 1807, 1807, 31,
129, 129, 59, 59, 59, 59, 1536, 1536, 1536, 50,
1536, 922, 1664,-32768,-32768, 4, 1420, 4,-32768,-32768,
-32768, 80,-32768, 31, 1740, 1155,-32768, 75, 1, 1604,
284, 92,-32768, 742,-32768, 6,-32768,-32768,-32768,-32768,
11, 284,-32768,-32768,-32768, 1420,-32768, 145,-32768, 1420,
80, 1536,-32768, 1420, 1271, 4, 1155,-32768, 1271, 138,
57, 80,-32768,-32768, 6, 65,-32768, 40, 1536, 1536,
1536, 4, 1720, 1223, 1720, 1720, 146, 1720, 1720, 1720,
284,-32768,-32768,-32768,-32768,-32768, 84, 45,-32768,-32768,
1420, 6,-32768, 15, 6, 110, 149, 1107,-32768,-32768,
75, 1420, 1420, 1420,-32768, 1604,-32768, 1604, 549, 139,
-32768, 1684, 1644, 1516, 1720, 6,-32768, 35, 922, 4,
922, 1536, 84, 1034, 1536, 4, 1720, 1604,-32768,-32768,
-32768, 147,-32768,-32768, 1271, 6, 1536, 84,-32768, 1604,
6, 6, 922, 84, 6, 922,-32768,-32768, 6, 922,
-32768, 922,-32768,-32768, 172, 180,-32768
};
static const short yypgoto[] = {-32768,
-32768, 157,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
78,-32768, 81, 17, 94, -50,-32768,-32768,-32768, 41,
-18, -26, -60,-32768,-32768, -104,-32768,-32768, 64, -19,
-3,-32768, -198,-32768, 363, 174, -42, 148, 183, -102,
324, -164, 458, -176
};
#define YYLAST 1861
static const short yytable[] = { 31,
168, 223, 224, 63, 172, 65, 68, 215, 134, 185,
-80, 235, 1, -80, 236, 134, 1, 118, 1, 64,
36, 31, 4, 120, 256, 258, 259, 260, 90, 262,
263, 264, 117, 117, 7, 280, 240, 201, 281, 37,
134, 135, 134, -80, -80, 267, 117, 117, 135, 132,
41, 41, 91, 92, 206, 135, 171, 24, 212, 38,
-80, 268, 1, 38, 190, -70, 278, 50, 41, 141,
142, 270, 144, 145, 146, 147, 148, 149, 290, 162,
135, 233, 135, 22, 219, 135, 140, 169, 247, 171,
122, 123, 91, 92, 136, 188, -88, 51, 58, -71,
167, 167, 232, 24, 44, 207, 128, 203, 71, 38,
89, 210, 37, 130, 131, 133, 197, 220, 221, 119,
143, 72, 158, 121, 124, 125, 91, 92, 184, 150,
196, 216, 161, 171, 200, 160, 163, 198, 136, 38,
41, 41, 7, 191, 195, 8, 9, 225, 239, 261,
-32768, 41, 273, 204, 205, 167, 218, 209, 246, 167,
47, 48, 49, 272, 291, 55, 55, 234, 55, 61,
288, 306, 64, 14, 15, 86, 87, 88, 55, 307,
89, 67, 294, 18, 19, 35, 177, 244, 52, 250,
276, 22, 53, 164, 165, 60, 249, 0, 241, 55,
41, 0, 0, 117, 183, 0, 41, 35, 41, 70,
35, 55, 0, 0, 0, 252, 253, 254, 282, 0,
284, 35, 0, 269, 0, 35, 271, 0, 0, 0,
0, 55, 55, 55, 55, 55, 55, 0, 0, 0,
0, 0, 298, 0, 274, 301, 41, 279, 0, 303,
0, 304, 217, 208, 0, 0, 182, 0, 55, 213,
0, 214, 41, 0, 55, 0, 0, 293, 285, 0,
0, 167, 296, 297, 0, 55, 300, 0, 0, 55,
302, 0, 0, 167, 0, 0, 0, 0, 55, 55,
0, 55, 55, 55, 55, 55, 55, 47, 0, 243,
177, 177, 177, 177, 0, 177, 177, 177, 0, 0,
41, 0, 0, 0, 55, 255, 41, 0, 0, 0,
0, 47, 55, 0, 0, 0, 0, 55, 84, 85,
86, 87, 88, 0, 0, 89, 0, 0, 0, 0,
0, 0, 177, 55, 0, 0, 0, 55, 0, 0,
0, 55, 55, 0, 177, 0, 55, 0, 0, 0,
0, 0, 0, 283, 0, 0, 0, 0, 0, 289,
182, 182, 182, 182, 0, 182, 182, 182, 0, 0,
54, 56, 0, 59, 0, 0, 137, 0, 55, 0,
0, 0, 0, 83, 0, 0, 0, 0, 0, 55,
55, 55, 0, 55, 0, 55, 55, 55, 0, 55,
55, 55, 182, 0, 59, 0, 0, 0, 0, 0,
0, 55, 0, 0, 182, 55, 83, 0, 0, 0,
0, 0, 55, 62, 0, 6, 7, 55, 189, 8,
9, 0, 0, 0, 0, 0, 151, 152, 153, 154,
155, 156, 0, 193, 194, 0, 0, 0, 0, 0,
0, 0, 0, 13, 0, 0, 0, 14, 15, 16,
17, 181, 0, 83, 0, 0, 0, 18, 19, 83,
20, 0, 21, 0, 0, 22, 23, -87, 0, 0,
192, 0, 114, 0, 83, 0, 0, 0, 0, 0,
0, 0, 0, 83, 83, 0, 83, 83, 83, 83,
83, 83, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 114, 242, 83,
0, 0, 245, 0, 0, 0, 0, 59, 0, 0,
0, 251, 231, 0, 0, 0, 0, 0, 0, 0,
0, 0, 7, 0, 0, 8, 9,-32768, 83, 0,
266, 0, 83, 0, 114, 0, 83, 83, 0, 114,
187, 83, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 14, 15, 181, 181, 181, 181, 0,
181, 181, 181, 18, 19, 0, 286, 114, 52, 0,
0, 22, 53, 83, 0, 0, 0, 0, 292, 0,
0, 295, 0, 0, 83, 83, 83, 299, 231, 114,
231, 231, 231, 0, 231, 231, 231, 181, 0, 187,
0, 0, 0, 0, 0, 0, 83, 0, 0, 181,
231, 114, 0, 0, 0, 0, 0, 83, 0, 0,
0, 0, 231, 0, 93, 0, 6, 7, 187, 0,
8, 9, 0, 0, 0, 0, 0, 0, 0, 248,
94, 0, 95, 96, 97, 98, 99, 100, 101, 102,
103, 104, 105, 0, 13, 0, 0, 0, 14, 15,
16, 17, 0, 0, 0, 0, 0, 0, 18, 19,
0, 20, 0, 21, 0, 275, 22, 23, 0, 0,
0, 24, 106, 38, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 114, 0, 114, 0,
0, 287, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 170, 0, 6, 7, 0, 0, 8, 9,
114, 0, 0, 114, 0, 0, 0, 114, 94, 114,
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 0, 13, 0, 0, 0, 14, 15, 16, 17,
0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
93, 21, 6, 7, 22, 23, 8, 9, 0, 24,
106, 38, 0, 0, 0, 0, 94, 0, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 0,
13, 0, 0, 0, 14, 15, 16, 17, 0, 0,
0, 0, 0, 0, 18, 19, 0, 20, 0, 21,
0, 0, 22, 23, 0, 0, 0, 24, 173, 38,
6, 7, 0, 0, 8, 9, 0, -79, 0, 0,
-79, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, -62, 66, 0, 6, 7, 174, 0,
8, 9, 14, 15, 16, 17, 1, 0, 10, 11,
-79, -79, 18, 19, 0, 20, 0, 175, 0, 0,
22, 176, 0, 12, 13, 0, 0, -79, 14, 15,
16, 17, 0, 0, 0, 0, 0, 0, 18, 19,
0, 20, 0, 21, 6, 7, 22, 23, 8, 9,
0, 24, 0, 0, 0, 0, 0, 0, 94, 0,
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 0, 13, 0, 0, 0, 14, 15, 16, 17,
0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
0, 21, 0, 0, 22, 23, 0, 0, 0, 24,
0, 38, 6, 7, 0, 0, 8, 9, 73, 0,
0, 74, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 75, 76, 77, 14, 15, 16, 17, 78, 0,
0, 80, 81, 82, 18, 19, 0, 0, 0, 52,
0, 0, 22, 53, 0, 0, 6, 7, 0, 38,
8, 9, 73, 0, 0, 74, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 75, 76, 77, 14, 15,
16, 17, 78, 0, 0, 80, 81, 82, 18, 19,
0, 0, 5, 52, 6, 7, 22, 53, 8, 9,
0, 0, 0, 38, 0, 0, 10, 11, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
7, 12, 13, 8, 9, 0, 14, 15, 16, 17,
0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
0, 21, 0, 0, 22, 23, 0, 13, 0, 24,
0, 14, 15, 16, 17, 0, 0, 0, 0, 0,
0, 18, 19, 0, 20, 62, 21, 6, 7, 22,
23, 8, 9, 0, 0, 0, 38, 0, 0, 0,
0, 0, 0, 0, 0, 199, 0, 6, 7, 0,
0, 8, 9, 0, 0, 13, 0, 0, 0, 14,
15, 16, 17, 0, 0, 0, 0, 0, 0, 18,
19, 0, 20, 0, 21, 13, 0, 22, 23, 14,
15, 16, 17, 0, 0, 0, 0, 0, 0, 18,
19, 0, 20, 257, 21, 6, 7, 22, 23, 8,
9, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 174, 0, 0, 0, 14, 15, 16,
17, 0, 0, 0, 0, 0, 0, 18, 19, 0,
20, 0, 175, 6, 7, 22, 53, 8, 9, 73,
0, 0, 74, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 75, 76, 77, 14, 15, 16, 17, 78,
0, 0, 80, 81, 82, 18, 19, 0, 0, 0,
52, 0, 0, 22, 53, 136, 6, 7, 0, 0,
8, 9, 73, 0, 0, 74, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 75, 76, 77, 14, 15,
16, 17, 78, 0, 79, 80, 81, 82, 18, 19,
0, 0, 0, 52, 6, 7, 22, 53, 8, 9,
73, 0, 0, 74, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 75, 76, 77, 14, 15, 16, 17,
78, 202, 0, 80, 81, 82, 18, 19, 0, 0,
0, 52, 6, 7, 22, 53, 8, 9, 73, 0,
0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 75, 76, 77, 14, 15, 16, 17, 78, 0,
0, 80, 81, 82, 18, 19, 0, 0, 0, 52,
6, 7, 22, 53, 8, 9, 73, 0, 0, 74,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
76, 0, 14, 15, 16, 17, 0, 0, 0, 80,
81, 82, 18, 19, 0, 0, 0, 52, 6, 7,
22, 53, 8, 9, 225, 0, 0, 226, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 6, 7,
0, 0, 8, 9, 0, 0, 0, 227, 228, 229,
14, 15, 16, 17, 230, 277, 0, 0, 6, 7,
18, 19, 8, 9, 73, 52, 13, 74, 22, 53,
14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
18, 19, 0, 20, 0, 21, 0, 75, 22, 23,
14, 15, 16, 17, 0, 0, 0, 80, 81, 82,
18, 19, 0, 0, 0, 52, 6, 7, 22, 53,
8, 9, 225, 0, 0, 226, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 227, 228, 229, 14, 15,
16, 17, 230, 0, 0, 0, 6, 7, 18, 19,
8, 9, 225, 52, 0, 226, 22, 53, 0, 0,
0, 0, 0, 0, 0, 0, 6, 211, 0, 0,
8, 9, 0, 0, 0, 227, 228, 0, 14, 15,
16, 17, 0, 0, 0, 0, 6, 7, 18, 19,
8, 9, 225, 52, 13, 226, 22, 53, 14, 15,
16, 17, 0, 0, 0, 0, 0, 0, 18, 19,
0, 20, 0, 21, 0, 227, 22, 23, 14, 15,
16, 17, 6, 7, 0, 0, 8, 9, 18, 19,
0, 0, 0, 52, 0, 0, 22, 53, 0, 0,
0, 0, 6, 7, 0, 0, 8, 9, 6, 7,
174, 0, 8, 9, 14, 15, 16, 17, 0, 0,
0, 0, 0, 0, 18, 19, 0, 20, 0, 175,
0, 0, 22, 53, 14, 15, 16, 17, 0, 0,
14, 15, 16, 17, 18, 19, 0, 20, 0, 52,
18, 19, 22, 53, 0, 52, 0, 7, 22, 53,
8, 9, 73, 0, 0,-32768, 0, 0, 0, 0,
7, 0, 0, 8, 9,-32768, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 14, 15,
0, 0, 0, 0, 0, 80, 81, 82, 18, 19,
0, 14, 15, 52, 0, 0, 22, 53,-32768,-32768,
-32768, 18, 19, 0, 0, 0, 52, 0, 0, 22,
53
};
static const short yycheck[] = { 3,
105, 1, 179, 23, 107, 24, 25, 172, 1, 112,
10, 1, 13, 13, 4, 1, 13, 37, 13, 23,
54, 25, 13, 42, 223, 224, 225, 226, 11, 228,
229, 230, 36, 37, 4, 1, 201, 140, 4, 56,
1, 41, 1, 43, 44, 1, 50, 51, 41, 53,
10, 11, 35, 36, 159, 41, 107, 58, 163, 60,
60, 238, 13, 60, 57, 55, 265, 54, 28, 73,
74, 57, 76, 77, 78, 79, 80, 81, 277, 98,
41, 184, 41, 53, 10, 41, 70, 106, 32, 140,
3, 4, 35, 36, 55, 114, 55, 54, 21, 55,
104, 105, 11, 58, 11, 56, 42, 150, 28, 60,
52, 162, 56, 50, 51, 5, 135, 43, 44, 39,
4, 28, 54, 43, 37, 38, 35, 36, 112, 31,
134, 174, 54, 184, 138, 4, 54, 32, 55, 60,
100, 101, 4, 54, 48, 7, 8, 9, 4, 4,
12, 111, 4, 157, 158, 159, 176, 161, 21, 163,
13, 14, 15, 54, 18, 18, 19, 186, 21, 22,
275, 0, 176, 35, 36, 47, 48, 49, 31, 0,
52, 25, 287, 45, 46, 3, 109, 207, 50, 216,
251, 53, 54, 100, 101, 22, 215, -1, 202, 52,
160, -1, -1, 207, 111, -1, 166, 25, 168, 27,
28, 64, -1, -1, -1, 219, 220, 221, 269, -1,
271, 39, -1, 242, -1, 43, 245, -1, -1, -1,
-1, 84, 85, 86, 87, 88, 89, -1, -1, -1,
-1, -1, 293, -1, 248, 296, 206, 266, -1, 300,
-1, 302, 175, 160, -1, -1, 109, -1, 111, 166,
-1, 168, 222, -1, 117, -1, -1, 286, 272, -1,
-1, 275, 291, 292, -1, 128, 295, -1, -1, 132,
299, -1, -1, 287, -1, -1, -1, -1, 141, 142,
-1, 144, 145, 146, 147, 148, 149, 150, -1, 206,
223, 224, 225, 226, -1, 228, 229, 230, -1, -1,
270, -1, -1, -1, 167, 222, 276, -1, -1, -1,
-1, 174, 175, -1, -1, -1, -1, 180, 45, 46,
47, 48, 49, -1, -1, 52, -1, -1, -1, -1,
-1, -1, 265, 196, -1, -1, -1, 200, -1, -1,
-1, 204, 205, -1, 277, -1, 209, -1, -1, -1,
-1, -1, -1, 270, -1, -1, -1, -1, -1, 276,
223, 224, 225, 226, -1, 228, 229, 230, -1, -1,
18, 19, -1, 21, -1, -1, 63, -1, 241, -1,
-1, -1, -1, 31, -1, -1, -1, -1, -1, 252,
253, 254, -1, 256, -1, 258, 259, 260, -1, 262,
263, 264, 265, -1, 52, -1, -1, -1, -1, -1,
-1, 274, -1, -1, 277, 278, 64, -1, -1, -1,
-1, -1, 285, 1, -1, 3, 4, 290, 115, 7,
8, -1, -1, -1, -1, -1, 84, 85, 86, 87,
88, 89, -1, 130, 131, -1, -1, -1, -1, -1,
-1, -1, -1, 31, -1, -1, -1, 35, 36, 37,
38, 109, -1, 111, -1, -1, -1, 45, 46, 117,
48, -1, 50, -1, -1, 53, 54, 55, -1, -1,
128, -1, 35, -1, 132, -1, -1, -1, -1, -1,
-1, -1, -1, 141, 142, -1, 144, 145, 146, 147,
148, 149, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 70, 205, 167,
-1, -1, 209, -1, -1, -1, -1, 175, -1, -1,
-1, 218, 180, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 4, -1, -1, 7, 8, 9, 196, -1,
237, -1, 200, -1, 107, -1, 204, 205, -1, 112,
113, 209, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 35, 36, 223, 224, 225, 226, -1,
228, 229, 230, 45, 46, -1, 273, 140, 50, -1,
-1, 53, 54, 241, -1, -1, -1, -1, 285, -1,
-1, 288, -1, -1, 252, 253, 254, 294, 256, 162,
258, 259, 260, -1, 262, 263, 264, 265, -1, 172,
-1, -1, -1, -1, -1, -1, 274, -1, -1, 277,
278, 184, -1, -1, -1, -1, -1, 285, -1, -1,
-1, -1, 290, -1, 1, -1, 3, 4, 201, -1,
7, 8, -1, -1, -1, -1, -1, -1, -1, 212,
17, -1, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, -1, 31, -1, -1, -1, 35, 36,
37, 38, -1, -1, -1, -1, -1, -1, 45, 46,
-1, 48, -1, 50, -1, 248, 53, 54, -1, -1,
-1, 58, 59, 60, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 269, -1, 271, -1,
-1, 274, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 1, -1, 3, 4, -1, -1, 7, 8,
293, -1, -1, 296, -1, -1, -1, 300, 17, 302,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, -1, 31, -1, -1, -1, 35, 36, 37, 38,
-1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
1, 50, 3, 4, 53, 54, 7, 8, -1, 58,
59, 60, -1, -1, -1, -1, 17, -1, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, -1,
31, -1, -1, -1, 35, 36, 37, 38, -1, -1,
-1, -1, -1, -1, 45, 46, -1, 48, -1, 50,
-1, -1, 53, 54, -1, -1, -1, 58, 1, 60,
3, 4, -1, -1, 7, 8, -1, 10, -1, -1,
13, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 0, 1, -1, 3, 4, 31, -1,
7, 8, 35, 36, 37, 38, 13, -1, 15, 16,
43, 44, 45, 46, -1, 48, -1, 50, -1, -1,
53, 54, -1, 30, 31, -1, -1, 60, 35, 36,
37, 38, -1, -1, -1, -1, -1, -1, 45, 46,
-1, 48, -1, 50, 3, 4, 53, 54, 7, 8,
-1, 58, -1, -1, -1, -1, -1, -1, 17, -1,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, -1, 31, -1, -1, -1, 35, 36, 37, 38,
-1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
-1, 50, -1, -1, 53, 54, -1, -1, -1, 58,
-1, 60, 3, 4, -1, -1, 7, 8, 9, -1,
-1, 12, 13, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 32, 33, 34, 35, 36, 37, 38, 39, -1,
-1, 42, 43, 44, 45, 46, -1, -1, -1, 50,
-1, -1, 53, 54, -1, -1, 3, 4, -1, 60,
7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 32, 33, 34, 35, 36,
37, 38, 39, -1, -1, 42, 43, 44, 45, 46,
-1, -1, 1, 50, 3, 4, 53, 54, 7, 8,
-1, -1, -1, 60, -1, -1, 15, 16, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 3,
4, 30, 31, 7, 8, -1, 35, 36, 37, 38,
-1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
-1, 50, -1, -1, 53, 54, -1, 31, -1, 58,
-1, 35, 36, 37, 38, -1, -1, -1, -1, -1,
-1, 45, 46, -1, 48, 1, 50, 3, 4, 53,
54, 7, 8, -1, -1, -1, 60, -1, -1, -1,
-1, -1, -1, -1, -1, 1, -1, 3, 4, -1,
-1, 7, 8, -1, -1, 31, -1, -1, -1, 35,
36, 37, 38, -1, -1, -1, -1, -1, -1, 45,
46, -1, 48, -1, 50, 31, -1, 53, 54, 35,
36, 37, 38, -1, -1, -1, -1, -1, -1, 45,
46, -1, 48, 1, 50, 3, 4, 53, 54, 7,
8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 31, -1, -1, -1, 35, 36, 37,
38, -1, -1, -1, -1, -1, -1, 45, 46, -1,
48, -1, 50, 3, 4, 53, 54, 7, 8, 9,
-1, -1, 12, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 32, 33, 34, 35, 36, 37, 38, 39,
-1, -1, 42, 43, 44, 45, 46, -1, -1, -1,
50, -1, -1, 53, 54, 55, 3, 4, -1, -1,
7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 32, 33, 34, 35, 36,
37, 38, 39, -1, 41, 42, 43, 44, 45, 46,
-1, -1, -1, 50, 3, 4, 53, 54, 7, 8,
9, -1, -1, 12, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 32, 33, 34, 35, 36, 37, 38,
39, 40, -1, 42, 43, 44, 45, 46, -1, -1,
-1, 50, 3, 4, 53, 54, 7, 8, 9, -1,
-1, 12, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 32, 33, 34, 35, 36, 37, 38, 39, -1,
-1, 42, 43, 44, 45, 46, -1, -1, -1, 50,
3, 4, 53, 54, 7, 8, 9, -1, -1, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 32,
33, -1, 35, 36, 37, 38, -1, -1, -1, 42,
43, 44, 45, 46, -1, -1, -1, 50, 3, 4,
53, 54, 7, 8, 9, -1, -1, 12, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 3, 4,
-1, -1, 7, 8, -1, -1, -1, 32, 33, 34,
35, 36, 37, 38, 39, 40, -1, -1, 3, 4,
45, 46, 7, 8, 9, 50, 31, 12, 53, 54,
35, 36, 37, 38, -1, -1, -1, -1, -1, -1,
45, 46, -1, 48, -1, 50, -1, 32, 53, 54,
35, 36, 37, 38, -1, -1, -1, 42, 43, 44,
45, 46, -1, -1, -1, 50, 3, 4, 53, 54,
7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 32, 33, 34, 35, 36,
37, 38, 39, -1, -1, -1, 3, 4, 45, 46,
7, 8, 9, 50, -1, 12, 53, 54, -1, -1,
-1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
7, 8, -1, -1, -1, 32, 33, -1, 35, 36,
37, 38, -1, -1, -1, -1, 3, 4, 45, 46,
7, 8, 9, 50, 31, 12, 53, 54, 35, 36,
37, 38, -1, -1, -1, -1, -1, -1, 45, 46,
-1, 48, -1, 50, -1, 32, 53, 54, 35, 36,
37, 38, 3, 4, -1, -1, 7, 8, 45, 46,
-1, -1, -1, 50, -1, -1, 53, 54, -1, -1,
-1, -1, 3, 4, -1, -1, 7, 8, 3, 4,
31, -1, 7, 8, 35, 36, 37, 38, -1, -1,
-1, -1, -1, -1, 45, 46, -1, 48, -1, 50,
-1, -1, 53, 54, 35, 36, 37, 38, -1, -1,
35, 36, 37, 38, 45, 46, -1, 48, -1, 50,
45, 46, 53, 54, -1, 50, -1, 4, 53, 54,
7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
4, -1, -1, 7, 8, 9, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 35, 36,
-1, -1, -1, -1, -1, 42, 43, 44, 45, 46,
-1, 35, 36, 50, -1, -1, 53, 54, 42, 43,
44, 45, 46, -1, -1, -1, 50, -1, -1, 53,
54
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/local/lib/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ yychar = (token), yylval = (value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYPURE
#define YYLEX yylex()
#endif
#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX yylex(&yylval, &yylloc)
#else
#define YYLEX yylex(&yylval)
#endif
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
#ifdef YYLSP_NEEDED
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
#endif
int yynerrs; /* number of parse errors so far */
#endif /* not YYPURE */
#if YYDEBUG != 0
int yydebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYINITDEPTH indicates the initial size of the parser's stacks */
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
/* YYMAXDEPTH is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_bcopy (from, to, count)
char *from;
char *to;
int count;
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#else /* __cplusplus */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_bcopy (char *from, char *to, int count)
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#endif
#line 169 "/usr/local/lib/bison.simple"
int
yyparse()
{
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK (yyvsp--, yyssp--)
#endif
int yystacksize = YYINITDEPTH;
#ifdef YYPURE
int yychar;
YYSTYPE yylval;
int yynerrs;
#ifdef YYLSP_NEEDED
YYLTYPE yylloc;
#endif
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Starting parse\n");
#endif
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack. */
yyssp = yyss - 1;
yyvsp = yyvs;
#ifdef YYLSP_NEEDED
yylsp = yyls;
#endif
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *yyvs1 = yyvs;
short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
YYLTYPE *yyls1 = yyls;
#endif
/* Get the current used size of the three stacks, in elements. */
int size = yyssp - yyss + 1;
#ifdef yyoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
#ifdef YYLSP_NEEDED
&yyls1, size * sizeof (*yylsp),
#endif
&yystacksize);
yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
yyls = yyls1;
#endif
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
__yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
__yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
__yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
yylsp = yyls + size - 1;
#endif
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Entering state %d\n", yystate);
#endif
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Reading a token: ");
#endif
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Now at end of input.\n");
#endif
}
else
{
yychar1 = YYTRANSLATE(yychar);
#if YYDEBUG != 0
if (yydebug)
{
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
#endif
fprintf (stderr, ")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus) yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
yyval = yyvsp[1-yylen]; /* implement default value of the action */
#if YYDEBUG != 0
if (yydebug)
{
int i;
fprintf (stderr, "Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symboles being reduced, and their result. */
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
}
#endif
switch (yyn) {
case 1:
#line 136 "awk.y"
{ expression_value = yyvsp[-1].nodeval; ;
break;}
case 2:
#line 141 "awk.y"
{
if (yyvsp[0].nodeval != NULL)
yyval.nodeval = yyvsp[0].nodeval;
else
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 3:
#line 150 "awk.y"
{
if (yyvsp[0].nodeval == NULL)
yyval.nodeval = yyvsp[-1].nodeval;
else if (yyvsp[-1].nodeval == NULL)
yyval.nodeval = yyvsp[0].nodeval;
else {
if (yyvsp[-1].nodeval->type != Node_rule_list)
yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
(NODE*)NULL);
yyval.nodeval = append_right (yyvsp[-1].nodeval,
node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
}
yyerrok;
;
break;}
case 4:
#line 164 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 5:
#line 165 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 6:
#line 169 "awk.y"
{ io_allowed = 0; ;
break;}
case 7:
#line 171 "awk.y"
{
if (begin_block) {
if (begin_block->type != Node_rule_list)
begin_block = node(begin_block, Node_rule_list,
(NODE *)NULL);
(void) append_right (begin_block, node(
node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL) );
} else
begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
yyval.nodeval = NULL;
io_allowed = 1;
yyerrok;
;
break;}
case 8:
#line 185 "awk.y"
{ io_allowed = 0; ;
break;}
case 9:
#line 187 "awk.y"
{
if (end_block) {
if (end_block->type != Node_rule_list)
end_block = node(end_block, Node_rule_list,
(NODE *)NULL);
(void) append_right (end_block, node(
node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL));
} else
end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
yyval.nodeval = NULL;
io_allowed = 1;
yyerrok;
;
break;}
case 10:
#line 202 "awk.y"
{
warning("BEGIN blocks must have an action part");
errcount++;
yyerrok;
;
break;}
case 11:
#line 208 "awk.y"
{
warning("END blocks must have an action part");
errcount++;
yyerrok;
;
break;}
case 12:
#line 214 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
break;}
case 13:
#line 216 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
break;}
case 14:
#line 218 "awk.y"
{
yyval.nodeval = node (yyvsp[-1].nodeval,
Node_rule_node,
node(node(node(make_number(0.0),
Node_field_spec,
(NODE *) NULL),
Node_expression_list,
(NODE *) NULL),
Node_K_print,
(NODE *) NULL));
yyerrok;
;
break;}
case 15:
#line 231 "awk.y"
{
func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 16:
#line 240 "awk.y"
{ yyval.sval = yyvsp[0].sval; ;
break;}
case 17:
#line 242 "awk.y"
{ yyval.sval = yyvsp[0].sval; ;
break;}
case 18:
#line 244 "awk.y"
{
yyerror("%s() is a built-in function, it cannot be redefined",
tokstart);
errcount++;
/* yyerrok; */
;
break;}
case 21:
#line 259 "awk.y"
{
param_counter = 0;
;
break;}
case 22:
#line 263 "awk.y"
{
yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
can_return = 1;
;
break;}
case 23:
#line 271 "awk.y"
{
yyval.nodeval = yyvsp[-2].nodeval;
can_return = 0;
;
break;}
case 24:
#line 280 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 25:
#line 282 "awk.y"
{ yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
break;}
case 26:
#line 291 "awk.y"
{ ++want_regexp; ;
break;}
case 27:
#line 293 "awk.y"
{
NODE *n;
size_t len;
getnode(n);
n->type = Node_regex;
len = strlen(yyvsp[-1].sval);
n->re_exp = make_string(yyvsp[-1].sval, len);
n->re_reg = make_regexp(yyvsp[-1].sval, len, 0, 1);
n->re_text = NULL;
n->re_flags = CONST;
n->re_cnt = 1;
yyval.nodeval = n;
;
break;}
case 28:
#line 311 "awk.y"
{ yyval.nodeval = yyvsp[-3].nodeval ; ;
break;}
case 29:
#line 313 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 30:
#line 318 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 31:
#line 320 "awk.y"
{
if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
yyval.nodeval = append_right(yyvsp[-1].nodeval,
node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
yyerrok;
;
break;}
case 32:
#line 328 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 33:
#line 330 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 36:
#line 340 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 37:
#line 342 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 38:
#line 344 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 39:
#line 346 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 40:
#line 348 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
break;}
case 41:
#line 350 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
break;}
case 42:
#line 352 "awk.y"
{
yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval,1),
(NODE *)NULL, variable(yyvsp[-3].sval,1)));
;
break;}
case 43:
#line 357 "awk.y"
{
yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
;
break;}
case 44:
#line 361 "awk.y"
{
yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
(NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
;
break;}
case 45:
#line 367 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
break;}
case 46:
#line 370 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
break;}
case 47:
#line 372 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
break;}
case 48:
#line 374 "awk.y"
{
if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL)
yyvsp[-2].nodeval = node(node(make_number(0.0),
Node_field_spec,
(NODE *) NULL),
Node_expression_list,
(NODE *) NULL);
yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
;
break;}
case 49:
#line 385 "awk.y"
{ NODETYPE type;
if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) {
if (do_lint)
warning("`next file' is a gawk extension");
if (do_unix || do_posix) {
/*
* can't use yyerror, since may have overshot
* the source line
*/
errcount++;
msg("`next file' is a gawk extension");
}
if (! io_allowed) {
/* same thing */
errcount++;
msg("`next file' used in BEGIN or END action");
}
type = Node_K_nextfile;
} else {
if (! io_allowed)
yyerror("next used in BEGIN or END action");
type = Node_K_next;
}
yyval.nodeval = node ((NODE *)NULL, type, (NODE *)NULL);
;
break;}
case 50:
#line 412 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
break;}
case 51:
#line 414 "awk.y"
{ if (! can_return) yyerror("return used outside function context"); ;
break;}
case 52:
#line 416 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
break;}
case 53:
#line 418 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ;
break;}
case 54:
#line 420 "awk.y"
{
if (do_lint)
warning("`delete array' is a gawk extension");
if (do_unix || do_posix) {
/*
* can't use yyerror, since may have overshot
* the source line
*/
errcount++;
msg("`delete array' is a gawk extension");
}
yyval.nodeval = node (variable(yyvsp[-1].sval,1), Node_K_delete, (NODE *) NULL);
;
break;}
case 55:
#line 434 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 56:
#line 439 "awk.y"
{ yyval.nodetypeval = yyvsp[0].nodetypeval; ;
break;}
case 57:
#line 441 "awk.y"
{ yyval.nodetypeval = yyvsp[0].nodetypeval; ;
break;}
case 58:
#line 446 "awk.y"
{
yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if,
node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
;
break;}
case 59:
#line 452 "awk.y"
{ yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
break;}
case 60:
#line 458 "awk.y"
{ want_assign = 0; ;
break;}
case 64:
#line 469 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 65:
#line 471 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
break;}
case 66:
#line 476 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 67:
#line 478 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
break;}
case 68:
#line 480 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
break;}
case 69:
#line 482 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
break;}
case 70:
#line 487 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 71:
#line 489 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 72:
#line 494 "awk.y"
{ yyval.nodeval = make_param(yyvsp[0].sval); ;
break;}
case 73:
#line 496 "awk.y"
{ yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
break;}
case 74:
#line 498 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 75:
#line 500 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 76:
#line 502 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 77:
#line 508 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 78:
#line 510 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 79:
#line 515 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 80:
#line 517 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 81:
#line 522 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
break;}
case 82:
#line 524 "awk.y"
{
yyval.nodeval = append_right(yyvsp[-2].nodeval,
node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
yyerrok;
;
break;}
case 83:
#line 530 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 84:
#line 532 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 85:
#line 534 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 86:
#line 536 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 87:
#line 541 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 88:
#line 543 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 89:
#line 548 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
break;}
case 90:
#line 550 "awk.y"
{
yyval.nodeval = append_right(yyvsp[-2].nodeval,
node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
yyerrok;
;
break;}
case 91:
#line 556 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 92:
#line 558 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 93:
#line 560 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 94:
#line 562 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 95:
#line 567 "awk.y"
{ want_assign = 0; ;
break;}
case 96:
#line 569 "awk.y"
{
if (do_lint && yyvsp[0].nodeval->type == Node_regex)
warning("Regular expression on left of assignment.");
yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
;
break;}
case 97:
#line 575 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ;
break;}
case 98:
#line 577 "awk.y"
{
yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
;
break;}
case 99:
#line 582 "awk.y"
{
if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
warning("non-redirected getline undefined inside BEGIN or END action");
yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
;
break;}
case 100:
#line 588 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
break;}
case 101:
#line 590 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
break;}
case 102:
#line 592 "awk.y"
{
if (yyvsp[-2].nodeval->type == Node_regex)
warning("Regular expression on left of MATCH operator.");
yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
;
break;}
case 103:
#line 598 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 104:
#line 600 "awk.y"
{
yyval.nodeval = node(node(make_number(0.0),
Node_field_spec,
(NODE *) NULL),
Node_nomatch,
yyvsp[0].nodeval);
;
break;}
case 105:
#line 608 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
break;}
case 106:
#line 610 "awk.y"
{
if (do_lint && yyvsp[0].nodeval->type == Node_regex)
warning("Regular expression on left of comparison.");
yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
;
break;}
case 107:
#line 616 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
break;}
case 108:
#line 618 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
break;}
case 109:
#line 620 "awk.y"
{ yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
break;}
case 110:
#line 622 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 111:
#line 624 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
break;}
case 112:
#line 629 "awk.y"
{ want_assign = 0; ;
break;}
case 113:
#line 631 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 114:
#line 633 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
break;}
case 115:
#line 635 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
break;}
case 116:
#line 637 "awk.y"
{
if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
warning("non-redirected getline undefined inside BEGIN or END action");
yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
;
break;}
case 117:
#line 643 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 118:
#line 645 "awk.y"
{ yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
break;}
case 119:
#line 647 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
break;}
case 120:
#line 649 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
break;}
case 121:
#line 651 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 122:
#line 653 "awk.y"
{ yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
break;}
case 123:
#line 655 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 124:
#line 657 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
break;}
case 126:
#line 664 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
break;}
case 127:
#line 666 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
break;}
case 128:
#line 668 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
break;}
case 129:
#line 670 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
break;}
case 130:
#line 672 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
break;}
case 131:
#line 674 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
break;}
case 132:
#line 676 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
break;}
case 133:
#line 678 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
break;}
case 134:
#line 683 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
break;}
case 135:
#line 685 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 136:
#line 688 "awk.y"
{ yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
break;}
case 137:
#line 690 "awk.y"
{ yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
break;}
case 138:
#line 692 "awk.y"
{
if (do_lint)
warning("call of `length' without parentheses is not portable");
yyval.nodeval = snode ((NODE *)NULL, Node_builtin, (int) yyvsp[0].lval);
if (do_posix)
warning( "call of `length' without parentheses is deprecated by POSIX");
;
break;}
case 139:
#line 700 "awk.y"
{
yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
;
break;}
case 141:
#line 705 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
break;}
case 142:
#line 707 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
break;}
case 143:
#line 709 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 144:
#line 711 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 145:
#line 714 "awk.y"
{ if (yyvsp[0].nodeval->type == Node_val) {
yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
yyval.nodeval = yyvsp[0].nodeval;
} else
yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL);
;
break;}
case 146:
#line 721 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 147:
#line 726 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 148:
#line 728 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 149:
#line 733 "awk.y"
{ yyval.nodeval = variable(yyvsp[0].sval,1); ;
break;}
case 150:
#line 735 "awk.y"
{
if (yyvsp[-1].nodeval->rnode == NULL) {
yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval->lnode);
freenode(yyvsp[-1].nodeval);
} else
yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval);
;
break;}
case 151:
#line 743 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
break;}
case 153:
#line 751 "awk.y"
{ yyerrok; ;
break;}
case 154:
#line 755 "awk.y"
{ yyerrok; ;
break;}
case 157:
#line 764 "awk.y"
{ yyerrok; want_assign = 0; ;
break;}
case 158:
#line 767 "awk.y"
{ yyerrok; ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
#line 440 "/usr/local/lib/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
#ifdef YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++yyvsp = yyval;
#ifdef YYLSP_NEEDED
yylsp++;
if (yylen == 0)
{
yylsp->first_line = yylloc.first_line;
yylsp->first_column = yylloc.first_column;
yylsp->last_line = (yylsp-1)->last_line;
yylsp->last_column = (yylsp-1)->last_column;
yylsp->text = 0;
}
else
{
yylsp->last_line = (yylsp+yylen-1)->last_line;
yylsp->last_column = (yylsp+yylen-1)->last_column;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yyerrlab: /* here on detecting error */
if (! yyerrstatus)
/* If not already recovering from an error, report this error. */
{
++yynerrs;
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, yytname[x]);
strcat(msg, "'");
count++;
}
}
yyerror(msg);
free(msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
yyerror("parse error");
}
yyerrlab1: /* here on error raised explicitly by an action */
if (yyerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (yyn) goto yydefault;
#endif
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss) YYABORT;
yyvsp--;
yystate = *--yyssp;
#ifdef YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting error token, ");
#endif
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
}
#line 770 "awk.y"
struct token {
const char *operator; /* text to match */
NODETYPE value; /* node type */
int class; /* lexical class */
unsigned flags; /* # of args. allowed and compatability */
# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
# define A(n) (1<<(n))
# define VERSION 0xFF00 /* old awk is zero */
# define NOT_OLD 0x0100 /* feature not in old awk */
# define NOT_POSIX 0x0200 /* feature not in POSIX */
# define GAWKX 0x0400 /* gawk extension */
NODE *(*ptr) (); /* function that implements this keyword */
};
extern NODE
*do_exp(), *do_getline(), *do_index(), *do_length(),
*do_sqrt(), *do_log(), *do_sprintf(), *do_substr(),
*do_split(), *do_system(), *do_int(), *do_close(),
*do_atan2(), *do_sin(), *do_cos(), *do_rand(),
*do_srand(), *do_match(), *do_tolower(), *do_toupper(),
*do_sub(), *do_gsub(), *do_strftime(), *do_systime();
/* Tokentab is sorted ascii ascending order, so it can be binary searched. */
static struct token tokentab[] = {
{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
{"END", Node_illegal, LEX_END, 0, 0},
{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
{"break", Node_K_break, LEX_BREAK, 0, 0},
{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
{"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
{"do", Node_K_do, LEX_DO, NOT_OLD, 0},
{"else", Node_illegal, LEX_ELSE, 0, 0},
{"exit", Node_K_exit, LEX_EXIT, 0, 0},
{"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp},
{"for", Node_K_for, LEX_FOR, 0, 0},
{"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0},
{"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0},
{"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0},
{"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub},
{"if", Node_K_if, LEX_IF, 0, 0},
{"in", Node_illegal, LEX_IN, 0, 0},
{"index", Node_builtin, LEX_BUILTIN, A(2), do_index},
{"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
{"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
{"next", Node_K_next, LEX_NEXT, 0, 0},
{"print", Node_K_print, LEX_PRINT, 0, 0},
{"printf", Node_K_printf, LEX_PRINTF, 0, 0},
{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_strftime},
{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
{"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime},
{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
{"while", Node_K_while, LEX_WHILE, 0, 0},
};
/* VARARGS0 */
static void
yyerror(va_alist)
va_dcl
{
va_list args;
const char *mesg = NULL;
register char *bp, *cp;
char *scan;
char buf[120];
static char end_of_file_line[] = "(END OF FILE)";
errcount++;
/* Find the current line in the input file */
if (lexptr) {
if (!thisline) {
cp = lexeme;
if (*cp == '\n') {
cp--;
mesg = "unexpected newline";
}
for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
;
if (*cp == '\n')
cp++;
thisline = cp;
}
/* NL isn't guaranteed */
bp = lexeme;
while (bp < lexend && *bp && *bp != '\n')
bp++;
} else {
thisline = end_of_file_line;
bp = thisline + strlen(thisline);
}
msg("%.*s", (int) (bp - thisline), thisline);
bp = buf;
cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
if (lexptr) {
scan = thisline;
while (bp < cp && scan < lexeme)
if (*scan++ == '\t')
*bp++ = '\t';
else
*bp++ = ' ';
*bp++ = '^';
*bp++ = ' ';
}
va_start(args);
if (mesg == NULL)
mesg = va_arg(args, char *);
strcpy(bp, mesg);
err("", buf, args);
va_end(args);
exit(2);
}
static char *
get_src_buf()
{
static int samefile = 0;
static int nextfile = 0;
static char *buf = NULL;
static int fd;
int n;
register char *scan;
static int len = 0;
static int did_newline = 0;
# define SLOP 128 /* enough space to hold most source lines */
if (nextfile > numfiles)
return NULL;
if (srcfiles[nextfile].stype == CMDLINE) {
if (len == 0) {
len = strlen(srcfiles[nextfile].val);
sourceline = 1;
lexptr = lexptr_begin = srcfiles[nextfile].val;
lexend = lexptr + len;
} else if (!did_newline && *(lexptr-1) != '\n') {
/*
* The following goop is to ensure that the source
* ends with a newline and that the entire current
* line is available for error messages.
*/
int offset;
did_newline = 1;
offset = lexptr - lexeme;
for (scan = lexeme; scan > lexptr_begin; scan--)
if (*scan == '\n') {
scan++;
break;
}
len = lexptr - scan;
emalloc(buf, char *, len+1, "get_src_buf");
memcpy(buf, scan, len);
thisline = buf;
lexptr = buf + len;
*lexptr = '\n';
lexeme = lexptr - offset;
lexptr_begin = buf;
lexend = lexptr + 1;
} else {
len = 0;
lexeme = lexptr = lexptr_begin = NULL;
}
if (lexptr == NULL && ++nextfile <= numfiles)
return get_src_buf();
return lexptr;
}
if (!samefile) {
source = srcfiles[nextfile].val;
if (source == NULL) {
if (buf) {
free(buf);
buf = NULL;
}
len = 0;
return lexeme = lexptr = lexptr_begin = NULL;
}
fd = pathopen(source);
if (fd == -1)
fatal("can't open source file \"%s\" for reading (%s)",
source, strerror(errno));
len = optimal_bufsize(fd);
if (buf)
free(buf);
emalloc(buf, char *, len + SLOP, "get_src_buf");
lexptr_begin = buf + SLOP;
samefile = 1;
sourceline = 1;
} else {
/*
* Here, we retain the current source line (up to length SLOP)
* in the beginning of the buffer that was overallocated above
*/
int offset;
int linelen;
offset = lexptr - lexeme;
for (scan = lexeme; scan > lexptr_begin; scan--)
if (*scan == '\n') {
scan++;
break;
}
linelen = lexptr - scan;
if (linelen > SLOP)
linelen = SLOP;
thisline = buf + SLOP - linelen;
memcpy(thisline, scan, linelen);
lexeme = buf + SLOP - offset;
lexptr_begin = thisline;
}
n = read(fd, buf + SLOP, len);
if (n == -1)
fatal("can't read sourcefile \"%s\" (%s)",
source, strerror(errno));
if (n == 0) {
samefile = 0;
nextfile++;
len = 0;
return get_src_buf();
}
lexptr = buf + SLOP;
lexend = lexptr + n;
return buf;
}
#define tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok)
char *
tokexpand()
{
static int toksize = 60;
int tokoffset;
tokoffset = tok - tokstart;
toksize *= 2;
if (tokstart)
erealloc(tokstart, char *, toksize, "tokexpand");
else
emalloc(tokstart, char *, toksize, "tokexpand");
tokend = tokstart + toksize;
tok = tokstart + tokoffset;
return tok;
}
#if DEBUG
char
nextc() {
if (lexptr && lexptr < lexend)
return *lexptr++;
else if (get_src_buf())
return *lexptr++;
else
return '\0';
}
#else
#define nextc() ((lexptr && lexptr < lexend) ? \
*lexptr++ : \
(get_src_buf() ? *lexptr++ : '\0') \
)
#endif
#define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
/*
* Read the input and turn it into tokens.
*/
static int
yylex()
{
register int c;
int seen_e = 0; /* These are for numbers */
int seen_point = 0;
int esc_seen; /* for literal strings */
int low, mid, high;
static int did_newline = 0;
char *tokkey;
if (!nextc())
return 0;
pushback();
#ifdef OS2
/*
* added for OS/2's extproc feature of cmd.exe
* (like #! in BSD sh)
*/
if (strncasecmp(lexptr, "extproc ", 8) == 0) {
while (*lexptr && *lexptr != '\n')
lexptr++;
}
#endif
lexeme = lexptr;
thisline = NULL;
if (want_regexp) {
int in_brack = 0;
want_regexp = 0;
tok = tokstart;
while ((c = nextc()) != 0) {
switch (c) {
case '[':
in_brack = 1;
break;
case ']':
in_brack = 0;
break;
case '\\':
if ((c = nextc()) == '\0') {
yyerror("unterminated regexp ends with \\ at end of file");
} else if (c == '\n') {
sourceline++;
continue;
} else
tokadd('\\');
break;
case '/': /* end of the regexp */
if (in_brack)
break;
pushback();
tokadd('\0');
yylval.sval = tokstart;
return REGEXP;
case '\n':
pushback();
yyerror("unterminated regexp");
case '\0':
yyerror("unterminated regexp at end of file");
}
tokadd(c);
}
}
retry:
while ((c = nextc()) == ' ' || c == '\t')
;
lexeme = lexptr ? lexptr - 1 : lexptr;
thisline = NULL;
tok = tokstart;
yylval.nodetypeval = Node_illegal;
switch (c) {
case 0:
return 0;
case '\n':
sourceline++;
return NEWLINE;
case '#': /* it's a comment */
while ((c = nextc()) != '\n') {
if (c == '\0')
return 0;
}
sourceline++;
return NEWLINE;
case '\\':
#ifdef RELAXED_CONTINUATION
/*
* This code puports to allow comments and/or whitespace
* after the `\' at the end of a line used for continuation.
* Use it at your own risk. We think it's a bad idea, which
* is why it's not on by default.
*/
if (!do_unix) {
/* strip trailing white-space and/or comment */
while ((c = nextc()) == ' ' || c == '\t')
continue;
if (c == '#')
while ((c = nextc()) != '\n')
if (c == '\0')
break;
pushback();
}
#endif /* RELAXED_CONTINUATION */
if (nextc() == '\n') {
sourceline++;
goto retry;
} else
yyerror("backslash not last character on line");
break;
case '$':
want_assign = 1;
return '$';
case ')':
case ']':
case '(':
case '[':
case ';':
case ':':
case '?':
case '{':
case ',':
return c;
case '*':
if ((c = nextc()) == '=') {
yylval.nodetypeval = Node_assign_times;
return ASSIGNOP;
} else if (do_posix) {
pushback();
return '*';
} else if (c == '*') {
/* make ** and **= aliases for ^ and ^= */
static int did_warn_op = 0, did_warn_assgn = 0;
if (nextc() == '=') {
if (do_lint && ! did_warn_assgn) {
did_warn_assgn = 1;
warning("**= is not allowed by POSIX");
}
yylval.nodetypeval = Node_assign_exp;
return ASSIGNOP;
} else {
pushback();
if (do_lint && ! did_warn_op) {
did_warn_op = 1;
warning("** is not allowed by POSIX");
}
return '^';
}
}
pushback();
return '*';
case '/':
if (want_assign) {
if (nextc() == '=') {
yylval.nodetypeval = Node_assign_quotient;
return ASSIGNOP;
}
pushback();
}
return '/';
case '%':
if (nextc() == '=') {
yylval.nodetypeval = Node_assign_mod;
return ASSIGNOP;
}
pushback();
return '%';
case '^':
{
static int did_warn_op = 0, did_warn_assgn = 0;
if (nextc() == '=') {
if (do_lint && ! did_warn_assgn) {
did_warn_assgn = 1;
warning("operator `^=' is not supported in old awk");
}
yylval.nodetypeval = Node_assign_exp;
return ASSIGNOP;
}
pushback();
if (do_lint && ! did_warn_op) {
did_warn_op = 1;
warning("operator `^' is not supported in old awk");
}
return '^';
}
case '+':
if ((c = nextc()) == '=') {
yylval.nodetypeval = Node_assign_plus;
return ASSIGNOP;
}
if (c == '+')
return INCREMENT;
pushback();
return '+';
case '!':
if ((c = nextc()) == '=') {
yylval.nodetypeval = Node_notequal;
return RELOP;
}
if (c == '~') {
yylval.nodetypeval = Node_nomatch;
want_assign = 0;
return MATCHOP;
}
pushback();
return '!';
case '<':
if (nextc() == '=') {
yylval.nodetypeval = Node_leq;
return RELOP;
}
yylval.nodetypeval = Node_less;
pushback();
return '<';
case '=':
if (nextc() == '=') {
yylval.nodetypeval = Node_equal;
return RELOP;
}
yylval.nodetypeval = Node_assign;
pushback();
return ASSIGNOP;
case '>':
if ((c = nextc()) == '=') {
yylval.nodetypeval = Node_geq;
return RELOP;
} else if (c == '>') {
yylval.nodetypeval = Node_redirect_append;
return APPEND_OP;
}
yylval.nodetypeval = Node_greater;
pushback();
return '>';
case '~':
yylval.nodetypeval = Node_match;
want_assign = 0;
return MATCHOP;
case '}':
/*
* Added did newline stuff. Easier than
* hacking the grammar
*/
if (did_newline) {
did_newline = 0;
return c;
}
did_newline++;
--lexptr; /* pick up } next time */
return NEWLINE;
case '"':
esc_seen = 0;
while ((c = nextc()) != '"') {
if (c == '\n') {
pushback();
yyerror("unterminated string");
}
if (c == '\\') {
c = nextc();
if (c == '\n') {
sourceline++;
continue;
}
esc_seen = 1;
tokadd('\\');
}
if (c == '\0') {
pushback();
yyerror("unterminated string");
}
tokadd(c);
}
yylval.nodeval = make_str_node(tokstart,
tok - tokstart, esc_seen ? SCAN : 0);
yylval.nodeval->flags |= PERM;
return YSTRING;
case '-':
if ((c = nextc()) == '=') {
yylval.nodetypeval = Node_assign_minus;
return ASSIGNOP;
}
if (c == '-')
return DECREMENT;
pushback();
return '-';
case '.':
c = nextc();
pushback();
if (!isdigit(c))
return '.';
else
c = '.'; /* FALL THROUGH */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* It's a number */
for (;;) {
int gotnumber = 0;
tokadd(c);
switch (c) {
case '.':
if (seen_point) {
gotnumber++;
break;
}
++seen_point;
break;
case 'e':
case 'E':
if (seen_e) {
gotnumber++;
break;
}
++seen_e;
if ((c = nextc()) == '-' || c == '+')
tokadd(c);
else
pushback();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
default:
gotnumber++;
}
if (gotnumber)
break;
c = nextc();
}
pushback();
yylval.nodeval = make_number(atof(tokstart));
yylval.nodeval->flags |= PERM;
return YNUMBER;
case '&':
if ((c = nextc()) == '&') {
yylval.nodetypeval = Node_and;
for (;;) {
c = nextc();
if (c == '\0')
break;
if (c == '#') {
while ((c = nextc()) != '\n' && c != '\0')
;
if (c == '\0')
break;
}
if (c == '\n')
sourceline++;
if (! isspace(c)) {
pushback();
break;
}
}
want_assign = 0;
return LEX_AND;
}
pushback();
return '&';
case '|':
if ((c = nextc()) == '|') {
yylval.nodetypeval = Node_or;
for (;;) {
c = nextc();
if (c == '\0')
break;
if (c == '#') {
while ((c = nextc()) != '\n' && c != '\0')
;
if (c == '\0')
break;
}
if (c == '\n')
sourceline++;
if (! isspace(c)) {
pushback();
break;
}
}
want_assign = 0;
return LEX_OR;
}
pushback();
return '|';
}
if (c != '_' && ! isalpha(c))
yyerror("Invalid char '%c' in expression\n", c);
/* it's some type of name-type-thing. Find its length */
tok = tokstart;
while (is_identchar(c)) {
tokadd(c);
c = nextc();
}
tokadd('\0');
emalloc(tokkey, char *, tok - tokstart, "yylex");
memcpy(tokkey, tokstart, tok - tokstart);
pushback();
/* See if it is a special token. */
low = 0;
high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
while (low <= high) {
int i/* , c */;
mid = (low + high) / 2;
c = *tokstart - tokentab[mid].operator[0];
i = c ? c : strcmp (tokstart, tokentab[mid].operator);
if (i < 0) { /* token < mid */
high = mid - 1;
} else if (i > 0) { /* token > mid */
low = mid + 1;
} else {
if (do_lint) {
if (tokentab[mid].flags & GAWKX)
warning("%s() is a gawk extension",
tokentab[mid].operator);
if (tokentab[mid].flags & NOT_POSIX)
warning("POSIX does not allow %s",
tokentab[mid].operator);
if (tokentab[mid].flags & NOT_OLD)
warning("%s is not supported in old awk",
tokentab[mid].operator);
}
if ((do_unix && (tokentab[mid].flags & GAWKX))
|| (do_posix && (tokentab[mid].flags & NOT_POSIX)))
break;
if (tokentab[mid].class == LEX_BUILTIN
|| tokentab[mid].class == LEX_LENGTH
)
yylval.lval = mid;
else
yylval.nodetypeval = tokentab[mid].value;
return tokentab[mid].class;
}
}
yylval.sval = tokkey;
if (*lexptr == '(')
return FUNC_CALL;
else {
want_assign = 1;
return NAME;
}
}
static NODE *
node_common(op)
NODETYPE op;
{
register NODE *r;
getnode(r);
r->type = op;
r->flags = MALLOC;
/* if lookahead is NL, lineno is 1 too high */
if (lexeme && *lexeme == '\n')
r->source_line = sourceline - 1;
else
r->source_line = sourceline;
r->source_file = source;
return r;
}
/*
* This allocates a node with defined lnode and rnode.
*/
NODE *
node(left, op, right)
NODE *left, *right;
NODETYPE op;
{
register NODE *r;
r = node_common(op);
r->lnode = left;
r->rnode = right;
return r;
}
/*
* This allocates a node with defined subnode and proc for builtin functions
* Checks for arg. count and supplies defaults where possible.
*/
static NODE *
snode(subn, op, idx)
NODETYPE op;
int idx;
NODE *subn;
{
register NODE *r;
register NODE *n;
int nexp = 0;
int args_allowed;
r = node_common(op);
/* traverse expression list to see how many args. given */
for (n= subn; n; n= n->rnode) {
nexp++;
if (nexp > 3)
break;
}
/* check against how many args. are allowed for this builtin */
args_allowed = tokentab[idx].flags & ARGS;
if (args_allowed && !(args_allowed & A(nexp)))
fatal("%s() cannot have %d argument%c",
tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
r->proc = tokentab[idx].ptr;
/* special case processing for a few builtins */
if (nexp == 0 && r->proc == do_length) {
subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
Node_expression_list,
(NODE *) NULL);
} else if (r->proc == do_match) {
if (subn->rnode->lnode->type != Node_regex)
subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
} else if (r->proc == do_sub || r->proc == do_gsub) {
if (subn->lnode->type != Node_regex)
subn->lnode = mk_rexp(subn->lnode);
if (nexp == 2)
append_right(subn, node(node(make_number(0.0),
Node_field_spec,
(NODE *) NULL),
Node_expression_list,
(NODE *) NULL));
else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
warning("string literal as last arg of substitute");
} else if (r->proc == do_split) {
if (nexp == 2)
append_right(subn,
node(FS_node, Node_expression_list, (NODE *) NULL));
n = subn->rnode->rnode->lnode;
if (n->type != Node_regex)
subn->rnode->rnode->lnode = mk_rexp(n);
if (nexp == 2)
subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
}
r->subnode = subn;
return r;
}
/*
* This allocates a Node_line_range node with defined condpair and
* zeroes the trigger word to avoid the temptation of assuming that calling
* 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'.
*/
/* Otherwise like node() */
static NODE *
mkrangenode(cpair)
NODE *cpair;
{
register NODE *r;
getnode(r);
r->type = Node_line_range;
r->condpair = cpair;
r->triggered = 0;
return r;
}
/* Build a for loop */
static NODE *
make_for_loop(init, cond, incr)
NODE *init, *cond, *incr;
{
register FOR_LOOP_HEADER *r;
NODE *n;
emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
getnode(n);
n->type = Node_illegal;
r->init = init;
r->cond = cond;
r->incr = incr;
n->sub.nodep.r.hd = r;
return n;
}
/*
* Install a name in the symbol table, even if it is already there.
* Caller must check against redefinition if that is desired.
*/
NODE *
install(name, value)
char *name;
NODE *value;
{
register NODE *hp;
register size_t len;
register int bucket;
len = strlen(name);
bucket = hash(name, len, (unsigned long) HASHSIZE);
getnode(hp);
hp->type = Node_hashnode;
hp->hnext = variables[bucket];
variables[bucket] = hp;
hp->hlength = len;
hp->hvalue = value;
hp->hname = name;
hp->hvalue->vname = name;
return hp->hvalue;
}
/* find the most recent hash node for name installed by install */
NODE *
lookup(name)
const char *name;
{
register NODE *bucket;
register size_t len;
len = strlen(name);
bucket = variables[hash(name, len, (unsigned long) HASHSIZE)];
while (bucket) {
if (bucket->hlength == len && STREQN(bucket->hname, name, len))
return bucket->hvalue;
bucket = bucket->hnext;
}
return NULL;
}
/*
* Add new to the rightmost branch of LIST. This uses n^2 time, so we make
* a simple attempt at optimizing it.
*/
static NODE *
append_right(list, new)
NODE *list, *new;
{
register NODE *oldlist;
static NODE *savefront = NULL, *savetail = NULL;
oldlist = list;
if (savefront == oldlist) {
savetail = savetail->rnode = new;
return oldlist;
} else
savefront = oldlist;
while (list->rnode != NULL)
list = list->rnode;
savetail = list->rnode = new;
return oldlist;
}
/*
* check if name is already installed; if so, it had better have Null value,
* in which case def is added as the value. Otherwise, install name with def
* as value.
*/
static void
func_install(params, def)
NODE *params;
NODE *def;
{
NODE *r;
pop_params(params->rnode);
pop_var(params, 0);
r = lookup(params->param);
if (r != NULL) {
fatal("function name `%s' previously defined", params->param);
} else
(void) install(params->param, node(params, Node_func, def));
}
static void
pop_var(np, freeit)
NODE *np;
int freeit;
{
register NODE *bucket, **save;
register size_t len;
char *name;
name = np->param;
len = strlen(name);
save = &(variables[hash(name, len, (unsigned long) HASHSIZE)]);
for (bucket = *save; bucket; bucket = bucket->hnext) {
if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
*save = bucket->hnext;
freenode(bucket);
if (freeit)
free(np->param);
return;
}
save = &(bucket->hnext);
}
}
static void
pop_params(params)
NODE *params;
{
register NODE *np;
for (np = params; np != NULL; np = np->rnode)
pop_var(np, 1);
}
static NODE *
make_param(name)
char *name;
{
NODE *r;
getnode(r);
r->type = Node_param_list;
r->rnode = NULL;
r->param = name;
r->param_cnt = param_counter++;
return (install(name, r));
}
/* Name points to a variable name. Make sure its in the symbol table */
NODE *
variable(name, can_free)
char *name;
int can_free;
{
register NODE *r;
static int env_loaded = 0;
if (!env_loaded && STREQ(name, "ENVIRON")) {
load_environ();
env_loaded = 1;
}
if ((r = lookup(name)) == NULL)
r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
else if (can_free)
free(name);
return r;
}
static NODE *
mk_rexp(exp)
NODE *exp;
{
if (exp->type == Node_regex)
return exp;
else {
NODE *n;
getnode(n);
n->type = Node_regex;
n->re_exp = exp;
n->re_text = NULL;
n->re_reg = NULL;
n->re_flags = 0;
n->re_cnt = 1;
return n;
}
}