Search code examples
flex-lexerm4

"ERROR: end of file in string" error coming from m4 when using flex


I have a flex input file which I've been working on, and I just changed it to use %option extra-type, but the version of flex which we had been using, 2.5.27, doesn't support it. (I get the following kinds of errors even with the version of the file which worked w/ the old version of flex)

So I tried to use a newer version (specifically, 2.5.22 & 2.5.25 of https://github.com/lexxmark/winflexbison), but I'm getting errors like win_flex.exe:extern_stdin:1978: ERROR: end of file in string

I even tried installing ubuntu via WSL, installing flex on that (2.6.4), and I get errors like

/usr/bin/m4:stdin:1969: ERROR: end of file in string
/usr/bin/m4:stdin:1964: ERROR: end of file in string

Going back to windows, I noticed that flex had left around some temporary files, and one of them contains the following:

m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
[[
#define YY_RULE_SETUP \
    YY_USER_ACTION
]])

m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl
/** The main scanner function which does all the work.
 */
YY_DECL
{
    yy_state_type yy_current_state;
    char *yy_cp, *yy_bp;
    int yy_act;
    M4_YY_DECL_GUTS_VAR();

m4_ifdef( [[M4_YY_NOT_REENTRANT]],
[[
    m4_ifdef( [[M4_YY_BISON_LVAL]],
    [[
        YYSTYPE * yylval;
    ]])
    m4_ifdef( [[<M4_YY_BISON_LLOC>]],
    [[
        YYLTYPE * yylloc;
    ]])
]])

With the m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl line being line 1978.

I'm not familiar with m4, but looking at the rest of the file, it seems like that m4_ifdef statement got mangled somehow?

Does anyone have any idea where to go from here?


Solution

  • Well, I found this, and they talked about something similar being broken after flex 2.5.39, so I downloaded the latest version of win-flex-bison using a version of flex no later than that, and it fixed the issue.