home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / gawk.sit / source / awk.tab.c < prev    next >
Text File  |  1990-09-18  |  93KB  |  3,012 lines

  1.  
  2. /*  A Bison parser, made from awk.y  */
  3.  
  4. #define    FUNC_CALL    258
  5. #define    NAME    259
  6. #define    REGEXP    260
  7. #define    ERROR    261
  8. #define    NUMBER    262
  9. #define    YSTRING    263
  10. #define    RELOP    264
  11. #define    APPEND_OP    265
  12. #define    ASSIGNOP    266
  13. #define    MATCHOP    267
  14. #define    NEWLINE    268
  15. #define    CONCAT_OP    269
  16. #define    LEX_BEGIN    270
  17. #define    LEX_END    271
  18. #define    LEX_IF    272
  19. #define    LEX_ELSE    273
  20. #define    LEX_RETURN    274
  21. #define    LEX_DELETE    275
  22. #define    LEX_WHILE    276
  23. #define    LEX_DO    277
  24. #define    LEX_FOR    278
  25. #define    LEX_BREAK    279
  26. #define    LEX_CONTINUE    280
  27. #define    LEX_PRINT    281
  28. #define    LEX_PRINTF    282
  29. #define    LEX_NEXT    283
  30. #define    LEX_EXIT    284
  31. #define    LEX_FUNCTION    285
  32. #define    LEX_GETLINE    286
  33. #define    LEX_IN    287
  34. #define    LEX_AND    288
  35. #define    LEX_OR    289
  36. #define    INCREMENT    290
  37. #define    DECREMENT    291
  38. #define    LEX_BUILTIN    292
  39. #define    LEX_LENGTH    293
  40. #define    UNARY    294
  41.  
  42. #line 26 "awk.y"
  43.  
  44.  
  45. #include "awk.h"
  46.  
  47. #ifdef DEBUG
  48. #define YYDEBUG 12
  49. #endif
  50.  
  51.  
  52. /*
  53.  * This line is necessary since the Bison parser skeleton uses bcopy.
  54.  * Systems without memcpy should use -DMEMCPY_MISSING, per the Makefile.
  55.  * It should not hurt anything if Yacc is being used instead of Bison.
  56.  */
  57. #define bcopy(s,d,n)    memcpy((d),(s),(n))
  58.  
  59. extern void msg();
  60. extern struct re_pattern_buffer *mk_re_parse();
  61.  
  62. NODE *node();
  63. NODE *lookup();
  64. NODE *install();
  65.  
  66. static NODE *snode();
  67. static NODE *mkrangenode();
  68. static FILE *pathopen();
  69. static NODE *make_for_loop();
  70. static NODE *append_right();
  71. static void func_install();
  72. static NODE *make_param();
  73. static int hashf();
  74. static void pop_params();
  75. static void pop_var();
  76. static int yylex ();
  77. static void yyerror();
  78.  
  79. static int want_regexp;        /* lexical scanning kludge */
  80. static int want_assign;        /* lexical scanning kludge */
  81. static int can_return;        /* lexical scanning kludge */
  82. static int io_allowed = 1;    /* lexical scanning kludge */
  83. static int lineno = 1;        /* for error msgs */
  84. static char *lexptr;        /* pointer to next char during parsing */
  85. static char *lexptr_begin;    /* keep track of where we were for error msgs */
  86. static int curinfile = -1;    /* index into sourcefiles[] */
  87. static int param_counter;
  88.  
  89. NODE *variables[HASHSIZE];
  90.  
  91. extern int errcount;
  92. extern NODE *begin_block;
  93. extern NODE *end_block;
  94.  
  95. #line 79 "awk.y"
  96. typedef union {
  97.     long lval;
  98.     AWKNUM fval;
  99.     NODE *nodeval;
  100.     NODETYPE nodetypeval;
  101.     char *sval;
  102.     NODE *(*ptrval)();
  103. } YYSTYPE;
  104.  
  105. #ifndef YYLTYPE
  106. typedef
  107.   struct yyltype
  108.     {
  109.       int timestamp;
  110.       int first_line;
  111.       int first_column;
  112.       int last_line;
  113.       int last_column;
  114.       char *text;
  115.    }
  116.   yyltype;
  117.  
  118. #define YYLTYPE yyltype
  119. #endif
  120.  
  121. #include <stdio.h>
  122.  
  123. #ifndef __STDC__
  124. #define const
  125. #endif
  126.  
  127.  
  128.  
  129. #define    YYFINAL        298
  130. #define    YYFLAG        -32768
  131. #define    YYNTBASE    61
  132.  
  133. #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 105)
  134.  
  135. static const char yytranslate[] = {     0,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139.      2,     2,    49,     2,     2,    52,    48,     2,     2,    53,
  140.     54,    46,    44,    60,    45,     2,    47,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,    40,    59,    41,
  142.      2,    42,    39,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.     55,     2,    56,    51,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,    57,    43,    58,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  160.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  161.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  162.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  163.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  164.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  165.     36,    37,    38,    50
  166. };
  167.  
  168. static const short yyrline[] = {     0,
  169.    138,   143,   151,   167,   168,   172,   174,   188,   190,   204,
  170.    210,   216,   218,   220,   222,   231,   233,   238,   242,   250,
  171.    259,   261,   270,   272,   283,   288,   293,   295,   303,   305,
  172.    310,   312,   318,   320,   322,   324,   326,   328,   330,   335,
  173.    339,   344,   347,   350,   352,   354,   357,   358,   360,   362,
  174.    364,   366,   371,   373,   378,   383,   390,   392,   397,   399,
  175.    404,   406,   411,   413,   415,   417,   422,   424,   429,   431,
  176.    433,   435,   437,   443,   445,   450,   452,   457,   459,   465,
  177.    467,   469,   471,   476,   478,   483,   485,   491,   493,   495,
  178.    497,   502,   505,   506,   508,   513,   522,   524,   526,   528,
  179.    530,   532,   534,   536,   538,   540,   542,   544,   549,   552,
  180.    553,   555,   557,   566,   568,   570,   572,   574,   576,   578,
  181.    580,   585,   587,   589,   591,   593,   595,   599,   601,   603,
  182.    605,   607,   609,   611,   615,   617,   619,   621,   623,   625,
  183.    627,   629,   634,   636,   641,   643,   645,   650,   654,   658,
  184.    662,   663,   667,   670
  185. };
  186.  
  187. static const char * const yytname[] = {     0,
  188. "error","$illegal.","FUNC_CALL","NAME","REGEXP","ERROR","NUMBER","YSTRING","RELOP","APPEND_OP",
  189. "ASSIGNOP","MATCHOP","NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN","LEX_DELETE",
  190. "LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT","LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION",
  191. "LEX_GETLINE","LEX_IN","LEX_AND","LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'",
  192. "'<'","'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY",
  193. "'^'","'$'","'('","')'","'['","']'","'{'","'}'","';'","','",
  194. "start"
  195. };
  196.  
  197. static const short yyr1[] = {     0,
  198.     61,    62,    62,    62,    62,    64,    63,    65,    63,    63,
  199.     63,    63,    63,    63,    63,    66,    66,    68,    67,    69,
  200.     70,    70,    72,    71,    73,    73,    74,    74,    74,    74,
  201.     75,    75,    76,    76,    76,    76,    76,    76,    76,    76,
  202.     76,    76,    76,    76,    76,    77,    76,    76,    78,    76,
  203.     76,    76,    79,    79,    80,    80,    81,    81,    82,    82,
  204.     83,    83,    84,    84,    84,    84,    85,    85,    86,    86,
  205.     86,    86,    86,    87,    87,    88,    88,    89,    89,    89,
  206.     89,    89,    89,    90,    90,    91,    91,    91,    91,    91,
  207.     91,    93,    92,    92,    92,    92,    92,    92,    92,    92,
  208.     92,    92,    92,    92,    92,    92,    92,    92,    95,    94,
  209.     94,    94,    94,    94,    94,    94,    94,    94,    94,    94,
  210.     94,    96,    96,    96,    96,    96,    96,    96,    96,    96,
  211.     96,    96,    96,    96,    96,    96,    96,    96,    96,    96,
  212.     96,    96,    97,    97,    98,    98,    98,    99,   100,   101,
  213.    102,   102,   103,   104
  214. };
  215.  
  216. static const short yyr2[] = {     0,
  217.      3,     1,     2,     1,     2,     0,     3,     0,     3,     2,
  218.      2,     2,     1,     2,     2,     1,     1,     0,     7,     3,
  219.      1,     3,     0,     4,     3,     4,     1,     2,     1,     2,
  220.      1,     2,     2,     2,     3,     1,     6,     8,     8,    10,
  221.      9,     2,     2,     6,     4,     0,     3,     3,     0,     4,
  222.      6,     2,     1,     1,     6,     9,     1,     2,     0,     1,
  223.      0,     2,     0,     2,     2,     2,     0,     1,     1,     3,
  224.      1,     2,     3,     0,     1,     0,     1,     1,     3,     1,
  225.      2,     3,     3,     0,     1,     1,     3,     1,     2,     3,
  226.      3,     0,     4,     5,     4,     3,     3,     3,     3,     1,
  227.      2,     3,     3,     3,     3,     5,     1,     2,     0,     4,
  228.      3,     3,     3,     1,     2,     3,     3,     3,     5,     1,
  229.      2,     2,     3,     4,     4,     1,     4,     2,     2,     2,
  230.      2,     1,     1,     1,     3,     3,     3,     3,     3,     3,
  231.      2,     2,     0,     1,     1,     4,     2,     2,     2,     1,
  232.      0,     1,     1,     2
  233. };
  234.  
  235. static const short yydefact[] = {    59,
  236.     57,    60,     0,    58,     4,     0,   145,   133,   134,     6,
  237.      8,    18,   143,     0,     0,     0,   126,     0,     0,    23,
  238.      0,     0,     0,    59,     0,     2,     0,     0,   100,    13,
  239.     21,   107,   132,     0,     0,     0,   153,     0,    10,    31,
  240.     59,     0,    11,     0,    61,   144,   128,   129,     0,     0,
  241.      0,     0,   142,   132,   141,     0,   101,   122,   147,    88,
  242.      0,    86,   148,     5,     3,     1,    15,     0,    12,    14,
  243.      0,     0,     0,     0,     0,     0,     0,     0,     0,    59,
  244.    108,     0,     0,     0,     0,     0,     0,     0,    92,   130,
  245.    131,    29,     0,    49,     0,     0,    59,     0,     0,     0,
  246.     53,    54,    46,    74,    59,     0,    27,     0,    36,     0,
  247.      0,   151,    59,     0,     0,    86,     0,     7,    32,     9,
  248.     17,    16,     0,     0,    96,     0,     0,     0,     0,    89,
  249.    150,     0,     0,   123,     0,   103,    99,   102,    97,    98,
  250.      0,   104,   105,   143,   154,    22,   139,   140,   136,   137,
  251.    138,   135,     0,     0,    74,     0,     0,     0,    74,    42,
  252.     43,     0,     0,    75,   149,    30,    28,   151,    80,   143,
  253.      0,     0,   114,    63,     0,    78,   120,   132,    52,     0,
  254.     34,    25,   152,    33,   127,   146,     0,    62,   124,   125,
  255.     24,    90,     0,    91,    87,    20,     0,    95,    93,     0,
  256.      0,     0,     0,     0,   145,     0,    47,    48,    26,    61,
  257.    115,     0,     0,     0,     0,     0,    81,     0,     0,     0,
  258.      0,     0,     0,     0,   121,   109,    35,    71,    69,     0,
  259.      0,    94,   106,    59,    50,     0,    59,     0,     0,     0,
  260.    113,    63,    65,    64,    66,    45,    82,    83,    79,   118,
  261.    116,   117,   111,   112,     0,     0,    59,    72,     0,     0,
  262.      0,     0,     0,     0,     0,    74,     0,     0,   110,    19,
  263.     73,    70,    55,    51,    37,     0,    59,    74,     0,    44,
  264.    119,    59,    59,     0,     0,    59,     0,    38,    39,    59,
  265.      0,    56,     0,    41,    40,     0,     0,     0
  266. };
  267.  
  268. static const short yydefgoto[] = {   296,
  269.     25,    26,    38,    42,   123,    27,    44,    67,    28,    29,
  270.     56,    30,   106,    39,   107,   162,   155,   108,   109,     2,
  271.      3,   125,   216,   230,   231,   163,   174,   175,   114,   115,
  272.     81,   153,   225,   256,    32,    45,    33,   111,   112,   134,
  273.    182,   113,   133
  274. };
  275.  
  276. static const short yypact[] = {    21,
  277. -32768,    37,  1020,-32768,-32768,   -32,     1,-32768,-32768,    17,
  278.     17,-32768,    11,    11,    11,    31,    45,  1757,  1757,-32768,
  279.   1738,  1757,  1112,    21,   540,-32768,    13,    40,-32768,-32768,
  280.    816,   142,    55,   612,  1092,  1112,-32768,    13,-32768,    37,
  281.     21,    13,-32768,    51,    59,-32768,-32768,-32768,  1092,  1092,
  282.   1757,  1625,    27,    -7,    27,    97,-32768,    27,-32768,-32768,
  283.      4,  1225,-32768,-32768,-32768,-32768,-32768,   706,-32768,-32768,
  284.   1625,  1625,   100,  1625,  1625,  1625,  1625,  1625,    76,    21,
  285.    300,  1625,  1757,  1757,  1757,  1757,  1757,  1757,-32768,-32768,
  286. -32768,-32768,    52,-32768,   109,    62,    21,    64,    17,    17,
  287. -32768,-32768,-32768,  1625,    21,   659,-32768,   763,-32768,   920,
  288.    612,    65,    21,    67,     7,  1324,    25,-32768,-32768,-32768,
  289. -32768,-32768,    70,  1757,-32768,    67,    67,  1225,    84,  1625,
  290. -32768,   101,  1159,-32768,   659,  1811,  1796,-32768,  1465,  1371,
  291.   1277,  1811,  1811,    11,-32768,  1324,   -10,   -10,    27,    27,
  292.     27,    27,  1625,  1625,  1625,    87,  1625,   863,  1672,-32768,
  293. -32768,    17,    17,  1324,-32768,-32768,-32768,    65,-32768,    11,
  294.   1738,  1112,-32768,     9,     0,  1512,   142,    83,-32768,   659,
  295. -32768,-32768,-32768,-32768,-32768,-32768,     8,   142,-32768,-32768,
  296. -32768,  1324,   134,-32768,  1324,-32768,  1625,-32768,  1324,  1225,
  297.     17,  1112,  1225,   122,   -16,    65,-32768,-32768,-32768,    59,
  298. -32768,     4,  1625,  1625,  1625,    17,  1691,  1178,  1691,  1691,
  299.    140,  1691,  1691,  1691,   939,-32768,-32768,-32768,-32768,    67,
  300.     23,-32768,  1324,    21,-32768,    26,    21,    94,   144,  1045,
  301. -32768,     9,  1324,  1324,  1324,-32768,  1512,-32768,  1512,   782,
  302.   1858,-32768,  1606,  1559,  1418,  1691,    21,-32768,    44,   863,
  303.     17,   863,  1625,    67,   973,  1625,    17,  1691,  1512,-32768,
  304. -32768,-32768,   131,-32768,-32768,  1225,    21,  1625,    67,-32768,
  305.   1512,    21,    21,   863,    67,    21,   863,-32768,-32768,    21,
  306.    863,-32768,   863,-32768,-32768,   163,   166,-32768
  307. };
  308.  
  309. static const short yypgoto[] = {-32768,
  310. -32768,   145,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   201,
  311. -32768,    78,   -54,    12,   225,-32768,-32768,-32768,-32768,   363,
  312.    104,   -39,   -70,-32768,-32768,  -152,-32768,-32768,    60,   -19,
  313.     -3,-32768,   -83,-32768,   146,  -126,    74,   178,  -100,   319,
  314.     10,   329,   -29
  315. };
  316.  
  317.  
  318. #define    YYLAST        1911
  319.  
  320.  
  321. static const short yytable[] = {    31,
  322.    217,    82,   201,    61,   130,   168,   206,   130,   228,   -77,
  323.    181,   229,   -77,   135,     7,   239,   117,   198,   213,    62,
  324.     35,    31,    43,   258,   176,   130,   130,    90,    91,     1,
  325.    110,   116,   116,     1,   196,    85,    86,    87,    36,    70,
  326.     88,   -77,   -77,   210,   271,   116,   116,   272,   128,     4,
  327.    214,   215,     1,   121,   122,    36,   180,   131,   -77,    80,
  328.    -85,   -67,    22,    80,   110,    89,    80,   136,   137,    24,
  329.    139,   140,   141,   142,   143,    37,   -68,    88,   146,   227,
  330.    186,   261,    80,    49,    80,    80,    46,    47,    48,    90,
  331.     91,    54,    54,   226,    54,    54,    24,    50,    37,   124,
  332.    164,   129,   110,   138,   154,    69,   144,   110,   126,   127,
  333.    160,   161,   156,   279,   157,   118,   159,    90,    91,   120,
  334.    131,   179,   187,    37,    54,   285,   192,    63,    66,   195,
  335.    191,   110,   193,   247,   249,   250,   251,   232,   253,   254,
  336.    255,   202,   238,   252,   119,   218,   263,   264,   282,   199,
  337.    200,   164,   212,   203,   110,   164,    54,    54,    54,    54,
  338.     54,    54,   297,    53,    55,   298,    58,    59,    62,    65,
  339.    241,   267,   269,   207,   208,     0,   110,   209,     0,     0,
  340.     34,   178,   236,   145,   281,    83,    84,    85,    86,    87,
  341.      0,     0,    88,   233,     0,     0,    58,    54,   116,     0,
  342.    158,   259,    34,     0,    68,    34,     0,     0,   165,   243,
  343.    244,   245,   235,     0,     0,    34,   184,    46,     0,    34,
  344.      0,    57,     0,     0,     0,     0,     0,   246,   147,   148,
  345.    149,   150,   151,   152,     0,     0,   265,     0,     0,     0,
  346.      0,     0,     0,    46,    54,     0,     0,     0,     0,   178,
  347.      0,     0,     0,   177,     0,     0,   110,     0,   110,   276,
  348.      0,     0,   164,     0,     0,     0,     0,     0,     0,   188,
  349.      0,     0,   274,     0,   164,     0,     0,     0,   280,     0,
  350.    110,     0,     0,   110,     0,     0,     0,   110,     0,   110,
  351.    178,   178,   178,   178,     0,   178,   178,   178,   178,     0,
  352.      0,     0,     0,     7,     0,     0,     8,     9,   173,     0,
  353.      0,     0,     0,     0,     0,     0,    58,     0,     0,     0,
  354.    178,   177,   178,   178,   178,     0,   178,   178,   178,   178,
  355.    167,     0,     0,     0,    14,    15,     0,   260,    41,    41,
  356.    262,   178,   178,    18,    19,     0,    20,     0,    21,     0,
  357.      0,    22,    23,     0,   178,     0,    41,     0,     0,   167,
  358.    270,     0,   177,   177,   177,   177,     0,   177,   177,   177,
  359.    177,   211,    40,    40,     0,     0,   173,     0,     0,   132,
  360.    284,     0,   204,     0,     0,   287,   288,     0,     0,   291,
  361.     40,     0,   177,   293,   177,   177,   177,     0,   177,   177,
  362.    177,   177,     0,     0,   167,     0,     0,     0,     0,     0,
  363.      0,     0,     0,   177,   177,     0,     0,   173,   173,   173,
  364.    173,     0,   173,   173,   173,   173,   177,    41,    41,     0,
  365.      0,     0,   185,     0,     0,     0,     0,     0,    41,     0,
  366.    183,     0,     0,     0,   189,   190,     0,   173,     0,   173,
  367.    173,   173,     0,   173,   173,   173,   173,     0,     0,     0,
  368.      0,    40,    40,     0,     0,     0,     0,     0,   173,   173,
  369.      0,     0,    40,     0,     0,     0,     0,     0,     0,     0,
  370.      0,   173,     0,     0,   273,     0,   275,     0,     0,     0,
  371.     41,    41,     0,     0,     0,     0,   183,     0,     0,     0,
  372.      0,     0,     0,     0,     0,     0,     0,     0,   289,     0,
  373.      0,   292,     0,     0,     0,   294,     0,   295,   234,     0,
  374.      0,   237,     0,     0,    40,    40,     0,     0,     0,    41,
  375.    242,     0,     0,     0,   240,     0,     0,     0,     0,   -59,
  376.     64,     0,     6,     7,    41,     0,     8,     9,   257,     0,
  377.      0,     0,     1,     0,    10,    11,     0,     0,     0,     0,
  378.      0,     0,     0,    40,     0,     0,     0,     0,   266,    12,
  379.     13,     0,     0,     0,    14,    15,    16,    17,    40,     0,
  380.      0,     0,   277,    18,    19,     0,    20,     0,    21,    41,
  381.      0,    22,    23,   278,   283,    41,    24,   286,     0,     0,
  382.      0,     0,     0,   290,     0,     0,     0,     0,     0,     0,
  383.      0,     0,    92,     0,     6,     7,     0,     0,     8,     9,
  384.      0,     0,     0,    40,     0,     0,     0,     0,    93,    40,
  385.     94,    95,    96,    97,    98,    99,   100,   101,   102,   103,
  386.    104,     0,    13,     0,     0,     0,    14,    15,    16,    17,
  387.      0,     0,     0,     0,     0,    18,    19,     0,    20,   166,
  388.     21,     6,     7,    22,    23,     8,     9,     0,    24,   105,
  389.     37,     0,     0,     0,     0,    93,     0,    94,    95,    96,
  390.     97,    98,    99,   100,   101,   102,   103,   104,     0,    13,
  391.      0,     0,     0,    14,    15,    16,    17,     0,     0,     0,
  392.      0,     0,    18,    19,     0,    20,    92,    21,     6,     7,
  393.     22,    23,     8,     9,     0,    24,   105,    37,     0,     0,
  394.      0,     0,    93,     0,    94,    95,    96,    97,    98,    99,
  395.    100,   101,   102,   103,   104,     0,    13,     0,     0,     0,
  396.     14,    15,    16,    17,     0,     0,     0,     0,     0,    18,
  397.     19,     0,    20,     0,    21,     0,     0,    22,    23,     0,
  398.      0,     0,    24,   169,    37,     6,     7,     0,     0,     8,
  399.      9,     0,   -76,     0,     0,   -76,     0,     0,     0,     0,
  400.      0,     0,     0,     0,     0,     7,     0,     0,     8,     9,
  401. -32768,     0,     0,   170,     0,     0,     0,    14,    15,    16,
  402.     17,     0,     0,     0,   -76,   -76,    18,    19,     0,    20,
  403.      0,   171,     0,     0,    22,   172,    14,    15,     6,     7,
  404.      0,   -76,     8,     9,    71,    18,    19,    72,    20,     0,
  405.    171,     0,     0,    22,    52,     0,     0,     0,     0,     0,
  406.      0,     0,     0,     0,     0,     0,    13,    73,    74,    75,
  407.     14,    15,    16,    17,    76,     0,    77,    78,    79,    18,
  408.     19,     0,    20,     0,    21,     6,     7,    22,    23,     8,
  409.      9,     0,     0,     0,     0,    80,     0,     0,     0,    93,
  410.      0,    94,    95,    96,    97,    98,    99,   100,   101,   102,
  411.    103,   104,     0,    13,     0,     0,     0,    14,    15,    16,
  412.     17,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  413.      0,    21,     0,     0,    22,    23,     0,     0,     0,    24,
  414.      0,    37,     6,     7,     0,     0,     8,     9,    71,     0,
  415.      0,    72,     1,     0,     0,     0,     0,     0,     0,     0,
  416.      0,     0,     7,     0,     0,     8,     9,     0,     0,     0,
  417.     13,    73,    74,    75,    14,    15,    16,    17,    76,     0,
  418.     77,    78,    79,    18,    19,     0,    20,     0,    21,     0,
  419.      0,    22,    23,    14,    15,     6,     7,     0,    37,     8,
  420.      9,    71,    18,    19,    72,    20,     0,   171,     0,     0,
  421.     22,    52,     0,     0,     0,     0,     0,     0,     0,     0,
  422.      0,     0,     0,    13,    73,    74,    75,    14,    15,    16,
  423.     17,    76,     0,    77,    78,    79,    18,    19,     0,    20,
  424.      5,    21,     6,     7,    22,    23,     8,     9,     0,     0,
  425.      0,    37,     0,     0,    10,    11,     0,     0,     0,     0,
  426.      0,     0,     0,     0,     0,     0,     0,     6,     7,    12,
  427.     13,     8,     9,     0,    14,    15,    16,    17,     0,     0,
  428.      0,     0,     0,    18,    19,     0,    20,     0,    21,     0,
  429.      0,    22,    23,     0,     0,    13,    24,     0,     0,    14,
  430.     15,    16,    17,     0,     0,     0,     0,     0,    18,    19,
  431.      0,    20,    60,    21,     6,     7,    22,    23,     8,     9,
  432.      0,     0,     0,    37,     0,     0,     0,     0,     0,     0,
  433.      0,     0,    60,     0,     6,     7,     0,     0,     8,     9,
  434.      0,     0,    13,     0,     0,     0,    14,    15,    16,    17,
  435.      0,     0,     0,     0,     0,    18,    19,     0,    20,     0,
  436.     21,     0,    13,    22,    23,   -84,    14,    15,    16,    17,
  437.      0,     0,     0,     0,     0,    18,    19,     0,    20,   194,
  438.     21,     6,     7,    22,    23,     8,     9,     0,     0,     0,
  439.      0,     0,     0,     0,     0,     0,     0,     0,   248,     0,
  440.      6,     7,     0,     0,     8,     9,     0,     0,     0,    13,
  441.      0,     0,     0,    14,    15,    16,    17,     0,     0,     0,
  442.      0,     0,    18,    19,     0,    20,     0,    21,   170,     0,
  443.     22,    23,    14,    15,    16,    17,     0,     0,     0,     0,
  444.      0,    18,    19,     0,    20,     0,   171,     6,     7,    22,
  445.     52,     8,     9,    71,     0,     0,    72,     0,     0,     0,
  446.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  447.      0,     0,     0,     0,     0,    13,    73,    74,    75,    14,
  448.     15,    16,    17,    76,     0,    77,    78,    79,    18,    19,
  449.      0,    20,     0,    21,     0,     0,    22,    23,   131,     6,
  450.      7,     0,     0,     8,     9,    71,     0,     0,    72,     0,
  451.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  452.      0,     0,     0,     0,     0,     0,     0,    13,    73,    74,
  453.     75,    14,    15,    16,    17,    76,   197,    77,    78,    79,
  454.     18,    19,     0,    20,     0,    21,     6,     7,    22,    23,
  455.      8,     9,    71,     0,     0,    72,     0,     0,     0,     0,
  456.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  457.      0,     0,     0,     0,    13,    73,    74,    75,    14,    15,
  458.     16,    17,    76,     0,    77,    78,    79,    18,    19,     0,
  459.     20,     0,    21,     6,     7,    22,    23,     8,     9,    71,
  460.      0,     0,    72,     0,     0,     0,     0,     0,     0,     0,
  461.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  462.      0,    13,    73,    74,     0,    14,    15,    16,    17,     0,
  463.      0,    77,    78,    79,    18,    19,     0,    20,     0,    21,
  464.      6,     7,    22,    23,     8,     9,   219,     0,     0,   220,
  465.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  466.      0,     0,     0,     0,     0,     0,     0,     0,   170,   221,
  467.    222,   223,    14,    15,    16,    17,   224,   268,     0,     0,
  468.      0,    18,    19,     0,    20,     0,   171,     6,     7,    22,
  469.     52,     8,     9,    71,     0,     0,    72,     0,     0,     0,
  470.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  471.      0,     0,     0,     0,     0,    13,    73,     0,     0,    14,
  472.     15,    16,    17,     0,     0,    77,    78,    79,    18,    19,
  473.      0,    20,     0,    21,     6,     7,    22,    23,     8,     9,
  474.    219,     0,     0,   220,     0,     0,     0,     0,     0,     0,
  475.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  476.      0,     0,   170,   221,   222,   223,    14,    15,    16,    17,
  477.    224,     0,     0,     0,     0,    18,    19,     0,    20,     0,
  478.    171,     6,     7,    22,    52,     8,     9,   219,     0,     0,
  479.    220,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  480.      0,     0,     0,     0,     0,     0,     0,     0,     0,   170,
  481.    221,   222,     0,    14,    15,    16,    17,     0,     0,     0,
  482.      0,     0,    18,    19,     0,    20,     0,   171,     6,     7,
  483.     22,    52,     8,     9,   219,     0,     0,   220,     0,     0,
  484.      0,     0,     0,     0,     0,     0,     0,     6,     7,     0,
  485.      0,     8,     9,     0,     0,     0,   170,   221,     0,     0,
  486.     14,    15,    16,    17,     0,     0,     0,     0,     0,    18,
  487.     19,     0,    20,     0,   171,    13,     0,    22,    52,    14,
  488.     15,    16,    17,     0,     0,     0,     0,     0,    18,    19,
  489.      0,    20,     0,    21,     6,   205,    22,    23,     8,     9,
  490.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  491.      0,     0,     0,     6,     7,     0,     0,     8,     9,     0,
  492.      0,     0,    13,     0,     0,     0,    14,    15,    16,    17,
  493.      0,     0,     0,     0,     0,    18,    19,     0,    20,     0,
  494.     21,   170,     0,    22,    23,    14,    15,    16,    17,     0,
  495.      0,     0,     0,     0,    18,    19,     0,    20,     0,   171,
  496.      6,     7,    22,    52,     8,     9,     0,     0,     0,     0,
  497.      0,     0,     0,     0,     0,     0,     0,     0,     0,     6,
  498.      7,     0,     0,     8,     9,     0,     0,     0,     0,     0,
  499.      0,     0,    14,    15,    16,    17,     0,     0,     0,     0,
  500.      0,    18,    19,     0,    20,     0,    51,     0,     0,    22,
  501.     52,    14,    15,    16,    17,     0,     0,     0,     0,     7,
  502.     18,    19,     8,     9,    71,    51,     0,-32768,    22,    52,
  503.      0,     0,     0,     0,     7,     0,     0,     8,     9,-32768,
  504.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  505.     14,    15,     0,     0,     0,     0,    77,    78,    79,    18,
  506.     19,     0,    20,     0,    21,    14,    15,    22,    23,     0,
  507.      0,-32768,-32768,-32768,    18,    19,     0,    20,     0,    21,
  508.      0,     7,    22,    23,     8,     9,   219,     0,     0,-32768,
  509.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  510.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  511.      0,     0,    14,    15,     0,     0,     0,     0,     0,     0,
  512.      0,    18,    19,     0,    20,     0,   171,     0,     0,    22,
  513.     52
  514. };
  515.  
  516. static const short yycheck[] = {     3,
  517.      1,    31,   155,    23,     1,   106,   159,     1,     1,    10,
  518.    111,     4,    13,    68,     4,    32,    36,   144,    10,    23,
  519.     53,    25,    11,     1,   108,     1,     1,    35,    36,    13,
  520.     34,    35,    36,    13,   135,    46,    47,    48,    55,    28,
  521.     51,    42,    43,   170,     1,    49,    50,     4,    52,    13,
  522.     42,    43,    13,     3,     4,    55,   111,    54,    59,    60,
  523.     54,    54,    52,    60,    68,    11,    60,    71,    72,    57,
  524.     74,    75,    76,    77,    78,    59,    54,    51,    82,   180,
  525.     56,    56,    60,    53,    60,    60,    13,    14,    15,    35,
  526.     36,    18,    19,    11,    21,    22,    57,    53,    59,    41,
  527.    104,     5,   106,     4,    53,    28,    31,   111,    49,    50,
  528.     99,   100,     4,   266,    53,    38,    53,    35,    36,    42,
  529.     54,   110,    53,    59,    51,   278,   130,    24,    25,   133,
  530.     47,   135,    32,   217,   218,   219,   220,     4,   222,   223,
  531.    224,    55,    21,     4,    41,   175,    53,     4,    18,   153,
  532.    154,   155,   172,   157,   158,   159,    83,    84,    85,    86,
  533.     87,    88,     0,    18,    19,     0,    21,    22,   172,    25,
  534.    210,   242,   256,   162,   163,    -1,   180,   168,    -1,    -1,
  535.      3,   108,   202,    80,   268,    44,    45,    46,    47,    48,
  536.     -1,    -1,    51,   197,    -1,    -1,    51,   124,   202,    -1,
  537.     97,   231,    25,    -1,    27,    28,    -1,    -1,   105,   213,
  538.    214,   215,   201,    -1,    -1,    38,   113,   144,    -1,    42,
  539.     -1,    21,    -1,    -1,    -1,    -1,    -1,   216,    83,    84,
  540.     85,    86,    87,    88,    -1,    -1,   240,    -1,    -1,    -1,
  541.     -1,    -1,    -1,   170,   171,    -1,    -1,    -1,    -1,   176,
  542.     -1,    -1,    -1,   108,    -1,    -1,   260,    -1,   262,   263,
  543.     -1,    -1,   266,    -1,    -1,    -1,    -1,    -1,    -1,   124,
  544.     -1,    -1,   261,    -1,   278,    -1,    -1,    -1,   267,    -1,
  545.    284,    -1,    -1,   287,    -1,    -1,    -1,   291,    -1,   293,
  546.    217,   218,   219,   220,    -1,   222,   223,   224,   225,    -1,
  547.     -1,    -1,    -1,     4,    -1,    -1,     7,     8,   108,    -1,
  548.     -1,    -1,    -1,    -1,    -1,    -1,   171,    -1,    -1,    -1,
  549.    247,   176,   249,   250,   251,    -1,   253,   254,   255,   256,
  550.    106,    -1,    -1,    -1,    35,    36,    -1,   234,    10,    11,
  551.    237,   268,   269,    44,    45,    -1,    47,    -1,    49,    -1,
  552.     -1,    52,    53,    -1,   281,    -1,    28,    -1,    -1,   135,
  553.    257,    -1,   217,   218,   219,   220,    -1,   222,   223,   224,
  554.    225,   171,    10,    11,    -1,    -1,   176,    -1,    -1,    61,
  555.    277,    -1,   158,    -1,    -1,   282,   283,    -1,    -1,   286,
  556.     28,    -1,   247,   290,   249,   250,   251,    -1,   253,   254,
  557.    255,   256,    -1,    -1,   180,    -1,    -1,    -1,    -1,    -1,
  558.     -1,    -1,    -1,   268,   269,    -1,    -1,   217,   218,   219,
  559.    220,    -1,   222,   223,   224,   225,   281,    99,   100,    -1,
  560.     -1,    -1,   114,    -1,    -1,    -1,    -1,    -1,   110,    -1,
  561.    112,    -1,    -1,    -1,   126,   127,    -1,   247,    -1,   249,
  562.    250,   251,    -1,   253,   254,   255,   256,    -1,    -1,    -1,
  563.     -1,    99,   100,    -1,    -1,    -1,    -1,    -1,   268,   269,
  564.     -1,    -1,   110,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  565.     -1,   281,    -1,    -1,   260,    -1,   262,    -1,    -1,    -1,
  566.    162,   163,    -1,    -1,    -1,    -1,   168,    -1,    -1,    -1,
  567.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   284,    -1,
  568.     -1,   287,    -1,    -1,    -1,   291,    -1,   293,   200,    -1,
  569.     -1,   203,    -1,    -1,   162,   163,    -1,    -1,    -1,   201,
  570.    212,    -1,    -1,    -1,   206,    -1,    -1,    -1,    -1,     0,
  571.      1,    -1,     3,     4,   216,    -1,     7,     8,   230,    -1,
  572.     -1,    -1,    13,    -1,    15,    16,    -1,    -1,    -1,    -1,
  573.     -1,    -1,    -1,   201,    -1,    -1,    -1,    -1,   240,    30,
  574.     31,    -1,    -1,    -1,    35,    36,    37,    38,   216,    -1,
  575.     -1,    -1,   264,    44,    45,    -1,    47,    -1,    49,   261,
  576.     -1,    52,    53,   265,   276,   267,    57,   279,    -1,    -1,
  577.     -1,    -1,    -1,   285,    -1,    -1,    -1,    -1,    -1,    -1,
  578.     -1,    -1,     1,    -1,     3,     4,    -1,    -1,     7,     8,
  579.     -1,    -1,    -1,   261,    -1,    -1,    -1,    -1,    17,   267,
  580.     19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  581.     29,    -1,    31,    -1,    -1,    -1,    35,    36,    37,    38,
  582.     -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,     1,
  583.     49,     3,     4,    52,    53,     7,     8,    -1,    57,    58,
  584.     59,    -1,    -1,    -1,    -1,    17,    -1,    19,    20,    21,
  585.     22,    23,    24,    25,    26,    27,    28,    29,    -1,    31,
  586.     -1,    -1,    -1,    35,    36,    37,    38,    -1,    -1,    -1,
  587.     -1,    -1,    44,    45,    -1,    47,     1,    49,     3,     4,
  588.     52,    53,     7,     8,    -1,    57,    58,    59,    -1,    -1,
  589.     -1,    -1,    17,    -1,    19,    20,    21,    22,    23,    24,
  590.     25,    26,    27,    28,    29,    -1,    31,    -1,    -1,    -1,
  591.     35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
  592.     45,    -1,    47,    -1,    49,    -1,    -1,    52,    53,    -1,
  593.     -1,    -1,    57,     1,    59,     3,     4,    -1,    -1,     7,
  594.      8,    -1,    10,    -1,    -1,    13,    -1,    -1,    -1,    -1,
  595.     -1,    -1,    -1,    -1,    -1,     4,    -1,    -1,     7,     8,
  596.      9,    -1,    -1,    31,    -1,    -1,    -1,    35,    36,    37,
  597.     38,    -1,    -1,    -1,    42,    43,    44,    45,    -1,    47,
  598.     -1,    49,    -1,    -1,    52,    53,    35,    36,     3,     4,
  599.     -1,    59,     7,     8,     9,    44,    45,    12,    47,    -1,
  600.     49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,    -1,
  601.     -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,    34,
  602.     35,    36,    37,    38,    39,    -1,    41,    42,    43,    44,
  603.     45,    -1,    47,    -1,    49,     3,     4,    52,    53,     7,
  604.      8,    -1,    -1,    -1,    -1,    60,    -1,    -1,    -1,    17,
  605.     -1,    19,    20,    21,    22,    23,    24,    25,    26,    27,
  606.     28,    29,    -1,    31,    -1,    -1,    -1,    35,    36,    37,
  607.     38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,
  608.     -1,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,    57,
  609.     -1,    59,     3,     4,    -1,    -1,     7,     8,     9,    -1,
  610.     -1,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  611.     -1,    -1,     4,    -1,    -1,     7,     8,    -1,    -1,    -1,
  612.     31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
  613.     41,    42,    43,    44,    45,    -1,    47,    -1,    49,    -1,
  614.     -1,    52,    53,    35,    36,     3,     4,    -1,    59,     7,
  615.      8,     9,    44,    45,    12,    47,    -1,    49,    -1,    -1,
  616.     52,    53,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  617.     -1,    -1,    -1,    31,    32,    33,    34,    35,    36,    37,
  618.     38,    39,    -1,    41,    42,    43,    44,    45,    -1,    47,
  619.      1,    49,     3,     4,    52,    53,     7,     8,    -1,    -1,
  620.     -1,    59,    -1,    -1,    15,    16,    -1,    -1,    -1,    -1,
  621.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,    30,
  622.     31,     7,     8,    -1,    35,    36,    37,    38,    -1,    -1,
  623.     -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,    -1,
  624.     -1,    52,    53,    -1,    -1,    31,    57,    -1,    -1,    35,
  625.     36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,
  626.     -1,    47,     1,    49,     3,     4,    52,    53,     7,     8,
  627.     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    -1,
  628.     -1,    -1,     1,    -1,     3,     4,    -1,    -1,     7,     8,
  629.     -1,    -1,    31,    -1,    -1,    -1,    35,    36,    37,    38,
  630.     -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,
  631.     49,    -1,    31,    52,    53,    54,    35,    36,    37,    38,
  632.     -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,     1,
  633.     49,     3,     4,    52,    53,     7,     8,    -1,    -1,    -1,
  634.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     1,    -1,
  635.      3,     4,    -1,    -1,     7,     8,    -1,    -1,    -1,    31,
  636.     -1,    -1,    -1,    35,    36,    37,    38,    -1,    -1,    -1,
  637.     -1,    -1,    44,    45,    -1,    47,    -1,    49,    31,    -1,
  638.     52,    53,    35,    36,    37,    38,    -1,    -1,    -1,    -1,
  639.     -1,    44,    45,    -1,    47,    -1,    49,     3,     4,    52,
  640.     53,     7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,
  641.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  642.     -1,    -1,    -1,    -1,    -1,    31,    32,    33,    34,    35,
  643.     36,    37,    38,    39,    -1,    41,    42,    43,    44,    45,
  644.     -1,    47,    -1,    49,    -1,    -1,    52,    53,    54,     3,
  645.      4,    -1,    -1,     7,     8,     9,    -1,    -1,    12,    -1,
  646.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  647.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
  648.     34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  649.     44,    45,    -1,    47,    -1,    49,     3,     4,    52,    53,
  650.      7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,
  651.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  652.     -1,    -1,    -1,    -1,    31,    32,    33,    34,    35,    36,
  653.     37,    38,    39,    -1,    41,    42,    43,    44,    45,    -1,
  654.     47,    -1,    49,     3,     4,    52,    53,     7,     8,     9,
  655.     -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  656.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  657.     -1,    31,    32,    33,    -1,    35,    36,    37,    38,    -1,
  658.     -1,    41,    42,    43,    44,    45,    -1,    47,    -1,    49,
  659.      3,     4,    52,    53,     7,     8,     9,    -1,    -1,    12,
  660.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  661.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,
  662.     33,    34,    35,    36,    37,    38,    39,    40,    -1,    -1,
  663.     -1,    44,    45,    -1,    47,    -1,    49,     3,     4,    52,
  664.     53,     7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,
  665.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  666.     -1,    -1,    -1,    -1,    -1,    31,    32,    -1,    -1,    35,
  667.     36,    37,    38,    -1,    -1,    41,    42,    43,    44,    45,
  668.     -1,    47,    -1,    49,     3,     4,    52,    53,     7,     8,
  669.      9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,
  670.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  671.     -1,    -1,    31,    32,    33,    34,    35,    36,    37,    38,
  672.     39,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,
  673.     49,     3,     4,    52,    53,     7,     8,     9,    -1,    -1,
  674.     12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  675.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,
  676.     32,    33,    -1,    35,    36,    37,    38,    -1,    -1,    -1,
  677.     -1,    -1,    44,    45,    -1,    47,    -1,    49,     3,     4,
  678.     52,    53,     7,     8,     9,    -1,    -1,    12,    -1,    -1,
  679.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,    -1,
  680.     -1,     7,     8,    -1,    -1,    -1,    31,    32,    -1,    -1,
  681.     35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
  682.     45,    -1,    47,    -1,    49,    31,    -1,    52,    53,    35,
  683.     36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,
  684.     -1,    47,    -1,    49,     3,     4,    52,    53,     7,     8,
  685.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  686.     -1,    -1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,
  687.     -1,    -1,    31,    -1,    -1,    -1,    35,    36,    37,    38,
  688.     -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,
  689.     49,    31,    -1,    52,    53,    35,    36,    37,    38,    -1,
  690.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  691.      3,     4,    52,    53,     7,     8,    -1,    -1,    -1,    -1,
  692.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,
  693.      4,    -1,    -1,     7,     8,    -1,    -1,    -1,    -1,    -1,
  694.     -1,    -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,
  695.     -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,
  696.     53,    35,    36,    37,    38,    -1,    -1,    -1,    -1,     4,
  697.     44,    45,     7,     8,     9,    49,    -1,    12,    52,    53,
  698.     -1,    -1,    -1,    -1,     4,    -1,    -1,     7,     8,     9,
  699.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  700.     35,    36,    -1,    -1,    -1,    -1,    41,    42,    43,    44,
  701.     45,    -1,    47,    -1,    49,    35,    36,    52,    53,    -1,
  702.     -1,    41,    42,    43,    44,    45,    -1,    47,    -1,    49,
  703.     -1,     4,    52,    53,     7,     8,     9,    -1,    -1,    12,
  704.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  705.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  706.     -1,    -1,    35,    36,    -1,    -1,    -1,    -1,    -1,    -1,
  707.     -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,
  708.     53
  709. };
  710. #define YYPURE 1
  711.  
  712. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  713. #line 3 "bison.simple"
  714.  
  715. /* Skeleton output parser for bison,
  716.    Copyright (C) 1984 Bob Corbett and Richard Stallman
  717.  
  718.    This program is free software; you can redistribute it and/or modify
  719.    it under the terms of the GNU General Public License as published by
  720.    the Free Software Foundation; either version 1, or (at your option)
  721.    any later version.
  722.  
  723.    This program is distributed in the hope that it will be useful,
  724.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  725.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  726.    GNU General Public License for more details.
  727.  
  728.    You should have received a copy of the GNU General Public License
  729.    along with this program; if not, write to the Free Software
  730.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  731.  
  732.  
  733. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  734. #include <alloca.h>
  735. #endif
  736.  
  737. /* This is the parser code that is written into each bison parser
  738.   when the %semantic_parser declaration is not specified in the grammar.
  739.   It was written by Richard Stallman by simplifying the hairy parser
  740.   used when %semantic_parser is specified.  */
  741.  
  742. /* Note: there must be only one dollar sign in this file.
  743.    It is replaced by the list of actions, each action
  744.    as one case of the switch.  */
  745.  
  746. #define yyerrok        (yyerrstatus = 0)
  747. #define yyclearin    (yychar = YYEMPTY)
  748. #define YYEMPTY        -2
  749. #define YYEOF        0
  750. #define YYFAIL        goto yyerrlab;
  751. #define YYACCEPT    return(0)
  752. #define YYABORT     return(1)
  753. #define YYERROR        goto yyerrlab
  754.  
  755. #define YYTERROR    1
  756. #define YYERRCODE    256
  757.  
  758. #ifndef YYIMPURE
  759. #define YYLEX        yylex()
  760. #endif
  761.  
  762. #ifndef YYPURE
  763. #define YYLEX        yylex(&yylval, &yylloc)
  764. #endif
  765.  
  766. /* If nonreentrant, generate the variables here */
  767.  
  768. #ifndef YYIMPURE
  769.  
  770. int    yychar;            /*  the lookahead symbol        */
  771. YYSTYPE    yylval;            /*  the semantic value of the        */
  772.                 /*  lookahead symbol            */
  773.  
  774. YYLTYPE yylloc;            /*  location data for the lookahead    */
  775.                 /*  symbol                */
  776.  
  777. int yynerrs;            /*  number of parse errors so far       */
  778. #endif  /* YYIMPURE */
  779.  
  780. #if YYDEBUG != 0
  781. int yydebug;            /*  nonzero means print parse trace    */
  782. /* Since this is uninitialized, it does not stop multiple parsers
  783.    from coexisting.  */
  784. #endif
  785.  
  786. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  787.  
  788. #ifndef    YYMAXDEPTH
  789. #define YYMAXDEPTH 200
  790. #endif
  791.  
  792. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  793.     (effective only if the built-in stack extension method is used).  */
  794.  
  795. #ifndef YYMAXLIMIT
  796. #define YYMAXLIMIT 10000
  797. #endif
  798.  
  799.  
  800. #line 90 "bison.simple"
  801. int
  802. yyparse()
  803. {
  804.   register int yystate;
  805.   register int yyn;
  806.   register short *yyssp;
  807.   register YYSTYPE *yyvsp;
  808.   YYLTYPE *yylsp;
  809.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  810.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  811.  
  812.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  813.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  814.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  815.  
  816.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  817.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  818.   YYLTYPE *yyls = yylsa;
  819.  
  820.   int yymaxdepth = YYMAXDEPTH;
  821.  
  822. #ifndef YYPURE
  823.   int yychar;
  824.   YYSTYPE yylval;
  825.   YYLTYPE yylloc;
  826.   int yynerrs;
  827. #endif
  828.  
  829.   YYSTYPE yyval;        /*  the variable used to return        */
  830.                 /*  semantic values from the action    */
  831.                 /*  routines                */
  832.  
  833.   int yylen;
  834.  
  835. #if YYDEBUG != 0
  836.   if (yydebug)
  837.     fprintf(stderr, "Starting parse\n");
  838. #endif
  839.  
  840.   yystate = 0;
  841.   yyerrstatus = 0;
  842.   yynerrs = 0;
  843.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  844.  
  845.   /* Initialize stack pointers.
  846.      Waste one element of value and location stack
  847.      so that they stay on the same level as the state stack.  */
  848.  
  849.   yyssp = yyss - 1;
  850.   yyvsp = yyvs;
  851.   yylsp = yyls;
  852.  
  853. /* Push a new state, which is found in  yystate  .  */
  854. /* In all cases, when you get here, the value and location stacks
  855.    have just been pushed. so pushing a state here evens the stacks.  */
  856. yynewstate:
  857.  
  858.   *++yyssp = yystate;
  859.  
  860.   if (yyssp >= yyss + yymaxdepth - 1)
  861.     {
  862.       /* Give user a chance to reallocate the stack */
  863.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  864.       YYSTYPE *yyvs1 = yyvs;
  865.       YYLTYPE *yyls1 = yyls;
  866.       short *yyss1 = yyss;
  867.  
  868.       /* Get the current used size of the three stacks, in elements.  */
  869.       int size = yyssp - yyss + 1;
  870.  
  871. #ifdef yyoverflow
  872.       /* Each stack pointer address is followed by the size of
  873.      the data in use in that stack, in bytes.  */
  874.       yyoverflow("parser stack overflow",
  875.          &yyss1, size * sizeof (*yyssp),
  876.          &yyvs1, size * sizeof (*yyvsp),
  877.          &yyls1, size * sizeof (*yylsp),
  878.          &yymaxdepth);
  879.  
  880.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  881. #else /* no yyoverflow */
  882.       /* Extend the stack our own way.  */
  883.       if (yymaxdepth >= YYMAXLIMIT)
  884.     yyerror("parser stack overflow");
  885.       yymaxdepth *= 2;
  886.       if (yymaxdepth > YYMAXLIMIT)
  887.     yymaxdepth = YYMAXLIMIT;
  888.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  889.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  890.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  891.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  892. #ifdef YYLSP_NEEDED
  893.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  894.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  895. #endif
  896. #endif /* no yyoverflow */
  897.  
  898.       yyssp = yyss + size - 1;
  899.       yyvsp = yyvs + size - 1;
  900. #ifdef YYLSP_NEEDED
  901.       yylsp = yyls + size - 1;
  902. #endif
  903.  
  904. #if YYDEBUG != 0
  905.       if (yydebug)
  906.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  907. #endif
  908.  
  909.       if (yyssp >= yyss + yymaxdepth - 1)
  910.     YYABORT;
  911.     }
  912.  
  913. #if YYDEBUG != 0
  914.   if (yydebug)
  915.     fprintf(stderr, "Entering state %d\n", yystate);
  916. #endif
  917.  
  918. /* Do appropriate processing given the current state.  */
  919. /* Read a lookahead token if we need one and don't already have one.  */
  920. yyresume:
  921.  
  922.   /* First try to decide what to do without reference to lookahead token.  */
  923.  
  924.   yyn = yypact[yystate];
  925.   if (yyn == YYFLAG)
  926.     goto yydefault;
  927.  
  928.   /* Not known => get a lookahead token if don't already have one.  */
  929.  
  930.   /* yychar is either YYEMPTY or YYEOF
  931.      or a valid token in external form.  */
  932.  
  933.   if (yychar == YYEMPTY)
  934.     {
  935. #if YYDEBUG != 0
  936.       if (yydebug)
  937.     fprintf(stderr, "Reading a token: ");
  938. #endif
  939.       yychar = YYLEX;
  940.     }
  941.  
  942.   /* Convert token to internal form (in yychar1) for indexing tables with */
  943.  
  944.   if (yychar <= 0)        /* This means end of input. */
  945.     {
  946.       yychar1 = 0;
  947.       yychar = YYEOF;        /* Don't call YYLEX any more */
  948.  
  949. #if YYDEBUG != 0
  950.       if (yydebug)
  951.     fprintf(stderr, "Now at end of input.\n");
  952. #endif
  953.     }
  954.   else
  955.     {
  956.       yychar1 = YYTRANSLATE(yychar);
  957.  
  958. #if YYDEBUG != 0
  959.       if (yydebug)
  960.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  961. #endif
  962.     }
  963.  
  964.   yyn += yychar1;
  965.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  966.     goto yydefault;
  967.  
  968.   yyn = yytable[yyn];
  969.  
  970.   /* yyn is what to do for this token type in this state.
  971.      Negative => reduce, -yyn is rule number.
  972.      Positive => shift, yyn is new state.
  973.        New state is final state => don't bother to shift,
  974.        just return success.
  975.      0, or most negative number => error.  */
  976.  
  977.   if (yyn < 0)
  978.     {
  979.       if (yyn == YYFLAG)
  980.     goto yyerrlab;
  981.       yyn = -yyn;
  982.       goto yyreduce;
  983.     }
  984.   else if (yyn == 0)
  985.     goto yyerrlab;
  986.  
  987.   if (yyn == YYFINAL)
  988.     YYACCEPT;
  989.  
  990.   /* Shift the lookahead token.  */
  991.  
  992. #if YYDEBUG != 0
  993.   if (yydebug)
  994.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  995. #endif
  996.  
  997.   /* Discard the token being shifted unless it is eof.  */
  998.   if (yychar != YYEOF)
  999.     yychar = YYEMPTY;
  1000.  
  1001.   *++yyvsp = yylval;
  1002. #ifdef YYLSP_NEEDED
  1003.   *++yylsp = yylloc;
  1004. #endif
  1005.  
  1006.   /* count tokens shifted since error; after three, turn off error status.  */
  1007.   if (yyerrstatus) yyerrstatus--;
  1008.  
  1009.   yystate = yyn;
  1010.   goto yynewstate;
  1011.  
  1012. /* Do the default action for the current state.  */
  1013. yydefault:
  1014.  
  1015.   yyn = yydefact[yystate];
  1016.   if (yyn == 0)
  1017.     goto yyerrlab;
  1018.  
  1019. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  1020. yyreduce:
  1021.   yylen = yyr2[yyn];
  1022.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  1023.  
  1024. #if YYDEBUG != 0
  1025.   if (yydebug)
  1026.     {
  1027.       if (yylen == 1)
  1028.     fprintf (stderr, "Reducing 1 value via line %d, ",
  1029.          yyrline[yyn]);
  1030.       else
  1031.     fprintf (stderr, "Reducing %d values via line %d, ",
  1032.          yylen, yyrline[yyn]);
  1033.     }
  1034. #endif
  1035.  
  1036.  
  1037.   switch (yyn) {
  1038.  
  1039. case 1:
  1040. #line 139 "awk.y"
  1041. { expression_value = yyvsp[-1].nodeval; ;
  1042.     break;}
  1043. case 2:
  1044. #line 144 "awk.y"
  1045.             if (yyvsp[0].nodeval != NULL)
  1046.                 yyval.nodeval = yyvsp[0].nodeval;
  1047.             else
  1048.                 yyval.nodeval = NULL;
  1049.             yyerrok;
  1050.         ;
  1051.     break;}
  1052. case 3:
  1053. #line 153 "awk.y"
  1054. {
  1055.             if (yyvsp[0].nodeval == NULL)
  1056.                 yyval.nodeval = yyvsp[-1].nodeval;
  1057.             else if (yyvsp[-1].nodeval == NULL)
  1058.                 yyval.nodeval = yyvsp[0].nodeval;
  1059.             else {
  1060.                 if (yyvsp[-1].nodeval->type != Node_rule_list)
  1061.                     yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
  1062.                         (NODE*)NULL);
  1063.                 yyval.nodeval = append_right (yyvsp[-1].nodeval,
  1064.                    node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
  1065.             }
  1066.             yyerrok;
  1067.         ;
  1068.     break;}
  1069. case 4:
  1070. #line 167 "awk.y"
  1071. { yyval.nodeval = NULL; ;
  1072.     break;}
  1073. case 5:
  1074. #line 168 "awk.y"
  1075. { yyval.nodeval = NULL; ;
  1076.     break;}
  1077. case 6:
  1078. #line 172 "awk.y"
  1079. { io_allowed = 0; ;
  1080.     break;}
  1081. case 7:
  1082. #line 174 "awk.y"
  1083. {
  1084.         if (begin_block) {
  1085.             if (begin_block->type != Node_rule_list)
  1086.                 begin_block = node(begin_block, Node_rule_list,
  1087.                     (NODE *)NULL);
  1088.             append_right (begin_block, node(
  1089.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1090.                 Node_rule_list, (NODE *)NULL) );
  1091.         } else
  1092.             begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1093.         yyval.nodeval = NULL;
  1094.         io_allowed = 1;
  1095.         yyerrok;
  1096.       ;
  1097.     break;}
  1098. case 8:
  1099. #line 188 "awk.y"
  1100. { io_allowed = 0; ;
  1101.     break;}
  1102. case 9:
  1103. #line 190 "awk.y"
  1104. {
  1105.         if (end_block) {
  1106.             if (end_block->type != Node_rule_list)
  1107.                 end_block = node(end_block, Node_rule_list,
  1108.                     (NODE *)NULL);
  1109.             append_right (end_block, node(
  1110.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1111.                 Node_rule_list, (NODE *)NULL));
  1112.         } else
  1113.             end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1114.         yyval.nodeval = NULL;
  1115.         io_allowed = 1;
  1116.         yyerrok;
  1117.       ;
  1118.     break;}
  1119. case 10:
  1120. #line 205 "awk.y"
  1121. {
  1122.         msg ("error near line %d: BEGIN blocks must have an action part", lineno);
  1123.         errcount++;
  1124.         yyerrok;
  1125.       ;
  1126.     break;}
  1127. case 11:
  1128. #line 211 "awk.y"
  1129. {
  1130.         msg ("error near line %d: END blocks must have an action part", lineno);
  1131.         errcount++;
  1132.         yyerrok;
  1133.       ;
  1134.     break;}
  1135. case 12:
  1136. #line 217 "awk.y"
  1137. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1138.     break;}
  1139. case 13:
  1140. #line 219 "awk.y"
  1141. { yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1142.     break;}
  1143. case 14:
  1144. #line 221 "awk.y"
  1145. { if(yyvsp[-1].nodeval) yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, (NODE *)NULL); yyerrok; ;
  1146.     break;}
  1147. case 15:
  1148. #line 223 "awk.y"
  1149. {
  1150.             func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
  1151.             yyval.nodeval = NULL;
  1152.             yyerrok;
  1153.         ;
  1154.     break;}
  1155. case 16:
  1156. #line 232 "awk.y"
  1157. { yyval.sval = yyvsp[0].sval; ;
  1158.     break;}
  1159. case 17:
  1160. #line 234 "awk.y"
  1161. { yyval.sval = yyvsp[0].sval; ;
  1162.     break;}
  1163. case 18:
  1164. #line 239 "awk.y"
  1165. {
  1166.             param_counter = 0;
  1167.         ;
  1168.     break;}
  1169. case 19:
  1170. #line 243 "awk.y"
  1171. {
  1172.             yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
  1173.             can_return = 1;
  1174.         ;
  1175.     break;}
  1176. case 20:
  1177. #line 251 "awk.y"
  1178. {
  1179.         yyval.nodeval = yyvsp[-1].nodeval;
  1180.         can_return = 0;
  1181.       ;
  1182.     break;}
  1183. case 21:
  1184. #line 260 "awk.y"
  1185. { yyval.nodeval = yyvsp[0].nodeval; ;
  1186.     break;}
  1187. case 22:
  1188. #line 262 "awk.y"
  1189. { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
  1190.     break;}
  1191. case 23:
  1192. #line 271 "awk.y"
  1193. { ++want_regexp; ;
  1194.     break;}
  1195. case 24:
  1196. #line 273 "awk.y"
  1197. {
  1198.           want_regexp = 0;
  1199.           yyval.nodeval = node((NODE *)NULL,Node_regex,(NODE *)mk_re_parse(yyvsp[-1].sval, 0));
  1200.           yyval.nodeval -> re_case = 0;
  1201.           emalloc (yyval.nodeval -> re_text, char *, strlen(yyvsp[-1].sval)+1, "regexp");
  1202.           strcpy (yyval.nodeval -> re_text, yyvsp[-1].sval);
  1203.         ;
  1204.     break;}
  1205. case 25:
  1206. #line 284 "awk.y"
  1207. {
  1208.             /* empty actions are different from missing actions */
  1209.             yyval.nodeval = node ((NODE *) NULL, Node_illegal, (NODE *) NULL);
  1210.         ;
  1211.     break;}
  1212. case 26:
  1213. #line 289 "awk.y"
  1214. { yyval.nodeval = yyvsp[-2].nodeval ; ;
  1215.     break;}
  1216. case 27:
  1217. #line 294 "awk.y"
  1218. { yyval.nodeval = yyvsp[0].nodeval; ;
  1219.     break;}
  1220. case 28:
  1221. #line 296 "awk.y"
  1222. {
  1223.             if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
  1224.                 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
  1225.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1226.                 node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
  1227.                 yyerrok;
  1228.         ;
  1229.     break;}
  1230. case 29:
  1231. #line 304 "awk.y"
  1232. { yyval.nodeval = NULL; ;
  1233.     break;}
  1234. case 30:
  1235. #line 306 "awk.y"
  1236. { yyval.nodeval = NULL; ;
  1237.     break;}
  1238. case 31:
  1239. #line 311 "awk.y"
  1240. { yyval.nodetypeval = Node_illegal; ;
  1241.     break;}
  1242. case 32:
  1243. #line 313 "awk.y"
  1244. { yyval.nodetypeval = Node_illegal; ;
  1245.     break;}
  1246. case 33:
  1247. #line 319 "awk.y"
  1248. { yyval.nodeval = NULL; ;
  1249.     break;}
  1250. case 34:
  1251. #line 321 "awk.y"
  1252. { yyval.nodeval = NULL; ;
  1253.     break;}
  1254. case 35:
  1255. #line 323 "awk.y"
  1256. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1257.     break;}
  1258. case 36:
  1259. #line 325 "awk.y"
  1260. { yyval.nodeval = yyvsp[0].nodeval; ;
  1261.     break;}
  1262. case 37:
  1263. #line 327 "awk.y"
  1264. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
  1265.     break;}
  1266. case 38:
  1267. #line 329 "awk.y"
  1268. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
  1269.     break;}
  1270. case 39:
  1271. #line 331 "awk.y"
  1272. {
  1273.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval),
  1274.             (NODE *)NULL, variable(yyvsp[-3].sval)));
  1275.       ;
  1276.     break;}
  1277. case 40:
  1278. #line 336 "awk.y"
  1279. {
  1280.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
  1281.       ;
  1282.     break;}
  1283. case 41:
  1284. #line 340 "awk.y"
  1285. {
  1286.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
  1287.             (NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
  1288.       ;
  1289.     break;}
  1290. case 42:
  1291. #line 346 "awk.y"
  1292. { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
  1293.     break;}
  1294. case 43:
  1295. #line 349 "awk.y"
  1296. { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
  1297.     break;}
  1298. case 44:
  1299. #line 351 "awk.y"
  1300. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1301.     break;}
  1302. case 45:
  1303. #line 353 "awk.y"
  1304. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval); ;
  1305.     break;}
  1306. case 46:
  1307. #line 355 "awk.y"
  1308. { if (! io_allowed) yyerror("next used in BEGIN or END action"); ;
  1309.     break;}
  1310. case 47:
  1311. #line 357 "awk.y"
  1312. { yyval.nodeval = node ((NODE *)NULL, Node_K_next, (NODE *)NULL); ;
  1313.     break;}
  1314. case 48:
  1315. #line 359 "awk.y"
  1316. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
  1317.     break;}
  1318. case 49:
  1319. #line 361 "awk.y"
  1320. { if (! can_return) yyerror("return used outside function context"); ;
  1321.     break;}
  1322. case 50:
  1323. #line 363 "awk.y"
  1324. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
  1325.     break;}
  1326. case 51:
  1327. #line 365 "awk.y"
  1328. { yyval.nodeval = node (variable(yyvsp[-4].sval), Node_K_delete, yyvsp[-2].nodeval); ;
  1329.     break;}
  1330. case 52:
  1331. #line 367 "awk.y"
  1332. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1333.     break;}
  1334. case 53:
  1335. #line 372 "awk.y"
  1336. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1337.     break;}
  1338. case 54:
  1339. #line 374 "awk.y"
  1340. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1341.     break;}
  1342. case 55:
  1343. #line 379 "awk.y"
  1344. {
  1345.         yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, 
  1346.             node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
  1347.       ;
  1348.     break;}
  1349. case 56:
  1350. #line 385 "awk.y"
  1351. { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
  1352.                 node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1353.     break;}
  1354. case 57:
  1355. #line 391 "awk.y"
  1356. { yyval.nodetypeval = NULL; ;
  1357.     break;}
  1358. case 58:
  1359. #line 393 "awk.y"
  1360. { yyval.nodetypeval = NULL; ;
  1361.     break;}
  1362. case 59:
  1363. #line 398 "awk.y"
  1364. { yyval.nodetypeval = NULL; ;
  1365.     break;}
  1366. case 60:
  1367. #line 400 "awk.y"
  1368. { yyval.nodetypeval = NULL; ;
  1369.     break;}
  1370. case 61:
  1371. #line 405 "awk.y"
  1372. { yyval.nodeval = NULL; ;
  1373.     break;}
  1374. case 62:
  1375. #line 407 "awk.y"
  1376. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
  1377.     break;}
  1378. case 63:
  1379. #line 412 "awk.y"
  1380. { yyval.nodeval = NULL; ;
  1381.     break;}
  1382. case 64:
  1383. #line 414 "awk.y"
  1384. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
  1385.     break;}
  1386. case 65:
  1387. #line 416 "awk.y"
  1388. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
  1389.     break;}
  1390. case 66:
  1391. #line 418 "awk.y"
  1392. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
  1393.     break;}
  1394. case 67:
  1395. #line 423 "awk.y"
  1396. { yyval.nodeval = NULL; ;
  1397.     break;}
  1398. case 68:
  1399. #line 425 "awk.y"
  1400. { yyval.nodeval = yyvsp[0].nodeval; ;
  1401.     break;}
  1402. case 69:
  1403. #line 430 "awk.y"
  1404. { yyval.nodeval = make_param(yyvsp[0].sval); ;
  1405.     break;}
  1406. case 70:
  1407. #line 432 "awk.y"
  1408. { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
  1409.     break;}
  1410. case 71:
  1411. #line 434 "awk.y"
  1412. { yyval.nodeval = NULL; ;
  1413.     break;}
  1414. case 72:
  1415. #line 436 "awk.y"
  1416. { yyval.nodeval = NULL; ;
  1417.     break;}
  1418. case 73:
  1419. #line 438 "awk.y"
  1420. { yyval.nodeval = NULL; ;
  1421.     break;}
  1422. case 74:
  1423. #line 444 "awk.y"
  1424. { yyval.nodeval = NULL; ;
  1425.     break;}
  1426. case 75:
  1427. #line 446 "awk.y"
  1428. { yyval.nodeval = yyvsp[0].nodeval; ;
  1429.     break;}
  1430. case 76:
  1431. #line 451 "awk.y"
  1432. { yyval.nodeval = NULL; ;
  1433.     break;}
  1434. case 77:
  1435. #line 453 "awk.y"
  1436. { yyval.nodeval = yyvsp[0].nodeval; ;
  1437.     break;}
  1438. case 78:
  1439. #line 458 "awk.y"
  1440. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1441.     break;}
  1442. case 79:
  1443. #line 460 "awk.y"
  1444. {
  1445.         yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1446.             node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1447.         yyerrok;
  1448.       ;
  1449.     break;}
  1450. case 80:
  1451. #line 466 "awk.y"
  1452. { yyval.nodeval = NULL; ;
  1453.     break;}
  1454. case 81:
  1455. #line 468 "awk.y"
  1456. { yyval.nodeval = NULL; ;
  1457.     break;}
  1458. case 82:
  1459. #line 470 "awk.y"
  1460. { yyval.nodeval = NULL; ;
  1461.     break;}
  1462. case 83:
  1463. #line 472 "awk.y"
  1464. { yyval.nodeval = NULL; ;
  1465.     break;}
  1466. case 84:
  1467. #line 477 "awk.y"
  1468. { yyval.nodeval = NULL; ;
  1469.     break;}
  1470. case 85:
  1471. #line 479 "awk.y"
  1472. { yyval.nodeval = yyvsp[0].nodeval; ;
  1473.     break;}
  1474. case 86:
  1475. #line 484 "awk.y"
  1476. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1477.     break;}
  1478. case 87:
  1479. #line 486 "awk.y"
  1480. {
  1481.             yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1482.                 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1483.             yyerrok;
  1484.         ;
  1485.     break;}
  1486. case 88:
  1487. #line 492 "awk.y"
  1488. { yyval.nodeval = NULL; ;
  1489.     break;}
  1490. case 89:
  1491. #line 494 "awk.y"
  1492. { yyval.nodeval = NULL; ;
  1493.     break;}
  1494. case 90:
  1495. #line 496 "awk.y"
  1496. { yyval.nodeval = NULL; ;
  1497.     break;}
  1498. case 91:
  1499. #line 498 "awk.y"
  1500. { yyval.nodeval = NULL; ;
  1501.     break;}
  1502. case 92:
  1503. #line 503 "awk.y"
  1504. { want_assign = 0; ;
  1505.     break;}
  1506. case 93:
  1507. #line 505 "awk.y"
  1508. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
  1509.     break;}
  1510. case 94:
  1511. #line 507 "awk.y"
  1512. { yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-3].nodeval); ;
  1513.     break;}
  1514. case 95:
  1515. #line 509 "awk.y"
  1516. {
  1517.           yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
  1518.              node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
  1519.         ;
  1520.     break;}
  1521. case 96:
  1522. #line 514 "awk.y"
  1523. {
  1524.           /* "too painful to do right" */
  1525.           /*
  1526.           if (! io_allowed && $3 == NULL)
  1527.             yyerror("non-redirected getline illegal inside BEGIN or END action");
  1528.           */
  1529.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1530.         ;
  1531.     break;}
  1532. case 97:
  1533. #line 523 "awk.y"
  1534. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1535.     break;}
  1536. case 98:
  1537. #line 525 "awk.y"
  1538. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1539.     break;}
  1540. case 99:
  1541. #line 527 "awk.y"
  1542. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1543.     break;}
  1544. case 100:
  1545. #line 529 "awk.y"
  1546. { yyval.nodeval = yyvsp[0].nodeval; ;
  1547.     break;}
  1548. case 101:
  1549. #line 531 "awk.y"
  1550. { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
  1551.     break;}
  1552. case 102:
  1553. #line 533 "awk.y"
  1554. { yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-2].nodeval); ;
  1555.     break;}
  1556. case 103:
  1557. #line 535 "awk.y"
  1558. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1559.     break;}
  1560. case 104:
  1561. #line 537 "awk.y"
  1562. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
  1563.     break;}
  1564. case 105:
  1565. #line 539 "awk.y"
  1566. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
  1567.     break;}
  1568. case 106:
  1569. #line 541 "awk.y"
  1570. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1571.     break;}
  1572. case 107:
  1573. #line 543 "awk.y"
  1574. { yyval.nodeval = yyvsp[0].nodeval; ;
  1575.     break;}
  1576. case 108:
  1577. #line 545 "awk.y"
  1578. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1579.     break;}
  1580. case 109:
  1581. #line 550 "awk.y"
  1582. { want_assign = 0; ;
  1583.     break;}
  1584. case 110:
  1585. #line 552 "awk.y"
  1586. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
  1587.     break;}
  1588. case 111:
  1589. #line 554 "awk.y"
  1590. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1591.     break;}
  1592. case 112:
  1593. #line 556 "awk.y"
  1594. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1595.     break;}
  1596. case 113:
  1597. #line 558 "awk.y"
  1598. {
  1599.           /* "too painful to do right" */
  1600.           /*
  1601.           if (! io_allowed && $3 == NULL)
  1602.             yyerror("non-redirected getline illegal inside BEGIN or END action");
  1603.           */
  1604.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1605.         ;
  1606.     break;}
  1607. case 114:
  1608. #line 567 "awk.y"
  1609. { yyval.nodeval = yyvsp[0].nodeval; ;
  1610.     break;}
  1611. case 115:
  1612. #line 569 "awk.y"
  1613. { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
  1614.     break;}
  1615. case 116:
  1616. #line 571 "awk.y"
  1617. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1618.     break;}
  1619. case 117:
  1620. #line 573 "awk.y"
  1621. { yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-2].nodeval); ;
  1622.     break;}
  1623. case 118:
  1624. #line 575 "awk.y"
  1625. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1626.     break;}
  1627. case 119:
  1628. #line 577 "awk.y"
  1629. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1630.     break;}
  1631. case 120:
  1632. #line 579 "awk.y"
  1633. { yyval.nodeval = yyvsp[0].nodeval; ;
  1634.     break;}
  1635. case 121:
  1636. #line 581 "awk.y"
  1637. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1638.     break;}
  1639. case 122:
  1640. #line 586 "awk.y"
  1641. { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
  1642.     break;}
  1643. case 123:
  1644. #line 588 "awk.y"
  1645. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1646.     break;}
  1647. case 124:
  1648. #line 590 "awk.y"
  1649. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, yyvsp[-3].ptrval); ;
  1650.     break;}
  1651. case 125:
  1652. #line 592 "awk.y"
  1653. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, yyvsp[-3].ptrval); ;
  1654.     break;}
  1655. case 126:
  1656. #line 594 "awk.y"
  1657. { yyval.nodeval = snode ((NODE *)NULL, Node_builtin, yyvsp[0].ptrval); ;
  1658.     break;}
  1659. case 127:
  1660. #line 596 "awk.y"
  1661. {
  1662.         yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
  1663.       ;
  1664.     break;}
  1665. case 128:
  1666. #line 600 "awk.y"
  1667. { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
  1668.     break;}
  1669. case 129:
  1670. #line 602 "awk.y"
  1671. { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
  1672.     break;}
  1673. case 130:
  1674. #line 604 "awk.y"
  1675. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
  1676.     break;}
  1677. case 131:
  1678. #line 606 "awk.y"
  1679. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
  1680.     break;}
  1681. case 132:
  1682. #line 608 "awk.y"
  1683. { yyval.nodeval = yyvsp[0].nodeval; ;
  1684.     break;}
  1685. case 133:
  1686. #line 610 "awk.y"
  1687. { yyval.nodeval = yyvsp[0].nodeval; ;
  1688.     break;}
  1689. case 134:
  1690. #line 612 "awk.y"
  1691. { yyval.nodeval = yyvsp[0].nodeval; ;
  1692.     break;}
  1693. case 135:
  1694. #line 616 "awk.y"
  1695. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
  1696.     break;}
  1697. case 136:
  1698. #line 618 "awk.y"
  1699. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
  1700.     break;}
  1701. case 137:
  1702. #line 620 "awk.y"
  1703. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
  1704.     break;}
  1705. case 138:
  1706. #line 622 "awk.y"
  1707. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
  1708.     break;}
  1709. case 139:
  1710. #line 624 "awk.y"
  1711. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
  1712.     break;}
  1713. case 140:
  1714. #line 626 "awk.y"
  1715. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
  1716.     break;}
  1717. case 141:
  1718. #line 628 "awk.y"
  1719. { yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL); ;
  1720.     break;}
  1721. case 142:
  1722. #line 630 "awk.y"
  1723. { yyval.nodeval = yyvsp[0].nodeval; ;
  1724.     break;}
  1725. case 143:
  1726. #line 635 "awk.y"
  1727. { yyval.nodeval = NULL; ;
  1728.     break;}
  1729. case 144:
  1730. #line 637 "awk.y"
  1731. { yyval.nodeval = yyvsp[0].nodeval; ;
  1732.     break;}
  1733. case 145:
  1734. #line 642 "awk.y"
  1735. { want_assign = 1; yyval.nodeval = variable (yyvsp[0].sval); ;
  1736.     break;}
  1737. case 146:
  1738. #line 644 "awk.y"
  1739. { want_assign = 1; yyval.nodeval = node (variable(yyvsp[-3].sval), Node_subscript, yyvsp[-1].nodeval); ;
  1740.     break;}
  1741. case 147:
  1742. #line 646 "awk.y"
  1743. { want_assign = 1; yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1744.     break;}
  1745. case 149:
  1746. #line 654 "awk.y"
  1747. { yyerrok; ;
  1748.     break;}
  1749. case 150:
  1750. #line 658 "awk.y"
  1751. { yyval.nodetypeval = Node_illegal; yyerrok; ;
  1752.     break;}
  1753. case 153:
  1754. #line 667 "awk.y"
  1755. { yyerrok; ;
  1756.     break;}
  1757. case 154:
  1758. #line 670 "awk.y"
  1759. { yyval.nodetypeval = Node_illegal; yyerrok; ;
  1760.     break;}
  1761. }
  1762.    /* the action file gets copied in in place of this dollarsign */
  1763. #line 327 "bison.simple"
  1764.  
  1765.   yyvsp -= yylen;
  1766.   yyssp -= yylen;
  1767. #ifdef YYLSP_NEEDED
  1768.   yylsp -= yylen;
  1769. #endif
  1770.  
  1771. #if YYDEBUG != 0
  1772.   if (yydebug)
  1773.     {
  1774.       short *ssp1 = yyss - 1;
  1775.       fprintf (stderr, "state stack now");
  1776.       while (ssp1 != yyssp)
  1777.     fprintf (stderr, " %d", *++ssp1);
  1778.       fprintf (stderr, "\n");
  1779.     }
  1780. #endif
  1781.  
  1782.   *++yyvsp = yyval;
  1783.  
  1784. #ifdef YYLSP_NEEDED
  1785.   yylsp++;
  1786.   if (yylen == 0)
  1787.     {
  1788.       yylsp->first_line = yylloc.first_line;
  1789.       yylsp->first_column = yylloc.first_column;
  1790.       yylsp->last_line = (yylsp-1)->last_line;
  1791.       yylsp->last_column = (yylsp-1)->last_column;
  1792.       yylsp->text = 0;
  1793.     }
  1794.   else
  1795.     {
  1796.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1797.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1798.     }
  1799. #endif
  1800.  
  1801.   /* Now "shift" the result of the reduction.
  1802.      Determine what state that goes to,
  1803.      based on the state we popped back to
  1804.      and the rule number reduced by.  */
  1805.  
  1806.   yyn = yyr1[yyn];
  1807.  
  1808.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1809.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1810.     yystate = yytable[yystate];
  1811.   else
  1812.     yystate = yydefgoto[yyn - YYNTBASE];
  1813.  
  1814.   goto yynewstate;
  1815.  
  1816. yyerrlab:   /* here on detecting error */
  1817.  
  1818.   if (! yyerrstatus)
  1819.     /* If not already recovering from an error, report this error.  */
  1820.     {
  1821.       ++yynerrs;
  1822.       yyerror("parse error");
  1823.     }
  1824.  
  1825.   if (yyerrstatus == 3)
  1826.     {
  1827.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1828.  
  1829.       /* return failure if at end of input */
  1830.       if (yychar == YYEOF)
  1831.     YYABORT;
  1832.  
  1833. #if YYDEBUG != 0
  1834.       if (yydebug)
  1835.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1836. #endif
  1837.  
  1838.       yychar = YYEMPTY;
  1839.     }
  1840.  
  1841.   /* Else will try to reuse lookahead token
  1842.      after shifting the error token.  */
  1843.  
  1844.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1845.  
  1846.   goto yyerrhandle;
  1847.  
  1848. yyerrdefault:  /* current state does not do anything special for the error token. */
  1849.  
  1850. #if 0
  1851.   /* This is wrong; only states that explicitly want error tokens
  1852.      should shift them.  */
  1853.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1854.   if (yyn) goto yydefault;
  1855. #endif
  1856.  
  1857. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1858.  
  1859.   if (yyssp == yyss) YYABORT;
  1860.   yyvsp--;
  1861.   yystate = *--yyssp;
  1862. #ifdef YYLSP_NEEDED
  1863.   yylsp--;
  1864. #endif
  1865.  
  1866. #if YYDEBUG != 0
  1867.   if (yydebug)
  1868.     {
  1869.       short *ssp1 = yyss - 1;
  1870.       fprintf (stderr, "Error: state stack now");
  1871.       while (ssp1 != yyssp)
  1872.     fprintf (stderr, " %d", *++ssp1);
  1873.       fprintf (stderr, "\n");
  1874.     }
  1875. #endif
  1876.  
  1877. yyerrhandle:
  1878.  
  1879.   yyn = yypact[yystate];
  1880.   if (yyn == YYFLAG)
  1881.     goto yyerrdefault;
  1882.  
  1883.   yyn += YYTERROR;
  1884.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1885.     goto yyerrdefault;
  1886.  
  1887.   yyn = yytable[yyn];
  1888.   if (yyn < 0)
  1889.     {
  1890.       if (yyn == YYFLAG)
  1891.     goto yyerrpop;
  1892.       yyn = -yyn;
  1893.       goto yyreduce;
  1894.     }
  1895.   else if (yyn == 0)
  1896.     goto yyerrpop;
  1897.  
  1898.   if (yyn == YYFINAL)
  1899.     YYACCEPT;
  1900.  
  1901. #if YYDEBUG != 0
  1902.   if (yydebug)
  1903.     fprintf(stderr, "Shifting error token, ");
  1904. #endif
  1905.  
  1906.   *++yyvsp = yylval;
  1907. #ifdef YYLSP_NEEDED
  1908.   *++yylsp = yylloc;
  1909. #endif
  1910.  
  1911.   yystate = yyn;
  1912.   goto yynewstate;
  1913. }
  1914. #line 673 "awk.y"
  1915.  
  1916.  
  1917. struct token {
  1918.     char *operator;        /* text to match */
  1919.     NODETYPE value;        /* node type */
  1920.     int class;        /* lexical class */
  1921.     short nostrict;        /* ignore if in strict compatibility mode */
  1922.     NODE *(*ptr) ();    /* function that implements this keyword */
  1923. };
  1924.  
  1925. extern NODE
  1926.     *do_exp(),    *do_getline(),    *do_index(),    *do_length(),
  1927.     *do_sqrt(),    *do_log(),    *do_sprintf(),    *do_substr(),
  1928.     *do_split(),    *do_system(),    *do_int(),    *do_close(),
  1929.     *do_atan2(),    *do_sin(),    *do_cos(),    *do_rand(),
  1930.     *do_srand(),    *do_match(),    *do_tolower(),    *do_toupper(),
  1931.     *do_sub(),    *do_gsub();
  1932.  
  1933. /* Special functions for debugging */
  1934. #ifdef DEBUG
  1935. NODE *do_prvars(), *do_bp();
  1936. #endif
  1937.  
  1938. /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
  1939.  
  1940. static struct token tokentab[] = {
  1941.     { "BEGIN",    Node_illegal,        LEX_BEGIN,    0,    0 },
  1942.     { "END",    Node_illegal,        LEX_END,    0,    0 },
  1943.     { "atan2",    Node_builtin,        LEX_BUILTIN,    0,    do_atan2 },
  1944. #ifdef DEBUG
  1945.     { "bp",        Node_builtin,        LEX_BUILTIN,    0,    do_bp },
  1946. #endif
  1947.     { "break",    Node_K_break,        LEX_BREAK,    0,    0 },
  1948.     { "close",    Node_builtin,        LEX_BUILTIN,    0,    do_close },
  1949.     { "continue",    Node_K_continue,    LEX_CONTINUE,    0,    0 },
  1950.     { "cos",    Node_builtin,        LEX_BUILTIN,    0,    do_cos },
  1951.     { "delete",    Node_K_delete,        LEX_DELETE,    0,    0 },
  1952.     { "do",        Node_K_do,        LEX_DO,        0,    0 },
  1953.     { "else",    Node_illegal,        LEX_ELSE,    0,    0 },
  1954.     { "exit",    Node_K_exit,        LEX_EXIT,    0,    0 },
  1955.     { "exp",    Node_builtin,        LEX_BUILTIN,    0,    do_exp },
  1956.     { "for",    Node_K_for,        LEX_FOR,    0,    0 },
  1957.     { "func",    Node_K_function,    LEX_FUNCTION,    0,    0 },
  1958.     { "function",    Node_K_function,    LEX_FUNCTION,    0,    0 },
  1959.     { "getline",    Node_K_getline,        LEX_GETLINE,    0,    0 },
  1960.     { "gsub",    Node_builtin,        LEX_BUILTIN,    0,    do_gsub },
  1961.     { "if",        Node_K_if,        LEX_IF,        0,    0 },
  1962.     { "in",        Node_illegal,        LEX_IN,        0,    0 },
  1963.     { "index",    Node_builtin,        LEX_BUILTIN,    0,    do_index },
  1964.     { "int",    Node_builtin,        LEX_BUILTIN,    0,    do_int },
  1965.     { "length",    Node_builtin,        LEX_LENGTH,    0,    do_length },
  1966.     { "log",    Node_builtin,        LEX_BUILTIN,    0,    do_log },
  1967.     { "match",    Node_builtin,        LEX_BUILTIN,    0,    do_match },
  1968.     { "next",    Node_K_next,        LEX_NEXT,    0,    0 },
  1969.     { "print",    Node_K_print,        LEX_PRINT,    0,    0 },
  1970.     { "printf",    Node_K_printf,        LEX_PRINTF,    0,    0 },
  1971. #ifdef DEBUG
  1972.     { "prvars",    Node_builtin,        LEX_BUILTIN,    0,    do_prvars },
  1973. #endif
  1974.     { "rand",    Node_builtin,        LEX_BUILTIN,    0,    do_rand },
  1975.     { "return",    Node_K_return,        LEX_RETURN,    0,    0 },
  1976.     { "sin",    Node_builtin,        LEX_BUILTIN,    0,    do_sin },
  1977.     { "split",    Node_builtin,        LEX_BUILTIN,    0,    do_split },
  1978.     { "sprintf",    Node_builtin,        LEX_BUILTIN,    0,    do_sprintf },
  1979.     { "sqrt",    Node_builtin,        LEX_BUILTIN,    0,    do_sqrt },
  1980.     { "srand",    Node_builtin,        LEX_BUILTIN,    0,    do_srand },
  1981.     { "sub",    Node_builtin,        LEX_BUILTIN,    0,    do_sub },
  1982.     { "substr",    Node_builtin,        LEX_BUILTIN,    0,    do_substr },
  1983.     { "system",    Node_builtin,        LEX_BUILTIN,    0,    do_system },
  1984.     { "tolower",    Node_builtin,        LEX_BUILTIN,    0,    do_tolower },
  1985.     { "toupper",    Node_builtin,        LEX_BUILTIN,    0,    do_toupper },
  1986.     { "while",    Node_K_while,        LEX_WHILE,    0,    0 },
  1987. };
  1988.  
  1989. static char *token_start;
  1990.  
  1991. /* VARARGS0 */
  1992. static void
  1993. yyerror(char *fmt,...)
  1994. {
  1995.     va_list args;
  1996.     char *mesg;
  1997.     register char *ptr, *beg;
  1998.     char *scan;
  1999. #ifdef THINK_C
  2000.     register int rindex;
  2001. #endif
  2002.  
  2003.     errcount++;
  2004.     /* Find the current line in the input file */
  2005.     if (! lexptr) {
  2006.         beg = "(END OF FILE)";
  2007.         ptr = beg + 13;
  2008.     } else {
  2009. #ifndef THINK_C
  2010.         if (*lexptr == '\n' && lexptr != lexptr_begin)
  2011. #else
  2012.         if ( ((*lexptr == '\n') || (*lexptr == '\r')) && lexptr != lexptr_begin)
  2013. #endif
  2014.             --lexptr;
  2015. #ifndef THINK_C
  2016.         for (beg = lexptr; beg != lexptr_begin && *beg != '\n'; --beg)
  2017. #else
  2018.         for (beg = lexptr; 
  2019.              beg != lexptr_begin && (*beg != '\n' || *beg != '\r'); --beg)
  2020. #endif
  2021.             ;
  2022.         /* NL isn't guaranteed */
  2023. #ifndef THINK_C
  2024.         for (ptr = lexptr; *ptr && *ptr != '\n'; ptr++)
  2025. #else
  2026.         for (ptr = lexptr; *ptr && (*ptr != '\n' || *ptr != '\r'); ptr++)
  2027. #endif
  2028.             ;
  2029.         if (beg != lexptr_begin)
  2030.             beg++;
  2031.     }
  2032. #ifndef THINK_C
  2033.     msg("syntax error near line %d:\n%.*s", lineno, ptr - beg, beg);
  2034. #else
  2035.     for ( rindex = 0; beg[rindex] != '\0'; rindex++ )
  2036.         if ( beg[rindex] == '\r' )
  2037.             beg[rindex] = '\n';
  2038.     msg("syntax error near line %d:\n%s", lineno, beg);
  2039. #endif
  2040.     scan = beg;
  2041.     while (scan < token_start)
  2042.         if (*scan++ == '\t')
  2043.             putc('\t', stderr);
  2044.         else
  2045.             putc(' ', stderr);
  2046.     putc('^', stderr);
  2047.     putc(' ', stderr);
  2048.     va_start(args, fmt);
  2049.     vfprintf(stderr, fmt, args);
  2050.     va_end(args);
  2051.     putc('\n', stderr);
  2052.     exit(1);
  2053. }
  2054.  
  2055. /*
  2056.  * Parse a C escape sequence.  STRING_PTR points to a variable containing a
  2057.  * pointer to the string to parse.  That pointer is updated past the
  2058.  * characters we use.  The value of the escape sequence is returned. 
  2059.  *
  2060.  * A negative value means the sequence \ newline was seen, which is supposed to
  2061.  * be equivalent to nothing at all. 
  2062.  *
  2063.  * If \ is followed by a null character, we return a negative value and leave
  2064.  * the string pointer pointing at the null character. 
  2065.  *
  2066.  * If \ is followed by 000, we return 0 and leave the string pointer after the
  2067.  * zeros.  A value of 0 does not mean end of string.  
  2068.  */
  2069.  
  2070. int
  2071. parse_escape(string_ptr)
  2072. char **string_ptr;
  2073. {
  2074.     register int c = *(*string_ptr)++;
  2075.     register int i;
  2076.     register int count;
  2077.  
  2078.     switch (c) {
  2079.     case 'a':
  2080.         return BELL;
  2081.     case 'b':
  2082.         return '\b';
  2083.     case 'f':
  2084.         return '\f';
  2085.     case 'n':
  2086.         return '\n';
  2087.     case 'r':
  2088.         return '\r';
  2089.     case 't':
  2090.         return '\t';
  2091.     case 'v':
  2092.         return '\v';
  2093.     case '\n':
  2094. #ifdef THINK_C
  2095.     case '\r':
  2096. #endif
  2097.         return -2;
  2098.     case 0:
  2099.         (*string_ptr)--;
  2100.         return -1;
  2101.     case '0':
  2102.     case '1':
  2103.     case '2':
  2104.     case '3':
  2105.     case '4':
  2106.     case '5':
  2107.     case '6':
  2108.     case '7':
  2109.         i = c - '0';
  2110.         count = 0;
  2111.         while (++count < 3) {
  2112.             if ((c = *(*string_ptr)++) >= '0' && c <= '7') {
  2113.                 i *= 8;
  2114.                 i += c - '0';
  2115.             } else {
  2116.                 (*string_ptr)--;
  2117.                 break;
  2118.             }
  2119.         }
  2120.         return i;
  2121.     case 'x':
  2122.         i = 0;
  2123.         while (1) {
  2124.             if (isxdigit((c = *(*string_ptr)++))) {
  2125.                 if (isdigit(c))
  2126.                     i += c - '0';
  2127.                 else if (isupper(c))
  2128.                     i += c - 'A' + 10;
  2129.                 else
  2130.                     i += c - 'a' + 10;
  2131.             } else {
  2132.                 (*string_ptr)--;
  2133.                 break;
  2134.             }
  2135.         }
  2136.         return i;
  2137.     default:
  2138.         return c;
  2139.     }
  2140. }
  2141.  
  2142. /*
  2143.  * Read the input and turn it into tokens. Input is now read from a file
  2144.  * instead of from malloc'ed memory. The main program takes a program
  2145.  * passed as a command line argument and writes it to a temp file. Otherwise
  2146.  * the file name is made available in an external variable.
  2147.  */
  2148.  
  2149. static int
  2150. yylex()
  2151. {
  2152.     register int c;
  2153.     register int namelen;
  2154.     register char *tokstart;
  2155.     char *tokkey;
  2156.     static did_newline = 0;    /* the grammar insists that actions end
  2157.                  * with newlines.  This was easier than
  2158.                  * hacking the grammar. */
  2159.     int seen_e = 0;        /* These are for numbers */
  2160.     int seen_point = 0;
  2161.     int esc_seen;
  2162.     extern char **sourcefile;
  2163.     extern int tempsource, numfiles;
  2164.     static int file_opened = 0;
  2165.     static FILE *fin;
  2166.     static char cbuf[BUFSIZ];
  2167.     int low, mid, high;
  2168. #ifdef DEBUG
  2169.     extern int debugging;
  2170. #endif
  2171.  
  2172.     if (! file_opened) {
  2173.         file_opened = 1;
  2174. #ifdef DEBUG
  2175.         if (debugging) {
  2176.             int i;
  2177.  
  2178.             for (i = 0; i <= numfiles; i++)
  2179.                 fprintf (stderr, "sourcefile[%d] = %s\n", i,
  2180.                         sourcefile[i]);
  2181.         }
  2182. #endif
  2183.     nextfile:
  2184.         if ((fin = pathopen (sourcefile[++curinfile])) == NULL)
  2185.             fatal("cannot open `%s' for reading (%s)",
  2186.                 sourcefile[curinfile],
  2187.                 strerror(errno));
  2188.         *(lexptr = cbuf) = '\0';
  2189.         /*
  2190.          * immediately unlink the tempfile so that it will
  2191.          * go away cleanly if we bomb.
  2192.          */
  2193.         if (tempsource && curinfile == 0)
  2194.             (void) unlink (sourcefile[curinfile]);
  2195.     }
  2196.  
  2197. retry:
  2198.     if (! *lexptr)
  2199.         if (fgets (cbuf, sizeof cbuf, fin) == NULL) {
  2200.             if (fin != NULL)
  2201.                 fclose (fin);    /* be neat and clean */
  2202.             if (curinfile < numfiles)
  2203.                 goto nextfile;
  2204.             return 0;
  2205.         } else
  2206.             lexptr = lexptr_begin = cbuf;
  2207.  
  2208.     if (want_regexp) {
  2209.         int in_brack = 0;
  2210.  
  2211.         want_regexp = 0;
  2212.         token_start = tokstart = lexptr;
  2213.         while (c = *lexptr++) {
  2214.             switch (c) {
  2215.             case '[':
  2216.                 in_brack = 1;
  2217.                 break;
  2218.             case ']':
  2219.                 in_brack = 0;
  2220.                 break;
  2221.             case '\\':
  2222.                 if (*lexptr++ == '\0') {
  2223.                     yyerror("unterminated regexp ends with \\");
  2224.                     return ERROR;
  2225. #ifndef THINK_C
  2226.                 } else if (lexptr[-1] == '\n')
  2227. #else
  2228.                 } else if ((lexptr[-1] == '\n') || (lexptr[-1] == '\r'))
  2229. #endif
  2230.                     goto retry;
  2231.                 break;
  2232.             case '/':    /* end of the regexp */
  2233.                 if (in_brack)
  2234.                     break;
  2235.  
  2236.                 lexptr--;
  2237.                 yylval.sval = tokstart;
  2238.                 return REGEXP;
  2239.             case '\n':
  2240. #ifdef THINK_C
  2241.             case '\r':
  2242. #endif
  2243.                 lineno++;
  2244.             case '\0':
  2245.                 lexptr--;    /* so error messages work */
  2246.                 yyerror("unterminated regexp");
  2247.                 return ERROR;
  2248.             }
  2249.         }
  2250.     }
  2251.  
  2252. #ifndef THINK_C
  2253.     if (*lexptr == '\n') {
  2254. #else
  2255.     if ((*lexptr == '\n') || (*lexptr == '\r')) {
  2256. #endif
  2257.         lexptr++;
  2258.         lineno++;
  2259.         return NEWLINE;
  2260.     }
  2261.  
  2262.     while (*lexptr == ' ' || *lexptr == '\t')
  2263.         lexptr++;
  2264.  
  2265.     token_start = tokstart = lexptr;
  2266.  
  2267.     switch (c = *lexptr++) {
  2268.     case 0:
  2269.         return 0;
  2270.  
  2271.     case '\n':
  2272. #ifdef THINK_C
  2273.     case '\r':
  2274. #endif
  2275.         lineno++;
  2276.         return NEWLINE;
  2277.  
  2278.     case '#':        /* it's a comment */
  2279. #ifndef THINK_C
  2280.         while (*lexptr != '\n' && *lexptr != '\0')
  2281. #else
  2282.         while (*lexptr != '\n' && *lexptr != '\0' && *lexptr != '\r' )
  2283. #endif
  2284.         
  2285.             lexptr++;
  2286.         goto retry;
  2287.  
  2288.     case '\\':
  2289. #ifndef THINK_C
  2290.         if (*lexptr == '\n') {
  2291. #else
  2292.         if ( (*lexptr == '\n') || (*lexptr == '\r')) {
  2293. #endif
  2294.             lineno++;
  2295.             lexptr++;
  2296.             goto retry;
  2297.         } else
  2298.             break;
  2299.     case ')':
  2300.     case ']':
  2301.     case '(':    
  2302.     case '[':
  2303.     case '$':
  2304.     case ';':
  2305.     case ':':
  2306.     case '?':
  2307.  
  2308.         /*
  2309.          * set node type to ILLEGAL because the action should set it
  2310.          * to the right thing 
  2311.          */
  2312.         yylval.nodetypeval = Node_illegal;
  2313.         return c;
  2314.  
  2315.     case '{':
  2316.     case ',':
  2317.         yylval.nodetypeval = Node_illegal;
  2318.         return c;
  2319.  
  2320.     case '*':
  2321.         if (*lexptr == '=') {
  2322.             yylval.nodetypeval = Node_assign_times;
  2323.             lexptr++;
  2324.             return ASSIGNOP;
  2325.         } else if (*lexptr == '*') {    /* make ** and **= aliases
  2326.                          * for ^ and ^= */
  2327.             if (lexptr[1] == '=') {
  2328.                 yylval.nodetypeval = Node_assign_exp;
  2329.                 lexptr += 2;
  2330.                 return ASSIGNOP;
  2331.             } else {
  2332.                 yylval.nodetypeval = Node_illegal;
  2333.                 lexptr++;
  2334.                 return '^';
  2335.             }
  2336.         }
  2337.         yylval.nodetypeval = Node_illegal;
  2338.         return c;
  2339.  
  2340.     case '/':
  2341.         if (want_assign && *lexptr == '=') {
  2342.             yylval.nodetypeval = Node_assign_quotient;
  2343.             lexptr++;
  2344.             return ASSIGNOP;
  2345.         }
  2346.         yylval.nodetypeval = Node_illegal;
  2347.         return c;
  2348.  
  2349.     case '%':
  2350.         if (*lexptr == '=') {
  2351.             yylval.nodetypeval = Node_assign_mod;
  2352.             lexptr++;
  2353.             return ASSIGNOP;
  2354.         }
  2355.         yylval.nodetypeval = Node_illegal;
  2356.         return c;
  2357.  
  2358.     case '^':
  2359.         if (*lexptr == '=') {
  2360.             yylval.nodetypeval = Node_assign_exp;
  2361.             lexptr++;
  2362.             return ASSIGNOP;
  2363.         }
  2364.         yylval.nodetypeval = Node_illegal;
  2365.         return c;
  2366.  
  2367.     case '+':
  2368.         if (*lexptr == '=') {
  2369.             yylval.nodetypeval = Node_assign_plus;
  2370.             lexptr++;
  2371.             return ASSIGNOP;
  2372.         }
  2373.         if (*lexptr == '+') {
  2374.             yylval.nodetypeval = Node_illegal;
  2375.             lexptr++;
  2376.             return INCREMENT;
  2377.         }
  2378.         yylval.nodetypeval = Node_illegal;
  2379.         return c;
  2380.  
  2381.     case '!':
  2382.         if (*lexptr == '=') {
  2383.             yylval.nodetypeval = Node_notequal;
  2384.             lexptr++;
  2385.             return RELOP;
  2386.         }
  2387.         if (*lexptr == '~') {
  2388.             yylval.nodetypeval = Node_nomatch;
  2389.             lexptr++;
  2390.             return MATCHOP;
  2391.         }
  2392.         yylval.nodetypeval = Node_illegal;
  2393.         return c;
  2394.  
  2395.     case '<':
  2396.         if (*lexptr == '=') {
  2397.             yylval.nodetypeval = Node_leq;
  2398.             lexptr++;
  2399.             return RELOP;
  2400.         }
  2401.         yylval.nodetypeval = Node_less;
  2402.         return c;
  2403.  
  2404.     case '=':
  2405.         if (*lexptr == '=') {
  2406.             yylval.nodetypeval = Node_equal;
  2407.             lexptr++;
  2408.             return RELOP;
  2409.         }
  2410.         yylval.nodetypeval = Node_assign;
  2411.         return ASSIGNOP;
  2412.  
  2413.     case '>':
  2414.         if (*lexptr == '=') {
  2415.             yylval.nodetypeval = Node_geq;
  2416.             lexptr++;
  2417.             return RELOP;
  2418.         } else if (*lexptr == '>') {
  2419.             yylval.nodetypeval = Node_redirect_append;
  2420.             lexptr++;
  2421.             return APPEND_OP;
  2422.         }
  2423.         yylval.nodetypeval = Node_greater;
  2424.         return c;
  2425.  
  2426.     case '~':
  2427.         yylval.nodetypeval = Node_match;
  2428.         return MATCHOP;
  2429.  
  2430.     case '}':
  2431.         /*
  2432.          * Added did newline stuff.  Easier than
  2433.          * hacking the grammar
  2434.          */
  2435.         if (did_newline) {
  2436.             did_newline = 0;
  2437.             return c;
  2438.         }
  2439.         did_newline++;
  2440.         --lexptr;
  2441.         return NEWLINE;
  2442.  
  2443.     case '"':
  2444.         esc_seen = 0;
  2445.         while (*lexptr != '\0') {
  2446.             switch (*lexptr++) {
  2447.             case '\\':
  2448.                 esc_seen = 1;
  2449. #ifndef THINK_C
  2450.                 if (*lexptr == '\n')
  2451. #else
  2452.                 if ((*lexptr == '\n') || (*lexptr == '\r'))
  2453. #endif
  2454.                     yyerror("newline in string");
  2455.                 if (*lexptr++ != '\0')
  2456.                     break;
  2457.                 /* fall through */
  2458.             case '\n':
  2459. #ifdef THINK_C
  2460.             case '\r':
  2461. #endif
  2462.                 lexptr--;
  2463.                 yyerror("unterminated string");
  2464.                 return ERROR;
  2465.             case '"':
  2466.                 yylval.nodeval = make_str_node(tokstart + 1,
  2467.                         lexptr-tokstart-2, esc_seen);
  2468.                 yylval.nodeval->flags |= PERM;
  2469.                 return YSTRING;
  2470.             }
  2471.         }
  2472.         return ERROR;
  2473.  
  2474.     case '-':
  2475.         if (*lexptr == '=') {
  2476.             yylval.nodetypeval = Node_assign_minus;
  2477.             lexptr++;
  2478.             return ASSIGNOP;
  2479.         }
  2480.         if (*lexptr == '-') {
  2481.             yylval.nodetypeval = Node_illegal;
  2482.             lexptr++;
  2483.             return DECREMENT;
  2484.         }
  2485.         yylval.nodetypeval = Node_illegal;
  2486.         return c;
  2487.  
  2488.     case '0':
  2489.     case '1':
  2490.     case '2':
  2491.     case '3':
  2492.     case '4':
  2493.     case '5':
  2494.     case '6':
  2495.     case '7':
  2496.     case '8':
  2497.     case '9':
  2498.     case '.':
  2499.         /* It's a number */
  2500.         for (namelen = 0; (c = tokstart[namelen]) != '\0'; namelen++) {
  2501.             switch (c) {
  2502.             case '.':
  2503.                 if (seen_point)
  2504.                     goto got_number;
  2505.                 ++seen_point;
  2506.                 break;
  2507.             case 'e':
  2508.             case 'E':
  2509.                 if (seen_e)
  2510.                     goto got_number;
  2511.                 ++seen_e;
  2512.                 if (tokstart[namelen + 1] == '-' ||
  2513.                     tokstart[namelen + 1] == '+')
  2514.                     namelen++;
  2515.                 break;
  2516.             case '0':
  2517.             case '1':
  2518.             case '2':
  2519.             case '3':
  2520.             case '4':
  2521.             case '5':
  2522.             case '6':
  2523.             case '7':
  2524.             case '8':
  2525.             case '9':
  2526.                 break;
  2527.             default:
  2528.                 goto got_number;
  2529.             }
  2530.         }
  2531.  
  2532. got_number:
  2533.         lexptr = tokstart + namelen;
  2534.         /*
  2535.         yylval.nodeval = make_string(tokstart, namelen);
  2536.         (void) force_number(yylval.nodeval);
  2537.         */
  2538.         yylval.nodeval = make_number(atof(tokstart));
  2539.         yylval.nodeval->flags |= PERM;
  2540.         return NUMBER;
  2541.  
  2542.     case '&':
  2543.         if (*lexptr == '&') {
  2544.             yylval.nodetypeval = Node_and;
  2545.             while (c = *++lexptr) {
  2546.                 if (c == '#')
  2547. #ifndef THINK_C
  2548.                     while ((c = *++lexptr) != '\n'
  2549. #else
  2550.                     while ((c = *++lexptr) != '\n' && c != '\r'
  2551. #endif
  2552.                            && c != '\0')
  2553.                         ;
  2554. #ifndef THINK_C
  2555.                 if (c == '\n')
  2556. #else
  2557.                 if (( c == '\n' ) || ( c == '\r'))
  2558. #endif
  2559.                     lineno++;
  2560.                 else if (! isspace(c))
  2561.                     break;
  2562.             }
  2563.             return LEX_AND;
  2564.         }
  2565.         return ERROR;
  2566.  
  2567.     case '|':
  2568.         if (*lexptr == '|') {
  2569.             yylval.nodetypeval = Node_or;
  2570.             while (c = *++lexptr) {
  2571.                 if (c == '#')
  2572. #ifndef THINK_C
  2573.                     while ((c = *++lexptr) != '\n'
  2574. #else
  2575.                     while ((c = *++lexptr) != '\n' && c != '\r'
  2576. #endif
  2577.                            && c != '\0')
  2578.                         ;
  2579. #ifndef THINK_C
  2580.                 if (c == '\n')
  2581. #else
  2582.                 if (( c == '\n' ) || ( c == '\r'))
  2583. #endif
  2584.                     lineno++;
  2585.                 else if (! isspace(c))
  2586.                     break;
  2587.             }
  2588.             return LEX_OR;
  2589.         }
  2590.         yylval.nodetypeval = Node_illegal;
  2591.         return c;
  2592.     }
  2593.  
  2594.     if (c != '_' && ! isalpha(c)) {
  2595.         yyerror("Invalid char '%c' in expression\n", c);
  2596.         return ERROR;
  2597.     }
  2598.  
  2599.     /* it's some type of name-type-thing.  Find its length */
  2600.     for (namelen = 0; is_identchar(tokstart[namelen]); namelen++)
  2601.         /* null */ ;
  2602.     emalloc(tokkey, char *, namelen+1, "yylex");
  2603.     memcpy(tokkey, tokstart, namelen);
  2604.     tokkey[namelen] = '\0';
  2605.  
  2606.     /* See if it is a special token.  */
  2607.     low = 0;
  2608.     high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
  2609.     while (low <= high) {
  2610.         int i, c;
  2611.  
  2612.         mid = (low + high) / 2;
  2613.         c = *tokstart - tokentab[mid].operator[0];
  2614.         i = c ? c : strcmp (tokkey, tokentab[mid].operator);
  2615.  
  2616.         if (i < 0) {        /* token < mid */
  2617.             high = mid - 1;
  2618.         } else if (i > 0) {    /* token > mid */
  2619.             low = mid + 1;
  2620.         } else {
  2621.             lexptr = tokstart + namelen;
  2622.             if (strict && tokentab[mid].nostrict)
  2623.                 break;
  2624.             if (tokentab[mid].class == LEX_BUILTIN
  2625.                 || tokentab[mid].class == LEX_LENGTH)
  2626.                 yylval.ptrval = tokentab[mid].ptr;
  2627.             else
  2628.                 yylval.nodetypeval = tokentab[mid].value;
  2629.             return tokentab[mid].class;
  2630.         }
  2631.     }
  2632.  
  2633.     /* It's a name.  See how long it is.  */
  2634.     yylval.sval = tokkey;
  2635.     lexptr = tokstart + namelen;
  2636.     if (*lexptr == '(')
  2637.         return FUNC_CALL;
  2638.     else
  2639.         return NAME;
  2640. }
  2641.  
  2642. #ifndef DEFPATH
  2643. #ifdef MSDOS
  2644. #define DEFPATH    "."
  2645. #define ENVSEP    ';'
  2646. #elif defined ( THINK_C )
  2647. #define DEFPATH "."
  2648. #define ENVSEP ' '
  2649. #else
  2650. #define DEFPATH    ".:/usr/lib/awk:/usr/local/lib/awk"
  2651. #define ENVSEP    ':'
  2652. #endif
  2653. #endif
  2654.  
  2655. static FILE *
  2656. pathopen (file)
  2657. char *file;
  2658. {
  2659.     static char *savepath = DEFPATH;
  2660.     static int first = 1;
  2661.     char *awkpath, *cp;
  2662.     char trypath[BUFSIZ];
  2663.     FILE *fp;
  2664. #ifdef DEBUG
  2665.     extern int debugging;
  2666. #endif
  2667.     int fd;
  2668.  
  2669.     if (strcmp (file, "-") == 0)
  2670.         return (stdin);
  2671.  
  2672.     if (strict)
  2673.         return (fopen (file, "r"));
  2674.  
  2675.     if (first) {
  2676.         first = 0;
  2677.         if ((awkpath = getenv ("AWKPATH")) != NULL && *awkpath)
  2678.             savepath = awkpath;    /* used for restarting */
  2679.     }
  2680.     awkpath = savepath;
  2681.  
  2682.     /* some kind of path name, no search */
  2683. #ifndef MSDOS
  2684.     if (strchr (file, '/') != NULL)
  2685. #else
  2686.     if (strchr (file, '/') != NULL || strchr (file, '\\') != NULL
  2687.             || strchr (file, ':') != NULL)
  2688. #endif
  2689.         return ( (fd = devopen (file, "r")) >= 0 ?
  2690.                 fdopen(fd, "r") :
  2691.                 NULL);
  2692.  
  2693.     do {
  2694.         trypath[0] = '\0';
  2695.         /* this should take into account limits on size of trypath */
  2696.         for (cp = trypath; *awkpath && *awkpath != ENVSEP; )
  2697.             *cp++ = *awkpath++;
  2698.  
  2699.         if (cp != trypath) {    /* nun-null element in path */
  2700.             *cp++ = '/';
  2701.             strcpy (cp, file);
  2702.         } else
  2703.             strcpy (trypath, file);
  2704. #ifdef DEBUG
  2705.         if (debugging)
  2706.             fprintf(stderr, "trying: %s\n", trypath);
  2707. #endif
  2708.         if ((fd = devopen (trypath, "r")) >= 0
  2709.             && (fp = fdopen(fd, "r")) != NULL)
  2710.             return (fp);
  2711.  
  2712.         /* no luck, keep going */
  2713.         if(*awkpath == ENVSEP && awkpath[1] != '\0')
  2714.             awkpath++;    /* skip colon */
  2715.     } while (*awkpath);
  2716. #ifdef MSDOS
  2717.     /*
  2718.      * Under DOS (and probably elsewhere) you might have one of the awk
  2719.      * paths defined, WITHOUT the current working directory in it.
  2720.      * Therefore you should try to open the file in the current directory.
  2721.      */
  2722.     return ( (fd = devopen(file, "r")) >= 0 ? fdopen(fd, "r") : NULL);
  2723. #elif defined ( THINK_C )
  2724.     /*
  2725.      * Under DOS (and probably elsewhere) you might have one of the awk
  2726.      * paths defined, WITHOUT the current working directory in it.
  2727.      * Therefore you should try to open the file in the current directory.
  2728.      */
  2729.     return ( (fd = devopen(file, "r")) >= 0 ? fdopen(fd, "r") : NULL);
  2730. #else
  2731.     return (NULL);
  2732. #endif
  2733. }
  2734.  
  2735. static NODE *
  2736. node_common(op)
  2737. NODETYPE op;
  2738. {
  2739.     register NODE *r;
  2740.     extern int numfiles;
  2741.     extern int tempsource;
  2742.     extern char **sourcefile;
  2743.  
  2744.     r = newnode(op);
  2745.     r->source_line = lineno;
  2746.     if (numfiles > -1 && ! tempsource)
  2747.         r->source_file = sourcefile[curinfile];
  2748.     else
  2749.         r->source_file = NULL;
  2750.     return r;
  2751. }
  2752.  
  2753. /*
  2754.  * This allocates a node with defined lnode and rnode. 
  2755.  * This should only be used by yyparse+co while reading in the program 
  2756.  */
  2757. NODE *
  2758. node(left, op, right)
  2759. NODE *left, *right;
  2760. NODETYPE op;
  2761. {
  2762.     register NODE *r;
  2763.  
  2764.     r = node_common(op);
  2765.     r->lnode = left;
  2766.     r->rnode = right;
  2767.     return r;
  2768. }
  2769.  
  2770. /*
  2771.  * This allocates a node with defined subnode and proc
  2772.  * Otherwise like node()
  2773.  */
  2774. static NODE *
  2775. snode(subn, op, procp)
  2776. NODETYPE op;
  2777. NODE *(*procp) ();
  2778. NODE *subn;
  2779. {
  2780.     register NODE *r;
  2781.  
  2782.     r = node_common(op);
  2783.     r->subnode = subn;
  2784.     r->proc = procp;
  2785.     return r;
  2786. }
  2787.  
  2788. /*
  2789.  * This allocates a Node_line_range node with defined condpair and
  2790.  * zeroes the trigger word to avoid the temptation of assuming that calling
  2791.  * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'. 
  2792.  */
  2793. /* Otherwise like node() */
  2794. static NODE *
  2795. mkrangenode(cpair)
  2796. NODE *cpair;
  2797. {
  2798.     register NODE *r;
  2799.  
  2800.     r = newnode(Node_line_range);
  2801.     r->condpair = cpair;
  2802.     r->triggered = 0;
  2803.     return r;
  2804. }
  2805.  
  2806. /* Build a for loop */
  2807. static NODE *
  2808. make_for_loop(init, cond, incr)
  2809. NODE *init, *cond, *incr;
  2810. {
  2811.     register FOR_LOOP_HEADER *r;
  2812.     NODE *n;
  2813.  
  2814.     emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
  2815.     n = newnode(Node_illegal);
  2816.     r->init = init;
  2817.     r->cond = cond;
  2818.     r->incr = incr;
  2819.     n->sub.nodep.r.hd = r;
  2820.     return n;
  2821. }
  2822.  
  2823. /*
  2824.  * Install a name in the hash table specified, even if it is already there.
  2825.  * Name stops with first non alphanumeric. Caller must check against
  2826.  * redefinition if that is desired. 
  2827.  */
  2828. NODE *
  2829. install(table, name, value)
  2830. NODE **table;
  2831. char *name;
  2832. NODE *value;
  2833. {
  2834.     register NODE *hp;
  2835.     register int len, bucket;
  2836.     register char *p;
  2837.  
  2838.     len = 0;
  2839.     p = name;
  2840.     while (is_identchar(*p))
  2841.         p++;
  2842.     len = p - name;
  2843.  
  2844.     hp = newnode(Node_hashnode);
  2845.     bucket = hashf(name, len, HASHSIZE);
  2846.     hp->hnext = table[bucket];
  2847.     table[bucket] = hp;
  2848.     hp->hlength = len;
  2849.     hp->hvalue = value;
  2850.     emalloc(hp->hname, char *, len + 1, "install");
  2851.     memcpy(hp->hname, name, len);
  2852.     hp->hname[len] = '\0';
  2853.     return hp->hvalue;
  2854. }
  2855.  
  2856. /*
  2857.  * find the most recent hash node for name name (ending with first
  2858.  * non-identifier char) installed by install 
  2859.  */
  2860. NODE *
  2861. lookup(table, name)
  2862. NODE **table;
  2863. char *name;
  2864. {
  2865.     register char *bp;
  2866.     register NODE *bucket;
  2867.     register int len;
  2868.  
  2869.     for (bp = name; is_identchar(*bp); bp++)
  2870.         ;
  2871.     len = bp - name;
  2872.     bucket = table[hashf(name, len, HASHSIZE)];
  2873.     while (bucket) {
  2874.         if (bucket->hlength == len && STREQN(bucket->hname, name, len))
  2875.             return bucket->hvalue;
  2876.         bucket = bucket->hnext;
  2877.     }
  2878.     return NULL;
  2879. }
  2880.  
  2881. #define HASHSTEP(old, c) ((old << 1) + c)
  2882. #define MAKE_POS(v) (v & ~0x80000000)    /* make number positive */
  2883.  
  2884. /*
  2885.  * return hash function on name.
  2886.  */
  2887. static int
  2888. hashf(name, len, hashsize)
  2889. register char *name;
  2890. register int len;
  2891. int hashsize;
  2892. {
  2893.     register int r = 0;
  2894.  
  2895.     while (len--)
  2896.         r = HASHSTEP(r, *name++);
  2897.  
  2898.     r = MAKE_POS(r) % hashsize;
  2899.     return r;
  2900. }
  2901.  
  2902. /*
  2903.  * Add new to the rightmost branch of LIST.  This uses n^2 time, so we make
  2904.  * a simple attempt at optimizing it.
  2905.  */
  2906. static NODE *
  2907. append_right(list, new)
  2908. NODE *list, *new;
  2909.  
  2910. {
  2911.     register NODE *oldlist;
  2912.     static NODE *savefront = NULL, *savetail = NULL;
  2913.  
  2914.     oldlist = list;
  2915.     if (savefront == oldlist) {
  2916.         savetail = savetail->rnode = new;
  2917.         return oldlist;
  2918.     } else
  2919.         savefront = oldlist;
  2920.     while (list->rnode != NULL)
  2921.         list = list->rnode;
  2922.     savetail = list->rnode = new;
  2923.     return oldlist;
  2924. }
  2925.  
  2926. /*
  2927.  * check if name is already installed;  if so, it had better have Null value,
  2928.  * in which case def is added as the value. Otherwise, install name with def
  2929.  * as value. 
  2930.  */
  2931. static void
  2932. func_install(params, def)
  2933. NODE *params;
  2934. NODE *def;
  2935. {
  2936.     NODE *r;
  2937.  
  2938.     pop_params(params->rnode);
  2939.     pop_var(params, 0);
  2940.     r = lookup(variables, params->param);
  2941.     if (r != NULL) {
  2942.         fatal("function name `%s' previously defined", params->param);
  2943.     } else
  2944.         (void) install(variables, params->param,
  2945.             node(params, Node_func, def));
  2946. }
  2947.  
  2948. static void
  2949. pop_var(np, freeit)
  2950. NODE *np;
  2951. int freeit;
  2952. {
  2953.     register char *bp;
  2954.     register NODE *bucket, **save;
  2955.     register int len;
  2956.     char *name;
  2957.  
  2958.     name = np->param;
  2959.     for (bp = name; is_identchar(*bp); bp++)
  2960.         ;
  2961.     len = bp - name;
  2962.     save = &(variables[hashf(name, len, HASHSIZE)]);
  2963.     for (bucket = *save; bucket; bucket = bucket->hnext) {
  2964.         if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
  2965.             *save = bucket->hnext;
  2966.             freenode(bucket);
  2967.             free(bucket->hname);
  2968.             if (freeit)
  2969.                 free(np->param);
  2970.             return;
  2971.         }
  2972.         save = &(bucket->hnext);
  2973.     }
  2974. }
  2975.  
  2976. static void
  2977. pop_params(params)
  2978. NODE *params;
  2979. {
  2980.     register NODE *np;
  2981.  
  2982.     for (np = params; np != NULL; np = np->rnode)
  2983.         pop_var(np, 1);
  2984. }
  2985.  
  2986. static NODE *
  2987. make_param(name)
  2988. char *name;
  2989. {
  2990.     NODE *r;
  2991.  
  2992.     r = newnode(Node_param_list);
  2993.     r->param = name;
  2994.     r->rnode = NULL;
  2995.     r->param_cnt = param_counter++;
  2996.     return (install(variables, name, r));
  2997. }
  2998.  
  2999. /* Name points to a variable name.  Make sure its in the symbol table */
  3000. NODE *
  3001. variable(name)
  3002. char *name;
  3003. {
  3004.     register NODE *r;
  3005.  
  3006.     if ((r = lookup(variables, name)) == NULL)
  3007.         r = install(variables, name,
  3008.             node(Nnull_string, Node_var, (NODE *) NULL));
  3009.     return r;
  3010. }
  3011.