home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / yaccsrc2 / ychfnd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-19  |  797 b   |  42 lines

  1.  
  2. # include "y2.h"     
  3. # include <string.h> 
  4.  
  5. chfind( t, s )
  6. register char * s;
  7.  
  8. {
  9.   int i;
  10.  
  11.   # ifdef debug
  12.   fprintf( ftable, "chfind t = %d s = %s ", t, s );
  13.   # endif 
  14.  
  15.   if ( s[ 0 ] == ' ' )
  16.     t = 0;
  17.   TLOOP( i )
  18.     {
  19.       if ( !strcmp( s, tokset[ i ].name ) )
  20.         {
  21.           # ifdef debug
  22.           fprintf( ftable, "ret = %d\n", i );
  23.           # endif 
  24.           return ( i );
  25.         }
  26.     }
  27.   NTLOOP( i )
  28.     {
  29.       if ( !strcmp( s, nontrst[ i ].name ) )
  30.         {
  31.           # ifdef debug
  32.           fprintf( ftable, "ret = %d\n", i + NTBASE );
  33.           # endif 
  34.           return ( i + NTBASE );
  35.         }
  36.     }
  37.   /* cannot find name */
  38.   if ( t > 1 )
  39.     error( "%s should have been defined earlier", s );
  40.   return ( defin( t, s ) );
  41. }
  42.