home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / comm / yaccunx / yothrs.1c < prev    next >
Encoding:
Text File  |  1983-12-24  |  1.8 KB  |  81 lines

  1. /* Edits:
  2.  *      06-Dec-80 Original code broken out of y1.c.
  3.  *      18-Dec-80 Add conditional code for Decus for tempfile deletion.
  4.  */
  5.  
  6. #include "y1.h"
  7.  
  8. others()
  9.    {
  10.    /* put out other arrays, copy the parsers */
  11.    register c, i, j;
  12.  
  13.    finput = fopen( PARSER, "r" );
  14.    if( finput == NULL ) error( "cannot find parser %s", PARSER );
  15.  
  16.    warray( "yyr1", levprd, nprod );
  17.  
  18.    aryfil( temp1, nprod, 0 );
  19.    PLOOP(1,i)temp1[i] = prdptr[i+1]-prdptr[i]-2;
  20.    warray( "yyr2", temp1, nprod );
  21.  
  22.    aryfil( temp1, nstate, -1000 );
  23.    TLOOP(i)
  24.       {
  25.       for( j=tstates[i]; j!=0; j=mstates[j] )
  26.          {
  27.          temp1[j] = tokset[i].value;
  28.          }
  29.       }
  30.    NTLOOP(i)
  31.       {
  32.       for( j=ntstates[i]; j!=0; j=mstates[j] )
  33.          {
  34.          temp1[j] = -i;
  35.          }
  36.       }
  37.    warray( "yychk", temp1, nstate );
  38.  
  39.    warray( "yydef", defact, nstate );
  40.  
  41.    /* copy parser text */
  42.  
  43.    while( (c=unix_getc(finput) ) != EOF )
  44.       {
  45.       if( c == '$' )
  46.          {
  47.          if( (c=unix_getc(finput)) != 'A' ) putc( '$', ftable );
  48.          else 
  49.             {
  50.             /* copy actions */
  51.             faction = fopen( ACTNAME, "r" );
  52.             if( faction == NULL ) error( "cannot reopen action tempfile" );
  53.             while( (c=unix_getc(faction) ) != EOF ) putc( c, ftable );
  54.             fclose(faction);
  55.             ZAPFILE(ACTNAME);
  56.             c = unix_getc(finput);
  57.             }
  58.          }
  59.       putc( c, ftable );
  60.       }
  61.  
  62.    fclose( ftable );
  63.    }
  64.  
  65. static char getbuf[30], *getbufptr = getbuf;
  66.  
  67. unix_getc(iop)
  68. FILE iop;
  69. {
  70.     if(getbufptr == getbuf)
  71.         return(getc(iop));
  72.     else
  73.         return(*--getbufptr);
  74. }
  75.  
  76. ungetc(c, iop)
  77. char c;
  78. FILE iop; /* WARNING: iop ignored ... ungetc's are multiplexed!!! */
  79. {
  80.     *getbufptr++ = c;
  81. }