Commit c7f88dcb authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Introduce some (weak) reentrancy into lexer.

	* dev/parse-asm-scan-gen.py: Maintain a stack of scanning states.
	This comes from the LRDE's Tiger Compiler's scanner.
parent 812bad96
2005-01-23 Benot Perrot <benoit@lrde.epita.fr>
Introduce some (weak) reentrancy into lexer.
* dev/parse-asm-scan-gen.py: Maintain a stack of scanning states.
This comes from the LRDE's Tiger Compiler's scanner.
2005-01-22 Benot Perrot <benoit@lrde.epita.fr>
Fix shell's `load' command.
......
......@@ -260,12 +260,44 @@ print """
}
%%
/* Depending upon the version of Flex (> 2.5.4), there might be a
function to reclaim all the memory Flex has allocated. If not,
simulate it. */
#if !( YY_FLEX_MAJOR_VERSION >= 2 \
&& YY_FLEX_MINOR_VERSION >= 5 \
&& defined YY_FLEX_SUBMINOR_VERSION \
&& YY_FLEX_SUBMINOR_VERSION >= 5)
static void
yylex_destroy(void)
{
yy_delete_buffer(YY_CURRENT_BUFFER);
}
#endif
namespace parse
{
// Stack of scanning states, used to have some (weak) reentrancy.
static std::stack<YY_BUFFER_STATE> states;
// Keep this scan_open valid for multiple calls (i.e., do use
// yyrestart).
void
scan_open(const std::string &filename, bool trace_p)
{
static bool first = true;
if (first)
{
first = false;
// Reclaim all the memory allocated by Flex at program termination
std::atexit((void (*) (void)) yylex_destroy);
}
// Save the current state
states.push(YY_CURRENT_BUFFER);
yy_flex_debug = trace_p;
if (filename == \"-\")
......@@ -282,12 +314,20 @@ namespace parse
exit (1);
}
}
yy_switch_to_buffer(yy_create_buffer (yyin, YY_BUF_SIZE));
}
void
scan_close (void)
{
fclose (yyin);
// Restore the current scanning state.
assertion(!states.empty());
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(states.top());
states.pop();
}
}
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment