home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / gawk2.0.t.Z / gawk2.0.t / awk.tab.c < prev    next >
Text File  |  1989-04-06  |  71KB  |  2,295 lines

  1.  
  2. /*  A Bison parser, made from awk.y  */
  3.  
  4. #define    NAME    258
  5. #define    REGEXP    259
  6. #define    YSTRING    260
  7. #define    ERROR    261
  8. #define    INCDEC    262
  9. #define    NUMBER    263
  10. #define    ASSIGNOP    264
  11. #define    RELOP    265
  12. #define    MATCHOP    266
  13. #define    NEWLINE    267
  14. #define    REDIRECT_OP    268
  15. #define    CONCAT_OP    269
  16. #define    LEX_BEGIN    270
  17. #define    LEX_END    271
  18. #define    LEX_IF    272
  19. #define    LEX_ELSE    273
  20. #define    LEX_RETURN    274
  21. #define    LEX_DELETE    275
  22. #define    LEX_WHILE    276
  23. #define    LEX_DO    277
  24. #define    LEX_FOR    278
  25. #define    LEX_BREAK    279
  26. #define    LEX_CONTINUE    280
  27. #define    LEX_PRINT    281
  28. #define    LEX_PRINTF    282
  29. #define    LEX_NEXT    283
  30. #define    LEX_EXIT    284
  31. #define    LEX_FUNCTION    285
  32. #define    LEX_GETLINE    286
  33. #define    LEX_SUB    287
  34. #define    LEX_MATCH    288
  35. #define    LEX_IN    289
  36. #define    LEX_AND    290
  37. #define    LEX_OR    291
  38. #define    INCREMENT    292
  39. #define    DECREMENT    293
  40. #define    LEX_BUILTIN    294
  41. #define    UNARY    295
  42.  
  43. #line 139 "awk.y"
  44.  
  45. #define YYDEBUG 12
  46. #define YYIMPROVE
  47.  
  48. #include "awk.h"
  49.  
  50. static int yylex ();
  51.  
  52. /*
  53.  * The following variable is used for a very sickening thing.
  54.  * The awk language uses white space as the string concatenation
  55.  * operator, but having a white space token that would have to appear
  56.  * everywhere in all the grammar rules would be unbearable.
  57.  * It turns out we can return CONCAT_OP exactly when there really
  58.  * is one, just from knowing what kinds of other tokens it can appear
  59.  * between (namely, constants, variables, or close parentheses).
  60.  * This is because concatenation has the lowest priority of all
  61.  * operators.  want_concat_token is used to remember that something
  62.  * that could be the left side of a concat has just been returned.
  63.  *
  64.  * If anyone knows a cleaner way to do this (don't look at the Un*x
  65.  * code to find one, though), please suggest it.
  66.  */
  67. static int want_concat_token;
  68.  
  69. /* Two more horrible kludges.  The same comment applies to these two too */
  70. static int want_regexp;        /* lexical scanning kludge */
  71. static int want_redirect;    /* similarly */
  72. int lineno = 1;            /* for error msgs */
  73.  
  74. /* During parsing of a gawk program, the pointer to the next character
  75.    is in this variable.  */
  76. char *lexptr;        /* moved it up here */
  77. char *lexptr_begin;    /* for error msgs */
  78. char *func_def;
  79. extern int errcount;
  80. extern struct obstack var_stack;
  81. extern NODE *begin_block;
  82. extern NODE *end_block;
  83. extern struct re_pattern_buffer *mk_re_parse();
  84. extern int param_counter;
  85. struct re_pattern_buffer *rp;
  86.  
  87. #line 183 "awk.y"
  88. typedef union {
  89.     long lval;
  90.     AWKNUM fval;
  91.     NODE *nodeval;
  92.     NODETYPE nodetypeval;
  93.     char *sval;
  94.     NODE *(*ptrval)();
  95. } YYSTYPE;
  96.  
  97. #ifndef YYLTYPE
  98. typedef
  99.   struct yyltype
  100.     {
  101.       int timestamp;
  102.       int first_line;
  103.       int first_column;
  104.       int last_line;
  105.       int last_column;
  106.       char *text;
  107.    }
  108.   yyltype;
  109.  
  110. #define YYLTYPE yyltype
  111. #endif
  112.  
  113. #define    YYOS9FREE {    \
  114.             if (yyss != 0) free(yyss);\
  115.             if (yyls != 0) free(yyls);\
  116.             if (yyvs != 0) free(yyvs);\
  117.         }
  118. #define    YYACCEPT    { YYOS9FREE; return(0);}
  119. #define    YYABORT    { YYOS9FREE; return(1);}
  120. #define    YYERROR    { YYOS9FREE; return(1);}
  121. #ifndef stdin
  122. #include <stdio.h>
  123. #endif
  124.  
  125.  
  126.  
  127. #define    YYFINAL        282
  128. #define    YYFLAG        -32768
  129. #define    YYNTBASE    60
  130.  
  131. #define YYTRANSLATE(x) (yytranslate[x])
  132.  
  133. static char yytranslate[] = {     0,
  134.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  135.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137.      2,     2,    51,     2,     2,    49,    46,     2,     2,    50,
  138.     58,    44,    42,    52,    43,     2,    45,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,    41,    59,     2,
  140.      2,     2,    40,     2,     2,     2,     2,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.     53,     2,    54,    48,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,    56,    55,    57,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  160.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  161.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  162.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  163.     36,    37,    38,    39,    47
  164. };
  165.  
  166. static short yyrline[] = {     0,
  167.    233,   238,   246,   258,   259,   263,   275,   287,   293,   299,
  168.    301,   303,   313,   318,   325,   330,   332,   334,   340,   342,
  169.    344,   346,   348,   355,   357,   365,   370,   375,   377,   383,
  170.    385,   389,   391,   396,   398,   400,   402,   404,   409,   411,
  171.    413,   415,   417,   419,   421,   423,   429,   432,   435,   437,
  172.    439,   441,   443,   445,   447,   449,   451,   453,   455,   457,
  173.    459,   464,   467,   474,   475,   480,   482,   485,   489,   491,
  174.    496,   500,   505,   507,   508,   513,   515,   519,   521,   526,
  175.    528,   534,   536,   537,   538,   542,   543,   545,   547,   549,
  176.    553,   555,   557,   559,   561,   563,   565,   567,   569,   571,
  177.    573,   575,   579,   584,   586,   588,   592,   594,   596,   598,
  178.    600,   602,   604,   606,   608,   612,   614,   616,   618,   620,
  179.    622,   625,   627,   632,   634,   638,   640,   642,   647,   651,
  180.    655,   659
  181. };
  182.  
  183. static char * yytname[] = {     0,
  184. "error","$illegal.","NAME","REGEXP","YSTRING","ERROR","INCDEC","NUMBER","ASSIGNOP","RELOP",
  185. "MATCHOP","NEWLINE","REDIRECT_OP","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN","LEX_DELETE",
  186. "LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT","LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION",
  187. "LEX_GETLINE","LEX_SUB","LEX_MATCH","LEX_IN","LEX_AND","LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","'?'",
  188. "':'","'+'","'-'","'*'","'/'","'%'","UNARY","'^'","'$'","'('",
  189. "'!'","','","'['","']'","'|'","'{'","'}'","')'","';'","start"
  190. };
  191.  
  192. static short yyr1[] = {     0,
  193.     60,    61,    61,    61,    61,    62,    62,    62,    62,    62,
  194.     62,    62,    64,    63,    65,    66,    66,    66,    66,    66,
  195.     66,    66,    66,    68,    67,    69,    69,    70,    70,    70,
  196.     70,    71,    71,    72,    72,    72,    72,    72,    73,    73,
  197.     73,    73,    73,    73,    73,    73,    73,    73,    74,    73,
  198.     75,    73,    76,    73,    77,    73,    73,    73,    73,    73,
  199.     73,    78,    78,    79,    79,    80,    81,    80,    82,    82,
  200.     83,    83,    83,    83,    83,    84,    84,    85,    85,    86,
  201.     86,    86,    86,    86,    86,    87,    87,    87,    87,    87,
  202.     88,    88,    88,    88,    88,    88,    88,    88,    88,    88,
  203.     89,    88,    88,    88,    88,    88,    88,    88,    88,    88,
  204.     88,    88,    88,    88,    88,    88,    88,    88,    88,    88,
  205.     88,    88,    88,    90,    90,    91,    91,    91,    92,    93,
  206.     94,    95
  207. };
  208.  
  209. static short yyr2[] = {     0,
  210.      2,     1,     2,     1,     2,     2,     2,     2,     2,     2,
  211.      2,     2,     0,     8,     4,     0,     1,     1,     3,     3,
  212.      2,     3,     3,     0,     4,     2,     3,     1,     2,     1,
  213.      2,     2,     2,     0,     1,     1,     2,     2,     2,     4,
  214.      1,     6,     8,    10,     9,     9,     2,     2,     0,     5,
  215.      0,     7,     0,     5,     0,     7,     2,     3,     3,     6,
  216.      2,     6,     9,     0,     2,     0,     0,     3,     0,     1,
  217.      1,     3,     1,     2,     3,     0,     1,     0,     1,     1,
  218.      3,     1,     2,     3,     3,     1,     4,     4,     2,     3,
  219.      4,     1,     3,     3,     4,     6,     6,     6,     6,     6,
  220.      0,     4,     4,     3,     5,     4,     2,     2,     2,     2,
  221.      2,     2,     1,     1,     1,     3,     3,     3,     3,     3,
  222.      3,     3,     3,     0,     1,     1,     4,     2,     2,     1,
  223.      1,     1
  224. };
  225.  
  226. static short yydefact[] = {    64,
  227.      0,     4,   126,   115,   114,    65,     0,     0,    13,   101,
  228.      0,     0,     0,     0,    92,     0,     0,    24,     0,     0,
  229.     16,     0,     2,     0,     0,    18,     0,    86,   113,     0,
  230.      0,    64,    34,   132,     6,     8,     0,    64,     7,     9,
  231.      0,   124,     0,     0,   126,   109,   110,     0,     0,     0,
  232.    108,    86,   107,     0,   128,    82,     0,     0,    80,    21,
  233.     89,     5,     3,    12,     0,    16,    16,    16,    10,    11,
  234.      0,     0,     0,    34,    34,     0,     0,     0,     0,     0,
  235.      0,     0,     0,     0,   111,   112,     0,     0,    80,     0,
  236.     32,    36,    35,   129,    30,     0,    76,     0,     0,    34,
  237.      0,     0,     0,    49,    53,     0,    76,   130,     0,    28,
  238.     41,     0,     0,    26,    64,    33,    34,    66,   125,     0,
  239.      0,     0,     0,     0,   131,    22,    83,     0,     0,    90,
  240.      0,    19,    20,    23,   104,    93,    94,     0,   122,     0,
  241.      0,     0,   120,   121,   117,   118,   119,   116,   124,   123,
  242.    106,   127,    38,    37,     0,     0,    77,     0,     0,     0,
  243.     76,    47,    48,     0,     0,     0,     0,    57,     0,    31,
  244.     29,    27,    61,     0,    39,     0,    67,   102,     0,     0,
  245.      0,    91,    25,    84,    85,    81,     0,     0,    95,    87,
  246.     88,     0,   103,     0,    59,     0,     0,     0,   126,     0,
  247.      0,    66,     0,    66,    58,    34,     0,     0,     0,     0,
  248.      0,     0,     0,    15,   105,    34,     0,    34,     0,     0,
  249.      0,    51,     0,    55,     0,    40,    73,    71,     0,     0,
  250.     68,    97,    98,    99,   100,    96,     0,     0,     0,     0,
  251.      0,     0,    76,    66,    50,    66,    54,    34,    74,     0,
  252.     62,    60,    42,     0,     0,    76,     0,     0,     0,    14,
  253.     75,    72,    34,    34,    34,     0,    34,    52,    56,     0,
  254.     43,     0,    34,     0,    63,    46,     0,    45,    44,     0,
  255.      0,     0
  256. };
  257.  
  258. static short yydefgoto[] = {   280,
  259.     22,    23,    24,    41,    64,    25,    26,    54,    35,   109,
  260.     36,    94,   110,   165,   244,   167,   246,   111,     1,   178,
  261.    208,   229,   230,   156,    87,    88,   112,    52,    42,   118,
  262.     29,   113,   114,   126,    38
  263. };
  264.  
  265. static short yypact[] = {-32768,
  266.    515,-32768,   -26,-32768,-32768,-32768,    72,    72,-32768,-32768,
  267.    -22,   -16,    95,    95,   -12,  1013,  1013,-32768,  1013,   619,
  268.    894,   297,-32768,    -2,   255,-32768,  1152,   503,    73,   641,
  269.    754,-32768,   134,-32768,-32768,-32768,   349,-32768,-32768,-32768,
  270.     60,    95,   943,  1013,    11,-32768,-32768,   641,   754,  1013,
  271.    -43,-32768,   -43,    64,    40,-32768,   174,     1,  1025,    62,
  272.    -43,-32768,-32768,-32768,   463,   894,   894,   894,-32768,-32768,
  273.   1013,   943,   964,   134,   134,  1013,  1013,  1013,  1013,  1013,
  274.   1013,  1013,    84,  1013,-32768,-32768,    67,    61,  1152,    49,
  275.    126,-32768,-32768,   145,-32768,    99,  1013,   153,   111,   134,
  276.    124,    27,    27,   127,   131,    27,  1013,-32768,   406,-32768,
  277. -32768,   817,   463,-32768,-32768,   126,   134,   183,-32768,   130,
  278.   1081,  1099,    67,   147,-32768,-32768,  1013,   805,   197,-32768,
  279.    406,    62,    70,   149,   593,-32768,  1199,   209,   539,   879,
  280.    879,  1138,   225,   225,   -43,   -43,   -43,   -43,    95,  1152,
  281. -32768,-32768,-32768,-32768,  1013,    27,  1152,   161,  1013,   690,
  282.   1069,-32768,-32768,   641,   567,   641,   567,-32768,    27,-32768,
  283. -32768,-32768,-32768,   406,   126,   123,-32768,-32768,   754,   754,
  284.    943,-32768,-32768,  1152,-32768,  1152,   182,    27,-32768,  1207,
  285.   1191,  1013,-32768,  1025,-32768,   754,  1025,   196,    79,   160,
  286.     67,   183,    67,   183,-32768,   134,     0,  1013,     1,     1,
  287.     67,  1025,   227,-32768,  1152,   134,    50,   134,   178,   199,
  288.    739,-32768,    27,-32768,    27,   145,-32768,-32768,    67,    36,
  289.    179,-32768,-32768,-32768,-32768,-32768,   690,    27,   690,  1013,
  290.    235,   835,  1013,   183,-32768,   183,-32768,   134,-32768,   166,
  291.    222,-32768,-32768,  1025,    67,  1013,    67,    27,    27,   145,
  292. -32768,-32768,   134,   134,   134,    67,   134,-32768,-32768,   690,
  293.    145,   690,   134,   690,-32768,-32768,   690,-32768,-32768,   241,
  294.    243,-32768
  295. };
  296.  
  297. static short yypgoto[] = {-32768,
  298. -32768,   223,-32768,-32768,-32768,   169,   -36,-32768,   122,   -57,
  299.      6,   -65,    12,-32768,-32768,-32768,-32768,-32768,   -15,  -147,
  300. -32768,-32768,-32768,  -101,    39,    -9,    -1,    24,-32768,    98,
  301.     19,   109,  -105,    65,   -24
  302. };
  303.  
  304.  
  305. #define    YYLAST        1262
  306.  
  307.  
  308. static short yytable[] = {    27,
  309.    227,   127,   228,   172,    82,   169,   120,   131,   140,   141,
  310.     58,    83,   115,    40,    51,    53,    91,    55,    59,    61,
  311.     27,    90,   116,    30,    28,   188,    31,    43,    89,    89,
  312.     70,    46,    47,    44,   160,   136,   249,    48,    32,    58,
  313.    115,   121,   122,    28,    28,    28,    89,    59,    61,   127,
  314.    127,   176,   128,    33,   223,   174,   225,   -69,   125,   200,
  315.    119,   127,   117,    31,    27,    27,    27,   124,   206,   135,
  316.    137,   139,   -79,   -79,   142,   143,   144,   145,   146,   147,
  317.    148,    84,   150,    32,   115,    34,   123,   250,   115,    28,
  318.     28,    28,   220,   -70,    83,   157,   258,    45,   259,   175,
  319.    128,   128,   152,   238,    66,   157,   115,   162,   163,    85,
  320.     86,   168,   128,    68,   149,    37,    37,   173,   -79,   -79,
  321.    171,    68,   129,   130,   125,   184,   186,    33,    30,    39,
  322.     34,    31,    65,    37,   153,   115,   154,     6,   190,   191,
  323.    226,   257,   171,    19,   211,    92,    69,    93,   155,   115,
  324.    237,   151,   239,   194,   266,   158,   153,   197,   154,   157,
  325.    159,   195,    89,    89,    89,    89,   261,   119,   262,   209,
  326.    210,   198,   207,   161,   205,   221,   164,    89,    89,   212,
  327.    166,   179,   260,    66,    67,   171,   217,   182,    57,    60,
  328.    215,   183,    73,   214,    89,   177,   243,   270,   271,   272,
  329.     68,   274,   201,   202,   203,   204,   231,   277,    66,    67,
  330.    187,   189,   115,   196,   115,   213,   219,   256,    34,   242,
  331.     77,    78,    79,    80,    81,    68,    82,   240,   245,   236,
  332.    247,   125,   241,    83,   132,   133,   134,   255,   254,   263,
  333.    281,   157,   282,   252,    63,   115,   193,   115,   251,   115,
  334.    253,     0,   115,     0,   157,     0,     0,     0,   216,     0,
  335.      0,   218,     0,   268,   269,   222,    32,   224,    79,    80,
  336.     81,     0,    82,   232,   233,   234,   235,     0,     0,    83,
  337.      0,   275,     0,   276,     0,   278,     0,     0,   279,    66,
  338.     67,     0,     0,   248,     0,     0,    -1,    62,     0,     3,
  339.      0,     4,     0,     0,     5,     0,    68,     0,   -16,     0,
  340.     33,     7,     8,    34,     0,     0,     0,     0,   264,   265,
  341.      0,   267,     0,     0,     0,     0,     9,    10,    11,    12,
  342.    273,   -16,   -16,    13,    14,    15,     0,     0,    16,    17,
  343.      0,    18,     0,     0,     0,    19,    20,    21,   -16,    95,
  344.      0,     3,   -16,     4,     0,   -16,     5,     0,     0,     0,
  345.      0,     0,     0,     0,     0,    96,     0,    97,    98,    99,
  346.    100,   101,   102,   103,   104,   105,   106,   107,     0,    10,
  347.     11,    12,     0,     0,     0,    13,    14,    15,     0,     0,
  348.     16,    17,     0,     0,     0,     0,     0,    19,    49,    50,
  349.      0,     0,     0,     0,    33,   108,   170,    34,     3,     0,
  350.      4,     0,     0,     5,     0,     0,     0,     0,     0,     0,
  351.      0,     0,    96,     0,    97,    98,    99,   100,   101,   102,
  352.    103,   104,   105,   106,   107,     0,    10,    11,    12,     0,
  353.      0,     0,    13,    14,    15,     0,     0,    16,    17,     0,
  354.      0,     0,     0,     0,    19,    49,    50,     0,     0,     0,
  355.      0,    33,   108,    95,    34,     3,     0,     4,     0,     0,
  356.      5,     0,     0,     0,     0,     0,     0,     0,     0,    96,
  357.      0,    97,    98,    99,   100,   101,   102,   103,   104,   105,
  358.    106,   107,     0,    10,    11,    12,     0,     0,     0,    13,
  359.     14,    15,     0,     0,    16,    17,     0,     0,     0,     0,
  360.      0,    19,    49,    50,   -17,     2,     0,     3,    33,     4,
  361.      0,    34,     5,     0,     0,     0,     6,     0,     0,     7,
  362.      8,     0,     0,     0,     0,     0,     0,   -17,   -17,     0,
  363.      0,     0,     0,     0,     9,    10,    11,    12,     0,   -16,
  364.    -16,    13,    14,    15,   -17,     0,    16,    17,   -17,    18,
  365.    -17,   -17,     0,    19,    20,    21,   -16,    56,     0,     3,
  366.    -16,     4,     0,   -16,     5,     0,     0,     0,   -78,   -78,
  367.     77,    78,    79,    80,    81,     0,    82,     0,     0,     0,
  368.      0,     0,     0,    83,     0,     0,     0,    10,    11,    12,
  369.      0,     0,-32768,    13,    14,    15,    73,     0,    16,    17,
  370.      0,     0,     0,     0,     0,    19,    49,    50,     0,    56,
  371.      0,     3,     0,     4,     0,   -78,     5,     0,     0,     0,
  372.      0,     0,     0,     0,    77,    78,    79,    80,    81,     0,
  373.     82,    56,     0,     3,     0,     4,     0,    83,     5,    10,
  374.     11,    12,     0,   -16,   -16,    13,    14,    15,     0,     0,
  375.     16,    17,     0,    18,     0,     0,     0,    19,    20,    21,
  376.    -16,    10,    11,    12,     0,     0,   -16,    13,    14,    15,
  377.      0,     0,    16,    17,     0,     0,     0,     0,     0,    19,
  378.     49,    50,     3,     0,     4,     0,     0,     5,   -78,     0,
  379.      0,   153,     0,   154,     0,     0,    96,     0,    97,    98,
  380.     99,   100,   101,   102,   103,   104,   105,   106,   107,     0,
  381.     10,    11,    12,     0,     0,     0,    13,    14,    15,     0,
  382.      0,    16,    17,     0,     0,     0,     0,     0,    19,    49,
  383.     50,     3,     0,     4,     0,    33,     5,     0,    34,     0,
  384.      0,     0,     0,     0,    56,     0,     3,     0,     4,     0,
  385.      0,     5,     0,     0,     0,     0,     0,     0,     0,    10,
  386.     11,    12,     0,     0,     0,    13,    14,    15,     0,     0,
  387.     16,    17,     0,     0,    10,    11,    12,    19,    49,    50,
  388.     13,    14,    15,     0,     0,    16,    17,    34,     0,     0,
  389.      0,     0,    19,    49,    50,   185,     0,     3,     0,     4,
  390.      0,     0,     5,     0,     0,     0,     0,     0,     0,     0,
  391.      0,     0,     0,     0,     0,     0,    71,    72,    32,     0,
  392.     73,     0,     0,     0,     0,    10,    11,    12,     0,     0,
  393.      0,    13,    14,    15,    71,    72,    16,    17,    73,     0,
  394.      0,    74,    75,    19,    49,    50,    76,     0,    77,    78,
  395.     79,    80,    81,     0,    82,     0,     0,     0,     0,    74,
  396.     75,    83,     0,     0,    76,    34,    77,    78,    79,    80,
  397.     81,     3,    82,     4,     0,     0,     5,     0,     0,    83,
  398.    153,     0,   154,    34,     0,     0,     3,     0,     4,     0,
  399.      0,     5,     0,     0,     0,     0,     0,     0,     0,    10,
  400.     11,    12,     0,     0,     0,    13,    14,    15,     0,     0,
  401.     16,    17,     0,     0,    10,    11,    12,    19,    49,    50,
  402.     13,    14,    15,     0,     0,    16,    17,     0,    18,     0,
  403.      0,     0,    19,    20,    21,     3,     0,     4,     0,     0,
  404.      5,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  405.      0,     0,     0,     0,     0,     0,     3,     0,     4,     0,
  406.      0,     5,     0,    10,    11,    12,     0,     0,     0,    13,
  407.     14,    15,     0,     0,    16,    17,     0,    18,     0,     0,
  408.      0,    19,    49,    50,    10,    11,    12,   138,     0,     0,
  409.     13,    14,    15,     0,     0,    16,    17,     0,     0,     0,
  410.      0,     0,    19,    49,    50,     3,     0,     4,     0,     0,
  411.      5,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  412.      0,     0,     0,     0,    71,    72,     0,     0,    73,     0,
  413.      0,     0,     0,    10,    11,    12,     0,     0,     0,    13,
  414.     14,    15,     0,     0,    16,    17,     0,     0,     0,    74,
  415.     75,    19,    49,    50,    76,     0,    77,    78,    79,    80,
  416.     81,   199,    82,     4,     0,     0,     5,     0,     0,    83,
  417.      0,     0,   125,     0,     0,     0,     0,     0,     0,     0,
  418.     71,    72,     0,     0,    73,     0,     0,     0,     0,    10,
  419.     11,    12,     0,     0,     0,    13,    14,    15,    71,    72,
  420.     16,    17,    73,     0,     0,    74,    75,    19,    49,    50,
  421.     76,     0,    77,    78,    79,    80,    81,     0,    82,     0,
  422.      0,     0,   180,    74,    75,    83,     0,     0,    76,     0,
  423.     77,    78,    79,    80,    81,     0,    82,    71,    72,     0,
  424.    181,    73,     0,    83,     0,     0,     0,     0,     0,     0,
  425.      0,    71,    72,     0,     0,    73,     0,     0,     0,     0,
  426.      0,     0,    74,    75,     0,     0,     0,    76,   192,    77,
  427.     78,    79,    80,    81,     0,    82,    74,    75,     0,     0,
  428.      0,    76,    83,    77,    78,    79,    80,    81,     0,    82,
  429.     71,    72,     0,     0,    73,     0,    83,     0,    71,-32768,
  430.      0,     0,    73,     0,     0,     0,    71,    72,     0,     0,
  431.     73,     0,     0,     0,     0,    74,     0,     0,     0,     0,
  432.      0,     0,    77,    78,    79,    80,    81,     0,    82,     0,
  433.     77,    78,    79,    80,    81,    83,    82,     0,    77,    78,
  434.     79,    80,    81,    83,    82,     0,     0,     0,     0,     0,
  435.      0,    83
  436. };
  437.  
  438. static short yycheck[] = {     1,
  439.      1,     1,     3,   109,    48,   107,    43,    65,    74,    75,
  440.     20,    55,    37,     8,    16,    17,    32,    19,    20,    21,
  441.     22,    31,    38,    50,     1,   131,    53,    50,    30,    31,
  442.     25,    13,    14,    50,   100,    72,     1,    50,    12,    49,
  443.     65,    43,    44,    20,    21,    22,    48,    49,    50,     1,
  444.      1,   117,    52,    56,   202,   113,   204,    58,    58,   161,
  445.     42,     1,     3,    53,    66,    67,    68,     4,   174,    71,
  446.     72,    73,    12,    13,    76,    77,    78,    79,    80,    81,
  447.     82,     9,    84,    12,   109,    59,    48,    52,   113,    66,
  448.     67,    68,    14,    58,    55,    97,   244,     3,   246,   115,
  449.     52,    52,    54,    54,    35,   107,   131,   102,   103,    37,
  450.     38,   106,    52,    52,    31,     7,     8,   112,    58,    59,
  451.    109,    52,    58,    59,    58,   127,   128,    56,    50,     8,
  452.     59,    53,    24,    25,    12,   160,    14,    12,   140,   141,
  453.    206,   243,   131,    49,   181,    12,    25,    14,    50,   174,
  454.    216,    87,   218,   155,   256,     3,    12,   159,    14,   161,
  455.     50,   156,   164,   165,   166,   167,     1,   149,     3,   179,
  456.    180,   160,    50,    50,   169,   200,    50,   179,   180,   181,
  457.     50,    52,   248,    35,    36,   174,   196,   123,    20,    21,
  458.    192,    45,    14,   188,   196,    13,   221,   263,   264,   265,
  459.     52,   267,   164,   165,   166,   167,   208,   273,    35,    36,
  460.     14,     3,   237,    53,   239,    34,    21,   242,    59,   221,
  461.     42,    43,    44,    45,    46,    52,    48,    50,   223,     3,
  462.    225,    58,    34,    55,    66,    67,    68,     3,   240,    18,
  463.      0,   243,     0,   238,    22,   270,   149,   272,   237,   274,
  464.    239,    -1,   277,    -1,   256,    -1,    -1,    -1,   194,    -1,
  465.     -1,   197,    -1,   258,   259,   201,    12,   203,    44,    45,
  466.     46,    -1,    48,   209,   210,   211,   212,    -1,    -1,    55,
  467.     -1,   270,    -1,   272,    -1,   274,    -1,    -1,   277,    35,
  468.     36,    -1,    -1,   229,    -1,    -1,     0,     1,    -1,     3,
  469.     -1,     5,    -1,    -1,     8,    -1,    52,    -1,    12,    -1,
  470.     56,    15,    16,    59,    -1,    -1,    -1,    -1,   254,   255,
  471.     -1,   257,    -1,    -1,    -1,    -1,    30,    31,    32,    33,
  472.    266,    35,    36,    37,    38,    39,    -1,    -1,    42,    43,
  473.     -1,    45,    -1,    -1,    -1,    49,    50,    51,    52,     1,
  474.     -1,     3,    56,     5,    -1,    59,     8,    -1,    -1,    -1,
  475.     -1,    -1,    -1,    -1,    -1,    17,    -1,    19,    20,    21,
  476.     22,    23,    24,    25,    26,    27,    28,    29,    -1,    31,
  477.     32,    33,    -1,    -1,    -1,    37,    38,    39,    -1,    -1,
  478.     42,    43,    -1,    -1,    -1,    -1,    -1,    49,    50,    51,
  479.     -1,    -1,    -1,    -1,    56,    57,     1,    59,     3,    -1,
  480.      5,    -1,    -1,     8,    -1,    -1,    -1,    -1,    -1,    -1,
  481.     -1,    -1,    17,    -1,    19,    20,    21,    22,    23,    24,
  482.     25,    26,    27,    28,    29,    -1,    31,    32,    33,    -1,
  483.     -1,    -1,    37,    38,    39,    -1,    -1,    42,    43,    -1,
  484.     -1,    -1,    -1,    -1,    49,    50,    51,    -1,    -1,    -1,
  485.     -1,    56,    57,     1,    59,     3,    -1,     5,    -1,    -1,
  486.      8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    17,
  487.     -1,    19,    20,    21,    22,    23,    24,    25,    26,    27,
  488.     28,    29,    -1,    31,    32,    33,    -1,    -1,    -1,    37,
  489.     38,    39,    -1,    -1,    42,    43,    -1,    -1,    -1,    -1,
  490.     -1,    49,    50,    51,    12,     1,    -1,     3,    56,     5,
  491.     -1,    59,     8,    -1,    -1,    -1,    12,    -1,    -1,    15,
  492.     16,    -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    -1,
  493.     -1,    -1,    -1,    -1,    30,    31,    32,    33,    -1,    35,
  494.     36,    37,    38,    39,    52,    -1,    42,    43,    56,    45,
  495.     58,    59,    -1,    49,    50,    51,    52,     1,    -1,     3,
  496.     56,     5,    -1,    59,     8,    -1,    -1,    -1,    12,    13,
  497.     42,    43,    44,    45,    46,    -1,    48,    -1,    -1,    -1,
  498.     -1,    -1,    -1,    55,    -1,    -1,    -1,    31,    32,    33,
  499.     -1,    -1,    10,    37,    38,    39,    14,    -1,    42,    43,
  500.     -1,    -1,    -1,    -1,    -1,    49,    50,    51,    -1,     1,
  501.     -1,     3,    -1,     5,    -1,    59,     8,    -1,    -1,    -1,
  502.     -1,    -1,    -1,    -1,    42,    43,    44,    45,    46,    -1,
  503.     48,     1,    -1,     3,    -1,     5,    -1,    55,     8,    31,
  504.     32,    33,    -1,    35,    36,    37,    38,    39,    -1,    -1,
  505.     42,    43,    -1,    45,    -1,    -1,    -1,    49,    50,    51,
  506.     52,    31,    32,    33,    -1,    -1,    58,    37,    38,    39,
  507.     -1,    -1,    42,    43,    -1,    -1,    -1,    -1,    -1,    49,
  508.     50,    51,     3,    -1,     5,    -1,    -1,     8,    58,    -1,
  509.     -1,    12,    -1,    14,    -1,    -1,    17,    -1,    19,    20,
  510.     21,    22,    23,    24,    25,    26,    27,    28,    29,    -1,
  511.     31,    32,    33,    -1,    -1,    -1,    37,    38,    39,    -1,
  512.     -1,    42,    43,    -1,    -1,    -1,    -1,    -1,    49,    50,
  513.     51,     3,    -1,     5,    -1,    56,     8,    -1,    59,    -1,
  514.     -1,    -1,    -1,    -1,     1,    -1,     3,    -1,     5,    -1,
  515.     -1,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,
  516.     32,    33,    -1,    -1,    -1,    37,    38,    39,    -1,    -1,
  517.     42,    43,    -1,    -1,    31,    32,    33,    49,    50,    51,
  518.     37,    38,    39,    -1,    -1,    42,    43,    59,    -1,    -1,
  519.     -1,    -1,    49,    50,    51,     1,    -1,     3,    -1,     5,
  520.     -1,    -1,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  521.     -1,    -1,    -1,    -1,    -1,    -1,    10,    11,    12,    -1,
  522.     14,    -1,    -1,    -1,    -1,    31,    32,    33,    -1,    -1,
  523.     -1,    37,    38,    39,    10,    11,    42,    43,    14,    -1,
  524.     -1,    35,    36,    49,    50,    51,    40,    -1,    42,    43,
  525.     44,    45,    46,    -1,    48,    -1,    -1,    -1,    -1,    35,
  526.     36,    55,    -1,    -1,    40,    59,    42,    43,    44,    45,
  527.     46,     3,    48,     5,    -1,    -1,     8,    -1,    -1,    55,
  528.     12,    -1,    14,    59,    -1,    -1,     3,    -1,     5,    -1,
  529.     -1,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,
  530.     32,    33,    -1,    -1,    -1,    37,    38,    39,    -1,    -1,
  531.     42,    43,    -1,    -1,    31,    32,    33,    49,    50,    51,
  532.     37,    38,    39,    -1,    -1,    42,    43,    -1,    45,    -1,
  533.     -1,    -1,    49,    50,    51,     3,    -1,     5,    -1,    -1,
  534.      8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  535.     -1,    -1,    -1,    -1,    -1,    -1,     3,    -1,     5,    -1,
  536.     -1,     8,    -1,    31,    32,    33,    -1,    -1,    -1,    37,
  537.     38,    39,    -1,    -1,    42,    43,    -1,    45,    -1,    -1,
  538.     -1,    49,    50,    51,    31,    32,    33,    34,    -1,    -1,
  539.     37,    38,    39,    -1,    -1,    42,    43,    -1,    -1,    -1,
  540.     -1,    -1,    49,    50,    51,     3,    -1,     5,    -1,    -1,
  541.      8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  542.     -1,    -1,    -1,    -1,    10,    11,    -1,    -1,    14,    -1,
  543.     -1,    -1,    -1,    31,    32,    33,    -1,    -1,    -1,    37,
  544.     38,    39,    -1,    -1,    42,    43,    -1,    -1,    -1,    35,
  545.     36,    49,    50,    51,    40,    -1,    42,    43,    44,    45,
  546.     46,     3,    48,     5,    -1,    -1,     8,    -1,    -1,    55,
  547.     -1,    -1,    58,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  548.     10,    11,    -1,    -1,    14,    -1,    -1,    -1,    -1,    31,
  549.     32,    33,    -1,    -1,    -1,    37,    38,    39,    10,    11,
  550.     42,    43,    14,    -1,    -1,    35,    36,    49,    50,    51,
  551.     40,    -1,    42,    43,    44,    45,    46,    -1,    48,    -1,
  552.     -1,    -1,    52,    35,    36,    55,    -1,    -1,    40,    -1,
  553.     42,    43,    44,    45,    46,    -1,    48,    10,    11,    -1,
  554.     52,    14,    -1,    55,    -1,    -1,    -1,    -1,    -1,    -1,
  555.     -1,    10,    11,    -1,    -1,    14,    -1,    -1,    -1,    -1,
  556.     -1,    -1,    35,    36,    -1,    -1,    -1,    40,    41,    42,
  557.     43,    44,    45,    46,    -1,    48,    35,    36,    -1,    -1,
  558.     -1,    40,    55,    42,    43,    44,    45,    46,    -1,    48,
  559.     10,    11,    -1,    -1,    14,    -1,    55,    -1,    10,    11,
  560.     -1,    -1,    14,    -1,    -1,    -1,    10,    11,    -1,    -1,
  561.     14,    -1,    -1,    -1,    -1,    35,    -1,    -1,    -1,    -1,
  562.     -1,    -1,    42,    43,    44,    45,    46,    -1,    48,    -1,
  563.     42,    43,    44,    45,    46,    55,    48,    -1,    42,    43,
  564.     44,    45,    46,    55,    48,    -1,    -1,    -1,    -1,    -1,
  565.     -1,    55
  566. };
  567. #define YYPURE 1
  568.  
  569. #line 2 "bison.simple"
  570.  
  571. /* Note: there must be only one dollar sign in this file.
  572.    It is replaced by the list of actions, each action
  573.    as one case of the switch.  */
  574.  
  575. #define yyerrok        (yyerrstatus = 0)
  576. #define yyclearin    (yychar = YYEMPTY)
  577. #define YYEMPTY        -2
  578. #define YYEOF        0
  579. #define YYFAIL        goto yyerrlab;
  580.  
  581. #define YYTERROR    1
  582.  
  583. #ifndef YYIMPURE
  584. #define YYLEX        yylex()
  585. #endif
  586.  
  587. #ifndef YYPURE
  588. #define YYLEX        yylex(&yylval, &yylloc)
  589. #endif
  590.  
  591. /* If nonreentrant, generate the variables here */
  592.  
  593. #ifndef YYIMPURE
  594.  
  595. int    yychar;            /*  the lookahead symbol        */
  596. YYSTYPE    yylval;            /*  the semantic value of the        */
  597.                 /*  lookahead symbol            */
  598.  
  599. YYLTYPE yylloc;            /*  location data for the lookahead    */
  600.                 /*  symbol                */
  601.  
  602. int yydebug = 0;        /*  nonzero means print parse trace    */
  603.  
  604. #endif  /* YYIMPURE */
  605.  
  606.  
  607. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  608.  
  609. #ifndef    YYMAXDEPTH
  610. #define YYMAXDEPTH 200
  611. #endif
  612.  
  613. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  614.     (effective only if the built-in stack extension method is used).  */
  615.  
  616. #ifndef YYMAXLIMIT
  617. #define YYMAXLIMIT 10000
  618. #endif
  619.  
  620.  
  621. #line 87 "bison.simple"
  622. int
  623. yyparse()
  624. {
  625.   register int yystate;
  626.   register int yyn;
  627.   register short *yyssp;
  628.   register YYSTYPE *yyvsp;
  629.   YYLTYPE *yylsp;
  630.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  631.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  632.  
  633.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  634.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  635.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  636.  
  637.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  638.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  639.   YYLTYPE *yyls = yylsa;
  640.  
  641.   int yymaxdepth = YYMAXDEPTH;
  642.  
  643. #ifndef YYPURE
  644.  
  645.   int yychar;
  646.   YYSTYPE yylval;
  647.   YYLTYPE yylloc;
  648.  
  649.   extern int yydebug;
  650.  
  651. #endif
  652.  
  653.  
  654.   YYSTYPE yyval;        /*  the variable used to return        */
  655.                 /*  semantic values from the action    */
  656.                 /*  routines                */
  657.  
  658.   int yylen;
  659.  
  660.   if (yydebug)
  661.     fprintf(stderr, "Starting parse\n");
  662.  
  663.   yystate = 0;
  664.   yyerrstatus = 0;
  665.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  666.  
  667.   /* Initialize stack pointers.
  668.      Waste one element of value and location stack
  669.      so that they stay on the same level as the state stack.  */
  670.  
  671.   yyssp = yyss - 1;
  672.   yyvsp = yyvs;
  673.   yylsp = yyls;
  674.  
  675. /* Push a new state, which is found in  yystate  .  */
  676. /* In all cases, when you get here, the value and location stacks
  677.    have just been pushed. so pushing a state here evens the stacks.  */
  678. yynewstate:
  679.  
  680.   *++yyssp = yystate;
  681.  
  682.   if (yyssp >= yyss + yymaxdepth - 1)
  683.     {
  684.       /* Give user a chance to reallocate the stack */
  685.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  686.       YYSTYPE *yyvs1 = yyvs;
  687.       YYLTYPE *yyls1 = yyls;
  688.       short *yyss1 = yyss;
  689.  
  690.       /* Get the current used size of the three stacks, in elements.  */
  691.       int size = yyssp - yyss + 1;
  692.  
  693. #ifdef yyoverflow
  694.       /* Each stack pointer address is followed by the size of
  695.      the data in use in that stack, in bytes.  */
  696.       yyoverflow("parser stack overflow",
  697.          &yyss1, size * sizeof (*yyssp),
  698.          &yyvs1, size * sizeof (*yyvsp),
  699.          &yyls1, size * sizeof (*yylsp),
  700.          &yymaxdepth);
  701.  
  702.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  703. #else /* no yyoverflow */
  704.       /* Extend the stack our own way.  */
  705.       if (yymaxdepth >= YYMAXLIMIT)
  706.     yyerror("parser stack overflow");
  707.       yymaxdepth *= 2;
  708.       if (yymaxdepth > YYMAXLIMIT)
  709.     yymaxdepth = YYMAXLIMIT;
  710.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  711.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  712.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  713.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  714.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  715.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  716. #endif /* no yyoverflow */
  717.  
  718.       yyssp = yyss + size - 1;
  719.       yylsp = yyls + size - 1;
  720.       yyvsp = yyvs + size - 1;
  721.  
  722.       if (yydebug)
  723.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  724.  
  725.       if (yyssp >= yyss + yymaxdepth - 1)
  726.     YYERROR;
  727.     }
  728.  
  729.   if (yydebug)
  730.     fprintf(stderr, "Entering state %d\n", yystate);
  731.  
  732. /* Do appropriate processing given the current state.  */
  733. /* Read a lookahead token if we need one and don't already have one.  */
  734. yyresume:
  735.  
  736.   /* First try to decide what to do without reference to lookahead token.  */
  737.  
  738.   yyn = yypact[yystate];
  739.   if (yyn == YYFLAG)
  740.     goto yydefault;
  741.  
  742.   /* Not known => get a lookahead token if don't already have one.  */
  743.  
  744.   /* yychar is either YYEMPTY or YYEOF
  745.      or a valid token in external form.  */
  746.  
  747.   if (yychar == YYEMPTY)
  748.     {
  749.       yychar = YYLEX;
  750.     }
  751.  
  752.   /* Convert token to internal form (in yychar1) for indexing tables with */
  753.  
  754.   if (yychar <= 0)        /* This means end of input. */
  755.     {
  756.       yychar1 = 0;
  757.       yychar = YYEOF;        /* Don't call YYLEX any more */
  758.  
  759.       if (yydebug)
  760.     fprintf(stderr, "Now at end of input.\n");
  761.     }
  762.   else
  763.     {
  764.       yychar1 = YYTRANSLATE(yychar);
  765.  
  766.       if (yydebug)
  767.     fprintf(stderr, "Parsing next token; it is %d (%s)\n", yychar, yytname[yychar1]);
  768.     }
  769.  
  770.   yyn += yychar1;
  771.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  772.     goto yydefault;
  773.  
  774.   yyn = yytable[yyn];
  775.  
  776.   /* yyn is what to do for this token type in this state.
  777.      Negative => reduce, -yyn is rule number.
  778.      Positive => shift, yyn is new state.
  779.        New state is final state => don't bother to shift,
  780.        just return success.
  781.      0, or most negative number => error.  */
  782.  
  783.   if (yyn < 0)
  784.     {
  785.       if (yyn == YYFLAG)
  786.     goto yyerrlab;
  787.       yyn = -yyn;
  788.       goto yyreduce;
  789.     }
  790.   else if (yyn == 0)
  791.     goto yyerrlab;
  792.  
  793.   if (yyn == YYFINAL)
  794.     YYACCEPT;
  795.  
  796.   /* Shift the lookahead token.  */
  797.  
  798.   if (yydebug)
  799.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  800.  
  801.   /* Discard the token being shifted unless it is eof.  */
  802.   if (yychar != YYEOF)
  803.     yychar = YYEMPTY;
  804.  
  805.   *++yyvsp = yylval;
  806.   *++yylsp = yylloc;
  807.  
  808.   /* count tokens shifted since error; after three, turn off error status.  */
  809.   if (yyerrstatus) yyerrstatus--;
  810.  
  811.   yystate = yyn;
  812.   goto yynewstate;
  813.  
  814. /* Do the default action for the current state.  */
  815. yydefault:
  816.  
  817.   yyn = yydefact[yystate];
  818.   if (yyn == 0)
  819.     goto yyerrlab;
  820.  
  821. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  822. yyreduce:
  823.   yylen = yyr2[yyn];
  824.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  825.  
  826.   if (yydebug)
  827.     {
  828.       if (yylen == 1)
  829.     fprintf (stderr, "Reducing 1 value via line %d, ",
  830.          yyrline[yyn]);
  831.       else
  832.     fprintf (stderr, "Reducing %d values via line %d, ",
  833.          yylen, yyrline[yyn]);
  834.     }
  835.  
  836.  
  837.   switch (yyn) {
  838.  
  839. case 1:
  840. #line 234 "awk.y"
  841. { expression_value = yyvsp[0].nodeval; ;
  842.     break;}
  843. case 2:
  844. #line 239 "awk.y"
  845.             if (yyvsp[0].nodeval != NULL)
  846.                 yyval.nodeval = node (yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL);
  847.             else
  848.                 yyval.nodeval = NULL;
  849.             yyerrok;
  850.         ;
  851.     break;}
  852. case 3:
  853. #line 248 "awk.y"
  854. {
  855.             if (yyvsp[0].nodeval == NULL)
  856.                 yyval.nodeval = yyvsp[-1].nodeval;
  857.             else if (yyvsp[-1].nodeval == NULL)
  858.                 yyval.nodeval = node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL);
  859.             else
  860.                 yyval.nodeval = append_right (yyvsp[-1].nodeval,
  861.                    node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
  862.             yyerrok;
  863.         ;
  864.     break;}
  865. case 4:
  866. #line 258 "awk.y"
  867. { yyval.nodeval = NULL; ;
  868.     break;}
  869. case 6:
  870. #line 264 "awk.y"
  871. {
  872.         if (begin_block)
  873.             append_right (begin_block, node(
  874.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  875.                 Node_rule_list, (NODE *)NULL) );
  876.         else
  877.             begin_block = node(node((NODE *)NULL,Node_rule_node,yyvsp[0].nodeval),
  878.                 Node_rule_list, (NODE *)NULL);
  879.         yyval.nodeval = NULL;
  880.         yyerrok;
  881.       ;
  882.     break;}
  883. case 7:
  884. #line 276 "awk.y"
  885. {
  886.         if (end_block)
  887.             append_right (end_block, node(
  888.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  889.                 Node_rule_list, (NODE *)NULL));
  890.         else
  891.             end_block = node(node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  892.                 Node_rule_list, (NODE *)NULL);
  893.         yyval.nodeval = NULL;
  894.         yyerrok;
  895.       ;
  896.     break;}
  897. case 8:
  898. #line 288 "awk.y"
  899. {
  900.         msg ("error near line %d: BEGIN blocks must have an action part", lineno);
  901.         errcount++;
  902.         yyerrok;
  903.       ;
  904.     break;}
  905. case 9:
  906. #line 294 "awk.y"
  907. {
  908.         msg ("error near line %d: END blocks must have an action part", lineno);
  909.         errcount++;
  910.         yyerrok;
  911.       ;
  912.     break;}
  913. case 10:
  914. #line 300 "awk.y"
  915. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  916.     break;}
  917. case 11:
  918. #line 302 "awk.y"
  919. { if(yyvsp[-1].nodeval) yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, (NODE *)NULL); yyerrok; ;
  920.     break;}
  921. case 12:
  922. #line 304 "awk.y"
  923. {
  924.             /*obstack_free(&var_stack, func_def);*/
  925.             func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
  926.             yyval.nodeval = NULL;
  927.             yyerrok;
  928.         ;
  929.     break;}
  930. case 13:
  931. #line 314 "awk.y"
  932. {
  933.             func_def = (char *) obstack_alloc(&var_stack, 0);
  934.             param_counter = 0;
  935.         ;
  936.     break;}
  937. case 14:
  938. #line 319 "awk.y"
  939. {
  940.             yyval.nodeval = append_right(make_param(yyvsp[-5].sval), yyvsp[-2].nodeval);
  941.         ;
  942.     break;}
  943. case 15:
  944. #line 326 "awk.y"
  945. { yyval.nodeval = yyvsp[-2].nodeval; ;
  946.     break;}
  947. case 16:
  948. #line 331 "awk.y"
  949. { yyval.nodeval = NULL; ;
  950.     break;}
  951. case 17:
  952. #line 333 "awk.y"
  953. { yyval.nodeval = yyvsp[0].nodeval; ;
  954.     break;}
  955. case 18:
  956. #line 335 "awk.y"
  957.           yyval.nodeval = node(
  958.                node(make_number((AWKNUM)0),Node_field_spec,(NODE*)NULL),
  959.                Node_match, yyvsp[0].nodeval);
  960.         ;
  961.     break;}
  962. case 19:
  963. #line 341 "awk.y"
  964. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  965.     break;}
  966. case 20:
  967. #line 343 "awk.y"
  968. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  969.     break;}
  970. case 21:
  971. #line 345 "awk.y"
  972. { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
  973.     break;}
  974. case 22:
  975. #line 347 "awk.y"
  976. { yyval.nodeval = yyvsp[-1].nodeval; ;
  977.     break;}
  978. case 23:
  979. #line 349 "awk.y"
  980. { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
  981.     break;}
  982. case 24:
  983. #line 356 "awk.y"
  984. { ++want_regexp; ;
  985.     break;}
  986. case 25:
  987. #line 358 "awk.y"
  988. { want_regexp = 0;
  989.           rp = mk_re_parse(yyvsp[-1].sval);
  990.           yyval.nodeval = node((NODE *)NULL, Node_regex, (NODE *)rp);
  991.         ;
  992.     break;}
  993. case 26:
  994. #line 366 "awk.y"
  995. {
  996.             /* empty actions are different from missing actions */
  997.             yyval.nodeval = node ((NODE *) NULL, Node_illegal, (NODE *) NULL);
  998.         ;
  999.     break;}
  1000. case 27:
  1001. #line 371 "awk.y"
  1002. { yyval.nodeval = yyvsp[-1].nodeval ; ;
  1003.     break;}
  1004. case 28:
  1005. #line 376 "awk.y"
  1006. { yyval.nodeval = node (yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL); ;
  1007.     break;}
  1008. case 29:
  1009. #line 378 "awk.y"
  1010. {
  1011.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1012.                 node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
  1013.                 yyerrok;
  1014.         ;
  1015.     break;}
  1016. case 30:
  1017. #line 384 "awk.y"
  1018. { yyval.nodeval = NULL; ;
  1019.     break;}
  1020. case 32:
  1021. #line 390 "awk.y"
  1022. { yyval.nodetypeval = Node_illegal; want_redirect = 0; ;
  1023.     break;}
  1024. case 33:
  1025. #line 392 "awk.y"
  1026. { yyval.nodetypeval = Node_illegal; want_redirect = 0; ;
  1027.     break;}
  1028. case 34:
  1029. #line 397 "awk.y"
  1030. { yyval.nodetypeval = Node_illegal; ;
  1031.     break;}
  1032. case 35:
  1033. #line 399 "awk.y"
  1034. { yyval.nodetypeval = Node_illegal; ;
  1035.     break;}
  1036. case 36:
  1037. #line 401 "awk.y"
  1038. { yyval.nodetypeval = Node_illegal; ;
  1039.     break;}
  1040. case 37:
  1041. #line 403 "awk.y"
  1042. { yyval.nodetypeval = Node_illegal; ;
  1043.     break;}
  1044. case 38:
  1045. #line 405 "awk.y"
  1046. { yyval.nodetypeval = Node_illegal; ;
  1047.     break;}
  1048. case 39:
  1049. #line 410 "awk.y"
  1050. { yyval.nodeval = NULL; ;
  1051.     break;}
  1052. case 40:
  1053. #line 412 "awk.y"
  1054. { yyval.nodeval = yyvsp[-2].nodeval; ;
  1055.     break;}
  1056. case 41:
  1057. #line 414 "awk.y"
  1058. { yyval.nodeval = yyvsp[0].nodeval; ;
  1059.     break;}
  1060. case 42:
  1061. #line 416 "awk.y"
  1062. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
  1063.     break;}
  1064. case 43:
  1065. #line 418 "awk.y"
  1066. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
  1067.     break;}
  1068. case 44:
  1069. #line 420 "awk.y"
  1070. { yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop (yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval)); ;
  1071.     break;}
  1072. case 45:
  1073. #line 422 "awk.y"
  1074. { yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop (yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval)); ;
  1075.     break;}
  1076. case 46:
  1077. #line 424 "awk.y"
  1078. {
  1079.             yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor,
  1080.                 make_for_loop(variable(yyvsp[-6].sval),
  1081.                     (NODE *)NULL, variable(yyvsp[-3].sval)));
  1082.         ;
  1083.     break;}
  1084. case 47:
  1085. #line 431 "awk.y"
  1086. { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
  1087.     break;}
  1088. case 48:
  1089. #line 434 "awk.y"
  1090. { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
  1091.     break;}
  1092. case 49:
  1093. #line 436 "awk.y"
  1094. { ++want_redirect; ;
  1095.     break;}
  1096. case 50:
  1097. #line 438 "awk.y"
  1098. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_print, yyvsp[-1].nodeval); ;
  1099.     break;}
  1100. case 51:
  1101. #line 440 "awk.y"
  1102. { ++want_redirect; want_concat_token = 0; ;
  1103.     break;}
  1104. case 52:
  1105. #line 442 "awk.y"
  1106. { yyval.nodeval = node (yyvsp[-4].nodeval, Node_K_print, yyvsp[-1].nodeval); ;
  1107.     break;}
  1108. case 53:
  1109. #line 444 "awk.y"
  1110. { ++want_redirect; ;
  1111.     break;}
  1112. case 54:
  1113. #line 446 "awk.y"
  1114. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_printf, yyvsp[-1].nodeval); ;
  1115.     break;}
  1116. case 55:
  1117. #line 448 "awk.y"
  1118. { ++want_redirect; want_concat_token = 0; ;
  1119.     break;}
  1120. case 56:
  1121. #line 450 "awk.y"
  1122. { yyval.nodeval = node (yyvsp[-4].nodeval, Node_K_printf, yyvsp[-1].nodeval); ;
  1123.     break;}
  1124. case 57:
  1125. #line 452 "awk.y"
  1126. { yyval.nodeval = node ((NODE *)NULL, Node_K_next, (NODE *)NULL); ;
  1127.     break;}
  1128. case 58:
  1129. #line 454 "awk.y"
  1130. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
  1131.     break;}
  1132. case 59:
  1133. #line 456 "awk.y"
  1134. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
  1135.     break;}
  1136. case 60:
  1137. #line 458 "awk.y"
  1138. { yyval.nodeval = node (variable(yyvsp[-4].sval), Node_K_delete, yyvsp[-2].nodeval); ;
  1139.     break;}
  1140. case 61:
  1141. #line 460 "awk.y"
  1142. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1143.     break;}
  1144. case 62:
  1145. #line 465 "awk.y"
  1146. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_if,
  1147.                 node (yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL)); ;
  1148.     break;}
  1149. case 63:
  1150. #line 469 "awk.y"
  1151. { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
  1152.                 node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1153.     break;}
  1154. case 65:
  1155. #line 476 "awk.y"
  1156. { yyval.nodetypeval = Node_illegal; ;
  1157.     break;}
  1158. case 66:
  1159. #line 481 "awk.y"
  1160. { want_redirect = 0; yyval.nodeval = NULL; ;
  1161.     break;}
  1162. case 67:
  1163. #line 483 "awk.y"
  1164. { want_redirect = 0; ;
  1165.     break;}
  1166. case 68:
  1167. #line 485 "awk.y"
  1168. { yyval.nodeval = node (yyvsp[0].nodeval, yyvsp[-2].nodetypeval, (NODE *)NULL); ;
  1169.     break;}
  1170. case 69:
  1171. #line 490 "awk.y"
  1172. { yyval.nodeval = NULL; ;
  1173.     break;}
  1174. case 71:
  1175. #line 497 "awk.y"
  1176. {
  1177.             yyval.nodeval = make_param(yyvsp[0].sval);
  1178.         ;
  1179.     break;}
  1180. case 72:
  1181. #line 501 "awk.y"
  1182. {
  1183.             yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval));
  1184.             yyerrok;
  1185.         ;
  1186.     break;}
  1187. case 73:
  1188. #line 506 "awk.y"
  1189. { yyval.nodeval = NULL; ;
  1190.     break;}
  1191. case 76:
  1192. #line 514 "awk.y"
  1193. { yyval.nodeval = NULL; /* node(NULL, Node_builtin, NULL); */ ;
  1194.     break;}
  1195. case 78:
  1196. #line 520 "awk.y"
  1197. { yyval.nodeval = NULL; ;
  1198.     break;}
  1199. case 79:
  1200. #line 522 "awk.y"
  1201. { yyval.nodeval = yyvsp[0].nodeval; ;
  1202.     break;}
  1203. case 80:
  1204. #line 527 "awk.y"
  1205. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1206.     break;}
  1207. case 81:
  1208. #line 529 "awk.y"
  1209. {
  1210.             yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1211.                 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1212.             yyerrok;
  1213.         ;
  1214.     break;}
  1215. case 82:
  1216. #line 535 "awk.y"
  1217. { yyval.nodeval = NULL; ;
  1218.     break;}
  1219. case 87:
  1220. #line 544 "awk.y"
  1221. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_and, yyvsp[0].nodeval); ;
  1222.     break;}
  1223. case 88:
  1224. #line 546 "awk.y"
  1225. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_or, yyvsp[0].nodeval); ;
  1226.     break;}
  1227. case 89:
  1228. #line 548 "awk.y"
  1229. { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
  1230.     break;}
  1231. case 90:
  1232. #line 550 "awk.y"
  1233. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1234.     break;}
  1235. case 91:
  1236. #line 554 "awk.y"
  1237. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, yyvsp[-3].ptrval); ;
  1238.     break;}
  1239. case 92:
  1240. #line 556 "awk.y"
  1241. { yyval.nodeval = snode ((NODE *)NULL, Node_builtin, yyvsp[0].ptrval); ;
  1242.     break;}
  1243. case 93:
  1244. #line 558 "awk.y"
  1245. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1246.     break;}
  1247. case 94:
  1248. #line 560 "awk.y"
  1249. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1250.     break;}
  1251. case 95:
  1252. #line 562 "awk.y"
  1253. { yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-3].nodeval); ;
  1254.     break;}
  1255. case 96:
  1256. #line 564 "awk.y"
  1257. { yyval.nodeval = node (variable(yyvsp[0].sval), Node_in_array, yyvsp[-4].nodeval); ;
  1258.     break;}
  1259. case 97:
  1260. #line 566 "awk.y"
  1261. { yyval.nodeval = node(yyvsp[-1].nodeval, yyvsp[-5].nodetypeval, yyvsp[-3].nodeval); ;
  1262.     break;}
  1263. case 98:
  1264. #line 568 "awk.y"
  1265. { yyval.nodeval = node(yyvsp[-1].nodeval, yyvsp[-5].nodetypeval, yyvsp[-3].nodeval); ;
  1266.     break;}
  1267. case 99:
  1268. #line 570 "awk.y"
  1269. { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1270.     break;}
  1271. case 100:
  1272. #line 572 "awk.y"
  1273. { yyval.nodeval = node(yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1274.     break;}
  1275. case 101:
  1276. #line 574 "awk.y"
  1277. {++want_redirect; ;
  1278.     break;}
  1279. case 102:
  1280. #line 576 "awk.y"
  1281. {
  1282.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1283.         ;
  1284.     break;}
  1285. case 103:
  1286. #line 580 "awk.y"
  1287. {
  1288.           yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
  1289.              node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
  1290.         ;
  1291.     break;}
  1292. case 104:
  1293. #line 585 "awk.y"
  1294. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1295.     break;}
  1296. case 105:
  1297. #line 587 "awk.y"
  1298. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1299.     break;}
  1300. case 106:
  1301. #line 589 "awk.y"
  1302. {
  1303.             yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
  1304.         ;
  1305.     break;}
  1306. case 107:
  1307. #line 593 "awk.y"
  1308. { yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL); ;
  1309.     break;}
  1310. case 108:
  1311. #line 595 "awk.y"
  1312. { yyval.nodeval = yyvsp[0].nodeval; ;
  1313.     break;}
  1314. case 109:
  1315. #line 597 "awk.y"
  1316. { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
  1317.     break;}
  1318. case 110:
  1319. #line 599 "awk.y"
  1320. { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
  1321.     break;}
  1322. case 111:
  1323. #line 601 "awk.y"
  1324. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
  1325.     break;}
  1326. case 112:
  1327. #line 603 "awk.y"
  1328. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
  1329.     break;}
  1330. case 113:
  1331. #line 605 "awk.y"
  1332. { yyval.nodeval = yyvsp[0].nodeval; ;
  1333.     break;}
  1334. case 114:
  1335. #line 607 "awk.y"
  1336. { yyval.nodeval = make_number (yyvsp[0].fval); ;
  1337.     break;}
  1338. case 115:
  1339. #line 609 "awk.y"
  1340. { yyval.nodeval = make_string (yyvsp[0].sval, -1); ;
  1341.     break;}
  1342. case 116:
  1343. #line 613 "awk.y"
  1344. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
  1345.     break;}
  1346. case 117:
  1347. #line 615 "awk.y"
  1348. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
  1349.     break;}
  1350. case 118:
  1351. #line 617 "awk.y"
  1352. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
  1353.     break;}
  1354. case 119:
  1355. #line 619 "awk.y"
  1356. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
  1357.     break;}
  1358. case 120:
  1359. #line 621 "awk.y"
  1360. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
  1361.     break;}
  1362. case 121:
  1363. #line 623 "awk.y"
  1364. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
  1365.     break;}
  1366. case 122:
  1367. #line 626 "awk.y"
  1368. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1369.     break;}
  1370. case 123:
  1371. #line 628 "awk.y"
  1372. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1373.     break;}
  1374. case 124:
  1375. #line 633 "awk.y"
  1376. { yyval.nodeval = NULL; ;
  1377.     break;}
  1378. case 126:
  1379. #line 639 "awk.y"
  1380. { yyval.nodeval = variable (yyvsp[0].sval); ;
  1381.     break;}
  1382. case 127:
  1383. #line 641 "awk.y"
  1384. { yyval.nodeval = node (variable(yyvsp[-3].sval), Node_subscript, yyvsp[-1].nodeval); ;
  1385.     break;}
  1386. case 128:
  1387. #line 643 "awk.y"
  1388. { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1389.     break;}
  1390. case 130:
  1391. #line 651 "awk.y"
  1392. { yyerrok; ;
  1393.     break;}
  1394. case 131:
  1395. #line 655 "awk.y"
  1396. { yyval.nodetypeval = Node_illegal; yyerrok; ;
  1397.     break;}
  1398. case 132:
  1399. #line 659 "awk.y"
  1400. { yyerrok; ;
  1401.     break;}
  1402. }
  1403.    /* the action file gets copied in in place of this dollarsign */
  1404. #line 303 "bison.simple"
  1405.  
  1406.   yyvsp -= yylen;
  1407.   yylsp -= yylen;
  1408.   yyssp -= yylen;
  1409.  
  1410.   if (yydebug)
  1411.     {
  1412.       short *ssp1 = yyss - 1;
  1413.       fprintf (stderr, "state stack now", yyssp-yyss);
  1414.       while (ssp1 != yyssp)
  1415.     fprintf (stderr, " %d", *++ssp1);
  1416.       fprintf (stderr, "\n");
  1417.     }
  1418.  
  1419.   *++yyvsp = yyval;
  1420.  
  1421.   yylsp++;
  1422.   if (yylen == 0)
  1423.     {
  1424.       yylsp->first_line = yylloc.first_line;
  1425.       yylsp->first_column = yylloc.first_column;
  1426.       yylsp->last_line = (yylsp-1)->last_line;
  1427.       yylsp->last_column = (yylsp-1)->last_column;
  1428.       yylsp->text = 0;
  1429.     }
  1430.   else
  1431.     {
  1432.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1433.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1434.     }
  1435.  
  1436.   /* Now "shift" the result of the reduction.
  1437.      Determine what state that goes to,
  1438.      based on the state we popped back to
  1439.      and the rule number reduced by.  */
  1440.  
  1441.   yyn = yyr1[yyn];
  1442.  
  1443.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1444.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1445.     yystate = yytable[yystate];
  1446.   else
  1447.     yystate = yydefgoto[yyn - YYNTBASE];
  1448.  
  1449.   goto yynewstate;
  1450.  
  1451. yyerrlab:   /* here on detecting error */
  1452.  
  1453.   if (! yyerrstatus)
  1454.     /* If not already recovering from an error, report this error.  */
  1455.     {
  1456.       yyerror("parse error");
  1457.     }
  1458.  
  1459.   if (yyerrstatus == 3)
  1460.     {
  1461.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1462.  
  1463.       /* return failure if at end of input */
  1464.       if (yychar == YYEOF)
  1465.     YYERROR;
  1466.  
  1467.       if (yydebug)
  1468.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1469.  
  1470.       yychar = YYEMPTY;
  1471.     }
  1472.  
  1473.   /* Else will try to reuse lookahead token
  1474.      after shifting the error token.  */
  1475.  
  1476.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1477.  
  1478.   goto yyerrhandle;
  1479.  
  1480. yyerrdefault:  /* current state does not do anything special for the error token. */
  1481.  
  1482. #if 0
  1483.   /* This is wrong; only states that explicitly want error tokens
  1484.      should shift them.  */
  1485.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1486.   if (yyn) goto yydefault;
  1487. #endif
  1488.  
  1489. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1490.  
  1491.   if (yyssp == yyss) YYERROR;
  1492.   yyvsp--;
  1493.   yylsp--;
  1494.   yystate = *--yyssp;
  1495.  
  1496.   if (yydebug)
  1497.     {
  1498.       short *ssp1 = yyss - 1;
  1499.       fprintf (stderr, "Error: state stack now", yyssp-yyss);
  1500.       while (ssp1 != yyssp)
  1501.     fprintf (stderr, " %d", *++ssp1);
  1502.       fprintf (stderr, "\n");
  1503.     }
  1504.  
  1505. yyerrhandle:
  1506.  
  1507.   yyn = yypact[yystate];
  1508.   if (yyn == YYFLAG)
  1509.     goto yyerrdefault;
  1510.  
  1511.   yyn += YYTERROR;
  1512.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1513.     goto yyerrdefault;
  1514.  
  1515.   yyn = yytable[yyn];
  1516.   if (yyn < 0)
  1517.     {
  1518.       if (yyn == YYFLAG)
  1519.     goto yyerrpop;
  1520.       yyn = -yyn;
  1521.       goto yyreduce;
  1522.     }
  1523.   else if (yyn == 0)
  1524.     goto yyerrpop;
  1525.  
  1526.   if (yyn == YYFINAL)
  1527.     YYACCEPT;
  1528.  
  1529.   if (yydebug)
  1530.     fprintf(stderr, "Shifting error token, ");
  1531.  
  1532.   *++yyvsp = yylval;
  1533.   *++yylsp = yylloc;
  1534.  
  1535.   yystate = yyn;
  1536.   goto yynewstate;
  1537. }
  1538.  
  1539. #line 662 "awk.y"
  1540.  
  1541.  
  1542. struct token {
  1543.     char *operator;
  1544.     NODETYPE value;
  1545.     int class;
  1546.     NODE *(*ptr) ();
  1547. };
  1548.  
  1549. #define NULL 0
  1550.  
  1551. NODE    *do_exp(),    *do_getline(),    *do_index(),    *do_length(),
  1552.     *do_sqrt(),    *do_log(),    *do_sprintf(),    *do_substr(),
  1553.     *do_split(),    *do_system(),    *do_int(),    *do_close(),
  1554.     *do_atan2(),    *do_sin(),    *do_cos(),    *do_rand(),
  1555.     *do_srand(),    *do_match();
  1556.  
  1557. /* Special functions for debugging */
  1558. #ifdef DEBUG
  1559. NODE *do_prvars(), *do_bp();
  1560. #endif
  1561.  
  1562. /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
  1563.  
  1564. static struct token tokentab[] = {
  1565.     { "BEGIN",    Node_illegal,        LEX_BEGIN,    0 },
  1566.     { "END",    Node_illegal,        LEX_END,    0 },
  1567.     { "atan2",    Node_builtin,        LEX_BUILTIN,    do_atan2 },
  1568. #ifdef DEBUG
  1569.     { "bp",        Node_builtin,        LEX_BUILTIN,    do_bp },
  1570. #endif
  1571.     { "break",    Node_K_break,        LEX_BREAK,    0 },
  1572.     { "close",    Node_builtin,        LEX_BUILTIN,    do_close },
  1573.     { "continue",    Node_K_continue,    LEX_CONTINUE,    0 },
  1574.     { "cos",    Node_builtin,        LEX_BUILTIN,    do_cos },
  1575.     { "delete",    Node_K_delete,        LEX_DELETE,    0 },
  1576.     { "do",        Node_K_do,        LEX_DO,        0 },
  1577.     { "else",    Node_illegal,        LEX_ELSE,    0 },
  1578.     { "exit",    Node_K_exit,        LEX_EXIT,    0 },
  1579.     { "exp",    Node_builtin,        LEX_BUILTIN,    do_exp },
  1580.     { "for",    Node_K_for,        LEX_FOR,    0 },
  1581.     { "func",    Node_K_function,    LEX_FUNCTION,    0 },
  1582.     { "function",    Node_K_function,    LEX_FUNCTION,    0 },
  1583.     { "getline",    Node_K_getline,        LEX_GETLINE,    0 },
  1584.     { "gsub",    Node_gsub,        LEX_SUB,    0 },
  1585.     { "if",        Node_K_if,        LEX_IF,        0 },
  1586.     { "in",        Node_illegal,        LEX_IN,        0 },
  1587.     { "index",    Node_builtin,        LEX_BUILTIN,    do_index },
  1588.     { "int",    Node_builtin,        LEX_BUILTIN,    do_int },
  1589.     { "length",    Node_builtin,        LEX_BUILTIN,    do_length },
  1590.     { "log",    Node_builtin,        LEX_BUILTIN,    do_log },
  1591.     { "match",    Node_K_match,        LEX_MATCH,    0 },
  1592.     { "next",    Node_K_next,        LEX_NEXT,    0 },
  1593.     { "print",    Node_K_print,        LEX_PRINT,    0 },
  1594.     { "printf",    Node_K_printf,        LEX_PRINTF,    0 },
  1595. #ifdef DEBUG
  1596.     { "prvars",    Node_builtin,        LEX_BUILTIN,    do_prvars },
  1597. #endif
  1598.     { "rand",    Node_builtin,        LEX_BUILTIN,    do_rand },
  1599.     { "return",    Node_K_return,        LEX_RETURN,    0 },
  1600.     { "sin",    Node_builtin,        LEX_BUILTIN,    do_sin },
  1601.     { "split",    Node_builtin,        LEX_BUILTIN,    do_split },
  1602.     { "sprintf",    Node_builtin,        LEX_BUILTIN,    do_sprintf },
  1603.     { "sqrt",    Node_builtin,        LEX_BUILTIN,    do_sqrt },
  1604.     { "srand",    Node_builtin,        LEX_BUILTIN,    do_srand },
  1605.     { "sub",    Node_sub,        LEX_SUB,    0 },
  1606.     { "substr",    Node_builtin,        LEX_BUILTIN,    do_substr },
  1607.     { "system",    Node_builtin,        LEX_BUILTIN,    do_system },
  1608.     { "while",    Node_K_while,        LEX_WHILE,    0 },
  1609. };
  1610.  
  1611. /* VARARGS0 */
  1612. yyerror(va_alist)
  1613. va_dcl
  1614. {
  1615.     va_list args;
  1616.     char *mesg;
  1617.     char *a1;
  1618.     register char *ptr, *beg;
  1619.     static int list = 0;
  1620.     char *scan;
  1621. #ifdef OSK
  1622.     char oskbuf[50];
  1623. #endif
  1624.  
  1625.     errcount++;
  1626.     va_start(args);
  1627.     mesg = va_arg(args, char *);
  1628.     if (mesg || !list) {
  1629.         /* Find the current line in the input file */
  1630.         if (!lexptr) {
  1631.             beg = "(END OF FILE)";
  1632.             ptr = beg + 13;
  1633.         } else {
  1634.             if (*lexptr == '\n' && lexptr != lexptr_begin)
  1635.                 --lexptr;
  1636.             for (beg = lexptr; beg != lexptr_begin && *beg != '\n'; --beg)
  1637.                 ;
  1638.             /* NL isn't guaranteed */
  1639.             for (ptr = lexptr; *ptr && *ptr != '\n'; ptr++)
  1640.                 ;
  1641.             if (beg != lexptr_begin)
  1642.                 beg++;
  1643.         }
  1644. #ifdef OSK
  1645.         sprintf(oskbuf,"syntax error near line %%d:\n%%.%ds", ptr - beg);
  1646.         msg(oskbuf, lineno, beg);
  1647. #else
  1648.         msg("syntax error near line %d:\n%.*s", lineno, ptr - beg, beg);
  1649. #endif
  1650.         scan = beg;
  1651.         while (scan <= lexptr)
  1652.             if (*scan++ == '\t')
  1653.                 putc('\t', stderr);
  1654.             else
  1655.                 putc(' ', stderr);
  1656.         putc('^', stderr);
  1657.         putc(' ', stderr);
  1658.         if (mesg) {
  1659.             vfprintf(stderr, mesg, args);
  1660.             va_end(args);
  1661.                 putc('\n', stderr);
  1662.             exit(1);
  1663.         } else {
  1664.             a1 = va_arg(args, char *);
  1665.             if (a1) {
  1666.                 fputs("expecting: ", stderr);
  1667.                 fputs(a1, stderr);
  1668.                 list = 1;
  1669.                 va_end(args);
  1670.                 return;
  1671.             }
  1672.         }
  1673.         va_end(args);
  1674.         return;
  1675.     }
  1676.     a1 = va_arg(args, char *);
  1677.     if (a1) {
  1678.         fputs(" or ", stderr);
  1679.         fputs(a1, stderr);
  1680.         va_end(args);
  1681.         putc('\n', stderr);
  1682.         return;
  1683.     }
  1684.     putc('\n', stderr);
  1685.     list = 0;
  1686.     va_end(args);
  1687. }
  1688.  
  1689. /*
  1690.  * Parse a C escape sequence.  STRING_PTR points to a variable containing a
  1691.  * pointer to the string to parse.  That pointer is updated past the
  1692.  * characters we use.  The value of the escape sequence is returned. 
  1693.  *
  1694.  * A negative value means the sequence \ newline was seen, which is supposed to
  1695.  * be equivalent to nothing at all. 
  1696.  *
  1697.  * If \ is followed by a null character, we return a negative value and leave
  1698.  * the string pointer pointing at the null character. 
  1699.  *
  1700.  * If \ is followed by 000, we return 0 and leave the string pointer after the
  1701.  * zeros.  A value of 0 does not mean end of string.  
  1702.  */
  1703.  
  1704. static int
  1705. parse_escape(string_ptr)
  1706. char **string_ptr;
  1707. {
  1708.     register int c = *(*string_ptr)++;
  1709.  
  1710.     switch (c) {
  1711.     case 'b':
  1712.         return '\b';
  1713.     case 'f':
  1714.         return '\f';
  1715.     case 'n':
  1716.         return '\n';
  1717.     case 'r':
  1718.         return '\r';
  1719.     case 't':
  1720.         return '\t';
  1721.     case 'v':
  1722.         return '\v';
  1723.     case '\n':
  1724.         return -2;
  1725.     case 0:
  1726.         (*string_ptr)--;
  1727.         return 0;
  1728.     case '0':
  1729.     case '1':
  1730.     case '2':
  1731.     case '3':
  1732.     case '4':
  1733.     case '5':
  1734.     case '6':
  1735.     case '7':
  1736.         {
  1737.             register int i = c - '0';
  1738.             register int count = 0;
  1739.  
  1740.             while (++count < 3) {
  1741.                 if ((c = *(*string_ptr)++) >= '0' && c <= '7') {
  1742.                     i *= 8;
  1743.                     i += c - '0';
  1744.                 } else {
  1745.                     (*string_ptr)--;
  1746.                     break;
  1747.                 }
  1748.             }
  1749.             return i;
  1750.         }
  1751.     default:
  1752.         return c;
  1753.     }
  1754. }
  1755.  
  1756. /*
  1757.  * Read the input and turn it into tokens. Input is now read from a file
  1758.  * instead of from malloc'ed memory. The main program takes a program
  1759.  * passed as a command line argument and writes it to a temp file. Otherwise
  1760.  * the file name is made available in an external variable.
  1761.  */
  1762.  
  1763. int curinfile = -1;
  1764.  
  1765. static int
  1766. yylex()
  1767. {
  1768.     register int c;
  1769.     register int namelen;
  1770.     register char *tokstart;
  1771.     register struct token *tokptr;
  1772.     char *tokkey;
  1773.     extern double atof();    /* know what happens if you forget this? */
  1774.     static did_newline = 0;    /* the grammar insists that actions end
  1775.                  * with newlines.  This was easier than
  1776.                  * hacking the grammar. */
  1777.     int do_concat;
  1778.     int seen_e = 0;        /* These are for numbers */
  1779.     int seen_point = 0;
  1780.     extern char **sourcefile;
  1781.     extern int tempsource, numfiles;
  1782.     extern FILE *pathopen();
  1783.     static int file_opened = 0;
  1784.     static FILE *fin;
  1785.     static char cbuf[BUFSIZ];
  1786.     int low, mid, high;
  1787.     extern int debugging;
  1788.  
  1789.     if (! file_opened) {
  1790.         file_opened = 1;
  1791. #ifdef DEBUG
  1792.         if (debugging) {
  1793.             int i;
  1794.  
  1795.             for (i = 0; i <= numfiles; i++)
  1796.                 fprintf (stderr, "sourcefile[%d] = %s\n", i,
  1797.                         sourcefile[i]);
  1798.         }
  1799. #endif
  1800.     nextfile:
  1801.         if ((fin = pathopen (sourcefile[++curinfile])) == NULL)
  1802.             fatal("cannot open `%s' for reading (%s)",
  1803.                 sourcefile[curinfile],
  1804.                 sys_errlist[errno]);
  1805.         *(lexptr = cbuf) = '\0';
  1806.         /*
  1807.          * immediately unlink the tempfile so that it will
  1808.          * go away cleanly if we bomb.
  1809.          */
  1810.         if (tempsource && curinfile == 0)
  1811.             (void) unlink (sourcefile[curinfile]);
  1812.     }
  1813.  
  1814. retry:
  1815.     if (! *lexptr)
  1816.         if (fgets (cbuf, sizeof cbuf, fin) == NULL) {
  1817.             if (fin != NULL)
  1818.                 fclose (fin);    /* be neat and clean */
  1819.             if (curinfile < numfiles)
  1820.                 goto nextfile;
  1821.             return 0;
  1822.         } else
  1823.             lexptr = lexptr_begin = cbuf;
  1824.  
  1825.     if (want_regexp) {
  1826.         want_regexp = 0;
  1827.  
  1828.         /*
  1829.          * there is a potential bug if a regexp is followed by an
  1830.          * equal sign: "/foo/=bar" would result in assign_quotient
  1831.          * being returned as the next token.  Nothing is done about
  1832.          * it since it is not valid awk, but maybe something should
  1833.          * be done anyway. 
  1834.          */
  1835.  
  1836.         tokstart = lexptr;
  1837.         while (c = *lexptr++) {
  1838.             switch (c) {
  1839.             case '\\':
  1840.                 if (*lexptr++ == '\0') {
  1841.                     yyerror("unterminated regexp ends with \\");
  1842.                     return ERROR;
  1843.                 } else if (lexptr[-1] == '\n')
  1844.                     goto retry;
  1845.                 break;
  1846.             case '/':    /* end of the regexp */
  1847.                 lexptr--;
  1848.                 yylval.sval = tokstart;
  1849.                 return REGEXP;
  1850.             case '\n':
  1851.                 lineno++;
  1852.             case '\0':
  1853.                 yyerror("unterminated regexp");
  1854.                 return ERROR;
  1855.             }
  1856.         }
  1857.     }
  1858.     do_concat = want_concat_token;
  1859.     want_concat_token = 0;
  1860.  
  1861.     if (*lexptr == '\n') {
  1862.         lexptr++;
  1863.         lineno++;
  1864.         return NEWLINE;
  1865.     }
  1866.  
  1867.     /*
  1868.      * if lexptr is at white space between two terminal tokens or parens,
  1869.      * it is a concatenation operator. 
  1870.      */
  1871.     if (do_concat && (*lexptr == ' ' || *lexptr == '\t')) {
  1872.         while (*lexptr == ' ' || *lexptr == '\t')
  1873.             lexptr++;
  1874.         if (isalnum(*lexptr) || *lexptr == '_' || *lexptr == '\"' ||
  1875.             *lexptr == '(' || *lexptr == '.' || *lexptr == '$' ||
  1876.             (*lexptr == '+' && *(lexptr+1) == '+') ||
  1877.             (*lexptr == '-' && *(lexptr+1) == '-'))
  1878.                     /* the '.' is for decimal pt */
  1879.             return CONCAT_OP;
  1880.     }
  1881.     while (*lexptr == ' ' || *lexptr == '\t')
  1882.         lexptr++;
  1883.  
  1884.     tokstart = lexptr;
  1885.  
  1886.     switch (c = *lexptr++) {
  1887.     case 0:
  1888.         return 0;
  1889.  
  1890.     case '\n':
  1891.         lineno++;
  1892.         return NEWLINE;
  1893.  
  1894.     case '#':        /* it's a comment */
  1895.         while (*lexptr != '\n' && *lexptr != '\0')
  1896.             lexptr++;
  1897.         goto retry;
  1898.  
  1899.     case '\\':
  1900.         if (*lexptr == '\n') {
  1901.             lineno++;
  1902.             lexptr++;
  1903.             want_concat_token = do_concat;
  1904.             goto retry;
  1905.         } else
  1906.             break;
  1907.     case ')':
  1908.     case ']':
  1909.         ++want_concat_token;
  1910.         /* fall through */
  1911.     case '(':    
  1912.     case '[':
  1913.     case '$':
  1914.     case ';':
  1915.     case ':':
  1916.     case '?':
  1917.  
  1918.         /*
  1919.          * set node type to ILLEGAL because the action should set it
  1920.          * to the right thing 
  1921.          */
  1922.         yylval.nodetypeval = Node_illegal;
  1923.         return c;
  1924.  
  1925.     case '{':
  1926.     case ',':
  1927.         while (isspace(*lexptr)) {
  1928.             if (*lexptr == '\n')
  1929.                 lineno++;
  1930.             lexptr++;
  1931.         }
  1932.         yylval.nodetypeval = Node_illegal;
  1933.         return c;
  1934.  
  1935.     case '*':
  1936.         if (*lexptr == '=') {
  1937.             yylval.nodetypeval = Node_assign_times;
  1938.             lexptr++;
  1939.             return ASSIGNOP;
  1940.         } else if (*lexptr == '*') {    /* make ** and **= aliases
  1941.                          * for ^ and ^= */
  1942.             if (lexptr[1] == '=') {
  1943.                 yylval.nodetypeval = Node_assign_exp;
  1944.                 lexptr += 2;
  1945.                 return ASSIGNOP;
  1946.             } else {
  1947.                 yylval.nodetypeval = Node_illegal;
  1948.                 lexptr++;
  1949.                 return '^';
  1950.             }
  1951.         }
  1952.         yylval.nodetypeval = Node_illegal;
  1953.         return c;
  1954.  
  1955.     case '/':
  1956.         if (*lexptr == '=') {
  1957.             yylval.nodetypeval = Node_assign_quotient;
  1958.             lexptr++;
  1959.             return ASSIGNOP;
  1960.         }
  1961.         yylval.nodetypeval = Node_illegal;
  1962.         return c;
  1963.  
  1964.     case '%':
  1965.         if (*lexptr == '=') {
  1966.             yylval.nodetypeval = Node_assign_mod;
  1967.             lexptr++;
  1968.             return ASSIGNOP;
  1969.         }
  1970.         yylval.nodetypeval = Node_illegal;
  1971.         return c;
  1972.  
  1973.     case '^':
  1974.         if (*lexptr == '=') {
  1975.             yylval.nodetypeval = Node_assign_exp;
  1976.             lexptr++;
  1977.             return ASSIGNOP;
  1978.         }
  1979.         yylval.nodetypeval = Node_illegal;
  1980.         return c;
  1981.  
  1982.     case '+':
  1983.         if (*lexptr == '=') {
  1984.             yylval.nodetypeval = Node_assign_plus;
  1985.             lexptr++;
  1986.             return ASSIGNOP;
  1987.         }
  1988.         if (*lexptr == '+') {
  1989.             yylval.nodetypeval = Node_illegal;
  1990.             lexptr++;
  1991.             return INCREMENT;
  1992.         }
  1993.         yylval.nodetypeval = Node_illegal;
  1994.         return c;
  1995.  
  1996.     case '!':
  1997.         if (*lexptr == '=') {
  1998.             yylval.nodetypeval = Node_notequal;
  1999.             lexptr++;
  2000.             return RELOP;
  2001.         }
  2002.         if (*lexptr == '~') {
  2003.             yylval.nodetypeval = Node_nomatch;
  2004.             if (! strict && lexptr[1] == '~') {
  2005.                 yylval.nodetypeval = Node_case_nomatch;
  2006.                 lexptr++;
  2007.             }
  2008.             lexptr++;
  2009.             return MATCHOP;
  2010.         }
  2011.         yylval.nodetypeval = Node_illegal;
  2012.         return c;
  2013.  
  2014.     case '<':
  2015.         if (want_redirect) {
  2016.             yylval.nodetypeval = Node_redirect_input;
  2017.             return REDIRECT_OP;
  2018.         }
  2019.         if (*lexptr == '=') {
  2020.             yylval.nodetypeval = Node_leq;
  2021.             lexptr++;
  2022.             return RELOP;
  2023.         }
  2024.         yylval.nodetypeval = Node_less;
  2025.         return RELOP;
  2026.  
  2027.     case '=':
  2028.         if (*lexptr == '=') {
  2029.             yylval.nodetypeval = Node_equal;
  2030.             lexptr++;
  2031.             return RELOP;
  2032.         }
  2033.         yylval.nodetypeval = Node_assign;
  2034.         return ASSIGNOP;
  2035.  
  2036.     case '>':
  2037.         if (want_redirect) {
  2038.             if (*lexptr == '>') {
  2039.                 yylval.nodetypeval = Node_redirect_append;
  2040.                 lexptr++;
  2041.             } else
  2042.                 yylval.nodetypeval = Node_redirect_output;
  2043.             return REDIRECT_OP;
  2044.         }
  2045.         if (*lexptr == '=') {
  2046.             yylval.nodetypeval = Node_geq;
  2047.             lexptr++;
  2048.             return RELOP;
  2049.         }
  2050.         yylval.nodetypeval = Node_greater;
  2051.         return RELOP;
  2052.  
  2053.     case '~':
  2054.         yylval.nodetypeval = Node_match;
  2055.         if (! strict && *lexptr == '~') {
  2056.             yylval.nodetypeval = Node_case_match;
  2057.             lexptr++;
  2058.         }
  2059.         return MATCHOP;
  2060.  
  2061.     case '}':
  2062.         /*
  2063.          * Added did newline stuff.  Easier than
  2064.          * hacking the grammar
  2065.          */
  2066.         if (did_newline) {
  2067.             did_newline = 0;
  2068.             return c;
  2069.         }
  2070.         did_newline++;
  2071.         --lexptr;
  2072.         return NEWLINE;
  2073.  
  2074.     case '"':
  2075.         while (*lexptr != '\0') {
  2076.             switch (*lexptr++) {
  2077.             case '\\':
  2078.                 if (*lexptr++ != '\0')
  2079.                     break;
  2080.                 /* fall through */
  2081.             case '\n':
  2082.                 yyerror("unterminated string");
  2083.                 return ERROR;
  2084.             case '\"':
  2085.                 /* Skip the doublequote */
  2086.                 yylval.sval = tokstart + 1;
  2087.                 ++want_concat_token;
  2088.                 return YSTRING;
  2089.             }
  2090.         }
  2091.         return ERROR;
  2092.  
  2093.     case '-':
  2094.         if (*lexptr == '=') {
  2095.             yylval.nodetypeval = Node_assign_minus;
  2096.             lexptr++;
  2097.             return ASSIGNOP;
  2098.         }
  2099.         if (*lexptr == '-') {
  2100.             yylval.nodetypeval = Node_illegal;
  2101.             lexptr++;
  2102.             return DECREMENT;
  2103.         }
  2104.  
  2105.         /*
  2106.          * It looks like space tab comma and newline are the legal
  2107.          * places for a UMINUS.  Have we missed any? 
  2108.          */
  2109.         if ((! isdigit(*lexptr) && *lexptr != '.') ||
  2110.             (lexptr > lexptr_begin + 1 &&
  2111.                     ! index(" \t,\n", lexptr[-2]))) {
  2112.  
  2113.             /*
  2114.              * set node type to ILLEGAL because the action should
  2115.              * set it to the right thing 
  2116.              */
  2117.             yylval.nodetypeval = Node_illegal;
  2118.             return c;
  2119.         }
  2120.         /* FALL through into number code */
  2121.     case '0':
  2122.     case '1':
  2123.     case '2':
  2124.     case '3':
  2125.     case '4':
  2126.     case '5':
  2127.     case '6':
  2128.     case '7':
  2129.     case '8':
  2130.     case '9':
  2131.     case '.':
  2132.         /* It's a number */
  2133.         if (c == '-')
  2134.             namelen = 1;
  2135.         else
  2136.             namelen = 0;
  2137.         for (; (c = tokstart[namelen]) != '\0'; namelen++) {
  2138.             switch (c) {
  2139.             case '.':
  2140.                 if (seen_point)
  2141.                     goto got_number;
  2142.                 ++seen_point;
  2143.                 break;
  2144.             case 'e':
  2145.             case 'E':
  2146.                 if (seen_e)
  2147.                     goto got_number;
  2148.                 ++seen_e;
  2149.                 if (tokstart[namelen + 1] == '-' || tokstart[namelen + 1] == '+')
  2150.                     namelen++;
  2151.                 break;
  2152.             case '0':
  2153.             case '1':
  2154.             case '2':
  2155.             case '3':
  2156.             case '4':
  2157.             case '5':
  2158.             case '6':
  2159.             case '7':
  2160.             case '8':
  2161.             case '9':
  2162.                 break;
  2163.             default:
  2164.                 goto got_number;
  2165.             }
  2166.         }
  2167.  
  2168. got_number:
  2169.         lexptr = tokstart + namelen;
  2170.         yylval.fval = atof(tokstart);
  2171.         ++want_concat_token;
  2172.         return NUMBER;
  2173.  
  2174.     case '&':
  2175.         if (*lexptr == '&') {
  2176.             yylval.nodetypeval = Node_and;
  2177.             lexptr++;
  2178.             return LEX_AND;
  2179.         }
  2180.         return ERROR;
  2181.  
  2182.     case '|':
  2183.         if (*lexptr == '|') {
  2184.             yylval.nodetypeval = Node_or;
  2185.             lexptr++;
  2186.             return LEX_OR;
  2187.         } else if (want_redirect) {
  2188.             yylval.nodetypeval = Node_redirect_pipe;
  2189.             return REDIRECT_OP;
  2190.         } else {
  2191.             yylval.nodetypeval = Node_illegal;
  2192.             return c;
  2193.         }
  2194.         break;
  2195.     }
  2196.  
  2197.     if (c != '_' && !isalpha(c)) {
  2198.         yyerror("Invalid char '%c' in expression\n", c);
  2199.         return ERROR;
  2200.     }
  2201.  
  2202.     /* it's some type of name-type-thing.  Find its length */
  2203.     for (namelen = 0; is_identchar(tokstart[namelen]); namelen++)
  2204.         /* null */ ;
  2205.     emalloc(tokkey, char *, namelen+1, "yylex");
  2206.     strncpy (tokkey, tokstart, namelen);
  2207.     tokkey[namelen] = '\0';
  2208.  
  2209.     /* See if it is a special token.  */
  2210.     low = 0;
  2211.     high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
  2212.     while (low <= high) {
  2213.         int i, c;
  2214.  
  2215.         mid = (low + high) / 2;
  2216.  
  2217.     compare:
  2218.         c = *tokstart - tokentab[mid].operator[0];
  2219.         i = c ? c : strcmp (tokkey, tokentab[mid].operator);
  2220.  
  2221.         if (i < 0) {        /* token < mid */
  2222.             high = mid - 1;
  2223.         } else if (i > 0) {    /* token > mid */
  2224.             low = mid + 1;
  2225.         } else {
  2226.             lexptr = tokstart + namelen;
  2227.             if (tokentab[mid].class == LEX_BUILTIN)
  2228.                 yylval.ptrval = tokentab[mid].ptr;
  2229.             else
  2230.                 yylval.nodetypeval = tokentab[mid].value;
  2231.             if (tokentab[mid].class == LEX_PRINT)
  2232.                 want_redirect++;
  2233.             return tokentab[mid].class;
  2234.         }
  2235.     }
  2236.  
  2237.     /* It's a name.  See how long it is.  */
  2238.     yylval.sval = tokkey;
  2239.     lexptr = tokstart + namelen;
  2240.     ++want_concat_token;
  2241.     return NAME;
  2242. }
  2243.  
  2244. #ifndef DEFPATH
  2245. #ifdef OSK
  2246. #define DEFPATH    ".:/h0/usr/lib/awk:/h0/usr/local/lib/awk"
  2247. #else
  2248. #define DEFPATH    ".:/usr/lib/awk:/usr/local/lib/awk"
  2249. #endif
  2250. #endif
  2251.  
  2252. FILE *
  2253. pathopen (file)
  2254. char *file;
  2255. {
  2256.     static char defpath[] = DEFPATH;
  2257.     static char *savepath;
  2258.     static int first = 1;
  2259.     extern char *getenv ();
  2260.     char *awkpath, *cp;
  2261.     char trypath[BUFSIZ];
  2262.     FILE *fp;
  2263.     extern int debugging;
  2264.  
  2265.     if (strict)
  2266.         return (fopen (file, "r"));
  2267.  
  2268.     if (first) {
  2269.         first = 0;
  2270.         if ((awkpath = getenv ("AWKPATH")) == NULL || ! *awkpath)
  2271.             awkpath = defpath;
  2272.         savepath = awkpath;    /* savepath used for restarting */
  2273.     } else
  2274.         awkpath = savepath;
  2275.  
  2276.     if (index (file, '/') != NULL)    /* some kind of path name, no search */
  2277.         return (fopen (file, "r"));
  2278.  
  2279.     do {
  2280.         for (cp = trypath; *awkpath && *awkpath != ':'; )
  2281.             *cp++ = *awkpath++;
  2282.         *cp++ = '/';
  2283.         *cp = '\0';    /* clear left over junk */
  2284.         strcat (cp, file);
  2285.         if ((fp = fopen (trypath, "r")) != NULL)
  2286.             return (fp);
  2287.  
  2288.         /* no luck, keep going */
  2289.         awkpath++;    /* skip colon */
  2290.     } while (*awkpath);
  2291.     return (NULL);
  2292. }
  2293.