3 /* This file contains the scanner for mylex(), the following functions and
4 * variables are exported :
6 * int yylineno; - The current line number.
8 * char scanc(); - Return next character.
10 * backc( c); - Push back one character.
13 * FILE *switch_input( new); - Scanner will from now on read from
14 * FILE *new; - 'new', old input-file is returned.
16 * The scanner must perform a lookahead of more than one character, so it uses
17 * it's own internal buffer.
24 /********* Internal variables + functions ***********************/
29 static char buf[BUF_SIZE], /* Bufer to save backc()-characters */
30 *bufptr = buf; /* Pointer to space for backc()-character */
32 FILE *infile; /*static FILE *infile = stdin;*/
42 return( getc( infile));
46 /***************************************************************/
51 /* Get next character, but delete al C-comments and count lines */
59 if ( c == '*') { /* start of comment */
60 while ( nextc() != '*' || nextc() != '/')
78 if ( bufptr >= buf + BUF_SIZE)
79 error( "backc(), no space in buffer left!");
88 FILE *switch_input( new)
91 /* Switch to a new input file, try to save the lookahead-characters in buf[]
92 * by calling ungetc(). If they can't be saved return NULL.
99 for ( ptr = buf; ptr < bufptr; ptr++)
100 if ( ungetc( *ptr, infile) == EOF && *ptr != EOF)