2 * eof_rules.lex : An example of using multiple buffers
3 * EOF rules, and start states
10 YY_BUFFER_STATE include_stack[MAX_NEST];
11 int include_count = -1;
20 ^"#include"[ \t]*\" BEGIN(INCLUDE);
21 <INCLUDE>\" BEGIN(INITIAL);
22 <INCLUDE>[^\"]+ { /* get the include file name */
23 if ( include_count >= MAX_NEST){
24 fprintf( stderr, "Too many include files" );
28 include_stack[++include_count] = YY_CURRENT_BUFFER;
30 yyin = fopen( yytext, "r" );
32 fprintf( stderr, "Unable to open \"%s\"\n",yytext);
36 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
42 fprintf( stderr, "EOF in include" );
46 if ( include_count <= 0 ){
49 yy_delete_buffer(include_stack[include_count--] );
50 yy_switch_to_buffer(include_stack[include_count] );