(flex.info.gz) How can I expand macros in the input?
Info Catalog
(flex.info.gz) How can I change the matching pattern at run time?
(flex.info.gz) FAQ
(flex.info.gz) How can I build a two-pass scanner?
How can I expand macros in the input?
=====================================
The best way to approach this problem is at a higher level, e.g., in
the parser.
However, you can do this using multiple input buffers.
%%
macro/[a-z]+ {
/* Saw the macro "macro" followed by extra stuff. */
main_buffer = YY_CURRENT_BUFFER;
expansion_buffer = yy_scan_string(expand(yytext));
yy_switch_to_buffer(expansion_buffer);
}
<<EOF>> {
if ( expansion_buffer )
{
// We were doing an expansion, return to where
// we were.
yy_switch_to_buffer(main_buffer);
yy_delete_buffer(expansion_buffer);
expansion_buffer = 0;
}
else
yyterminate();
}
You probably will want a stack of expansion buffers to allow nested
macros. From the above though hopefully the idea is clear.
Info Catalog
(flex.info.gz) How can I change the matching pattern at run time?
(flex.info.gz) FAQ
(flex.info.gz) How can I build a two-pass scanner?
automatically generated byinfo2html