home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2-YACC.ZIP / YWRITM.1C < prev    next >
Text File  |  1989-09-29  |  1KB  |  53 lines

  1. /*
  2.   HEADER: CUG     nnn.nn;
  3.   TITLE:     YACC - Yet Another Compilier-Compilier
  4.   VERSION:     1.0 for IBM-PC
  5.   DATE:      JAN 28, 1985
  6.   DESCRIPTION:     LALR(1) Parser Generator. From UNIX
  7.   KEYWORDS:     Parser Generator Compilier-Compilier YACC
  8.   SYSTEM:     IBM-PC and Compatiables
  9.   FILENAME:      YWRITM.1C
  10.   WARNINGS:     This program is not for the casual user. It will
  11.          be useful primarily to expert developers.
  12.   CRC:         N/A
  13.   SEE-ALSO:     LEX and PREP
  14.   AUTHORS:     Scott Guthery 11100 leafwood lane Austin, TX 78750
  15.   COMPILERS:     DESMET-C
  16.   REFERENCES:     UNIX Systems Manuals
  17. */
  18.  
  19. #include "y1.h"
  20.  
  21. extern char sarr[ISIZE];
  22.  
  23. char *writem(int *pp)
  24.  
  25.    {
  26.    /* creates output string for item pointed to by pp */
  27.    int i,*p;
  28.    char *q;
  29.  
  30.    for( p=pp; *p>0 ; ++p ) ;
  31.    p = prdptr[-*p];
  32.    q = chcopy( sarr, nontrst[*p-NTBASE].name );
  33.    q = chcopy( q, " : " );
  34.  
  35.    for(;;)
  36.       {
  37.       *q++ = (char) ( ++p==pp ? '_' : ' ' );
  38.       *q = '\0';
  39.       if((i = *p) <= 0) break;
  40.       q = chcopy( q, symnam(i) );
  41.       if( q> &sarr[ISIZE-30] ) error( "item too big" );
  42.       }
  43.  
  44.    if( (i = *pp) < 0 )
  45.       {
  46.       /* an item calling for a reduction */
  47.       q = chcopy( q, "    (" );
  48.       sprintf( q, "%d)", -i );
  49.       }
  50.  
  51.    return( sarr );
  52.    }
  53.