home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuawk.zip / awktab.c < prev    next >
C/C++ Source or Header  |  1997-05-11  |  120KB  |  3,935 lines

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