Although flex supports yypush_buffer_state for managing nested include files, this cannot be used consistently for in memory files.
Specifically yy_scan_buffer(), uses yy_switch_to_buffer(), which overwrites the top buffer state, this forces managing of in memory files in separate stack, with specific handling also in <>.
As a suggestion replacing the call to yy_switch_to_buffer() with yypush_buffer_state(), would allow consistent usage of a common stack for all buffers.
An alternative, which would be more consistent with the file buffers, would be to remove the yy_switch_to_buffer() and get the user to use yypush_buffer_state() explicitly.
I haven't submitted a pull request as the changes could break existing code, although this could be managed by a suitable conditional control.
Although flex supports yypush_buffer_state for managing nested include files, this cannot be used consistently for in memory files.
Specifically yy_scan_buffer(), uses yy_switch_to_buffer(), which overwrites the top buffer state, this forces managing of in memory files in separate stack, with specific handling also in <>.
As a suggestion replacing the call to yy_switch_to_buffer() with yypush_buffer_state(), would allow consistent usage of a common stack for all buffers. An alternative, which would be more consistent with the file buffers, would be to remove the yy_switch_to_buffer() and get the user to use yypush_buffer_state() explicitly.
I haven't submitted a pull request as the changes could break existing code, although this could be managed by a suitable conditional control.