home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2-YACC.ZIP / YFLSET.1C < prev    next >
Text File  |  1989-09-29  |  1KB  |  51 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:      YFLSET.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. struct looksets *flset( struct looksets *p )
  22.  
  23.    {
  24.    /* decide if the lookahead set pointed to by p is known */
  25.    /* return pointer to a perminent location for the set */
  26.  
  27.    register struct looksets *q;
  28.    int j, *w;
  29.    register *u, *v;
  30.  
  31.    for( q = &lkst[nlset]; q-- > lkst; )
  32.       {
  33.       u = p->lset;
  34.       v = q->lset;
  35.       w = & v[tbitset];
  36.       while( v<w) if( *u++ != *v++ ) goto more;
  37.       /* we have matched */
  38.       return( q );
  39. more: 
  40.       ;
  41.       }
  42.    /* add a new one */
  43.    q = &lkst[nlset++];
  44.    if( nlset >= LSETSIZE )error("too many lookahead sets" );
  45.    SETLOOP(j)
  46.       {
  47.       q->lset[j] = p->lset[j];
  48.       }
  49.    return( q );
  50.    }
  51.