help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two-pass parser or AST with Bison?


From: Evan Lavelle
Subject: Re: Two-pass parser or AST with Bison?
Date: Tue, 06 Jan 2009 15:22:53 +0000
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Matthias Kramm wrote:

I'll probably define myself some C macros so that I can at least
write something like
    E = E '+' E {pass2only append($1);append($3);append(OP_ADD);}
.
But it would of course be more nifty if the default behaviour "execute an action only if the pass is 2" could be placed
somewhere central.

You really want a bison equivalent of flex's YY_USER_ACTION, but I don't think there is one. You could hack the bison output if you're desperate - maybe something in/around YY_REDUCE_PRINT.

Any pointers to a pure C AST implementation, by any chance?

There's a C runtime for Antlr, so I guess all the AST code has C versions as well - I don't think it existed when I needed it. The C++ version has ~80 .hpp and .cpp files for the AST bits (I think I found it in a lib directory somewhere in the source tree).

-Evan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]