Re: very simple preprocessor using flex (vpetrucci)
11 Apr 2005 00:13:33 -0400

          From comp.compilers

Related articles
very simple preprocessor using flex (2005-04-02)
Re: very simple preprocessor using flex (2005-04-11)
| List of all articles for this month |

From: (vpetrucci)
Newsgroups: comp.compilers
Date: 11 Apr 2005 00:13:33 -0400
References: 05-04-012
Keywords: macros
Posted-Date: 11 Apr 2005 00:13:33 EDT

> [Macro expansion is tricky. Either you need to build your own pushback
> system, or you have to treat each macro that's being expanded like a
> little nested include file. People have known how to do this since
> the 1960s, but it's not written down in many places. -John]


By "expanded like a little nested include file" Do You mean using
Something like this:

        p_def p = def_find(yytext);
        YY_BUFFER_STATE oldbuf;
        if (p) {
                /* rescan replaced input */
                oldbuf = YY_CURRENT_BUFFER;
                BEGIN INITIAL;
        } else {

The problem is that bison (parser) has already called yylex() and want
back a return of some token matched. when i switch to buffer and call
BEGIN, the lexer continue to scan or wait _another_ call yylex() by
the parser?


[That's kind of it except for the minor detail that your code doesn't actually
scan the included text. You need to keep an explicit stack of sources. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.