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;
24 <COMMENT>"}" BEGIN(INITIAL);
25 <COMMENT>"$include"[ \t]*"(" BEGIN(INCLUDE);
26 <COMMENT>[ \t]* /* skip whitespace */
28 <INCLUDE>")" BEGIN(COMMENT);
29 <INCLUDE>[ \t]* /* skip whitespace */
30 <INCLUDE>[^ \t\n() ]+ { /* get the include file name */
31 if ( include_count >= MAX_NEST){
32 fprintf( stderr, "Too many include files" );
36 include_stack[++include_count] = YY_CURRENT_BUFFER;
38 yyin = fopen( yytext, "r" );
40 fprintf( stderr, "Unable to open %s",yytext);
44 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
50 fprintf( stderr, "EOF in include" );
55 fprintf( stderr, "EOF in comment" );
59 if ( include_count <= 0 ){
62 yy_delete_buffer(include_stack[include_count--] );
63 yy_switch_to_buffer(include_stack[include_count] );