home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2-YACC.ZIP / YGTNM.4C < prev    next >
Text File  |  1989-09-30  |  1KB  |  49 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:      YGTNM.4C
  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. #include "y4.h"
  21.  
  22. int gtnm( void )
  23.    {
  24.  
  25.    register s, val, c;
  26.  
  27.    /* read and convert an integer from the standard input */
  28.    /* return the terminating character */
  29.    /* blanks, tabs, and newlines are ignored */
  30.  
  31.    s = 1;
  32.    val = 0;
  33.  
  34.    while( (c=unix_getc(finput)) != EOF )
  35.       {
  36.       if( isdigit(c) )
  37.          {
  38.          val = val * 10 + c - '0';
  39.          }
  40.       else if ( c == '-' ) s = -1;
  41.       else if ( c == '\r') continue;
  42.       else break;
  43.       }
  44.    *pmem++ = s*val;
  45.    if( pmem > &mem0[MEMSIZE] ) error( "out of space" );
  46.    return( c );
  47.  
  48.    }
  49.