BNFC/bnfc — pull request #91 by cwelton (2014-05-09 00:40:12+00:00)
Title: fixes for lexer_initialize using yyreset()

For C family parsers there is a bug in initialize lexer.

This bug manifests as follows:
1. I have two documents to be parsed, document A and document B
2. Individually Document A results in a failed parse, Document B (which happens to be "" - an empty string) results in a valid parse
3. When run one after one another Document B results in a failed parse instead of a valid parse due to the initial state of the lexer not being properly setup.

To fix it, this code:

void initialize_lexer(FILE *inp) { yyin = inp; BEGIN YYINITIAL; }

Should be replaced with:

void initialize_lexer(FILE *inp) { yyrestart(inp); BEGIN YYINITIAL; }