home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
TOP
/
USR
/
SRC
/
gawk2.0.t.Z
/
gawk2.0.t
/
awk.tab.c
< prev
next >
Wrap
Text File
|
1989-04-06
|
71KB
|
2,295 lines
/* A Bison parser, made from awk.y */
#define NAME 258
#define REGEXP 259
#define YSTRING 260
#define ERROR 261
#define INCDEC 262
#define NUMBER 263
#define ASSIGNOP 264
#define RELOP 265
#define MATCHOP 266
#define NEWLINE 267
#define REDIRECT_OP 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_SUB 287
#define LEX_MATCH 288
#define LEX_IN 289
#define LEX_AND 290
#define LEX_OR 291
#define INCREMENT 292
#define DECREMENT 293
#define LEX_BUILTIN 294
#define UNARY 295
#line 139 "awk.y"
#define YYDEBUG 12
#define YYIMPROVE
#include "awk.h"
static int yylex ();
/*
* The following variable is used for a very sickening thing.
* The awk language uses white space as the string concatenation
* operator, but having a white space token that would have to appear
* everywhere in all the grammar rules would be unbearable.
* It turns out we can return CONCAT_OP exactly when there really
* is one, just from knowing what kinds of other tokens it can appear
* between (namely, constants, variables, or close parentheses).
* This is because concatenation has the lowest priority of all
* operators. want_concat_token is used to remember that something
* that could be the left side of a concat has just been returned.
*
* If anyone knows a cleaner way to do this (don't look at the Un*x
* code to find one, though), please suggest it.
*/
static int want_concat_token;
/* Two more horrible kludges. The same comment applies to these two too */
static int want_regexp; /* lexical scanning kludge */
static int want_redirect; /* similarly */
int lineno = 1; /* for error msgs */
/* During parsing of a gawk program, the pointer to the next character
is in this variable. */
char *lexptr; /* moved it up here */
char *lexptr_begin; /* for error msgs */
char *func_def;
extern int errcount;
extern struct obstack var_stack;
extern NODE *begin_block;
extern NODE *end_block;
extern struct re_pattern_buffer *mk_re_parse();
extern int param_counter;
struct re_pattern_buffer *rp;
#line 183 "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
#define YYOS9FREE { \
if (yyss != 0) free(yyss);\
if (yyls != 0) free(yyls);\
if (yyvs != 0) free(yyvs);\
}
#define YYACCEPT { YYOS9FREE; return(0);}
#define YYABORT { YYOS9FREE; return(1);}
#define YYERROR { YYOS9FREE; return(1);}
#ifndef stdin
#include <stdio.h>
#endif
#define YYFINAL 282
#define YYFLAG -32768
#define YYNTBASE 60
#define YYTRANSLATE(x) (yytranslate[x])
static 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, 51, 2, 2, 49, 46, 2, 2, 50,
58, 44, 42, 52, 43, 2, 45, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 41, 59, 2,
2, 2, 40, 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,
53, 2, 54, 48, 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, 56, 55, 57, 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, 39, 47
};
static short yyrline[] = { 0,
233, 238, 246, 258, 259, 263, 275, 287, 293, 299,
301, 303, 313, 318, 325, 330, 332, 334, 340, 342,
344, 346, 348, 355, 357, 365, 370, 375, 377, 383,
385, 389, 391, 396, 398, 400, 402, 404, 409, 411,
413, 415, 417, 419, 421, 423, 429, 432, 435, 437,
439, 441, 443, 445, 447, 449, 451, 453, 455, 457,
459, 464, 467, 474, 475, 480, 482, 485, 489, 491,
496, 500, 505, 507, 508, 513, 515, 519, 521, 526,
528, 534, 536, 537, 538, 542, 543, 545, 547, 549,
553, 555, 557, 559, 561, 563, 565, 567, 569, 571,
573, 575, 579, 584, 586, 588, 592, 594, 596, 598,
600, 602, 604, 606, 608, 612, 614, 616, 618, 620,
622, 625, 627, 632, 634, 638, 640, 642, 647, 651,
655, 659
};
static char * yytname[] = { 0,
"error","$illegal.","NAME","REGEXP","YSTRING","ERROR","INCDEC","NUMBER","ASSIGNOP","RELOP",
"MATCHOP","NEWLINE","REDIRECT_OP","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_SUB","LEX_MATCH","LEX_IN","LEX_AND","LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","'?'",
"':'","'+'","'-'","'*'","'/'","'%'","UNARY","'^'","'$'","'('",
"'!'","','","'['","']'","'|'","'{'","'}'","')'","';'","start"
};
static short yyr1[] = { 0,
60, 61, 61, 61, 61, 62, 62, 62, 62, 62,
62, 62, 64, 63, 65, 66, 66, 66, 66, 66,
66, 66, 66, 68, 67, 69, 69, 70, 70, 70,
70, 71, 71, 72, 72, 72, 72, 72, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 74, 73,
75, 73, 76, 73, 77, 73, 73, 73, 73, 73,
73, 78, 78, 79, 79, 80, 81, 80, 82, 82,
83, 83, 83, 83, 83, 84, 84, 85, 85, 86,
86, 86, 86, 86, 86, 87, 87, 87, 87, 87,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
89, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 90, 90, 91, 91, 91, 92, 93,
94, 95
};
static short yyr2[] = { 0,
2, 1, 2, 1, 2, 2, 2, 2, 2, 2,
2, 2, 0, 8, 4, 0, 1, 1, 3, 3,
2, 3, 3, 0, 4, 2, 3, 1, 2, 1,
2, 2, 2, 0, 1, 1, 2, 2, 2, 4,
1, 6, 8, 10, 9, 9, 2, 2, 0, 5,
0, 7, 0, 5, 0, 7, 2, 3, 3, 6,
2, 6, 9, 0, 2, 0, 0, 3, 0, 1,
1, 3, 1, 2, 3, 0, 1, 0, 1, 1,
3, 1, 2, 3, 3, 1, 4, 4, 2, 3,
4, 1, 3, 3, 4, 6, 6, 6, 6, 6,
0, 4, 4, 3, 5, 4, 2, 2, 2, 2,
2, 2, 1, 1, 1, 3, 3, 3, 3, 3,
3, 3, 3, 0, 1, 1, 4, 2, 2, 1,
1, 1
};
static short yydefact[] = { 64,
0, 4, 126, 115, 114, 65, 0, 0, 13, 101,
0, 0, 0, 0, 92, 0, 0, 24, 0, 0,
16, 0, 2, 0, 0, 18, 0, 86, 113, 0,
0, 64, 34, 132, 6, 8, 0, 64, 7, 9,
0, 124, 0, 0, 126, 109, 110, 0, 0, 0,
108, 86, 107, 0, 128, 82, 0, 0, 80, 21,
89, 5, 3, 12, 0, 16, 16, 16, 10, 11,
0, 0, 0, 34, 34, 0, 0, 0, 0, 0,
0, 0, 0, 0, 111, 112, 0, 0, 80, 0,
32, 36, 35, 129, 30, 0, 76, 0, 0, 34,
0, 0, 0, 49, 53, 0, 76, 130, 0, 28,
41, 0, 0, 26, 64, 33, 34, 66, 125, 0,
0, 0, 0, 0, 131, 22, 83, 0, 0, 90,
0, 19, 20, 23, 104, 93, 94, 0, 122, 0,
0, 0, 120, 121, 117, 118, 119, 116, 124, 123,
106, 127, 38, 37, 0, 0, 77, 0, 0, 0,
76, 47, 48, 0, 0, 0, 0, 57, 0, 31,
29, 27, 61, 0, 39, 0, 67, 102, 0, 0,
0, 91, 25, 84, 85, 81, 0, 0, 95, 87,
88, 0, 103, 0, 59, 0, 0, 0, 126, 0,
0, 66, 0, 66, 58, 34, 0, 0, 0, 0,
0, 0, 0, 15, 105, 34, 0, 34, 0, 0,
0, 51, 0, 55, 0, 40, 73, 71, 0, 0,
68, 97, 98, 99, 100, 96, 0, 0, 0, 0,
0, 0, 76, 66, 50, 66, 54, 34, 74, 0,
62, 60, 42, 0, 0, 76, 0, 0, 0, 14,
75, 72, 34, 34, 34, 0, 34, 52, 56, 0,
43, 0, 34, 0, 63, 46, 0, 45, 44, 0,
0, 0
};
static short yydefgoto[] = { 280,
22, 23, 24, 41, 64, 25, 26, 54, 35, 109,
36, 94, 110, 165, 244, 167, 246, 111, 1, 178,
208, 229, 230, 156, 87, 88, 112, 52, 42, 118,
29, 113, 114, 126, 38
};
static short yypact[] = {-32768,
515,-32768, -26,-32768,-32768,-32768, 72, 72,-32768,-32768,
-22, -16, 95, 95, -12, 1013, 1013,-32768, 1013, 619,
894, 297,-32768, -2, 255,-32768, 1152, 503, 73, 641,
754,-32768, 134,-32768,-32768,-32768, 349,-32768,-32768,-32768,
60, 95, 943, 1013, 11,-32768,-32768, 641, 754, 1013,
-43,-32768, -43, 64, 40,-32768, 174, 1, 1025, 62,
-43,-32768,-32768,-32768, 463, 894, 894, 894,-32768,-32768,
1013, 943, 964, 134, 134, 1013, 1013, 1013, 1013, 1013,
1013, 1013, 84, 1013,-32768,-32768, 67, 61, 1152, 49,
126,-32768,-32768, 145,-32768, 99, 1013, 153, 111, 134,
124, 27, 27, 127, 131, 27, 1013,-32768, 406,-32768,
-32768, 817, 463,-32768,-32768, 126, 134, 183,-32768, 130,
1081, 1099, 67, 147,-32768,-32768, 1013, 805, 197,-32768,
406, 62, 70, 149, 593,-32768, 1199, 209, 539, 879,
879, 1138, 225, 225, -43, -43, -43, -43, 95, 1152,
-32768,-32768,-32768,-32768, 1013, 27, 1152, 161, 1013, 690,
1069,-32768,-32768, 641, 567, 641, 567,-32768, 27,-32768,
-32768,-32768,-32768, 406, 126, 123,-32768,-32768, 754, 754,
943,-32768,-32768, 1152,-32768, 1152, 182, 27,-32768, 1207,
1191, 1013,-32768, 1025,-32768, 754, 1025, 196, 79, 160,
67, 183, 67, 183,-32768, 134, 0, 1013, 1, 1,
67, 1025, 227,-32768, 1152, 134, 50, 134, 178, 199,
739,-32768, 27,-32768, 27, 145,-32768,-32768, 67, 36,
179,-32768,-32768,-32768,-32768,-32768, 690, 27, 690, 1013,
235, 835, 1013, 183,-32768, 183,-32768, 134,-32768, 166,
222,-32768,-32768, 1025, 67, 1013, 67, 27, 27, 145,
-32768,-32768, 134, 134, 134, 67, 134,-32768,-32768, 690,
145, 690, 134, 690,-32768,-32768, 690,-32768,-32768, 241,
243,-32768
};
static short yypgoto[] = {-32768,
-32768, 223,-32768,-32768,-32768, 169, -36,-32768, 122, -57,
6, -65, 12,-32768,-32768,-32768,-32768,-32768, -15, -147,
-32768,-32768,-32768, -101, 39, -9, -1, 24,-32768, 98,
19, 109, -105, 65, -24
};
#define YYLAST 1262
static short yytable[] = { 27,
227, 127, 228, 172, 82, 169, 120, 131, 140, 141,
58, 83, 115, 40, 51, 53, 91, 55, 59, 61,
27, 90, 116, 30, 28, 188, 31, 43, 89, 89,
70, 46, 47, 44, 160, 136, 249, 48, 32, 58,
115, 121, 122, 28, 28, 28, 89, 59, 61, 127,
127, 176, 128, 33, 223, 174, 225, -69, 125, 200,
119, 127, 117, 31, 27, 27, 27, 124, 206, 135,
137, 139, -79, -79, 142, 143, 144, 145, 146, 147,
148, 84, 150, 32, 115, 34, 123, 250, 115, 28,
28, 28, 220, -70, 83, 157, 258, 45, 259, 175,
128, 128, 152, 238, 66, 157, 115, 162, 163, 85,
86, 168, 128, 68, 149, 37, 37, 173, -79, -79,
171, 68, 129, 130, 125, 184, 186, 33, 30, 39,
34, 31, 65, 37, 153, 115, 154, 6, 190, 191,
226, 257, 171, 19, 211, 92, 69, 93, 155, 115,
237, 151, 239, 194, 266, 158, 153, 197, 154, 157,
159, 195, 89, 89, 89, 89, 261, 119, 262, 209,
210, 198, 207, 161, 205, 221, 164, 89, 89, 212,
166, 179, 260, 66, 67, 171, 217, 182, 57, 60,
215, 183, 73, 214, 89, 177, 243, 270, 271, 272,
68, 274, 201, 202, 203, 204, 231, 277, 66, 67,
187, 189, 115, 196, 115, 213, 219, 256, 34, 242,
77, 78, 79, 80, 81, 68, 82, 240, 245, 236,
247, 125, 241, 83, 132, 133, 134, 255, 254, 263,
281, 157, 282, 252, 63, 115, 193, 115, 251, 115,
253, 0, 115, 0, 157, 0, 0, 0, 216, 0,
0, 218, 0, 268, 269, 222, 32, 224, 79, 80,
81, 0, 82, 232, 233, 234, 235, 0, 0, 83,
0, 275, 0, 276, 0, 278, 0, 0, 279, 66,
67, 0, 0, 248, 0, 0, -1, 62, 0, 3,
0, 4, 0, 0, 5, 0, 68, 0, -16, 0,
33, 7, 8, 34, 0, 0, 0, 0, 264, 265,
0, 267, 0, 0, 0, 0, 9, 10, 11, 12,
273, -16, -16, 13, 14, 15, 0, 0, 16, 17,
0, 18, 0, 0, 0, 19, 20, 21, -16, 95,
0, 3, -16, 4, 0, -16, 5, 0, 0, 0,
0, 0, 0, 0, 0, 96, 0, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 0, 10,
11, 12, 0, 0, 0, 13, 14, 15, 0, 0,
16, 17, 0, 0, 0, 0, 0, 19, 49, 50,
0, 0, 0, 0, 33, 108, 170, 34, 3, 0,
4, 0, 0, 5, 0, 0, 0, 0, 0, 0,
0, 0, 96, 0, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 0, 10, 11, 12, 0,
0, 0, 13, 14, 15, 0, 0, 16, 17, 0,
0, 0, 0, 0, 19, 49, 50, 0, 0, 0,
0, 33, 108, 95, 34, 3, 0, 4, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 96,
0, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106, 107, 0, 10, 11, 12, 0, 0, 0, 13,
14, 15, 0, 0, 16, 17, 0, 0, 0, 0,
0, 19, 49, 50, -17, 2, 0, 3, 33, 4,
0, 34, 5, 0, 0, 0, 6, 0, 0, 7,
8, 0, 0, 0, 0, 0, 0, -17, -17, 0,
0, 0, 0, 0, 9, 10, 11, 12, 0, -16,
-16, 13, 14, 15, -17, 0, 16, 17, -17, 18,
-17, -17, 0, 19, 20, 21, -16, 56, 0, 3,
-16, 4, 0, -16, 5, 0, 0, 0, -78, -78,
77, 78, 79, 80, 81, 0, 82, 0, 0, 0,
0, 0, 0, 83, 0, 0, 0, 10, 11, 12,
0, 0,-32768, 13, 14, 15, 73, 0, 16, 17,
0, 0, 0, 0, 0, 19, 49, 50, 0, 56,
0, 3, 0, 4, 0, -78, 5, 0, 0, 0,
0, 0, 0, 0, 77, 78, 79, 80, 81, 0,
82, 56, 0, 3, 0, 4, 0, 83, 5, 10,
11, 12, 0, -16, -16, 13, 14, 15, 0, 0,
16, 17, 0, 18, 0, 0, 0, 19, 20, 21,
-16, 10, 11, 12, 0, 0, -16, 13, 14, 15,
0, 0, 16, 17, 0, 0, 0, 0, 0, 19,
49, 50, 3, 0, 4, 0, 0, 5, -78, 0,
0, 153, 0, 154, 0, 0, 96, 0, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 0,
10, 11, 12, 0, 0, 0, 13, 14, 15, 0,
0, 16, 17, 0, 0, 0, 0, 0, 19, 49,
50, 3, 0, 4, 0, 33, 5, 0, 34, 0,
0, 0, 0, 0, 56, 0, 3, 0, 4, 0,
0, 5, 0, 0, 0, 0, 0, 0, 0, 10,
11, 12, 0, 0, 0, 13, 14, 15, 0, 0,
16, 17, 0, 0, 10, 11, 12, 19, 49, 50,
13, 14, 15, 0, 0, 16, 17, 34, 0, 0,
0, 0, 19, 49, 50, 185, 0, 3, 0, 4,
0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 71, 72, 32, 0,
73, 0, 0, 0, 0, 10, 11, 12, 0, 0,
0, 13, 14, 15, 71, 72, 16, 17, 73, 0,
0, 74, 75, 19, 49, 50, 76, 0, 77, 78,
79, 80, 81, 0, 82, 0, 0, 0, 0, 74,
75, 83, 0, 0, 76, 34, 77, 78, 79, 80,
81, 3, 82, 4, 0, 0, 5, 0, 0, 83,
153, 0, 154, 34, 0, 0, 3, 0, 4, 0,
0, 5, 0, 0, 0, 0, 0, 0, 0, 10,
11, 12, 0, 0, 0, 13, 14, 15, 0, 0,
16, 17, 0, 0, 10, 11, 12, 19, 49, 50,
13, 14, 15, 0, 0, 16, 17, 0, 18, 0,
0, 0, 19, 20, 21, 3, 0, 4, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 0, 4, 0,
0, 5, 0, 10, 11, 12, 0, 0, 0, 13,
14, 15, 0, 0, 16, 17, 0, 18, 0, 0,
0, 19, 49, 50, 10, 11, 12, 138, 0, 0,
13, 14, 15, 0, 0, 16, 17, 0, 0, 0,
0, 0, 19, 49, 50, 3, 0, 4, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 71, 72, 0, 0, 73, 0,
0, 0, 0, 10, 11, 12, 0, 0, 0, 13,
14, 15, 0, 0, 16, 17, 0, 0, 0, 74,
75, 19, 49, 50, 76, 0, 77, 78, 79, 80,
81, 199, 82, 4, 0, 0, 5, 0, 0, 83,
0, 0, 125, 0, 0, 0, 0, 0, 0, 0,
71, 72, 0, 0, 73, 0, 0, 0, 0, 10,
11, 12, 0, 0, 0, 13, 14, 15, 71, 72,
16, 17, 73, 0, 0, 74, 75, 19, 49, 50,
76, 0, 77, 78, 79, 80, 81, 0, 82, 0,
0, 0, 180, 74, 75, 83, 0, 0, 76, 0,
77, 78, 79, 80, 81, 0, 82, 71, 72, 0,
181, 73, 0, 83, 0, 0, 0, 0, 0, 0,
0, 71, 72, 0, 0, 73, 0, 0, 0, 0,
0, 0, 74, 75, 0, 0, 0, 76, 192, 77,
78, 79, 80, 81, 0, 82, 74, 75, 0, 0,
0, 76, 83, 77, 78, 79, 80, 81, 0, 82,
71, 72, 0, 0, 73, 0, 83, 0, 71,-32768,
0, 0, 73, 0, 0, 0, 71, 72, 0, 0,
73, 0, 0, 0, 0, 74, 0, 0, 0, 0,
0, 0, 77, 78, 79, 80, 81, 0, 82, 0,
77, 78, 79, 80, 81, 83, 82, 0, 77, 78,
79, 80, 81, 83, 82, 0, 0, 0, 0, 0,
0, 83
};
static short yycheck[] = { 1,
1, 1, 3, 109, 48, 107, 43, 65, 74, 75,
20, 55, 37, 8, 16, 17, 32, 19, 20, 21,
22, 31, 38, 50, 1, 131, 53, 50, 30, 31,
25, 13, 14, 50, 100, 72, 1, 50, 12, 49,
65, 43, 44, 20, 21, 22, 48, 49, 50, 1,
1, 117, 52, 56, 202, 113, 204, 58, 58, 161,
42, 1, 3, 53, 66, 67, 68, 4, 174, 71,
72, 73, 12, 13, 76, 77, 78, 79, 80, 81,
82, 9, 84, 12, 109, 59, 48, 52, 113, 66,
67, 68, 14, 58, 55, 97, 244, 3, 246, 115,
52, 52, 54, 54, 35, 107, 131, 102, 103, 37,
38, 106, 52, 52, 31, 7, 8, 112, 58, 59,
109, 52, 58, 59, 58, 127, 128, 56, 50, 8,
59, 53, 24, 25, 12, 160, 14, 12, 140, 141,
206, 243, 131, 49, 181, 12, 25, 14, 50, 174,
216, 87, 218, 155, 256, 3, 12, 159, 14, 161,
50, 156, 164, 165, 166, 167, 1, 149, 3, 179,
180, 160, 50, 50, 169, 200, 50, 179, 180, 181,
50, 52, 248, 35, 36, 174, 196, 123, 20, 21,
192, 45, 14, 188, 196, 13, 221, 263, 264, 265,
52, 267, 164, 165, 166, 167, 208, 273, 35, 36,
14, 3, 237, 53, 239, 34, 21, 242, 59, 221,
42, 43, 44, 45, 46, 52, 48, 50, 223, 3,
225, 58, 34, 55, 66, 67, 68, 3, 240, 18,
0, 243, 0, 238, 22, 270, 149, 272, 237, 274,
239, -1, 277, -1, 256, -1, -1, -1, 194, -1,
-1, 197, -1, 258, 259, 201, 12, 203, 44, 45,
46, -1, 48, 209, 210, 211, 212, -1, -1, 55,
-1, 270, -1, 272, -1, 274, -1, -1, 277, 35,
36, -1, -1, 229, -1, -1, 0, 1, -1, 3,
-1, 5, -1, -1, 8, -1, 52, -1, 12, -1,
56, 15, 16, 59, -1, -1, -1, -1, 254, 255,
-1, 257, -1, -1, -1, -1, 30, 31, 32, 33,
266, 35, 36, 37, 38, 39, -1, -1, 42, 43,
-1, 45, -1, -1, -1, 49, 50, 51, 52, 1,
-1, 3, 56, 5, -1, 59, 8, -1, -1, -1,
-1, -1, -1, -1, -1, 17, -1, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, -1, 31,
32, 33, -1, -1, -1, 37, 38, 39, -1, -1,
42, 43, -1, -1, -1, -1, -1, 49, 50, 51,
-1, -1, -1, -1, 56, 57, 1, 59, 3, -1,
5, -1, -1, 8, -1, -1, -1, -1, -1, -1,
-1, -1, 17, -1, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, -1, 31, 32, 33, -1,
-1, -1, 37, 38, 39, -1, -1, 42, 43, -1,
-1, -1, -1, -1, 49, 50, 51, -1, -1, -1,
-1, 56, 57, 1, 59, 3, -1, 5, -1, -1,
8, -1, -1, -1, -1, -1, -1, -1, -1, 17,
-1, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, -1, 31, 32, 33, -1, -1, -1, 37,
38, 39, -1, -1, 42, 43, -1, -1, -1, -1,
-1, 49, 50, 51, 12, 1, -1, 3, 56, 5,
-1, 59, 8, -1, -1, -1, 12, -1, -1, 15,
16, -1, -1, -1, -1, -1, -1, 35, 36, -1,
-1, -1, -1, -1, 30, 31, 32, 33, -1, 35,
36, 37, 38, 39, 52, -1, 42, 43, 56, 45,
58, 59, -1, 49, 50, 51, 52, 1, -1, 3,
56, 5, -1, 59, 8, -1, -1, -1, 12, 13,
42, 43, 44, 45, 46, -1, 48, -1, -1, -1,
-1, -1, -1, 55, -1, -1, -1, 31, 32, 33,
-1, -1, 10, 37, 38, 39, 14, -1, 42, 43,
-1, -1, -1, -1, -1, 49, 50, 51, -1, 1,
-1, 3, -1, 5, -1, 59, 8, -1, -1, -1,
-1, -1, -1, -1, 42, 43, 44, 45, 46, -1,
48, 1, -1, 3, -1, 5, -1, 55, 8, 31,
32, 33, -1, 35, 36, 37, 38, 39, -1, -1,
42, 43, -1, 45, -1, -1, -1, 49, 50, 51,
52, 31, 32, 33, -1, -1, 58, 37, 38, 39,
-1, -1, 42, 43, -1, -1, -1, -1, -1, 49,
50, 51, 3, -1, 5, -1, -1, 8, 58, -1,
-1, 12, -1, 14, -1, -1, 17, -1, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, -1,
31, 32, 33, -1, -1, -1, 37, 38, 39, -1,
-1, 42, 43, -1, -1, -1, -1, -1, 49, 50,
51, 3, -1, 5, -1, 56, 8, -1, 59, -1,
-1, -1, -1, -1, 1, -1, 3, -1, 5, -1,
-1, 8, -1, -1, -1, -1, -1, -1, -1, 31,
32, 33, -1, -1, -1, 37, 38, 39, -1, -1,
42, 43, -1, -1, 31, 32, 33, 49, 50, 51,
37, 38, 39, -1, -1, 42, 43, 59, -1, -1,
-1, -1, 49, 50, 51, 1, -1, 3, -1, 5,
-1, -1, 8, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 10, 11, 12, -1,
14, -1, -1, -1, -1, 31, 32, 33, -1, -1,
-1, 37, 38, 39, 10, 11, 42, 43, 14, -1,
-1, 35, 36, 49, 50, 51, 40, -1, 42, 43,
44, 45, 46, -1, 48, -1, -1, -1, -1, 35,
36, 55, -1, -1, 40, 59, 42, 43, 44, 45,
46, 3, 48, 5, -1, -1, 8, -1, -1, 55,
12, -1, 14, 59, -1, -1, 3, -1, 5, -1,
-1, 8, -1, -1, -1, -1, -1, -1, -1, 31,
32, 33, -1, -1, -1, 37, 38, 39, -1, -1,
42, 43, -1, -1, 31, 32, 33, 49, 50, 51,
37, 38, 39, -1, -1, 42, 43, -1, 45, -1,
-1, -1, 49, 50, 51, 3, -1, 5, -1, -1,
8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 3, -1, 5, -1,
-1, 8, -1, 31, 32, 33, -1, -1, -1, 37,
38, 39, -1, -1, 42, 43, -1, 45, -1, -1,
-1, 49, 50, 51, 31, 32, 33, 34, -1, -1,
37, 38, 39, -1, -1, 42, 43, -1, -1, -1,
-1, -1, 49, 50, 51, 3, -1, 5, -1, -1,
8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 10, 11, -1, -1, 14, -1,
-1, -1, -1, 31, 32, 33, -1, -1, -1, 37,
38, 39, -1, -1, 42, 43, -1, -1, -1, 35,
36, 49, 50, 51, 40, -1, 42, 43, 44, 45,
46, 3, 48, 5, -1, -1, 8, -1, -1, 55,
-1, -1, 58, -1, -1, -1, -1, -1, -1, -1,
10, 11, -1, -1, 14, -1, -1, -1, -1, 31,
32, 33, -1, -1, -1, 37, 38, 39, 10, 11,
42, 43, 14, -1, -1, 35, 36, 49, 50, 51,
40, -1, 42, 43, 44, 45, 46, -1, 48, -1,
-1, -1, 52, 35, 36, 55, -1, -1, 40, -1,
42, 43, 44, 45, 46, -1, 48, 10, 11, -1,
52, 14, -1, 55, -1, -1, -1, -1, -1, -1,
-1, 10, 11, -1, -1, 14, -1, -1, -1, -1,
-1, -1, 35, 36, -1, -1, -1, 40, 41, 42,
43, 44, 45, 46, -1, 48, 35, 36, -1, -1,
-1, 40, 55, 42, 43, 44, 45, 46, -1, 48,
10, 11, -1, -1, 14, -1, 55, -1, 10, 11,
-1, -1, 14, -1, -1, -1, 10, 11, -1, -1,
14, -1, -1, -1, -1, 35, -1, -1, -1, -1,
-1, -1, 42, 43, 44, 45, 46, -1, 48, -1,
42, 43, 44, 45, 46, 55, 48, -1, 42, 43,
44, 45, 46, 55, 48, -1, -1, -1, -1, -1,
-1, 55
};
#define YYPURE 1
#line 2 "bison.simple"
/* 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 YYFAIL goto yyerrlab;
#define YYTERROR 1
#ifndef YYIMPURE
#define YYLEX yylex()
#endif
#ifndef YYPURE
#define YYLEX yylex(&yylval, &yylloc)
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYIMPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
int yydebug = 0; /* nonzero means print parse trace */
#endif /* YYIMPURE */
/* YYMAXDEPTH indicates the initial size of the parser's stacks */
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 200
#endif
/* YYMAXLIMIT is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#ifndef YYMAXLIMIT
#define YYMAXLIMIT 10000
#endif
#line 87 "bison.simple"
int
yyparse()
{
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1; /* lookahead token as an internal (translated) token number */
short yyssa[YYMAXDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */
YYLTYPE yylsa[YYMAXDEPTH]; /* the location stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
YYLTYPE *yyls = yylsa;
int yymaxdepth = YYMAXDEPTH;
#ifndef YYPURE
int yychar;
YYSTYPE yylval;
YYLTYPE yylloc;
extern int yydebug;
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
if (yydebug)
fprintf(stderr, "Starting parse\n");
yystate = 0;
yyerrstatus = 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;
yylsp = yyls;
/* 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 + yymaxdepth - 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;
YYLTYPE *yyls1 = yyls;
short *yyss1 = yyss;
/* 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),
&yyls1, size * sizeof (*yylsp),
&yymaxdepth);
yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yymaxdepth >= YYMAXLIMIT)
yyerror("parser stack overflow");
yymaxdepth *= 2;
if (yymaxdepth > YYMAXLIMIT)
yymaxdepth = YYMAXLIMIT;
yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yylsp = yyls + size - 1;
yyvsp = yyvs + size - 1;
if (yydebug)
fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
if (yyssp >= yyss + yymaxdepth - 1)
YYERROR;
}
if (yydebug)
fprintf(stderr, "Entering state %d\n", yystate);
/* 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)
{
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)
fprintf(stderr, "Now at end of input.\n");
}
else
{
yychar1 = YYTRANSLATE(yychar);
if (yydebug)
fprintf(stderr, "Parsing next token; it is %d (%s)\n", yychar, yytname[yychar1]);
}
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)
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
*++yylsp = yylloc;
/* 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)
{
if (yylen == 1)
fprintf (stderr, "Reducing 1 value via line %d, ",
yyrline[yyn]);
else
fprintf (stderr, "Reducing %d values via line %d, ",
yylen, yyrline[yyn]);
}
switch (yyn) {
case 1:
#line 234 "awk.y"
{ expression_value = yyvsp[0].nodeval; ;
break;}
case 2:
#line 239 "awk.y"
{
if (yyvsp[0].nodeval != NULL)
yyval.nodeval = node (yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL);
else
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 3:
#line 248 "awk.y"
{
if (yyvsp[0].nodeval == NULL)
yyval.nodeval = yyvsp[-1].nodeval;
else if (yyvsp[-1].nodeval == NULL)
yyval.nodeval = node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL);
else
yyval.nodeval = append_right (yyvsp[-1].nodeval,
node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
yyerrok;
;
break;}
case 4:
#line 258 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 6:
#line 264 "awk.y"
{
if (begin_block)
append_right (begin_block, node(
node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL) );
else
begin_block = node(node((NODE *)NULL,Node_rule_node,yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL);
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 7:
#line 276 "awk.y"
{
if (end_block)
append_right (end_block, node(
node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL));
else
end_block = node(node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
Node_rule_list, (NODE *)NULL);
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 8:
#line 288 "awk.y"
{
msg ("error near line %d: BEGIN blocks must have an action part", lineno);
errcount++;
yyerrok;
;
break;}
case 9:
#line 294 "awk.y"
{
msg ("error near line %d: END blocks must have an action part", lineno);
errcount++;
yyerrok;
;
break;}
case 10:
#line 300 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
break;}
case 11:
#line 302 "awk.y"
{ if(yyvsp[-1].nodeval) yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, (NODE *)NULL); yyerrok; ;
break;}
case 12:
#line 304 "awk.y"
{
/*obstack_free(&var_stack, func_def);*/
func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
yyval.nodeval = NULL;
yyerrok;
;
break;}
case 13:
#line 314 "awk.y"
{
func_def = (char *) obstack_alloc(&var_stack, 0);
param_counter = 0;
;
break;}
case 14:
#line 319 "awk.y"
{
yyval.nodeval = append_right(make_param(yyvsp[-5].sval), yyvsp[-2].nodeval);
;
break;}
case 15:
#line 326 "awk.y"
{ yyval.nodeval = yyvsp[-2].nodeval; ;
break;}
case 16:
#line 331 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 17:
#line 333 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 18:
#line 335 "awk.y"
{
yyval.nodeval = node(
node(make_number((AWKNUM)0),Node_field_spec,(NODE*)NULL),
Node_match, yyvsp[0].nodeval);
;
break;}
case 19:
#line 341 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
break;}
case 20:
#line 343 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
break;}
case 21:
#line 345 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
break;}
case 22:
#line 347 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 23:
#line 349 "awk.y"
{ yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
break;}
case 24:
#line 356 "awk.y"
{ ++want_regexp; ;
break;}
case 25:
#line 358 "awk.y"
{ want_regexp = 0;
rp = mk_re_parse(yyvsp[-1].sval);
yyval.nodeval = node((NODE *)NULL, Node_regex, (NODE *)rp);
;
break;}
case 26:
#line 366 "awk.y"
{
/* empty actions are different from missing actions */
yyval.nodeval = node ((NODE *) NULL, Node_illegal, (NODE *) NULL);
;
break;}
case 27:
#line 371 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval ; ;
break;}
case 28:
#line 376 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL); ;
break;}
case 29:
#line 378 "awk.y"
{
yyval.nodeval = append_right(yyvsp[-1].nodeval,
node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
yyerrok;
;
break;}
case 30:
#line 384 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 32:
#line 390 "awk.y"
{ yyval.nodetypeval = Node_illegal; want_redirect = 0; ;
break;}
case 33:
#line 392 "awk.y"
{ yyval.nodetypeval = Node_illegal; want_redirect = 0; ;
break;}
case 34:
#line 397 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 35:
#line 399 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 36:
#line 401 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 37:
#line 403 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 38:
#line 405 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 39:
#line 410 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 40:
#line 412 "awk.y"
{ yyval.nodeval = yyvsp[-2].nodeval; ;
break;}
case 41:
#line 414 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 42:
#line 416 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
break;}
case 43:
#line 418 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
break;}
case 44:
#line 420 "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 45:
#line 422 "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 46:
#line 424 "awk.y"
{
yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor,
make_for_loop(variable(yyvsp[-6].sval),
(NODE *)NULL, variable(yyvsp[-3].sval)));
;
break;}
case 47:
#line 431 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
break;}
case 48:
#line 434 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
break;}
case 49:
#line 436 "awk.y"
{ ++want_redirect; ;
break;}
case 50:
#line 438 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_print, yyvsp[-1].nodeval); ;
break;}
case 51:
#line 440 "awk.y"
{ ++want_redirect; want_concat_token = 0; ;
break;}
case 52:
#line 442 "awk.y"
{ yyval.nodeval = node (yyvsp[-4].nodeval, Node_K_print, yyvsp[-1].nodeval); ;
break;}
case 53:
#line 444 "awk.y"
{ ++want_redirect; ;
break;}
case 54:
#line 446 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_printf, yyvsp[-1].nodeval); ;
break;}
case 55:
#line 448 "awk.y"
{ ++want_redirect; want_concat_token = 0; ;
break;}
case 56:
#line 450 "awk.y"
{ yyval.nodeval = node (yyvsp[-4].nodeval, Node_K_printf, yyvsp[-1].nodeval); ;
break;}
case 57:
#line 452 "awk.y"
{ yyval.nodeval = node ((NODE *)NULL, Node_K_next, (NODE *)NULL); ;
break;}
case 58:
#line 454 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
break;}
case 59:
#line 456 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
break;}
case 60:
#line 458 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[-4].sval), Node_K_delete, yyvsp[-2].nodeval); ;
break;}
case 61:
#line 460 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 62:
#line 465 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_if,
node (yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL)); ;
break;}
case 63:
#line 469 "awk.y"
{ yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
break;}
case 65:
#line 476 "awk.y"
{ yyval.nodetypeval = Node_illegal; ;
break;}
case 66:
#line 481 "awk.y"
{ want_redirect = 0; yyval.nodeval = NULL; ;
break;}
case 67:
#line 483 "awk.y"
{ want_redirect = 0; ;
break;}
case 68:
#line 485 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, yyvsp[-2].nodetypeval, (NODE *)NULL); ;
break;}
case 69:
#line 490 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 71:
#line 497 "awk.y"
{
yyval.nodeval = make_param(yyvsp[0].sval);
;
break;}
case 72:
#line 501 "awk.y"
{
yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval));
yyerrok;
;
break;}
case 73:
#line 506 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 76:
#line 514 "awk.y"
{ yyval.nodeval = NULL; /* node(NULL, Node_builtin, NULL); */ ;
break;}
case 78:
#line 520 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 79:
#line 522 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 80:
#line 527 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
break;}
case 81:
#line 529 "awk.y"
{
yyval.nodeval = append_right(yyvsp[-2].nodeval,
node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
yyerrok;
;
break;}
case 82:
#line 535 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 87:
#line 544 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_and, yyvsp[0].nodeval); ;
break;}
case 88:
#line 546 "awk.y"
{ yyval.nodeval = node (yyvsp[-3].nodeval, Node_or, yyvsp[0].nodeval); ;
break;}
case 89:
#line 548 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
break;}
case 90:
#line 550 "awk.y"
{ yyval.nodeval = yyvsp[-1].nodeval; ;
break;}
case 91:
#line 554 "awk.y"
{ yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, yyvsp[-3].ptrval); ;
break;}
case 92:
#line 556 "awk.y"
{ yyval.nodeval = snode ((NODE *)NULL, Node_builtin, yyvsp[0].ptrval); ;
break;}
case 93:
#line 558 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 94:
#line 560 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 95:
#line 562 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-3].nodeval); ;
break;}
case 96:
#line 564 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-4].nodeval); ;
break;}
case 97:
#line 566 "awk.y"
{ yyval.nodeval = node(yyvsp[-1].nodeval, yyvsp[-5].nodetypeval, yyvsp[-3].nodeval); ;
break;}
case 98:
#line 568 "awk.y"
{ yyval.nodeval = node(yyvsp[-1].nodeval, yyvsp[-5].nodetypeval, yyvsp[-3].nodeval); ;
break;}
case 99:
#line 570 "awk.y"
{ yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
break;}
case 100:
#line 572 "awk.y"
{ yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
break;}
case 101:
#line 574 "awk.y"
{++want_redirect; ;
break;}
case 102:
#line 576 "awk.y"
{
yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
;
break;}
case 103:
#line 580 "awk.y"
{
yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
;
break;}
case 104:
#line 585 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 105:
#line 587 "awk.y"
{ yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
break;}
case 106:
#line 589 "awk.y"
{
yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
;
break;}
case 107:
#line 593 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL); ;
break;}
case 108:
#line 595 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 109:
#line 597 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
break;}
case 110:
#line 599 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
break;}
case 111:
#line 601 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
break;}
case 112:
#line 603 "awk.y"
{ yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
break;}
case 113:
#line 605 "awk.y"
{ yyval.nodeval = yyvsp[0].nodeval; ;
break;}
case 114:
#line 607 "awk.y"
{ yyval.nodeval = make_number (yyvsp[0].fval); ;
break;}
case 115:
#line 609 "awk.y"
{ yyval.nodeval = make_string (yyvsp[0].sval, -1); ;
break;}
case 116:
#line 613 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
break;}
case 117:
#line 615 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
break;}
case 118:
#line 617 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
break;}
case 119:
#line 619 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
break;}
case 120:
#line 621 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
break;}
case 121:
#line 623 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
break;}
case 122:
#line 626 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, Node_concat, yyvsp[0].nodeval); ;
break;}
case 123:
#line 628 "awk.y"
{ yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
break;}
case 124:
#line 633 "awk.y"
{ yyval.nodeval = NULL; ;
break;}
case 126:
#line 639 "awk.y"
{ yyval.nodeval = variable (yyvsp[0].sval); ;
break;}
case 127:
#line 641 "awk.y"
{ yyval.nodeval = node (variable(yyvsp[-3].sval), Node_subscript, yyvsp[-1].nodeval); ;
break;}
case 128:
#line 643 "awk.y"
{ yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
break;}
case 130:
#line 651 "awk.y"
{ yyerrok; ;
break;}
case 131:
#line 655 "awk.y"
{ yyval.nodetypeval = Node_illegal; yyerrok; ;
break;}
case 132:
#line 659 "awk.y"
{ yyerrok; ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
#line 303 "bison.simple"
yyvsp -= yylen;
yylsp -= yylen;
yyssp -= yylen;
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "state stack now", yyssp-yyss);
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
*++yyvsp = yyval;
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;
}
/* 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. */
{
yyerror("parse error");
}
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)
YYERROR;
if (yydebug)
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
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) YYERROR;
yyvsp--;
yylsp--;
yystate = *--yyssp;
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "Error: state stack now", yyssp-yyss);
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
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)
fprintf(stderr, "Shifting error token, ");
*++yyvsp = yylval;
*++yylsp = yylloc;
yystate = yyn;
goto yynewstate;
}
#line 662 "awk.y"
struct token {
char *operator;
NODETYPE value;
int class;
NODE *(*ptr) ();
};
#define NULL 0
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();
/* Special functions for debugging */
#ifdef DEBUG
NODE *do_prvars(), *do_bp();
#endif
/* Tokentab is sorted ascii ascending order, so it can be binary searched. */
static struct token tokentab[] = {
{ "BEGIN", Node_illegal, LEX_BEGIN, 0 },
{ "END", Node_illegal, LEX_END, 0 },
{ "atan2", Node_builtin, LEX_BUILTIN, do_atan2 },
#ifdef DEBUG
{ "bp", Node_builtin, LEX_BUILTIN, do_bp },
#endif
{ "break", Node_K_break, LEX_BREAK, 0 },
{ "close", Node_builtin, LEX_BUILTIN, do_close },
{ "continue", Node_K_continue, LEX_CONTINUE, 0 },
{ "cos", Node_builtin, LEX_BUILTIN, do_cos },
{ "delete", Node_K_delete, LEX_DELETE, 0 },
{ "do", Node_K_do, LEX_DO, 0 },
{ "else", Node_illegal, LEX_ELSE, 0 },
{ "exit", Node_K_exit, LEX_EXIT, 0 },
{ "exp", Node_builtin, LEX_BUILTIN, do_exp },
{ "for", Node_K_for, LEX_FOR, 0 },
{ "func", Node_K_function, LEX_FUNCTION, 0 },
{ "function", Node_K_function, LEX_FUNCTION, 0 },
{ "getline", Node_K_getline, LEX_GETLINE, 0 },
{ "gsub", Node_gsub, LEX_SUB, 0 },
{ "if", Node_K_if, LEX_IF, 0 },
{ "in", Node_illegal, LEX_IN, 0 },
{ "index", Node_builtin, LEX_BUILTIN, do_index },
{ "int", Node_builtin, LEX_BUILTIN, do_int },
{ "length", Node_builtin, LEX_BUILTIN, do_length },
{ "log", Node_builtin, LEX_BUILTIN, do_log },
{ "match", Node_K_match, LEX_MATCH, 0 },
{ "next", Node_K_next, LEX_NEXT, 0 },
{ "print", Node_K_print, LEX_PRINT, 0 },
{ "printf", Node_K_printf, LEX_PRINTF, 0 },
#ifdef DEBUG
{ "prvars", Node_builtin, LEX_BUILTIN, do_prvars },
#endif
{ "rand", Node_builtin, LEX_BUILTIN, do_rand },
{ "return", Node_K_return, LEX_RETURN, 0 },
{ "sin", Node_builtin, LEX_BUILTIN, do_sin },
{ "split", Node_builtin, LEX_BUILTIN, do_split },
{ "sprintf", Node_builtin, LEX_BUILTIN, do_sprintf },
{ "sqrt", Node_builtin, LEX_BUILTIN, do_sqrt },
{ "srand", Node_builtin, LEX_BUILTIN, do_srand },
{ "sub", Node_sub, LEX_SUB, 0 },
{ "substr", Node_builtin, LEX_BUILTIN, do_substr },
{ "system", Node_builtin, LEX_BUILTIN, do_system },
{ "while", Node_K_while, LEX_WHILE, 0 },
};
/* VARARGS0 */
yyerror(va_alist)
va_dcl
{
va_list args;
char *mesg;
char *a1;
register char *ptr, *beg;
static int list = 0;
char *scan;
#ifdef OSK
char oskbuf[50];
#endif
errcount++;
va_start(args);
mesg = va_arg(args, char *);
if (mesg || !list) {
/* Find the current line in the input file */
if (!lexptr) {
beg = "(END OF FILE)";
ptr = beg + 13;
} else {
if (*lexptr == '\n' && lexptr != lexptr_begin)
--lexptr;
for (beg = lexptr; beg != lexptr_begin && *beg != '\n'; --beg)
;
/* NL isn't guaranteed */
for (ptr = lexptr; *ptr && *ptr != '\n'; ptr++)
;
if (beg != lexptr_begin)
beg++;
}
#ifdef OSK
sprintf(oskbuf,"syntax error near line %%d:\n%%.%ds", ptr - beg);
msg(oskbuf, lineno, beg);
#else
msg("syntax error near line %d:\n%.*s", lineno, ptr - beg, beg);
#endif
scan = beg;
while (scan <= lexptr)
if (*scan++ == '\t')
putc('\t', stderr);
else
putc(' ', stderr);
putc('^', stderr);
putc(' ', stderr);
if (mesg) {
vfprintf(stderr, mesg, args);
va_end(args);
putc('\n', stderr);
exit(1);
} else {
a1 = va_arg(args, char *);
if (a1) {
fputs("expecting: ", stderr);
fputs(a1, stderr);
list = 1;
va_end(args);
return;
}
}
va_end(args);
return;
}
a1 = va_arg(args, char *);
if (a1) {
fputs(" or ", stderr);
fputs(a1, stderr);
va_end(args);
putc('\n', stderr);
return;
}
putc('\n', stderr);
list = 0;
va_end(args);
}
/*
* Parse a C escape sequence. STRING_PTR points to a variable containing a
* pointer to the string to parse. That pointer is updated past the
* characters we use. The value of the escape sequence is returned.
*
* A negative value means the sequence \ newline was seen, which is supposed to
* be equivalent to nothing at all.
*
* If \ is followed by a null character, we return a negative value and leave
* the string pointer pointing at the null character.
*
* If \ is followed by 000, we return 0 and leave the string pointer after the
* zeros. A value of 0 does not mean end of string.
*/
static int
parse_escape(string_ptr)
char **string_ptr;
{
register int c = *(*string_ptr)++;
switch (c) {
case 'b':
return '\b';
case 'f':
return '\f';
case 'n':
return '\n';
case 'r':
return '\r';
case 't':
return '\t';
case 'v':
return '\v';
case '\n':
return -2;
case 0:
(*string_ptr)--;
return 0;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
register int i = c - '0';
register int count = 0;
while (++count < 3) {
if ((c = *(*string_ptr)++) >= '0' && c <= '7') {
i *= 8;
i += c - '0';
} else {
(*string_ptr)--;
break;
}
}
return i;
}
default:
return c;
}
}
/*
* Read the input and turn it into tokens. Input is now read from a file
* instead of from malloc'ed memory. The main program takes a program
* passed as a command line argument and writes it to a temp file. Otherwise
* the file name is made available in an external variable.
*/
int curinfile = -1;
static int
yylex()
{
register int c;
register int namelen;
register char *tokstart;
register struct token *tokptr;
char *tokkey;
extern double atof(); /* know what happens if you forget this? */
static did_newline = 0; /* the grammar insists that actions end
* with newlines. This was easier than
* hacking the grammar. */
int do_concat;
int seen_e = 0; /* These are for numbers */
int seen_point = 0;
extern char **sourcefile;
extern int tempsource, numfiles;
extern FILE *pathopen();
static int file_opened = 0;
static FILE *fin;
static char cbuf[BUFSIZ];
int low, mid, high;
extern int debugging;
if (! file_opened) {
file_opened = 1;
#ifdef DEBUG
if (debugging) {
int i;
for (i = 0; i <= numfiles; i++)
fprintf (stderr, "sourcefile[%d] = %s\n", i,
sourcefile[i]);
}
#endif
nextfile:
if ((fin = pathopen (sourcefile[++curinfile])) == NULL)
fatal("cannot open `%s' for reading (%s)",
sourcefile[curinfile],
sys_errlist[errno]);
*(lexptr = cbuf) = '\0';
/*
* immediately unlink the tempfile so that it will
* go away cleanly if we bomb.
*/
if (tempsource && curinfile == 0)
(void) unlink (sourcefile[curinfile]);
}
retry:
if (! *lexptr)
if (fgets (cbuf, sizeof cbuf, fin) == NULL) {
if (fin != NULL)
fclose (fin); /* be neat and clean */
if (curinfile < numfiles)
goto nextfile;
return 0;
} else
lexptr = lexptr_begin = cbuf;
if (want_regexp) {
want_regexp = 0;
/*
* there is a potential bug if a regexp is followed by an
* equal sign: "/foo/=bar" would result in assign_quotient
* being returned as the next token. Nothing is done about
* it since it is not valid awk, but maybe something should
* be done anyway.
*/
tokstart = lexptr;
while (c = *lexptr++) {
switch (c) {
case '\\':
if (*lexptr++ == '\0') {
yyerror("unterminated regexp ends with \\");
return ERROR;
} else if (lexptr[-1] == '\n')
goto retry;
break;
case '/': /* end of the regexp */
lexptr--;
yylval.sval = tokstart;
return REGEXP;
case '\n':
lineno++;
case '\0':
yyerror("unterminated regexp");
return ERROR;
}
}
}
do_concat = want_concat_token;
want_concat_token = 0;
if (*lexptr == '\n') {
lexptr++;
lineno++;
return NEWLINE;
}
/*
* if lexptr is at white space between two terminal tokens or parens,
* it is a concatenation operator.
*/
if (do_concat && (*lexptr == ' ' || *lexptr == '\t')) {
while (*lexptr == ' ' || *lexptr == '\t')
lexptr++;
if (isalnum(*lexptr) || *lexptr == '_' || *lexptr == '\"' ||
*lexptr == '(' || *lexptr == '.' || *lexptr == '$' ||
(*lexptr == '+' && *(lexptr+1) == '+') ||
(*lexptr == '-' && *(lexptr+1) == '-'))
/* the '.' is for decimal pt */
return CONCAT_OP;
}
while (*lexptr == ' ' || *lexptr == '\t')
lexptr++;
tokstart = lexptr;
switch (c = *lexptr++) {
case 0:
return 0;
case '\n':
lineno++;
return NEWLINE;
case '#': /* it's a comment */
while (*lexptr != '\n' && *lexptr != '\0')
lexptr++;
goto retry;
case '\\':
if (*lexptr == '\n') {
lineno++;
lexptr++;
want_concat_token = do_concat;
goto retry;
} else
break;
case ')':
case ']':
++want_concat_token;
/* fall through */
case '(':
case '[':
case '$':
case ';':
case ':':
case '?':
/*
* set node type to ILLEGAL because the action should set it
* to the right thing
*/
yylval.nodetypeval = Node_illegal;
return c;
case '{':
case ',':
while (isspace(*lexptr)) {
if (*lexptr == '\n')
lineno++;
lexptr++;
}
yylval.nodetypeval = Node_illegal;
return c;
case '*':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_times;
lexptr++;
return ASSIGNOP;
} else if (*lexptr == '*') { /* make ** and **= aliases
* for ^ and ^= */
if (lexptr[1] == '=') {
yylval.nodetypeval = Node_assign_exp;
lexptr += 2;
return ASSIGNOP;
} else {
yylval.nodetypeval = Node_illegal;
lexptr++;
return '^';
}
}
yylval.nodetypeval = Node_illegal;
return c;
case '/':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_quotient;
lexptr++;
return ASSIGNOP;
}
yylval.nodetypeval = Node_illegal;
return c;
case '%':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_mod;
lexptr++;
return ASSIGNOP;
}
yylval.nodetypeval = Node_illegal;
return c;
case '^':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_exp;
lexptr++;
return ASSIGNOP;
}
yylval.nodetypeval = Node_illegal;
return c;
case '+':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_plus;
lexptr++;
return ASSIGNOP;
}
if (*lexptr == '+') {
yylval.nodetypeval = Node_illegal;
lexptr++;
return INCREMENT;
}
yylval.nodetypeval = Node_illegal;
return c;
case '!':
if (*lexptr == '=') {
yylval.nodetypeval = Node_notequal;
lexptr++;
return RELOP;
}
if (*lexptr == '~') {
yylval.nodetypeval = Node_nomatch;
if (! strict && lexptr[1] == '~') {
yylval.nodetypeval = Node_case_nomatch;
lexptr++;
}
lexptr++;
return MATCHOP;
}
yylval.nodetypeval = Node_illegal;
return c;
case '<':
if (want_redirect) {
yylval.nodetypeval = Node_redirect_input;
return REDIRECT_OP;
}
if (*lexptr == '=') {
yylval.nodetypeval = Node_leq;
lexptr++;
return RELOP;
}
yylval.nodetypeval = Node_less;
return RELOP;
case '=':
if (*lexptr == '=') {
yylval.nodetypeval = Node_equal;
lexptr++;
return RELOP;
}
yylval.nodetypeval = Node_assign;
return ASSIGNOP;
case '>':
if (want_redirect) {
if (*lexptr == '>') {
yylval.nodetypeval = Node_redirect_append;
lexptr++;
} else
yylval.nodetypeval = Node_redirect_output;
return REDIRECT_OP;
}
if (*lexptr == '=') {
yylval.nodetypeval = Node_geq;
lexptr++;
return RELOP;
}
yylval.nodetypeval = Node_greater;
return RELOP;
case '~':
yylval.nodetypeval = Node_match;
if (! strict && *lexptr == '~') {
yylval.nodetypeval = Node_case_match;
lexptr++;
}
return MATCHOP;
case '}':
/*
* Added did newline stuff. Easier than
* hacking the grammar
*/
if (did_newline) {
did_newline = 0;
return c;
}
did_newline++;
--lexptr;
return NEWLINE;
case '"':
while (*lexptr != '\0') {
switch (*lexptr++) {
case '\\':
if (*lexptr++ != '\0')
break;
/* fall through */
case '\n':
yyerror("unterminated string");
return ERROR;
case '\"':
/* Skip the doublequote */
yylval.sval = tokstart + 1;
++want_concat_token;
return YSTRING;
}
}
return ERROR;
case '-':
if (*lexptr == '=') {
yylval.nodetypeval = Node_assign_minus;
lexptr++;
return ASSIGNOP;
}
if (*lexptr == '-') {
yylval.nodetypeval = Node_illegal;
lexptr++;
return DECREMENT;
}
/*
* It looks like space tab comma and newline are the legal
* places for a UMINUS. Have we missed any?
*/
if ((! isdigit(*lexptr) && *lexptr != '.') ||
(lexptr > lexptr_begin + 1 &&
! index(" \t,\n", lexptr[-2]))) {
/*
* set node type to ILLEGAL because the action should
* set it to the right thing
*/
yylval.nodetypeval = Node_illegal;
return c;
}
/* FALL through into number code */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '.':
/* It's a number */
if (c == '-')
namelen = 1;
else
namelen = 0;
for (; (c = tokstart[namelen]) != '\0'; namelen++) {
switch (c) {
case '.':
if (seen_point)
goto got_number;
++seen_point;
break;
case 'e':
case 'E':
if (seen_e)
goto got_number;
++seen_e;
if (tokstart[namelen + 1] == '-' || tokstart[namelen + 1] == '+')
namelen++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
default:
goto got_number;
}
}
got_number:
lexptr = tokstart + namelen;
yylval.fval = atof(tokstart);
++want_concat_token;
return NUMBER;
case '&':
if (*lexptr == '&') {
yylval.nodetypeval = Node_and;
lexptr++;
return LEX_AND;
}
return ERROR;
case '|':
if (*lexptr == '|') {
yylval.nodetypeval = Node_or;
lexptr++;
return LEX_OR;
} else if (want_redirect) {
yylval.nodetypeval = Node_redirect_pipe;
return REDIRECT_OP;
} else {
yylval.nodetypeval = Node_illegal;
return c;
}
break;
}
if (c != '_' && !isalpha(c)) {
yyerror("Invalid char '%c' in expression\n", c);
return ERROR;
}
/* it's some type of name-type-thing. Find its length */
for (namelen = 0; is_identchar(tokstart[namelen]); namelen++)
/* null */ ;
emalloc(tokkey, char *, namelen+1, "yylex");
strncpy (tokkey, tokstart, namelen);
tokkey[namelen] = '\0';
/* 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;
compare:
c = *tokstart - tokentab[mid].operator[0];
i = c ? c : strcmp (tokkey, tokentab[mid].operator);
if (i < 0) { /* token < mid */
high = mid - 1;
} else if (i > 0) { /* token > mid */
low = mid + 1;
} else {
lexptr = tokstart + namelen;
if (tokentab[mid].class == LEX_BUILTIN)
yylval.ptrval = tokentab[mid].ptr;
else
yylval.nodetypeval = tokentab[mid].value;
if (tokentab[mid].class == LEX_PRINT)
want_redirect++;
return tokentab[mid].class;
}
}
/* It's a name. See how long it is. */
yylval.sval = tokkey;
lexptr = tokstart + namelen;
++want_concat_token;
return NAME;
}
#ifndef DEFPATH
#ifdef OSK
#define DEFPATH ".:/h0/usr/lib/awk:/h0/usr/local/lib/awk"
#else
#define DEFPATH ".:/usr/lib/awk:/usr/local/lib/awk"
#endif
#endif
FILE *
pathopen (file)
char *file;
{
static char defpath[] = DEFPATH;
static char *savepath;
static int first = 1;
extern char *getenv ();
char *awkpath, *cp;
char trypath[BUFSIZ];
FILE *fp;
extern int debugging;
if (strict)
return (fopen (file, "r"));
if (first) {
first = 0;
if ((awkpath = getenv ("AWKPATH")) == NULL || ! *awkpath)
awkpath = defpath;
savepath = awkpath; /* savepath used for restarting */
} else
awkpath = savepath;
if (index (file, '/') != NULL) /* some kind of path name, no search */
return (fopen (file, "r"));
do {
for (cp = trypath; *awkpath && *awkpath != ':'; )
*cp++ = *awkpath++;
*cp++ = '/';
*cp = '\0'; /* clear left over junk */
strcat (cp, file);
if ((fp = fopen (trypath, "r")) != NULL)
return (fp);
/* no luck, keep going */
awkpath++; /* skip colon */
} while (*awkpath);
return (NULL);
}