Next: , Previous: , Up: FAQ   [Contents][Index]

Can I build nested parsers that work with the same input file?

This is not going to work without some additional effort. The reason is that flex block-buffers the input it reads from yyin. This means that the “outermost” yylex(), when called, will automatically slurp up the first 8K of input available on yyin, and subsequent calls to other yylex()’s won’t see that input. You might be tempted to work around this problem by redefining YY_INPUT to only return a small amount of text, but it turns out that that approach is quite difficult. Instead, the best solution is to combine all of your scanners into one large scanner, using a different exclusive start condition for each.