lex_var.h revision 145519
1145519Sdarrenr/* $FreeBSD: head/contrib/ipfilter/tools/lex_var.h 145519 2005-04-25 18:20:15Z darrenr $ */ 2145510Sdarrenr 3145510Sdarrenr 4145510Sdarrenrextern long string_start; 5145510Sdarrenrextern long string_end; 6145510Sdarrenrextern char *string_val; 7145510Sdarrenrextern long pos; 8145510Sdarrenr 9145510Sdarrenr#define YY_INPUT(buf, result, max_size) \ 10145510Sdarrenr if (pos >= string_start && pos <= string_end) { \ 11145510Sdarrenr buf[0] = string_val[pos - string_start]; \ 12145510Sdarrenr pos++; \ 13145510Sdarrenr result = 1; \ 14145510Sdarrenr } else if ( yy_current_buffer->yy_is_interactive ) \ 15145510Sdarrenr { \ 16145510Sdarrenr int c = '*', n; \ 17145510Sdarrenr for ( n = 0; n < 1 && \ 18145510Sdarrenr (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 19145510Sdarrenr buf[n] = (char) c; \ 20145510Sdarrenr if ( c == '\n' ) \ 21145510Sdarrenr buf[n++] = (char) c; \ 22145510Sdarrenr if ( c == EOF && ferror( yyin ) ) \ 23145510Sdarrenr YY_FATAL_ERROR( "input in flex scanner failed" ); \ 24145510Sdarrenr result = n; \ 25145510Sdarrenr pos++; \ 26145510Sdarrenr } \ 27145510Sdarrenr else if ( ((result = fread( buf, 1, 1, yyin )) == 0) \ 28145510Sdarrenr && ferror( yyin ) ) \ 29145510Sdarrenr YY_FATAL_ERROR( "input in flex scanner failed" ); 30145510Sdarrenr 31145510Sdarrenr#ifdef input 32145510Sdarrenr# undef input 33145510Sdarrenr# define input() (((pos >= string_start) && (pos < string_end)) ? \ 34145510Sdarrenr yysptr = yysbuf, string_val[pos++ - string_start] : \ 35145510Sdarrenr ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \ 36145510Sdarrenr getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \ 37145510Sdarrenr yytchar) == EOF ? (pos++, 0) : (pos++, yytchar)) 38145510Sdarrenr#endif 39145510Sdarrenr 40145510Sdarrenr#ifdef lex_input 41145510Sdarrenr# undef lex_input 42145510Sdarrenr# define lex_input() (((pos >= string_start) && (pos < string_end)) ? \ 43145510Sdarrenr yysptr = yysbuf, string_val[pos++ - string_start] : \ 44145510Sdarrenr ((yytchar = yysptr > yysbuf ? U(*--yysptr) : \ 45145510Sdarrenr getc(yyin)) == 10 ? (pos++, yylineno++, yytchar) : \ 46145510Sdarrenr yytchar) == EOF ? (pos++, 0) : (pos++, yytchar)) 47145510Sdarrenr#endif 48145510Sdarrenr 49145510Sdarrenr#ifdef unput 50145510Sdarrenr# undef unput 51145510Sdarrenr# define unput(c) { if (pos > 0) pos--; \ 52145510Sdarrenr yytchar = (c); if (yytchar == '\n') yylineno--; \ 53145510Sdarrenr *yysptr++ = yytchar; } 54145510Sdarrenr#endif 55145510Sdarrenr 56