home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gawk-2.15.5-src.lha / GNU / src / amiga / gawk-2.15.5 / awktab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-19  |  102.3 KB  |  3,320 lines

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