(flex.info)How can I build a two-pass scanner?


Next: How do I match any string not matched in the preceding rules? Prev: How can I expand macros in the input? Up: FAQ
Enter node , (file) or (file)node

How can I build a two-pass scanner?
===================================

One way to do it is to filter the first pass to a temporary file, then
process the temporary file on the second pass.  You will probably see a
performance hit, due to all the disk I/O.

   When you need to look ahead far forward like this, it almost always
means that the right solution is to build a parse tree of the entire
input, then walk it after the parse in order to generate the output.  In
a sense, this is a two-pass approach, once through the text and once
through the parse tree, but the performance hit for the latter is
usually an order of magnitude smaller, since everything is already
classified, in binary format, and residing in memory.


automatically generated by info2www version 1.2.2.9