home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 4.ddi / COM.ZIP / COMGRAM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-02  |  28.2 KB  |  978 lines

  1.  
  2. /*  A Bison parser, made from com.y  */
  3.  
  4. #define    YDEBUG    258
  5. #define    NOYDEBUG    259
  6. #define    SHIFT_RIGHT    260
  7. #define    SHIFT_LEFT    261
  8. #define    LOGICAL_OR    262
  9. #define    LOGICAL_AND    263
  10. #define    NOT_EQ    264
  11. #define    EQ    265
  12. #define    GT_EQ    266
  13. #define    LT_EQ    267
  14. #define    BYTE_LITCONST    268
  15. #define    CONSTANT    269
  16. #define    LITCONST    270
  17. #define    STRING    271
  18. #define    SEND    272
  19. #define    WAIT    273
  20. #define    FOR    274
  21. #define    EOL    275
  22. #define    ANYTHING    276
  23. #define    ELSE    277
  24. #define    END    278
  25. #define    BELL    279
  26. #define    NOTIFY    280
  27. #define    ON    281
  28. #define    OFF    282
  29. #define    SLOW    283
  30. #define    CLOSE    284
  31. #define    WINDOW    285
  32. #define    DISPLAYCOMMENT    286
  33. #define    ERASECOMMENT    287
  34.  
  35.  
  36. /* Make the generated module separately compilable */
  37.  
  38. #ifdef BORLAND
  39.  #pragma warn -sus                /* No suspicious pointer messages */
  40. #endif
  41.  
  42. #define YYDEBUG 1
  43. #define CUSTOM_SIZE 200            /* Initial allocation for custom resources */
  44.  
  45. extern "C" {
  46. #include    <String.H>
  47. #include    <CType.H>
  48. #include    <stdlib.h>
  49. #include    <stdio.h>
  50. #include    <io.h>
  51. }
  52.             
  53. #include    "pcodes.h"        /* P-codes understood by the com engine        */
  54.  
  55. extern    short  yystate;
  56. extern    FILE * comOut;
  57.         
  58. char    *p;                    /* General purpose pointer                    */
  59. char    *pbase;             /* Pointer to base of generic structure        */
  60. long    psize;                /* Size of data pointed to by p                */
  61. char    *junk;                /* Pointer to someting about to be trashed  */
  62. int        *pi;                /* Integer pointer                            */
  63. short   *ps;                /* Short pointer                            */
  64. int        x;                    /* Work variable                            */
  65.         
  66. int     yyerror(char *);
  67. int     yylex();
  68.         
  69.  
  70. typedef union
  71. {
  72.     int    ival;                /* Integer value                            */
  73.     long lval;                /* Long value                                */
  74.     char * ptr;                /* General pointer                            */
  75. } YYSTYPE;
  76.  
  77. #ifndef YYLTYPE
  78. typedef
  79.   struct yyltype
  80.     {
  81.       int timestamp;
  82.       int first_line;
  83.       int first_column;
  84.       int last_line;
  85.       int last_column;
  86.       char *text;
  87.    }
  88.   yyltype;
  89.  
  90. #define YYLTYPE yyltype
  91. #endif
  92.  
  93. #include <stdio.h>
  94.  
  95. #ifndef __STDC__
  96. #define const
  97. #endif
  98.  
  99.  
  100.  
  101. #define    YYFINAL        91
  102. #define    YYFLAG        -32768
  103. #define    YYNTBASE    50
  104.  
  105. #define YYTRANSLATE(x) ((unsigned)(x) <= 287 ? yytranslate[x] : 67)
  106.  
  107. static const char yytranslate[] = {     0,
  108.      2,     2,     2,     2,     2,     2,     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,    43,     2,     2,     2,    42,    35,     2,    48,
  112.     49,    40,    38,    45,    39,     2,    41,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,    47,    36,
  114.     46,    37,     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,    34,     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,    33,     2,    44,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  122.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  123.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  124.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  125.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  126.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  127.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  128.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  129.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  130.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  131.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  132.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  133.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  134.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  135.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  136.     26,    27,    28,    29,    30,    31,    32
  137. };
  138.  
  139. static const short yyrline[] = {     0,
  140.    107,   108,   109,   110,   113,   114,   115,   116,   117,   118,
  141.    119,   120,   121,   122,   125,   131,   141,   147,   154,   162,
  142.    168,   176,   187,   197,   201,   208,   214,   223,   230,   231,
  143.    235,   236,   240,   244,   248,   252,   256,   260,   264,   268,
  144.    272,   276,   280,   284,   288,   292,   296,   300,   304,   308,
  145.    312,   316,   327,   335,   338,   341
  146. };
  147.  
  148. static const char * const yytname[] = {     0,
  149. "error","$illegal.","YDEBUG","NOYDEBUG","SHIFT_RIGHT","SHIFT_LEFT","LOGICAL_OR","LOGICAL_AND","NOT_EQ","EQ",
  150. "GT_EQ","LT_EQ","BYTE_LITCONST","CONSTANT","LITCONST","STRING","SEND","WAIT","FOR","EOL",
  151. "ANYTHING","ELSE","END","BELL","NOTIFY","ON","OFF","SLOW","CLOSE","WINDOW",
  152. "DISPLAYCOMMENT","ERASECOMMENT","'|'","'^'","'&'","'<'","'>'","'+'","'-'","'*'",
  153. "'/'","'%'","'!'","'~'","','","'='","';'","'('","')'","com"
  154. };
  155.  
  156. static const short yyr1[] = {     0,
  157.     50,    50,    50,    50,    51,    51,    51,    51,    51,    51,
  158.     51,    51,    51,    51,    52,    53,    54,    55,    56,    57,
  159.     58,    58,    59,    60,    60,    61,    62,    62,    63,    63,
  160.     63,    63,    63,    63,    63,    63,    63,    63,    63,    63,
  161.     63,    63,    63,    63,    63,    63,    63,    63,    63,    63,
  162.     63,    63,    63,    64,    65,    66
  163. };
  164.  
  165. static const short yyr2[] = {     0,
  166.      0,     2,     2,     2,     1,     1,     1,     1,     1,     1,
  167.      1,     1,     1,     1,     3,     2,     1,     2,     2,     1,
  168.      2,     3,     3,     2,     2,     1,     2,     2,     1,     1,
  169.      1,     2,     2,     2,     3,     3,     3,     3,     3,     3,
  170.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  171.      3,     3,     3,     1,     1,     1
  172. };
  173.  
  174. static const short yydefact[] = {     1,
  175.      0,     4,     0,     0,     0,    20,    26,     0,     0,     0,
  176.     17,     0,     2,     3,    12,    13,    11,    10,     5,     6,
  177.      7,    14,     9,     8,    24,    25,    21,     0,    56,    54,
  178.     55,     0,     0,     0,     0,     0,    19,    29,    31,    30,
  179.     27,    28,    18,    16,     0,    22,    23,    32,    34,    33,
  180.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  181.      0,     0,     0,     0,     0,     0,     0,     0,     0,    15,
  182.     35,    36,    37,    39,    40,    43,    44,    45,    46,    41,
  183.     38,    42,    48,    47,    50,    49,    51,    52,    53,     0,
  184.      0
  185. };
  186.  
  187. static const short yydefgoto[] = {     1,
  188.     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
  189.     23,    24,    37,    38,    39,    40
  190. };
  191.  
  192. static const short yypact[] = {-32768,
  193.     58,-32768,     0,    -3,   224,-32768,-32768,    -7,   -11,    12,
  194. -32768,   227,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  195. -32768,-32768,-32768,-32768,-32768,-32768,-32768,    23,-32768,-32768,
  196. -32768,    44,   227,   227,   227,   227,    -4,-32768,-32768,-32768,
  197. -32768,-32768,-32768,-32768,   104,-32768,-32768,   -30,-32768,-32768,
  198.     59,   227,   227,   227,   227,   227,   227,   227,   227,   227,
  199.    227,   227,   227,   227,   227,   227,   227,   227,   227,-32768,
  200. -32768,   -24,   -24,   119,   157,   220,   220,    79,    79,   166,
  201.    174,   212,    79,    79,   -30,   -30,-32768,-32768,-32768,    62,
  202. -32768
  203. };
  204.  
  205. static const short yypgoto[] = {-32768,
  206. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  207. -32768,-32768,   -12,-32768,-32768,-32768
  208. };
  209.  
  210.  
  211. #define    YYLAST        275
  212.  
  213.  
  214. static const short yytable[] = {    45,
  215.     52,    53,    54,    55,    56,    57,    58,    59,    41,    67,
  216.     68,    69,    27,    65,    66,    67,    68,    69,    43,    42,
  217.     48,    49,    50,    51,    28,    25,    26,    44,    60,    61,
  218.     62,    63,    64,    65,    66,    67,    68,    69,    46,    72,
  219.     73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
  220.     83,    84,    85,    86,    87,    88,    89,    90,     2,    47,
  221.      3,    91,     0,    52,    53,    54,    55,    56,    57,    58,
  222.     59,     0,     0,     0,     4,     5,     0,     0,     0,     0,
  223.      6,     7,     8,    52,    53,     0,     9,     0,    10,    11,
  224.      0,    60,    61,    62,    63,    64,    65,    66,    67,    68,
  225.     69,     0,     0,    12,     0,     0,     0,    71,    52,    53,
  226.     54,    55,    56,    57,    58,    59,    65,    66,    67,    68,
  227.     69,     0,     0,    52,    53,     0,    55,    56,    57,    58,
  228.     59,     0,     0,     0,     0,     0,    60,    61,    62,    63,
  229.     64,    65,    66,    67,    68,    69,     0,     0,     0,     0,
  230.     70,    60,    61,    62,    63,    64,    65,    66,    67,    68,
  231.     69,    52,    53,     0,     0,    56,    57,    58,    59,     0,
  232.     52,    53,     0,     0,    56,    57,    58,    59,    52,    53,
  233.      0,     0,    56,    57,    58,    59,     0,     0,     0,    60,
  234.     61,    62,    63,    64,    65,    66,    67,    68,    69,    61,
  235.     62,    63,    64,    65,    66,    67,    68,    69,    62,    63,
  236.     64,    65,    66,    67,    68,    69,    52,    53,     0,     0,
  237.     56,    57,    58,    59,    52,    53,     0,     0,     0,     0,
  238.     58,    59,     0,     0,     0,     0,    29,    30,    31,    29,
  239.     30,    31,    32,     0,     0,     0,     0,    63,    64,    65,
  240.     66,    67,    68,    69,     0,    63,    64,    65,    66,    67,
  241.     68,    69,    33,     0,     0,    33,    34,    35,     0,    34,
  242.     35,    36,     0,     0,    36
  243. };
  244.  
  245. static const short yycheck[] = {    12,
  246.      5,     6,     7,     8,     9,    10,    11,    12,    16,    40,
  247.     41,    42,    16,    38,    39,    40,    41,    42,    30,    27,
  248.     33,    34,    35,    36,    28,    26,    27,    16,    33,    34,
  249.     35,    36,    37,    38,    39,    40,    41,    42,    16,    52,
  250.     53,    54,    55,    56,    57,    58,    59,    60,    61,    62,
  251.     63,    64,    65,    66,    67,    68,    69,     0,     1,    16,
  252.      3,     0,    -1,     5,     6,     7,     8,     9,    10,    11,
  253.     12,    -1,    -1,    -1,    17,    18,    -1,    -1,    -1,    -1,
  254.     23,    24,    25,     5,     6,    -1,    29,    -1,    31,    32,
  255.     -1,    33,    34,    35,    36,    37,    38,    39,    40,    41,
  256.     42,    -1,    -1,    46,    -1,    -1,    -1,    49,     5,     6,
  257.      7,     8,     9,    10,    11,    12,    38,    39,    40,    41,
  258.     42,    -1,    -1,     5,     6,    -1,     8,     9,    10,    11,
  259.     12,    -1,    -1,    -1,    -1,    -1,    33,    34,    35,    36,
  260.     37,    38,    39,    40,    41,    42,    -1,    -1,    -1,    -1,
  261.     47,    33,    34,    35,    36,    37,    38,    39,    40,    41,
  262.     42,     5,     6,    -1,    -1,     9,    10,    11,    12,    -1,
  263.      5,     6,    -1,    -1,     9,    10,    11,    12,     5,     6,
  264.     -1,    -1,     9,    10,    11,    12,    -1,    -1,    -1,    33,
  265.     34,    35,    36,    37,    38,    39,    40,    41,    42,    34,
  266.     35,    36,    37,    38,    39,    40,    41,    42,    35,    36,
  267.     37,    38,    39,    40,    41,    42,     5,     6,    -1,    -1,
  268.      9,    10,    11,    12,     5,     6,    -1,    -1,    -1,    -1,
  269.     11,    12,    -1,    -1,    -1,    -1,    13,    14,    15,    13,
  270.     14,    15,    19,    -1,    -1,    -1,    -1,    36,    37,    38,
  271.     39,    40,    41,    42,    -1,    36,    37,    38,    39,    40,
  272.     41,    42,    39,    -1,    -1,    39,    43,    44,    -1,    43,
  273.     44,    48,    -1,    -1,    48
  274. };
  275. #define YYPURE 1
  276.  
  277. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  278.  
  279.  
  280. /* Skeleton output parser for bison,
  281.    Copyright (C) 1984 Bob Corbett and Richard Stallman
  282.  
  283.    This program is free software; you can redistribute it and/or modify
  284.    it under the terms of the GNU General Public License as published by
  285.    the Free Software Foundation; either version 1, or (at your option)
  286.    any later version.
  287.  
  288.    This program is distributed in the hope that it will be useful,
  289.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  290.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  291.    GNU General Public License for more details.
  292.  
  293.    You should have received a copy of the GNU General Public License
  294.    along with this program; if not, write to the Free Software
  295.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  296.  
  297.  
  298. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  299. #include <alloca.h>
  300. #endif
  301.  
  302. /* TCC */
  303. #ifdef MSDOS
  304. #define bcopy(s, d, l) memcpy((d), (s), (l))
  305. char * alloca (unsigned);
  306. #endif
  307.  
  308. /* This is the parser code that is written into each bison parser
  309.   when the %semantic_parser declaration is not specified in the grammar.
  310.   It was written by Richard Stallman by simplifying the hairy parser
  311.   used when %semantic_parser is specified.  */
  312.  
  313. /* Note: there must be only one dollar sign in this file.
  314.    It is replaced by the list of actions, each action
  315.    as one case of the switch.  */
  316.  
  317. #define yyerrok        (yyerrstatus = 0)
  318. #define yyclearin    (yychar = YYEMPTY)
  319. #define YYEMPTY        -2
  320. #define YYEOF        0
  321. #define YYFAIL        goto yyerrlab;
  322. #define YYACCEPT    return(0)
  323. #define YYABORT     return(1)
  324. #define YYERROR        goto yyerrlab
  325.  
  326. #define YYTERROR    1
  327. #define YYERRCODE    256
  328.  
  329. #ifndef YYIMPURE
  330. #define YYLEX        yylex()
  331. #endif
  332.  
  333. #ifndef YYPURE
  334. #define YYLEX        yylex(&yylval, &yylloc)
  335. #endif
  336.  
  337. /* If nonreentrant, generate the variables here */
  338.  
  339. #ifndef YYIMPURE
  340.  
  341. int    yychar;            /*  the lookahead symbol        */
  342. YYSTYPE    yylval;            /*  the semantic value of the        */
  343.                 /*  lookahead symbol            */
  344.  
  345. YYLTYPE yylloc;            /*  location data for the lookahead    */
  346.                 /*  symbol                */
  347.  
  348. int yynerrs;            /*  number of parse errors so far       */
  349. #endif  /* YYIMPURE */
  350.  
  351. #if YYDEBUG != 0
  352. int yydebug;            /*  nonzero means print parse trace    */
  353. /* Since this is uninitialized, it does not stop multiple parsers
  354.    from coexisting.  */
  355. #endif
  356.  
  357. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  358.  
  359. #ifndef    YYMAXDEPTH
  360. #define YYMAXDEPTH 200
  361. #endif
  362.  
  363. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  364.     (effective only if the built-in stack extension method is used).  */
  365.  
  366. #ifndef YYMAXLIMIT
  367. #define YYMAXLIMIT 10000
  368. #endif
  369.  
  370.  
  371.  
  372. int
  373. yyparse()
  374. {
  375.   register int yystate;
  376.   register int yyn;
  377.   register short *yyssp;
  378.   register YYSTYPE *yyvsp;
  379.   YYLTYPE *yylsp;
  380.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  381.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  382.  
  383.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  384.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  385.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  386.  
  387.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  388.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  389.   YYLTYPE *yyls = yylsa;
  390.  
  391.   int yymaxdepth = YYMAXDEPTH;
  392.  
  393. #ifndef YYPURE
  394.   int yychar;
  395.   YYSTYPE yylval;
  396.   YYLTYPE yylloc;
  397.   int yynerrs;
  398. #endif
  399.  
  400.   YYSTYPE yyval;        /*  the variable used to return        */
  401.                 /*  semantic values from the action    */
  402.                 /*  routines                */
  403.  
  404.   int yylen;
  405.  
  406. #if YYDEBUG != 0
  407.   if (yydebug)
  408.     fprintf(stderr, "Starting parse\n");
  409. #endif
  410.  
  411.   yystate = 0;
  412.   yyerrstatus = 0;
  413.   yynerrs = 0;
  414.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  415.  
  416.   /* Initialize stack pointers.
  417.      Waste one element of value and location stack
  418.      so that they stay on the same level as the state stack.  */
  419.  
  420.   yyssp = yyss - 1;
  421.   yyvsp = yyvs;
  422.   yylsp = yyls;
  423.  
  424. /* Push a new state, which is found in  yystate  .  */
  425. /* In all cases, when you get here, the value and location stacks
  426.    have just been pushed. so pushing a state here evens the stacks.  */
  427. yynewstate:
  428.  
  429.   *++yyssp = yystate;
  430.  
  431.   if (yyssp >= yyss + yymaxdepth - 1)
  432.     {
  433.       /* Give user a chance to reallocate the stack */
  434.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  435.       YYSTYPE *yyvs1 = yyvs;
  436.       YYLTYPE *yyls1 = yyls;
  437.       short *yyss1 = yyss;
  438.  
  439.       /* Get the current used size of the three stacks, in elements.  */
  440.       int size = yyssp - yyss + 1;
  441.  
  442. #ifdef yyoverflow
  443.       /* Each stack pointer address is followed by the size of
  444.      the data in use in that stack, in bytes.  */
  445.       yyoverflow("parser stack overflow",
  446.          &yyss1, size * sizeof (*yyssp),
  447.          &yyvs1, size * sizeof (*yyvsp),
  448.          &yyls1, size * sizeof (*yylsp),
  449.          &yymaxdepth);
  450.  
  451.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  452. #else /* no yyoverflow */
  453.       /* Extend the stack our own way.  */
  454.       if (yymaxdepth >= YYMAXLIMIT)
  455.     yyerror("parser stack overflow");
  456.       yymaxdepth *= 2;
  457.       if (yymaxdepth > YYMAXLIMIT)
  458.     yymaxdepth = YYMAXLIMIT;
  459.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  460.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  461.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  462.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  463. #ifdef YYLSP_NEEDED
  464.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  465.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  466. #endif
  467. #endif /* no yyoverflow */
  468.  
  469.       yyssp = yyss + size - 1;
  470.       yyvsp = yyvs + size - 1;
  471. #ifdef YYLSP_NEEDED
  472.       yylsp = yyls + size - 1;
  473. #endif
  474.  
  475. #if YYDEBUG != 0
  476.       if (yydebug)
  477.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  478. #endif
  479.  
  480.       if (yyssp >= yyss + yymaxdepth - 1)
  481.     YYABORT;
  482.     }
  483.  
  484. #if YYDEBUG != 0
  485.   if (yydebug)
  486.     fprintf(stderr, "Entering state %d\n", yystate);
  487. #endif
  488.  
  489. /* Do appropriate processing given the current state.  */
  490. /* Read a lookahead token if we need one and don't already have one.  */
  491. yyresume:
  492.  
  493.   /* First try to decide what to do without reference to lookahead token.  */
  494.  
  495.   yyn = yypact[yystate];
  496.   if (yyn == YYFLAG)
  497.     goto yydefault;
  498.  
  499.   /* Not known => get a lookahead token if don't already have one.  */
  500.  
  501.   /* yychar is either YYEMPTY or YYEOF
  502.      or a valid token in external form.  */
  503.  
  504.   if (yychar == YYEMPTY)
  505.     {
  506. #if YYDEBUG != 0
  507.       if (yydebug)
  508.     fprintf(stderr, "Reading a token: ");
  509. #endif
  510.       yychar = YYLEX;
  511.     }
  512.  
  513.   /* Convert token to internal form (in yychar1) for indexing tables with */
  514.  
  515.   if (yychar <= 0)        /* This means end of input. */
  516.     {
  517.       yychar1 = 0;
  518.       yychar = YYEOF;        /* Don't call YYLEX any more */
  519.  
  520. #if YYDEBUG != 0
  521.       if (yydebug)
  522.     fprintf(stderr, "Now at end of input.\n");
  523. #endif
  524.     }
  525.   else
  526.     {
  527.       yychar1 = YYTRANSLATE(yychar);
  528.  
  529. #if YYDEBUG != 0
  530.       if (yydebug)
  531.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  532. #endif
  533.     }
  534.  
  535.   yyn += yychar1;
  536.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  537.     goto yydefault;
  538.  
  539.   yyn = yytable[yyn];
  540.  
  541.   /* yyn is what to do for this token type in this state.
  542.      Negative => reduce, -yyn is rule number.
  543.      Positive => shift, yyn is new state.
  544.        New state is final state => don't bother to shift,
  545.        just return success.
  546.      0, or most negative number => error.  */
  547.  
  548.   if (yyn < 0)
  549.     {
  550.       if (yyn == YYFLAG)
  551.     goto yyerrlab;
  552.       yyn = -yyn;
  553.       goto yyreduce;
  554.     }
  555.   else if (yyn == 0)
  556.     goto yyerrlab;
  557.  
  558.   if (yyn == YYFINAL)
  559.     YYACCEPT;
  560.  
  561.   /* Shift the lookahead token.  */
  562.  
  563. #if YYDEBUG != 0
  564.   if (yydebug)
  565.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  566. #endif
  567.  
  568.   /* Discard the token being shifted unless it is eof.  */
  569.   if (yychar != YYEOF)
  570.     yychar = YYEMPTY;
  571.  
  572.   *++yyvsp = yylval;
  573. #ifdef YYLSP_NEEDED
  574.   *++yylsp = yylloc;
  575. #endif
  576.  
  577.   /* count tokens shifted since error; after three, turn off error status.  */
  578.   if (yyerrstatus) yyerrstatus--;
  579.  
  580.   yystate = yyn;
  581.   goto yynewstate;
  582.  
  583. /* Do the default action for the current state.  */
  584. yydefault:
  585.  
  586.   yyn = yydefact[yystate];
  587.   if (yyn == 0)
  588.     goto yyerrlab;
  589.  
  590. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  591. yyreduce:
  592.   yylen = yyr2[yyn];
  593.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  594.  
  595. #if YYDEBUG != 0
  596.   if (yydebug)
  597.     {
  598.       if (yylen == 1)
  599.     fprintf (stderr, "Reducing 1 value via line %d, ",
  600.          yyrline[yyn]);
  601.       else
  602.     fprintf (stderr, "Reducing %d values via line %d, ",
  603.          yylen, yyrline[yyn]);
  604.     }
  605. #endif
  606.  
  607.  
  608.   switch (yyn) {
  609.  
  610. case 15:
  611. {
  612.                         printf ("Result=%i\n", yyvsp[-1].lval);
  613.                     ;
  614.     break;}
  615. case 16:
  616. {
  617.                         fputc(PC_DISPCOM, comOut);    // Display comment text
  618.                         /* Length is +2 to include length byte + terminator */
  619.                         fputc(strlen(yyvsp[0].ptr)+2, comOut);// Write the length
  620.                         fputs(yyvsp[0].ptr, comOut);            // Write string    w/o null
  621.                         fputc(0, comOut);            // Termnate it
  622.                     ;
  623.     break;}
  624. case 17:
  625. {
  626.                         fputc(PC_ERASECOM, comOut);
  627.                     ;
  628.     break;}
  629. case 18:
  630. {
  631.                         fputc(PC_CLOSEWINDOW, comOut);
  632.                     ;
  633.     break;}
  634. case 19:
  635. {
  636.                         fputc(PC_WAIT, comOut);
  637.                         x=yyvsp[0].lval;                        // Make it into an INT
  638.                         (void) fwrite(&x, sizeof(int), 1, comOut);
  639.                     ;
  640.     break;}
  641. case 20:
  642. {
  643.                         fputc(PC_END, comOut);    /* Write the end command */
  644.                     ;
  645.     break;}
  646. case 21:
  647. {
  648.                         fputc(PC_SEND, comOut);        // Start a send command
  649.                         /* Length is +1 to include the length byte */
  650.                         fputc(strlen(yyvsp[0].ptr)+1, comOut);// Write the length
  651.                         fputs(yyvsp[0].ptr, comOut);            // Write string    w/o null
  652.                         /* NOTE: WE DON'T TERMINATE THE STRING! */
  653.                     ;
  654.     break;}
  655. case 22:
  656. {
  657.                         fputc(PC_SENDSLOW, comOut);    // Start a send command
  658.                         /* Length is +1 to include the length byte */
  659.                         fputc(strlen(yyvsp[0].ptr)+1, comOut);// Write the length
  660.                         fputs(yyvsp[0].ptr, comOut);            // Write string    w/o null
  661.                         /* NOTE: WE DON'T TERMINATE THE STRING! */
  662.                     ;
  663.     break;}
  664. case 23:
  665. {
  666.                         fputc(PC_WAITFOR, comOut);    // Wait for a string
  667.                         /* Length is +2 to include length byte + terminator */
  668.                         fputc(strlen(yyvsp[0].ptr)+2, comOut);// Write the length
  669.                         fputs(yyvsp[0].ptr, comOut);            // Write string    w/o null
  670.                         fputc(0, comOut);            // Termnate it
  671.                     ;
  672.     break;}
  673. case 24:
  674. {
  675.                         yydebug=1;
  676.                     ;
  677.     break;}
  678. case 25:
  679. {
  680.                         yydebug=0;
  681.                     ;
  682.     break;}
  683. case 26:
  684. {
  685.                         fputc(PC_BELL, comOut);            // Beep!
  686.                     ;
  687.     break;}
  688. case 27:
  689. {
  690.                         fputc(PC_NOTIFY, comOut);
  691.                         /* Length is +2 because we have a null terminator     */
  692.                         /*  and we include the length byte.                    */
  693.                         fputc(strlen(yyvsp[0].ptr)+2, comOut); // Write the length
  694.                         fputs(yyvsp[0].ptr, comOut);             // Write string w/o null
  695.                         fputc(0, comOut);             // Termnate it w/null
  696.                     ;
  697.     break;}
  698. case 28:
  699. {
  700.                         fputc(PC_NOTIFYOFF, comOut);    // Remove notify box
  701.                     ;
  702.     break;}
  703. case 30:
  704. {
  705.                         yyval.lval=yyvsp[0].ival;            /* Avoid type mismatch warning */
  706.                     ;
  707.     break;}
  708. case 32:
  709. {
  710.                         yyval.lval=(-yyvsp[0].lval);
  711.                     ;
  712.     break;}
  713. case 33:
  714. {
  715.                         yyval.lval=(~yyvsp[0].lval);
  716.                     ;
  717.     break;}
  718. case 34:
  719. {
  720.                         yyval.lval=(!yyvsp[0].lval);
  721.                     ;
  722.     break;}
  723. case 35:
  724. {
  725.                         yyval.lval=yyvsp[-1].lval;
  726.                     ;
  727.     break;}
  728. case 36:
  729. {
  730.                         yyval.lval=(yyvsp[-2].lval >> yyvsp[0].lval);
  731.                     ;
  732.     break;}
  733. case 37:
  734. {
  735.                         yyval.lval=(yyvsp[-2].lval << yyvsp[0].lval);
  736.                     ;
  737.     break;}
  738. case 38:
  739. {
  740.                         yyval.lval=(yyvsp[-2].lval ^ yyvsp[0].lval);
  741.                     ;
  742.     break;}
  743. case 39:
  744. {
  745.                         yyval.lval=(yyvsp[-2].lval || yyvsp[0].lval);
  746.                     ;
  747.     break;}
  748. case 40:
  749. {
  750.                         yyval.lval=(yyvsp[-2].lval && yyvsp[0].lval);
  751.                     ;
  752.     break;}
  753. case 41:
  754. {
  755.                         yyval.lval=(yyvsp[-2].lval | yyvsp[0].lval);
  756.                     ;
  757.     break;}
  758. case 42:
  759. {
  760.                         yyval.lval=(yyvsp[-2].lval & yyvsp[0].lval);
  761.                     ;
  762.     break;}
  763. case 43:
  764. {
  765.                         yyval.lval=(yyvsp[-2].lval != yyvsp[0].lval);
  766.                     ;
  767.     break;}
  768. case 44:
  769. {
  770.                         yyval.lval=(yyvsp[-2].lval == yyvsp[0].lval);
  771.                     ;
  772.     break;}
  773. case 45:
  774. {
  775.                         yyval.lval=(yyvsp[-2].lval >= yyvsp[0].lval);
  776.                     ;
  777.     break;}
  778. case 46:
  779. {
  780.                         yyval.lval=(yyvsp[-2].lval <= yyvsp[0].lval);
  781.                     ;
  782.     break;}
  783. case 47:
  784. {
  785.                         yyval.lval=(yyvsp[-2].lval > yyvsp[0].lval);
  786.                     ;
  787.     break;}
  788. case 48:
  789. {
  790.                         yyval.lval=(yyvsp[-2].lval < yyvsp[0].lval);
  791.                     ;
  792.     break;}
  793. case 49:
  794. {
  795.                         yyval.lval=(yyvsp[-2].lval - yyvsp[0].lval);
  796.                     ;
  797.     break;}
  798. case 50:
  799. {
  800.                         yyval.lval=(yyvsp[-2].lval + yyvsp[0].lval);
  801.                     ;
  802.     break;}
  803. case 51:
  804. {
  805.                         yyval.lval=(yyvsp[-2].lval * yyvsp[0].lval);
  806.                     ;
  807.     break;}
  808. case 52:
  809. {
  810.                         if (yyvsp[0].lval!=0) {
  811.                             yyval.lval=(yyvsp[-2].lval / yyvsp[0].lval);
  812.                         } else {
  813.                             /* This error should be handled properly!   */
  814.                             /* At the moment, I don't know how - sorry. */
  815.                             yyerror("Attempt to divide by zero");
  816.                             break;
  817.                         }
  818.                     ;
  819.     break;}
  820. case 53:
  821. {
  822.                         yyval.lval=(yyvsp[-2].lval % yyvsp[0].lval);
  823.                     ;
  824.     break;}
  825. }
  826.    /* the action file gets copied in in place of this dollarsign */
  827.  
  828.  
  829.   yyvsp -= yylen;
  830.   yyssp -= yylen;
  831. #ifdef YYLSP_NEEDED
  832.   yylsp -= yylen;
  833. #endif
  834.  
  835. #if YYDEBUG != 0
  836.   if (yydebug)
  837.     {
  838.       short *ssp1 = yyss - 1;
  839.       fprintf (stderr, "state stack now");
  840.       while (ssp1 != yyssp)
  841.     fprintf (stderr, " %d", *++ssp1);
  842.       fprintf (stderr, "\n");
  843.     }
  844. #endif
  845.  
  846.   *++yyvsp = yyval;
  847.  
  848. #ifdef YYLSP_NEEDED
  849.   yylsp++;
  850.   if (yylen == 0)
  851.     {
  852.       yylsp->first_line = yylloc.first_line;
  853.       yylsp->first_column = yylloc.first_column;
  854.       yylsp->last_line = (yylsp-1)->last_line;
  855.       yylsp->last_column = (yylsp-1)->last_column;
  856.       yylsp->text = 0;
  857.     }
  858.   else
  859.     {
  860.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  861.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  862.     }
  863. #endif
  864.  
  865.   /* Now "shift" the result of the reduction.
  866.      Determine what state that goes to,
  867.      based on the state we popped back to
  868.      and the rule number reduced by.  */
  869.  
  870.   yyn = yyr1[yyn];
  871.  
  872.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  873.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  874.     yystate = yytable[yystate];
  875.   else
  876.     yystate = yydefgoto[yyn - YYNTBASE];
  877.  
  878.   goto yynewstate;
  879.  
  880. yyerrlab:   /* here on detecting error */
  881.  
  882.   if (! yyerrstatus)
  883.     /* If not already recovering from an error, report this error.  */
  884.     {
  885.       ++yynerrs;
  886.       yyerror("parse error");
  887.     }
  888.  
  889.   if (yyerrstatus == 3)
  890.     {
  891.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  892.  
  893.       /* return failure if at end of input */
  894.       if (yychar == YYEOF)
  895.     YYABORT;
  896.  
  897. #if YYDEBUG != 0
  898.       if (yydebug)
  899.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  900. #endif
  901.  
  902.       yychar = YYEMPTY;
  903.     }
  904.  
  905.   /* Else will try to reuse lookahead token
  906.      after shifting the error token.  */
  907.  
  908.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  909.  
  910.   goto yyerrhandle;
  911.  
  912. yyerrdefault:  /* current state does not do anything special for the error token. */
  913.  
  914. #if 0
  915.   /* This is wrong; only states that explicitly want error tokens
  916.      should shift them.  */
  917.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  918.   if (yyn) goto yydefault;
  919. #endif
  920.  
  921. yyerrpop:   /* pop the current state because it cannot handle the error token */
  922.  
  923.   if (yyssp == yyss) YYABORT;
  924.   yyvsp--;
  925.   yystate = *--yyssp;
  926. #ifdef YYLSP_NEEDED
  927.   yylsp--;
  928. #endif
  929.  
  930. #if YYDEBUG != 0
  931.   if (yydebug)
  932.     {
  933.       short *ssp1 = yyss - 1;
  934.       fprintf (stderr, "Error: state stack now");
  935.       while (ssp1 != yyssp)
  936.     fprintf (stderr, " %d", *++ssp1);
  937.       fprintf (stderr, "\n");
  938.     }
  939. #endif
  940.  
  941. yyerrhandle:
  942.  
  943.   yyn = yypact[yystate];
  944.   if (yyn == YYFLAG)
  945.     goto yyerrdefault;
  946.  
  947.   yyn += YYTERROR;
  948.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  949.     goto yyerrdefault;
  950.  
  951.   yyn = yytable[yyn];
  952.   if (yyn < 0)
  953.     {
  954.       if (yyn == YYFLAG)
  955.     goto yyerrpop;
  956.       yyn = -yyn;
  957.       goto yyreduce;
  958.     }
  959.   else if (yyn == 0)
  960.     goto yyerrpop;
  961.  
  962.   if (yyn == YYFINAL)
  963.     YYACCEPT;
  964.  
  965. #if YYDEBUG != 0
  966.   if (yydebug)
  967.     fprintf(stderr, "Shifting error token, ");
  968. #endif
  969.  
  970.   *++yyvsp = yylval;
  971. #ifdef YYLSP_NEEDED
  972.   *++yylsp = yylloc;
  973. #endif
  974.  
  975.   yystate = yyn;
  976.   goto yynewstate;
  977. }
  978.