#INCLUDE BEGIN(incl);
<incl>[ \t]* {/* eat the whitespace*/ }
<incl>[^ \t\n]+ { // got the include file name
if (TOK_PRINT) printf("[SYSTEM]: >>> Went into %s\n",yytext);
if (TOK_PRINT) printf("[SYSTEM]: >>> Include Stack level:%d\n",include_stack_ptr);
if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
{
fprintf(stderr,"### Fatal Error! Includes nested too deeply!\n Maybe you got the file include itself and loop forever!\n>>Exit...\n");
exit(-1);
}
else
{
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
yyin = fopen( yytext, "r" );
if ( ! yyin )
{
fprintf(stderr,"### Fatal error! ### \nCan not open included file \"%s\"! \n>>Exit...\n", yytext);
exit(-1);
}
else
{
if (TOK_PRINT) printf(" >>> open file %s!\n", yytext);
}
BEGIN(INITIAL);
}
}
<<EOF>> {// end of file
if (include_stack_ptr )
{
srcLineNum--;
if(pre_process) popFileName();// pop filename, for tracking src file line stuff
if (TOK_PRINT) printf("[SYSTEM]: <<< EOF of Include file, Current Level:%d\n" ,include_stack_ptr);
if ( --include_stack_ptr < 0 )
{
yyterminate();
}
else
{
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer(include_stack[include_stack_ptr] );
if (TOK_PRINT) printf("[SYSTEM]: <<< Out Include file\n");
}
}
else
yyterminate();
#INCLUDE BEGIN(incl);
<incl>[ \t]* {/* eat the whitespace*/ }
<incl>[^ \t\n]+ { // got the include file name
if (TOK_PRINT) printf("[SYSTEM]: >>> Went into %s\n",yytext);
if (TOK_PRINT) printf("[SYSTEM]: >>> Include Stack level:%d\n",include_stack_ptr);
if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
{
fprintf(stderr,"### Fatal Error! Includes nested too deeply!\n Maybe you got the file include itself and loop forever!\n>>Exit...\n");
exit(-1);
}
else
{
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
yyin = fopen( yytext, "r" );
if ( ! yyin )
{
fprintf(stderr,"### Fatal error! ### \nCan not open included file \"%s\"! \n>>Exit...\n", yytext);
exit(-1);
}
else
{
if (TOK_PRINT) printf(" >>> open file %s!\n", yytext);
BEGIN(INITIAL);
}
}
<<EOF>> {// end of file
if (include_stack_ptr )
{
srcLineNum--;
if(pre_process) popFileName();// pop filename, for tracking src file line stuff
if (TOK_PRINT) printf("[SYSTEM]: <<< EOF of Include file, Current Level:%d\n" ,include_stack_ptr);
if ( --include_stack_ptr < 0 )
{
yyterminate();
}
else
{
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer(include_stack[include_stack_ptr] );
if (TOK_PRINT) printf("[SYSTEM]: <<< Out Include file\n");
}
}
else
yyterminate();