home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / command.y.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  42.3 KB  |  1,478 lines

  1.  
  2. /*  A Bison parser, made from command.y
  3.     by GNU Bison version 1.28  */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    NUM    257
  8. #define    STRING    258
  9. #define    IDSTRING    259
  10. #define    ERR    260
  11. #define    LSHIFT    261
  12. #define    RSHIFT    262
  13. #define    COMPLE    263
  14. #define    COMPGE    264
  15. #define    COMPEQ    265
  16. #define    COMPNE    266
  17. #define    COMPAND    267
  18. #define    COMPOR    268
  19. #define    COMPXOR    269
  20. #define    PRINT    270
  21. #define    NEG    271
  22.  
  23. #line 4 "command.y"
  24.  
  25.  
  26. #include <stdarg.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29.  
  30. #include "StringUtils.h"
  31. #include "xmalloc.h"
  32. #include "command.h"
  33. #include "command_parser.h"
  34.  
  35. #include "log.h"
  36. #define _L    LOG_COMMANDS|LOG_INFO
  37.  
  38. //#define YYDEBUG 1
  39. #define YYERROR_VERBOSE 1
  40.  
  41. int yyerror(char *s);
  42. int yylex(void);
  43.  
  44. extern command_symbol_table *command_scope;
  45.  
  46. extern void lexer_error(char *format, ...);
  47.  
  48. #define  ASSIGNSTMT(x,y)    do { if (x.u.sym) \
  49.                                 command_set_args(NULL, x.u.sym, &y, NULL); \
  50.                             } while (0)
  51.                         
  52. #define  ASSIGN(z,x,y)    do { if (!x.u.sym || \
  53.                             !command_set_args(&z, x.u.sym,&y, NULL)) \
  54.                                   z.type = ca_VOID; } while (0)
  55.  
  56. #define  NUMBINOP(z,px,x,n,OP,py,y)    do { if (x.type == y.type && x.type == ca_NUM) { \
  57.                                 z.type = ca_NUM; \
  58.                                 z.u.num = px x.u.num OP py y.u.num; \
  59.                             } else { \
  60.                                 parse_error("expected numeric arguments for '" n "'"); \
  61.                                   z.type = ca_VOID; \
  62.                             } } while (0)
  63.  
  64. #define  NUMUNOP(z,n,OP,px,x) do { if (x.type == ca_NUM) { \
  65.                                 z.type = ca_NUM; \
  66.                                 z.u.num = OP px x.u.num ; \
  67.                             } else { \
  68.                                 parse_error("expected numeric argument for '" n "'"); \
  69.                                   z.type = ca_VOID; \
  70.                             } } while (0)
  71.  
  72.  
  73. #line 54 "command.y"
  74. typedef union 
  75. {
  76.     command_exprval        expr;
  77.     command_symbol *sym;
  78. } YYSTYPE;
  79. #include <stdio.h>
  80.  
  81. #ifndef __cplusplus
  82. #ifndef __STDC__
  83. #define const
  84. #endif
  85. #endif
  86.  
  87.  
  88.  
  89. #define    YYFINAL        114
  90. #define    YYFLAG        -32768
  91. #define    YYNTBASE    37
  92.  
  93. #define YYTRANSLATE(x) ((unsigned)(x) <= 271 ? yytranslate[x] : 58)
  94.  
  95. static const char yytranslate[] = {     0,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,    26,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,    33,     2,     2,     2,     2,    20,     2,    35,
  100.     36,    21,    19,    27,    18,     2,    22,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,    29,    25,    32,
  102.     17,    31,    28,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,    30,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,    23,     2,    34,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  118.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  119.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  120.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
  122.      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
  123.     24
  124. };
  125.  
  126. #if YYDEBUG != 0
  127. static const short yyprhs[] = {     0,
  128.      0,     1,     4,     6,     8,     9,    11,    13,    15,    18,
  129.     19,    22,    24,    26,    30,    32,    40,    47,    53,    58,
  130.     62,    65,    67,    69,    73,    77,    79,    81,    87,    89,
  131.     93,    97,   101,   103,   107,   111,   115,   117,   121,   125,
  132.    127,   131,   135,   139,   143,   145,   149,   153,   155,   159,
  133.    163,   165,   169,   173,   175,   178,   181,   184,   186,   188,
  134.    190,   192,   197,   204,   213,   224,   237,   252,   256
  135. };
  136.  
  137. static const short yyrhs[] = {    -1,
  138.     37,    39,     0,    25,     0,    26,     0,     0,    44,     0,
  139.     40,     0,    38,     0,    16,    41,     0,     0,    41,    42,
  140.      0,    47,     0,     5,     0,    43,    17,    46,     0,    45,
  141.      0,    43,    42,    42,    42,    42,    42,    42,     0,    43,
  142.     42,    42,    42,    42,    42,     0,    43,    42,    42,    42,
  143.     42,     0,    43,    42,    42,    42,     0,    43,    42,    42,
  144.      0,    43,    42,     0,    43,     0,    48,     0,    46,    27,
  145.     48,     0,    43,    17,    47,     0,    48,     0,    49,     0,
  146.     49,    28,    42,    29,    48,     0,    50,     0,    49,    13,
  147.     50,     0,    49,    14,    50,     0,    49,    15,    50,     0,
  148.     51,     0,    50,    20,    51,     0,    50,    23,    51,     0,
  149.     50,    30,    51,     0,    52,     0,    51,    11,    52,     0,
  150.     51,    12,    52,     0,    53,     0,    52,     9,    53,     0,
  151.     52,    10,    53,     0,    52,    31,    53,     0,    52,    32,
  152.     53,     0,    54,     0,    53,     7,    54,     0,    53,     8,
  153.     54,     0,    55,     0,    54,    19,    55,     0,    54,    18,
  154.     55,     0,    56,     0,    55,    21,    56,     0,    55,    22,
  155.     56,     0,    57,     0,    18,    56,     0,    33,    56,     0,
  156.     34,    56,     0,     6,     0,     3,     0,     4,     0,     5,
  157.      0,    43,    35,    42,    36,     0,    43,    35,    42,    27,
  158.     42,    36,     0,    43,    35,    42,    27,    42,    27,    42,
  159.     36,     0,    43,    35,    42,    27,    42,    27,    42,    27,
  160.     42,    36,     0,    43,    35,    42,    27,    42,    27,    42,
  161.     27,    42,    27,    42,    36,     0,    43,    35,    42,    27,
  162.     42,    27,    42,    27,    42,    27,    42,    27,    42,    36,
  163.      0,    35,    43,    36,     0,    35,    42,    36,     0
  164. };
  165.  
  166. #endif
  167.  
  168. #if YYDEBUG != 0
  169. static const short yyrline[] = { 0,
  170.    101,   102,   105,   106,   108,   109,   110,   111,   114,   117,
  171.    118,   125,   128,   145,   152,   159,   168,   177,   186,   195,
  172.    204,   212,   218,   219,   224,   226,   229,   230,   245,   246,
  173.    248,   250,   253,   254,   256,   258,   261,   263,   264,   267,
  174.    269,   271,   273,   275,   278,   279,   280,   282,   283,   300,
  175.    303,   306,   307,   324,   326,   328,   330,   334,   336,   339,
  176.    342,   361,   372,   382,   392,   402,   412,   422,   428
  177. };
  178. #endif
  179.  
  180.  
  181. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  182.  
  183. static const char * const yytname[] = {   "$","error","$undefined.","NUM","STRING",
  184. "IDSTRING","ERR","LSHIFT","RSHIFT","COMPLE","COMPGE","COMPEQ","COMPNE","COMPAND",
  185. "COMPOR","COMPXOR","PRINT","'='","'-'","'+'","'&'","'*'","'/'","'|'","NEG","';'",
  186. "'\\n'","','","'?'","':'","'^'","'>'","'<'","'!'","'~'","'('","')'","input",
  187. "eol","line","printstmt","printexprlist","expr","id","assignstmt","assignline",
  188. "comma","assign","cond","logcond","binlogcond","compeq","comp","shift","factor",
  189. "term","unary","atom", NULL
  190. };
  191. #endif
  192.  
  193. static const short yyr1[] = {     0,
  194.     37,    37,    38,    38,    39,    39,    39,    39,    40,    41,
  195.     41,    42,    43,    44,    44,    45,    45,    45,    45,    45,
  196.     45,    45,    46,    46,    47,    47,    48,    48,    49,    49,
  197.     49,    49,    50,    50,    50,    50,    51,    51,    51,    52,
  198.     52,    52,    52,    52,    53,    53,    53,    54,    54,    54,
  199.     55,    55,    55,    56,    56,    56,    56,    57,    57,    57,
  200.     57,    57,    57,    57,    57,    57,    57,    57,    57
  201. };
  202.  
  203. static const short yyr2[] = {     0,
  204.      0,     2,     1,     1,     0,     1,     1,     1,     2,     0,
  205.      2,     1,     1,     3,     1,     7,     6,     5,     4,     3,
  206.      2,     1,     1,     3,     3,     1,     1,     5,     1,     3,
  207.      3,     3,     1,     3,     3,     3,     1,     3,     3,     1,
  208.      3,     3,     3,     3,     1,     3,     3,     1,     3,     3,
  209.      1,     3,     3,     1,     2,     2,     2,     1,     1,     1,
  210.      1,     4,     6,     8,    10,    12,    14,     3,     3
  211. };
  212.  
  213. static const short yydefact[] = {     1,
  214.      0,    13,    10,     3,     4,     8,     2,     7,    22,     6,
  215.     15,     9,    59,    60,    61,    58,     0,     0,     0,     0,
  216.      0,    21,     0,    12,    26,    27,    29,    33,    37,    40,
  217.     45,    48,    51,    54,    11,     0,    14,    23,    55,    56,
  218.     57,     0,     0,    20,     0,     0,     0,     0,     0,     0,
  219.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  220.      0,     0,     0,     0,     0,     0,    69,    68,    19,    25,
  221.      0,    30,    31,    32,     0,    34,    35,    36,    38,    39,
  222.     41,    42,    43,    44,    46,    47,    50,    49,    52,    53,
  223.     24,    18,     0,    62,     0,    17,     0,    28,    16,     0,
  224.     63,     0,     0,    64,     0,     0,    65,     0,     0,    66,
  225.      0,    67,     0,     0
  226. };
  227.  
  228. static const short yydefgoto[] = {     1,
  229.      6,     7,     8,    12,    22,    36,    10,    11,    37,    24,
  230.     25,    26,    27,    28,    29,    30,    31,    32,    33,    34
  231. };
  232.  
  233. static const short yypact[] = {-32768,
  234.     31,-32768,-32768,-32768,-32768,-32768,-32768,-32768,     0,-32768,
  235. -32768,    83,-32768,-32768,    -8,-32768,    83,    83,    83,    83,
  236.     83,    83,   -16,-32768,-32768,    49,    46,    18,    29,    45,
  237.     53,    90,-32768,-32768,-32768,   -28,   -17,-32768,-32768,-32768,
  238. -32768,     6,     5,    83,    83,    83,    83,    83,    83,    83,
  239.     83,    83,    83,    83,    83,    83,    83,    83,    83,    83,
  240.     83,    83,    83,    83,    83,    83,-32768,-32768,    83,-32768,
  241.    -12,    46,    46,    46,    26,    18,    18,    18,    29,    29,
  242.     45,    45,    45,    45,    53,    53,    90,    90,-32768,-32768,
  243. -32768,    83,    83,-32768,    83,    83,    -4,-32768,-32768,    83,
  244. -32768,    10,    83,-32768,    38,    83,-32768,    43,    83,-32768,
  245.     42,-32768,    67,-32768
  246. };
  247.  
  248. static const short yypgoto[] = {-32768,
  249. -32768,-32768,-32768,-32768,     4,    -1,-32768,-32768,-32768,    30,
  250.    -15,-32768,    72,    71,    39,    25,    54,    63,    -6,-32768
  251. };
  252.  
  253.  
  254. #define    YYLAST        126
  255.  
  256.  
  257. static const short yytable[] = {     9,
  258.     45,    38,    13,    14,    15,    16,    46,    23,   -13,    66,
  259.     23,    39,    40,    41,    93,    35,    17,    18,    46,    43,
  260.     23,    45,   100,    94,    42,    44,   -13,   -13,    54,    55,
  261.    113,   101,    19,    20,    21,     2,   103,    56,    57,    46,
  262.     68,    67,    23,    23,    23,   104,     3,    69,    23,    71,
  263.     91,    60,    61,    75,    95,     4,     5,    89,    90,    58,
  264.     59,    47,    48,    49,   106,    51,   114,    23,    52,   109,
  265.     62,    63,    92,   107,    70,    53,    50,   112,   110,    98,
  266.     81,    82,    83,    84,     0,    13,    14,    15,    16,     0,
  267.     23,    23,    79,    80,    23,    96,    97,     0,    23,    99,
  268.     18,    23,     0,   102,    23,     0,   105,    23,     0,   108,
  269.     64,    65,   111,    85,    86,    19,    20,    21,    72,    73,
  270.     74,    76,    77,    78,    87,    88
  271. };
  272.  
  273. static const short yycheck[] = {     1,
  274.     17,    17,     3,     4,     5,     6,    35,     9,    17,    27,
  275.     12,    18,    19,    20,    27,    12,    17,    18,    35,    21,
  276.     22,    17,    27,    36,    21,    22,    35,    36,    11,    12,
  277.      0,    36,    33,    34,    35,     5,    27,     9,    10,    35,
  278.     36,    36,    44,    45,    46,    36,    16,    44,    50,    46,
  279.     66,     7,     8,    50,    29,    25,    26,    64,    65,    31,
  280.     32,    13,    14,    15,    27,    20,     0,    69,    23,    27,
  281.     18,    19,    69,    36,    45,    30,    28,    36,    36,    95,
  282.     56,    57,    58,    59,    -1,     3,     4,     5,     6,    -1,
  283.     92,    93,    54,    55,    96,    92,    93,    -1,   100,    96,
  284.     18,   103,    -1,   100,   106,    -1,   103,   109,    -1,   106,
  285.     21,    22,   109,    60,    61,    33,    34,    35,    47,    48,
  286.     49,    51,    52,    53,    62,    63
  287. };
  288. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  289. #line 3 "/usr/lib/bison.simple"
  290. /* This file comes from bison-1.28.  */
  291.  
  292. /* Skeleton output parser for bison,
  293.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  294.  
  295.    This program is free software; you can redistribute it and/or modify
  296.    it under the terms of the GNU General Public License as published by
  297.    the Free Software Foundation; either version 2, or (at your option)
  298.    any later version.
  299.  
  300.    This program is distributed in the hope that it will be useful,
  301.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  302.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  303.    GNU General Public License for more details.
  304.  
  305.    You should have received a copy of the GNU General Public License
  306.    along with this program; if not, write to the Free Software
  307.    Foundation, Inc., 59 Temple Place - Suite 330,
  308.    Boston, MA 02111-1307, USA.  */
  309.  
  310. /* As a special exception, when this file is copied by Bison into a
  311.    Bison output file, you may use that output file without restriction.
  312.    This special exception was added by the Free Software Foundation
  313.    in version 1.24 of Bison.  */
  314.  
  315. /* This is the parser code that is written into each bison parser
  316.   when the %semantic_parser declaration is not specified in the grammar.
  317.   It was written by Richard Stallman by simplifying the hairy parser
  318.   used when %semantic_parser is specified.  */
  319.  
  320. #ifndef YYSTACK_USE_ALLOCA
  321. #ifdef alloca
  322. #define YYSTACK_USE_ALLOCA
  323. #else /* alloca not defined */
  324. #ifdef __GNUC__
  325. #define YYSTACK_USE_ALLOCA
  326. #define alloca __builtin_alloca
  327. #else /* not GNU C.  */
  328. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
  329. #define YYSTACK_USE_ALLOCA
  330. #include <alloca.h>
  331. #else /* not sparc */
  332. /* We think this test detects Watcom and Microsoft C.  */
  333. /* This used to test MSDOS, but that is a bad idea
  334.    since that symbol is in the user namespace.  */
  335. #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
  336. #if 0 /* No need for malloc.h, which pollutes the namespace;
  337.      instead, just don't use alloca.  */
  338. #include <malloc.h>
  339. #endif
  340. #else /* not MSDOS, or __TURBOC__ */
  341. #if defined(_AIX)
  342. /* I don't know what this was needed for, but it pollutes the namespace.
  343.    So I turned it off.   rms, 2 May 1997.  */
  344. /* #include <malloc.h>  */
  345.  #pragma alloca
  346. #define YYSTACK_USE_ALLOCA
  347. #else /* not MSDOS, or __TURBOC__, or _AIX */
  348. #if 0
  349. #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
  350.          and on HPUX 10.  Eventually we can turn this on.  */
  351. #define YYSTACK_USE_ALLOCA
  352. #define alloca __builtin_alloca
  353. #endif /* __hpux */
  354. #endif
  355. #endif /* not _AIX */
  356. #endif /* not MSDOS, or __TURBOC__ */
  357. #endif /* not sparc */
  358. #endif /* not GNU C */
  359. #endif /* alloca not defined */
  360. #endif /* YYSTACK_USE_ALLOCA not defined */
  361.  
  362. #ifdef YYSTACK_USE_ALLOCA
  363. #define YYSTACK_ALLOC alloca
  364. #else
  365. #define YYSTACK_ALLOC malloc
  366. #endif
  367.  
  368. /* Note: there must be only one dollar sign in this file.
  369.    It is replaced by the list of actions, each action
  370.    as one case of the switch.  */
  371.  
  372. #define yyerrok        (yyerrstatus = 0)
  373. #define yyclearin    (yychar = YYEMPTY)
  374. #define YYEMPTY        -2
  375. #define YYEOF        0
  376. #define YYACCEPT    goto yyacceptlab
  377. #define YYABORT     goto yyabortlab
  378. #define YYERROR        goto yyerrlab1
  379. /* Like YYERROR except do call yyerror.
  380.    This remains here temporarily to ease the
  381.    transition to the new meaning of YYERROR, for GCC.
  382.    Once GCC version 2 has supplanted version 1, this can go.  */
  383. #define YYFAIL        goto yyerrlab
  384. #define YYRECOVERING()  (!!yyerrstatus)
  385. #define YYBACKUP(token, value) \
  386. do                                \
  387.   if (yychar == YYEMPTY && yylen == 1)                \
  388.     { yychar = (token), yylval = (value);            \
  389.       yychar1 = YYTRANSLATE (yychar);                \
  390.       YYPOPSTACK;                        \
  391.       goto yybackup;                        \
  392.     }                                \
  393.   else                                \
  394.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  395. while (0)
  396.  
  397. #define YYTERROR    1
  398. #define YYERRCODE    256
  399.  
  400. #ifndef YYPURE
  401. #define YYLEX        yylex()
  402. #endif
  403.  
  404. #ifdef YYPURE
  405. #ifdef YYLSP_NEEDED
  406. #ifdef YYLEX_PARAM
  407. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  408. #else
  409. #define YYLEX        yylex(&yylval, &yylloc)
  410. #endif
  411. #else /* not YYLSP_NEEDED */
  412. #ifdef YYLEX_PARAM
  413. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  414. #else
  415. #define YYLEX        yylex(&yylval)
  416. #endif
  417. #endif /* not YYLSP_NEEDED */
  418. #endif
  419.  
  420. /* If nonreentrant, generate the variables here */
  421.  
  422. #ifndef YYPURE
  423.  
  424. int    yychar;            /*  the lookahead symbol        */
  425. YYSTYPE    yylval;            /*  the semantic value of the        */
  426.                 /*  lookahead symbol            */
  427.  
  428. #ifdef YYLSP_NEEDED
  429. YYLTYPE yylloc;            /*  location data for the lookahead    */
  430.                 /*  symbol                */
  431. #endif
  432.  
  433. int yynerrs;            /*  number of parse errors so far       */
  434. #endif  /* not YYPURE */
  435.  
  436. #if YYDEBUG != 0
  437. int yydebug;            /*  nonzero means print parse trace    */
  438. /* Since this is uninitialized, it does not stop multiple parsers
  439.    from coexisting.  */
  440. #endif
  441.  
  442. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  443.  
  444. #ifndef    YYINITDEPTH
  445. #define YYINITDEPTH 200
  446. #endif
  447.  
  448. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  449.     (effective only if the built-in stack extension method is used).  */
  450.  
  451. #if YYMAXDEPTH == 0
  452. #undef YYMAXDEPTH
  453. #endif
  454.  
  455. #ifndef YYMAXDEPTH
  456. #define YYMAXDEPTH 10000
  457. #endif
  458.  
  459. /* Define __yy_memcpy.  Note that the size argument
  460.    should be passed with type unsigned int, because that is what the non-GCC
  461.    definitions require.  With GCC, __builtin_memcpy takes an arg
  462.    of type size_t, but it can handle unsigned int.  */
  463.  
  464. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  465. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  466. #else                /* not GNU C or C++ */
  467. #ifndef __cplusplus
  468.  
  469. /* This is the most reliable way to avoid incompatibilities
  470.    in available built-in functions on various systems.  */
  471. static void
  472. __yy_memcpy (to, from, count)
  473.      char *to;
  474.      char *from;
  475.      unsigned int count;
  476. {
  477.   register char *f = from;
  478.   register char *t = to;
  479.   register int i = count;
  480.  
  481.   while (i-- > 0)
  482.     *t++ = *f++;
  483. }
  484.  
  485. #else /* __cplusplus */
  486.  
  487. /* This is the most reliable way to avoid incompatibilities
  488.    in available built-in functions on various systems.  */
  489. static void
  490. __yy_memcpy (char *to, char *from, unsigned int count)
  491. {
  492.   register char *t = to;
  493.   register char *f = from;
  494.   register int i = count;
  495.  
  496.   while (i-- > 0)
  497.     *t++ = *f++;
  498. }
  499.  
  500. #endif
  501. #endif
  502.  
  503. #line 217 "/usr/lib/bison.simple"
  504.  
  505. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  506.    into yyparse.  The argument should have type void *.
  507.    It should actually point to an object.
  508.    Grammar actions can access the variable by casting it
  509.    to the proper pointer type.  */
  510.  
  511. #ifdef YYPARSE_PARAM
  512. #ifdef __cplusplus
  513. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  514. #define YYPARSE_PARAM_DECL
  515. #else /* not __cplusplus */
  516. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  517. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  518. #endif /* not __cplusplus */
  519. #else /* not YYPARSE_PARAM */
  520. #define YYPARSE_PARAM_ARG
  521. #define YYPARSE_PARAM_DECL
  522. #endif /* not YYPARSE_PARAM */
  523.  
  524. /* Prevent warning if -Wstrict-prototypes.  */
  525. #ifdef __GNUC__
  526. #ifdef YYPARSE_PARAM
  527. int yyparse (void *);
  528. #else
  529. int yyparse (void);
  530. #endif
  531. #endif
  532.  
  533. int
  534. yyparse(YYPARSE_PARAM_ARG)
  535.      YYPARSE_PARAM_DECL
  536. {
  537.   register int yystate;
  538.   register int yyn;
  539.   register short *yyssp;
  540.   register YYSTYPE *yyvsp;
  541.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  542.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  543.  
  544.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  545.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  546.  
  547.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  548.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  549.  
  550. #ifdef YYLSP_NEEDED
  551.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  552.   YYLTYPE *yyls = yylsa;
  553.   YYLTYPE *yylsp;
  554.  
  555. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  556. #else
  557. #define YYPOPSTACK   (yyvsp--, yyssp--)
  558. #endif
  559.  
  560.   int yystacksize = YYINITDEPTH;
  561.   int yyfree_stacks = 0;
  562.  
  563. #ifdef YYPURE
  564.   int yychar;
  565.   YYSTYPE yylval;
  566.   int yynerrs;
  567. #ifdef YYLSP_NEEDED
  568.   YYLTYPE yylloc;
  569. #endif
  570. #endif
  571.  
  572.   YYSTYPE yyval;        /*  the variable used to return        */
  573.                 /*  semantic values from the action    */
  574.                 /*  routines                */
  575.  
  576.   int yylen;
  577.  
  578. #if YYDEBUG != 0
  579.   if (yydebug)
  580.     fprintf(stderr, "Starting parse\n");
  581. #endif
  582.  
  583.   yystate = 0;
  584.   yyerrstatus = 0;
  585.   yynerrs = 0;
  586.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  587.  
  588.   /* Initialize stack pointers.
  589.      Waste one element of value and location stack
  590.      so that they stay on the same level as the state stack.
  591.      The wasted elements are never initialized.  */
  592.  
  593.   yyssp = yyss - 1;
  594.   yyvsp = yyvs;
  595. #ifdef YYLSP_NEEDED
  596.   yylsp = yyls;
  597. #endif
  598.  
  599. /* Push a new state, which is found in  yystate  .  */
  600. /* In all cases, when you get here, the value and location stacks
  601.    have just been pushed. so pushing a state here evens the stacks.  */
  602. yynewstate:
  603.  
  604.   *++yyssp = yystate;
  605.  
  606.   if (yyssp >= yyss + yystacksize - 1)
  607.     {
  608.       /* Give user a chance to reallocate the stack */
  609.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  610.       YYSTYPE *yyvs1 = yyvs;
  611.       short *yyss1 = yyss;
  612. #ifdef YYLSP_NEEDED
  613.       YYLTYPE *yyls1 = yyls;
  614. #endif
  615.  
  616.       /* Get the current used size of the three stacks, in elements.  */
  617.       int size = yyssp - yyss + 1;
  618.  
  619. #ifdef yyoverflow
  620.       /* Each stack pointer address is followed by the size of
  621.      the data in use in that stack, in bytes.  */
  622. #ifdef YYLSP_NEEDED
  623.       /* This used to be a conditional around just the two extra args,
  624.      but that might be undefined if yyoverflow is a macro.  */
  625.       yyoverflow("parser stack overflow",
  626.          &yyss1, size * sizeof (*yyssp),
  627.          &yyvs1, size * sizeof (*yyvsp),
  628.          &yyls1, size * sizeof (*yylsp),
  629.          &yystacksize);
  630. #else
  631.       yyoverflow("parser stack overflow",
  632.          &yyss1, size * sizeof (*yyssp),
  633.          &yyvs1, size * sizeof (*yyvsp),
  634.          &yystacksize);
  635. #endif
  636.  
  637.       yyss = yyss1; yyvs = yyvs1;
  638. #ifdef YYLSP_NEEDED
  639.       yyls = yyls1;
  640. #endif
  641. #else /* no yyoverflow */
  642.       /* Extend the stack our own way.  */
  643.       if (yystacksize >= YYMAXDEPTH)
  644.     {
  645.       yyerror("parser stack overflow");
  646.       if (yyfree_stacks)
  647.         {
  648.           free (yyss);
  649.           free (yyvs);
  650. #ifdef YYLSP_NEEDED
  651.           free (yyls);
  652. #endif
  653.         }
  654.       return 2;
  655.     }
  656.       yystacksize *= 2;
  657.       if (yystacksize > YYMAXDEPTH)
  658.     yystacksize = YYMAXDEPTH;
  659. #ifndef YYSTACK_USE_ALLOCA
  660.       yyfree_stacks = 1;
  661. #endif
  662.       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
  663.       __yy_memcpy ((char *)yyss, (char *)yyss1,
  664.            size * (unsigned int) sizeof (*yyssp));
  665.       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
  666.       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
  667.            size * (unsigned int) sizeof (*yyvsp));
  668. #ifdef YYLSP_NEEDED
  669.       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
  670.       __yy_memcpy ((char *)yyls, (char *)yyls1,
  671.            size * (unsigned int) sizeof (*yylsp));
  672. #endif
  673. #endif /* no yyoverflow */
  674.  
  675.       yyssp = yyss + size - 1;
  676.       yyvsp = yyvs + size - 1;
  677. #ifdef YYLSP_NEEDED
  678.       yylsp = yyls + size - 1;
  679. #endif
  680.  
  681. #if YYDEBUG != 0
  682.       if (yydebug)
  683.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  684. #endif
  685.  
  686.       if (yyssp >= yyss + yystacksize - 1)
  687.     YYABORT;
  688.     }
  689.  
  690. #if YYDEBUG != 0
  691.   if (yydebug)
  692.     fprintf(stderr, "Entering state %d\n", yystate);
  693. #endif
  694.  
  695.   goto yybackup;
  696.  yybackup:
  697.  
  698. /* Do appropriate processing given the current state.  */
  699. /* Read a lookahead token if we need one and don't already have one.  */
  700. /* yyresume: */
  701.  
  702.   /* First try to decide what to do without reference to lookahead token.  */
  703.  
  704.   yyn = yypact[yystate];
  705.   if (yyn == YYFLAG)
  706.     goto yydefault;
  707.  
  708.   /* Not known => get a lookahead token if don't already have one.  */
  709.  
  710.   /* yychar is either YYEMPTY or YYEOF
  711.      or a valid token in external form.  */
  712.  
  713.   if (yychar == YYEMPTY)
  714.     {
  715. #if YYDEBUG != 0
  716.       if (yydebug)
  717.     fprintf(stderr, "Reading a token: ");
  718. #endif
  719.       yychar = YYLEX;
  720.     }
  721.  
  722.   /* Convert token to internal form (in yychar1) for indexing tables with */
  723.  
  724.   if (yychar <= 0)        /* This means end of input. */
  725.     {
  726.       yychar1 = 0;
  727.       yychar = YYEOF;        /* Don't call YYLEX any more */
  728.  
  729. #if YYDEBUG != 0
  730.       if (yydebug)
  731.     fprintf(stderr, "Now at end of input.\n");
  732. #endif
  733.     }
  734.   else
  735.     {
  736.       yychar1 = YYTRANSLATE(yychar);
  737.  
  738. #if YYDEBUG != 0
  739.       if (yydebug)
  740.     {
  741.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  742.       /* Give the individual parser a way to print the precise meaning
  743.          of a token, for further debugging info.  */
  744. #ifdef YYPRINT
  745.       YYPRINT (stderr, yychar, yylval);
  746. #endif
  747.       fprintf (stderr, ")\n");
  748.     }
  749. #endif
  750.     }
  751.  
  752.   yyn += yychar1;
  753.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  754.     goto yydefault;
  755.  
  756.   yyn = yytable[yyn];
  757.  
  758.   /* yyn is what to do for this token type in this state.
  759.      Negative => reduce, -yyn is rule number.
  760.      Positive => shift, yyn is new state.
  761.        New state is final state => don't bother to shift,
  762.        just return success.
  763.      0, or most negative number => error.  */
  764.  
  765.   if (yyn < 0)
  766.     {
  767.       if (yyn == YYFLAG)
  768.     goto yyerrlab;
  769.       yyn = -yyn;
  770.       goto yyreduce;
  771.     }
  772.   else if (yyn == 0)
  773.     goto yyerrlab;
  774.  
  775.   if (yyn == YYFINAL)
  776.     YYACCEPT;
  777.  
  778.   /* Shift the lookahead token.  */
  779.  
  780. #if YYDEBUG != 0
  781.   if (yydebug)
  782.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  783. #endif
  784.  
  785.   /* Discard the token being shifted unless it is eof.  */
  786.   if (yychar != YYEOF)
  787.     yychar = YYEMPTY;
  788.  
  789.   *++yyvsp = yylval;
  790. #ifdef YYLSP_NEEDED
  791.   *++yylsp = yylloc;
  792. #endif
  793.  
  794.   /* count tokens shifted since error; after three, turn off error status.  */
  795.   if (yyerrstatus) yyerrstatus--;
  796.  
  797.   yystate = yyn;
  798.   goto yynewstate;
  799.  
  800. /* Do the default action for the current state.  */
  801. yydefault:
  802.  
  803.   yyn = yydefact[yystate];
  804.   if (yyn == 0)
  805.     goto yyerrlab;
  806.  
  807. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  808. yyreduce:
  809.   yylen = yyr2[yyn];
  810.   if (yylen > 0)
  811.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  812.  
  813. #if YYDEBUG != 0
  814.   if (yydebug)
  815.     {
  816.       int i;
  817.  
  818.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  819.            yyn, yyrline[yyn]);
  820.  
  821.       /* Print the symbols being reduced, and their result.  */
  822.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  823.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  824.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  825.     }
  826. #endif
  827.  
  828.  
  829.   switch (yyn) {
  830.  
  831. case 9:
  832. #line 114 "command.y"
  833. { logger(_L|LOG_USER, "\n"); ;
  834.     break;}
  835. case 11:
  836. #line 118 "command.y"
  837. { if (yyvsp[0].expr.type == ca_NUM) logger(_L|LOG_USER, "%d", yyvsp[0].expr.u.num);
  838.                                 else if (yyvsp[0].expr.type == ca_STRING) { 
  839.                                     logger(_L|LOG_USER, "%s", yyvsp[0].expr.u.str); xfree(yyvsp[0].expr.u.str); }
  840.                                 ;
  841.     break;}
  842. case 12:
  843. #line 125 "command.y"
  844. { yyval.expr=yyvsp[0].expr; ;
  845.     break;}
  846. case 13:
  847. #line 128 "command.y"
  848.                 char *str = yyvsp[0].expr.u.str;
  849.                 if (command_match_symbol(command_scope, str, &yyval.expr.u.sym))
  850.                 {
  851.                     yyval.expr.type = ca_SYM;
  852. //                    logger(_L | LOG_USER, "got an ID (%s)\n", str);
  853.                 }
  854.                 else
  855.                 {
  856.                                 logger(_L |LOG_USER|LOG_ERROR, "unknown identifier '%s'\n", 
  857.                                         str);
  858.                                 yyval.expr.type = ca_SYM;
  859.                                 yyval.expr.u.sym = NULL;
  860.                 }
  861.                             ;
  862.     break;}
  863. case 14:
  864. #line 145 "command.y"
  865. { ASSIGNSTMT(yyvsp[-2].expr, yyvsp[0].expr);  ;
  866.     break;}
  867. case 15:
  868. #line 152 "command.y"
  869. { yyvsp[0].expr.type = ca_VOID; ;
  870.     break;}
  871. case 16:
  872. #line 159 "command.y"
  873. {
  874.                                 if (yyvsp[-6].expr.u.sym == NULL) {
  875.                                     yyval.expr.type = ca_VOID;    // error case
  876.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-6].expr.u.sym, 
  877.                                             &yyvsp[-5].expr, &yyvsp[-4].expr, &yyvsp[-3].expr, &yyvsp[-2].expr, &yyvsp[-1].expr, &yyvsp[0].expr, NULL)) {
  878.                                     yyval.expr.type = ca_VOID;    // error case
  879.                                 }
  880.                                 ;
  881.     break;}
  882. case 17:
  883. #line 168 "command.y"
  884. {
  885.                                 if (yyvsp[-5].expr.u.sym == NULL) {
  886.                                     yyval.expr.type = ca_VOID;    // error case
  887.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-5].expr.u.sym, 
  888.                                             &yyvsp[-4].expr, &yyvsp[-3].expr, &yyvsp[-2].expr, &yyvsp[-1].expr, &yyvsp[0].expr, NULL)) {
  889.                                     yyval.expr.type = ca_VOID;    // error case
  890.                                 }
  891.                                 ;
  892.     break;}
  893. case 18:
  894. #line 177 "command.y"
  895. {
  896.                                 if (yyvsp[-4].expr.u.sym == NULL) {
  897.                                     yyval.expr.type = ca_VOID;    // error case
  898.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-4].expr.u.sym, 
  899.                                             &yyvsp[-3].expr, &yyvsp[-2].expr, &yyvsp[-1].expr, &yyvsp[0].expr, NULL)) {
  900.                                     yyval.expr.type = ca_VOID;    // error case
  901.                                 }
  902.                                 ;
  903.     break;}
  904. case 19:
  905. #line 186 "command.y"
  906. {
  907.                                 if (yyvsp[-3].expr.u.sym == NULL) {
  908.                                     yyval.expr.type = ca_VOID;    // error case
  909.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-3].expr.u.sym, 
  910.                                             &yyvsp[-2].expr, &yyvsp[-1].expr, &yyvsp[0].expr, NULL)) {
  911.                                     yyval.expr.type = ca_VOID;    // error case
  912.                                 }
  913.                                 ;
  914.     break;}
  915. case 20:
  916. #line 195 "command.y"
  917. {
  918.                                 if (yyvsp[-2].expr.u.sym == NULL) {
  919.                                     yyval.expr.type = ca_VOID;    // error case
  920.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-2].expr.u.sym, 
  921.                                             &yyvsp[-1].expr, &yyvsp[0].expr, NULL)) {
  922.                                     yyval.expr.type = ca_VOID;    // error case
  923.                                 }
  924.                                 ;
  925.     break;}
  926. case 21:
  927. #line 204 "command.y"
  928.                                  if (yyvsp[-1].expr.u.sym == NULL) {
  929.                                     yyval.expr.type = ca_VOID;    // error case
  930.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-1].expr.u.sym, 
  931.                                             &yyvsp[0].expr, NULL)) {
  932.                                         yyval.expr.type = ca_VOID;    // error case
  933.                                     }
  934.                                 ;
  935.     break;}
  936. case 22:
  937. #line 212 "command.y"
  938. {
  939.                                 if (yyvsp[0].expr.u.sym != NULL) 
  940.                                    command_set_args(NULL, yyvsp[0].expr.u.sym, NULL);
  941.                         ;
  942.     break;}
  943. case 23:
  944. #line 218 "command.y"
  945. { yyval.expr = yyvsp[0].expr; ;
  946.     break;}
  947. case 24:
  948. #line 219 "command.y"
  949. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,",",|,,yyvsp[0].expr);
  950.                                  ;
  951.     break;}
  952. case 25:
  953. #line 225 "command.y"
  954. { ASSIGN(yyval.expr, yyvsp[-2].expr, yyvsp[0].expr); ;
  955.     break;}
  956. case 26:
  957. #line 226 "command.y"
  958. { yyval.expr = yyvsp[0].expr; ;
  959.     break;}
  960. case 27:
  961. #line 229 "command.y"
  962. { yyval.expr = yyvsp[0].expr; ;
  963.     break;}
  964. case 28:
  965. #line 230 "command.y"
  966. {
  967.                                 if (yyvsp[-4].expr.type == ca_NUM && yyvsp[-4].expr.u.num)
  968.                                     yyval.expr = yyvsp[-2].expr;
  969.                                 else if (yyvsp[-4].expr.type == ca_NUM && !yyvsp[-4].expr.u.num)
  970.                                     yyval.expr = yyvsp[0].expr;
  971.                                 else if (yyvsp[-4].expr.type == ca_STRING && *yyvsp[-4].expr.u.str)
  972.                                     yyval.expr = yyvsp[-2].expr;
  973.                                 else if (yyvsp[-4].expr.type == ca_STRING && !*yyvsp[-4].expr.u.str)
  974.                                     yyval.expr = yyvsp[0].expr;
  975.                                 else 
  976.                                     parse_error("invalid arguments to '?:'");
  977.                                     
  978.                                 ;
  979.     break;}
  980. case 29:
  981. #line 245 "command.y"
  982. { yyval.expr =  yyvsp[0].expr; ;
  983.     break;}
  984. case 30:
  985. #line 246 "command.y"
  986. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"&&",&&,,yyvsp[0].expr);    ;
  987.     break;}
  988. case 31:
  989. #line 248 "command.y"
  990. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"||",||,,yyvsp[0].expr); ;
  991.     break;}
  992. case 32:
  993. #line 250 "command.y"
  994. { NUMBINOP(yyval.expr,!!, yyvsp[-2].expr, "^^", !=, !!,yyvsp[0].expr); ;
  995.     break;}
  996. case 33:
  997. #line 253 "command.y"
  998. { yyval.expr = yyvsp[0].expr; ;
  999.     break;}
  1000. case 34:
  1001. #line 254 "command.y"
  1002. { NUMBINOP(yyval.expr,,yyvsp[-2].expr, "&", &,,yyvsp[0].expr); ;
  1003.     break;}
  1004. case 35:
  1005. #line 256 "command.y"
  1006. { NUMBINOP(yyval.expr,,yyvsp[-2].expr, "|", |,,yyvsp[0].expr); ;
  1007.     break;}
  1008. case 36:
  1009. #line 258 "command.y"
  1010. { NUMBINOP(yyval.expr,,yyvsp[-2].expr, "^", ^,,yyvsp[0].expr); ;
  1011.     break;}
  1012. case 37:
  1013. #line 261 "command.y"
  1014. { yyval.expr = yyvsp[0].expr; ;
  1015.     break;}
  1016. case 38:
  1017. #line 263 "command.y"
  1018. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"==",==,,yyvsp[0].expr); ;
  1019.     break;}
  1020. case 39:
  1021. #line 264 "command.y"
  1022. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"!=",!=,,yyvsp[0].expr); ;
  1023.     break;}
  1024. case 40:
  1025. #line 267 "command.y"
  1026. { yyval.expr = yyvsp[0].expr; ;
  1027.     break;}
  1028. case 41:
  1029. #line 269 "command.y"
  1030. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"<=",<=,,yyvsp[0].expr); ;
  1031.     break;}
  1032. case 42:
  1033. #line 271 "command.y"
  1034. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,">=",>=,,yyvsp[0].expr); ;
  1035.     break;}
  1036. case 43:
  1037. #line 273 "command.y"
  1038. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,">",>,,yyvsp[0].expr); ;
  1039.     break;}
  1040. case 44:
  1041. #line 275 "command.y"
  1042. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"<",<,,yyvsp[0].expr); ;
  1043.     break;}
  1044. case 45:
  1045. #line 278 "command.y"
  1046. { yyval.expr = yyvsp[0].expr; ;
  1047.     break;}
  1048. case 46:
  1049. #line 279 "command.y"
  1050. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"<<",<<,,yyvsp[0].expr); ;
  1051.     break;}
  1052. case 47:
  1053. #line 280 "command.y"
  1054. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,">>",>>,,yyvsp[0].expr); ;
  1055.     break;}
  1056. case 48:
  1057. #line 282 "command.y"
  1058. { yyval.expr = yyvsp[0].expr; ;
  1059.     break;}
  1060. case 49:
  1061. #line 283 "command.y"
  1062. {
  1063.                                 if (yyvsp[-2].expr.type == ca_NUM && yyvsp[0].expr.type == ca_NUM) {
  1064.                                     yyval.expr.type = ca_NUM;
  1065.                                     yyval.expr.u.num = yyvsp[-2].expr.u.num + yyvsp[0].expr.u.num;
  1066.                                 } else if (yyvsp[-2].expr.type == ca_STRING && 
  1067.                                             yyvsp[0].expr.type == ca_STRING) {
  1068.                                     yyval.expr.type = ca_STRING;
  1069.                                     yyval.expr.u.str = (char *)xrealloc(yyvsp[-2].expr.u.str, 
  1070.                                                 strlen(yyvsp[-2].expr.u.str) + strlen(yyvsp[0].expr.u.str) + 1);
  1071.                                     strcat(yyval.expr.u.str, yyvsp[0].expr.u.str);
  1072.                                     free(yyvsp[0].expr.u.str);
  1073.                                 } else {
  1074.                                     yyval.expr.type = ca_VOID;
  1075.                                     parse_error("type mismatch in '+'");
  1076.                                 }
  1077.                                 ;
  1078.     break;}
  1079. case 50:
  1080. #line 300 "command.y"
  1081. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"-",-,,yyvsp[0].expr); ;
  1082.     break;}
  1083. case 51:
  1084. #line 303 "command.y"
  1085. {
  1086.                                 yyval.expr = yyvsp[0].expr; 
  1087.                                 ;
  1088.     break;}
  1089. case 52:
  1090. #line 306 "command.y"
  1091. { NUMBINOP(yyval.expr,,yyvsp[-2].expr,"*",*,,yyvsp[0].expr); ;
  1092.     break;}
  1093. case 53:
  1094. #line 307 "command.y"
  1095. {
  1096.                                 if (yyvsp[-2].expr.type == ca_NUM && yyvsp[0].expr.type == ca_NUM) {
  1097.                                     yyval.expr.type = ca_NUM;
  1098.                                     if (yyvsp[0].expr.u.num <= yyval.expr.u.num / 65536) {
  1099.                                         parse_error("divide overflow in '/'");
  1100.                                         yyval.expr.u.num = 0;
  1101.                                     } else {
  1102.                                         yyval.expr.u.num /= yyvsp[0].expr.u.num;
  1103.                                     }
  1104.                                 } else {
  1105.                                     yyval.expr.type = ca_VOID;
  1106.                                     parse_error("expected numeric arguments for '/'");
  1107.                                 }
  1108.                                 ;
  1109.     break;}
  1110. case 54:
  1111. #line 324 "command.y"
  1112. { yyval.expr = yyvsp[0].expr; ;
  1113.     break;}
  1114. case 55:
  1115. #line 326 "command.y"
  1116. { NUMUNOP(yyval.expr,"unary minus",-,,yyvsp[0].expr); ;
  1117.     break;}
  1118. case 56:
  1119. #line 328 "command.y"
  1120. { NUMUNOP(yyval.expr,"!",!,,yyvsp[0].expr); ;
  1121.     break;}
  1122. case 57:
  1123. #line 330 "command.y"
  1124. { NUMUNOP(yyval.expr,"~",~,,yyvsp[0].expr); ;
  1125.     break;}
  1126. case 58:
  1127. #line 334 "command.y"
  1128. { printf("!!! error !!!\n"); 
  1129.                                     yyerrok; ;
  1130.     break;}
  1131. case 59:
  1132. #line 336 "command.y"
  1133. { //printf("!!! num (%d)\n",$1.u.num); 
  1134.                                     yyval.expr.type = ca_NUM; yyval.expr.u.num = yyvsp[0].expr.u.num; ;
  1135.     break;}
  1136. case 60:
  1137. #line 339 "command.y"
  1138. { //printf("ID\n");     
  1139.                                     yyval.expr.type = ca_STRING; yyval.expr.u.str = yyvsp[0].expr.u.str;
  1140.                                 ;
  1141.     break;}
  1142. case 61:
  1143. #line 342 "command.y"
  1144.                                     yyval.expr = yyvsp[0].expr;
  1145.                                 ;
  1146.     break;}
  1147. case 62:
  1148. #line 361 "command.y"
  1149. {
  1150.                                 if (yyvsp[-3].expr.u.sym == NULL) {
  1151.                                     yyval.expr.type = ca_VOID;    // error case
  1152.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-3].expr.u.sym, 
  1153.                                             &yyvsp[-1].expr, NULL)) {
  1154.                                         yyval.expr.type = ca_VOID;    // error case
  1155.                                     }
  1156.                                 ;
  1157.     break;}
  1158. case 63:
  1159. #line 372 "command.y"
  1160. {
  1161.                                 if (yyvsp[-5].expr.u.sym == NULL) {
  1162.                                     yyval.expr.type = ca_VOID;    // error case
  1163.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-5].expr.u.sym, 
  1164.                                             &yyvsp[-3].expr, &yyvsp[-1].expr, NULL)) {
  1165.                                     yyval.expr.type = ca_VOID;    // error case
  1166.                                 }
  1167.                                 ;
  1168.     break;}
  1169. case 64:
  1170. #line 382 "command.y"
  1171. {
  1172.                                 if (yyvsp[-7].expr.u.sym == NULL) {
  1173.                                     yyval.expr.type = ca_VOID;    // error case
  1174.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-7].expr.u.sym, 
  1175.                                             &yyvsp[-5].expr, &yyvsp[-3].expr, &yyvsp[-1].expr, NULL)) {
  1176.                                     yyval.expr.type = ca_VOID;    // error case
  1177.                                 }
  1178.                                 ;
  1179.     break;}
  1180. case 65:
  1181. #line 392 "command.y"
  1182. {
  1183.                                 if (yyvsp[-9].expr.u.sym == NULL) {
  1184.                                     yyval.expr.type = ca_VOID;    // error case
  1185.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-9].expr.u.sym, 
  1186.                                             &yyvsp[-7].expr, &yyvsp[-5].expr, &yyvsp[-3].expr, &yyvsp[-1].expr, NULL)) {
  1187.                                     yyval.expr.type = ca_VOID;    // error case
  1188.                                 }
  1189.                                 ;
  1190.     break;}
  1191. case 66:
  1192. #line 402 "command.y"
  1193. {
  1194.                                 if (yyvsp[-11].expr.u.sym == NULL) {
  1195.                                     yyval.expr.type = ca_VOID;    // error case
  1196.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-11].expr.u.sym, 
  1197.                                             &yyvsp[-9].expr, &yyvsp[-7].expr, &yyvsp[-5].expr, &yyvsp[-3].expr, &yyvsp[-1].expr, NULL)) {
  1198.                                     yyval.expr.type = ca_VOID;    // error case
  1199.                                 }
  1200.                                 ;
  1201.     break;}
  1202. case 67:
  1203. #line 412 "command.y"
  1204. {
  1205.                                 if (yyvsp[-13].expr.u.sym == NULL) {
  1206.                                     yyval.expr.type = ca_VOID;    // error case
  1207.                                 } else if (!command_set_args(&yyval.expr, yyvsp[-13].expr.u.sym, 
  1208.                                             &yyvsp[-11].expr, &yyvsp[-9].expr, &yyvsp[-7].expr, &yyvsp[-5].expr, &yyvsp[-3].expr, &yyvsp[-1].expr, NULL)) {
  1209.                                     yyval.expr.type = ca_VOID;    // error case
  1210.                                 }
  1211.                                 ;
  1212.     break;}
  1213. case 68:
  1214. #line 422 "command.y"
  1215. {
  1216.                                     if (!yyvsp[-1].expr.u.sym || !command_get_val(yyvsp[-1].expr.u.sym, &yyval.expr)) {
  1217.                                         yyval.expr.type = ca_VOID;    // error case
  1218.                                     }
  1219.                                 ;
  1220.     break;}
  1221. case 69:
  1222. #line 428 "command.y"
  1223. {
  1224.                                     yyval.expr = yyvsp[-1].expr;
  1225.                                 ;
  1226.     break;}
  1227. }
  1228.    /* the action file gets copied in in place of this dollarsign */
  1229. #line 543 "/usr/lib/bison.simple"
  1230.  
  1231.   yyvsp -= yylen;
  1232.   yyssp -= yylen;
  1233. #ifdef YYLSP_NEEDED
  1234.   yylsp -= yylen;
  1235. #endif
  1236.  
  1237. #if YYDEBUG != 0
  1238.   if (yydebug)
  1239.     {
  1240.       short *ssp1 = yyss - 1;
  1241.       fprintf (stderr, "state stack now");
  1242.       while (ssp1 != yyssp)
  1243.     fprintf (stderr, " %d", *++ssp1);
  1244.       fprintf (stderr, "\n");
  1245.     }
  1246. #endif
  1247.  
  1248.   *++yyvsp = yyval;
  1249.  
  1250. #ifdef YYLSP_NEEDED
  1251.   yylsp++;
  1252.   if (yylen == 0)
  1253.     {
  1254.       yylsp->first_line = yylloc.first_line;
  1255.       yylsp->first_column = yylloc.first_column;
  1256.       yylsp->last_line = (yylsp-1)->last_line;
  1257.       yylsp->last_column = (yylsp-1)->last_column;
  1258.       yylsp->text = 0;
  1259.     }
  1260.   else
  1261.     {
  1262.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1263.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1264.     }
  1265. #endif
  1266.  
  1267.   /* Now "shift" the result of the reduction.
  1268.      Determine what state that goes to,
  1269.      based on the state we popped back to
  1270.      and the rule number reduced by.  */
  1271.  
  1272.   yyn = yyr1[yyn];
  1273.  
  1274.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1275.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1276.     yystate = yytable[yystate];
  1277.   else
  1278.     yystate = yydefgoto[yyn - YYNTBASE];
  1279.  
  1280.   goto yynewstate;
  1281.  
  1282. yyerrlab:   /* here on detecting error */
  1283.  
  1284.   if (! yyerrstatus)
  1285.     /* If not already recovering from an error, report this error.  */
  1286.     {
  1287.       ++yynerrs;
  1288.  
  1289. #ifdef YYERROR_VERBOSE
  1290.       yyn = yypact[yystate];
  1291.  
  1292.       if (yyn > YYFLAG && yyn < YYLAST)
  1293.     {
  1294.       int size = 0;
  1295.       char *msg;
  1296.       int x, count;
  1297.  
  1298.       count = 0;
  1299.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1300.       for (x = (yyn < 0 ? -yyn : 0);
  1301.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1302.         if (yycheck[x + yyn] == x)
  1303.           size += strlen(yytname[x]) + 15, count++;
  1304.       msg = (char *) malloc(size + 15);
  1305.       if (msg != 0)
  1306.         {
  1307.           strcpy(msg, "parse error");
  1308.  
  1309.           if (count < 5)
  1310.         {
  1311.           count = 0;
  1312.           for (x = (yyn < 0 ? -yyn : 0);
  1313.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1314.             if (yycheck[x + yyn] == x)
  1315.               {
  1316.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1317.             strcat(msg, yytname[x]);
  1318.             strcat(msg, "'");
  1319.             count++;
  1320.               }
  1321.         }
  1322.           yyerror(msg);
  1323.           free(msg);
  1324.         }
  1325.       else
  1326.         yyerror ("parse error; also virtual memory exceeded");
  1327.     }
  1328.       else
  1329. #endif /* YYERROR_VERBOSE */
  1330.     yyerror("parse error");
  1331.     }
  1332.  
  1333.   goto yyerrlab1;
  1334. yyerrlab1:   /* here on error raised explicitly by an action */
  1335.  
  1336.   if (yyerrstatus == 3)
  1337.     {
  1338.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1339.  
  1340.       /* return failure if at end of input */
  1341.       if (yychar == YYEOF)
  1342.     YYABORT;
  1343.  
  1344. #if YYDEBUG != 0
  1345.       if (yydebug)
  1346.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1347. #endif
  1348.  
  1349.       yychar = YYEMPTY;
  1350.     }
  1351.  
  1352.   /* Else will try to reuse lookahead token
  1353.      after shifting the error token.  */
  1354.  
  1355.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1356.  
  1357.   goto yyerrhandle;
  1358.  
  1359. yyerrdefault:  /* current state does not do anything special for the error token. */
  1360.  
  1361. #if 0
  1362.   /* This is wrong; only states that explicitly want error tokens
  1363.      should shift them.  */
  1364.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1365.   if (yyn) goto yydefault;
  1366. #endif
  1367.  
  1368. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1369.  
  1370.   if (yyssp == yyss) YYABORT;
  1371.   yyvsp--;
  1372.   yystate = *--yyssp;
  1373. #ifdef YYLSP_NEEDED
  1374.   yylsp--;
  1375. #endif
  1376.  
  1377. #if YYDEBUG != 0
  1378.   if (yydebug)
  1379.     {
  1380.       short *ssp1 = yyss - 1;
  1381.       fprintf (stderr, "Error: state stack now");
  1382.       while (ssp1 != yyssp)
  1383.     fprintf (stderr, " %d", *++ssp1);
  1384.       fprintf (stderr, "\n");
  1385.     }
  1386. #endif
  1387.  
  1388. yyerrhandle:
  1389.  
  1390.   yyn = yypact[yystate];
  1391.   if (yyn == YYFLAG)
  1392.     goto yyerrdefault;
  1393.  
  1394.   yyn += YYTERROR;
  1395.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1396.     goto yyerrdefault;
  1397.  
  1398.   yyn = yytable[yyn];
  1399.   if (yyn < 0)
  1400.     {
  1401.       if (yyn == YYFLAG)
  1402.     goto yyerrpop;
  1403.       yyn = -yyn;
  1404.       goto yyreduce;
  1405.     }
  1406.   else if (yyn == 0)
  1407.     goto yyerrpop;
  1408.  
  1409.   if (yyn == YYFINAL)
  1410.     YYACCEPT;
  1411.  
  1412. #if YYDEBUG != 0
  1413.   if (yydebug)
  1414.     fprintf(stderr, "Shifting error token, ");
  1415. #endif
  1416.  
  1417.   *++yyvsp = yylval;
  1418. #ifdef YYLSP_NEEDED
  1419.   *++yylsp = yylloc;
  1420. #endif
  1421.  
  1422.   yystate = yyn;
  1423.   goto yynewstate;
  1424.  
  1425.  yyacceptlab:
  1426.   /* YYACCEPT comes here.  */
  1427.   if (yyfree_stacks)
  1428.     {
  1429.       free (yyss);
  1430.       free (yyvs);
  1431. #ifdef YYLSP_NEEDED
  1432.       free (yyls);
  1433. #endif
  1434.     }
  1435.   return 0;
  1436.  
  1437.  yyabortlab:
  1438.   /* YYABORT comes here.  */
  1439.   if (yyfree_stacks)
  1440.     {
  1441.       free (yyss);
  1442.       free (yyvs);
  1443. #ifdef YYLSP_NEEDED
  1444.       free (yyls);
  1445. #endif
  1446.     }
  1447.   return 1;
  1448. }
  1449. #line 435 "command.y"
  1450.  
  1451.  
  1452. void parse_error(const char *format, ...)
  1453. {
  1454.     va_list va;
  1455.     static char buf[256], *bptr;
  1456.     va_start(va, format);
  1457.     bptr = mvprintf(buf, sizeof(buf), format, va);
  1458.     lexer_error("%s", bptr);
  1459. }
  1460.  
  1461. int yyerror(char *s)
  1462. {
  1463.     parse_error("%s\n",s);
  1464.     return 0;
  1465. }
  1466.  
  1467. int    command_parse(command_symbol_table *universe)
  1468. {
  1469.     command_scope = universe;
  1470.     // ignore errors
  1471.     while (yyparse());
  1472.     return 1;
  1473. }
  1474.  
  1475.