Two-pass parser or AST with Bison?

2009-01-06 Thread Matthias Kramm
Hi All, I'm still busy compiling ActionScript 3.0, which, among others, supports forward function calls: function bar() { foo("", 3) } function foo(s:String, i:int) { } In order to properly resolve these (and check for correct arguments), I can currently think about three

Re: Two-pass parser or AST with Bison?

2009-01-06 Thread Evan Lavelle
I had this problem some years ago, when I was first using Bison. I had a simple language, which I could handle in a single parser pass; this was easy, and I could do everything in the Bison actions. I then added some functionality, which was primarily forward-referencing of externals (mainly f

Re: Two-pass parser or AST with Bison?

2009-01-06 Thread Matthias Kramm
Hi Evan, thanks for the many tips! On Tue, Jan 06, 2009 at 09:57:34AM +, Evan Lavelle wrote: > I had a lot of this, but I mainly put it in the C++ code called from the > actions, where it was a trivial addition - if you're in the wrong pass, > you just return. Right now, I do a lot in t

Re: Two-pass parser or AST with Bison?

2009-01-06 Thread Luca
Matthias Kramm ha scritto: Hi All, I'm still busy compiling ActionScript 3.0, which, among others, supports forward function calls: function bar() { foo("", 3) } function foo(s:String, i:int) { } In order to properly resolve these (and check for correct arguments), I ca

Re: Two-pass parser or AST with Bison?

2009-01-06 Thread Evan Lavelle
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