Hi Evan, thanks for the many tips!
On Tue, Jan 06, 2009 at 09:57:34AM +0000, Evan Lavelle <eml-bi...@cyconix.com> 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 the actions itself, so doing a "if(pass==2)" almost everywhere does clutter up the source code quite a lot. 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. > This keeps the grammar clean. Alternatively, you might > also consider writing two grammars - in the first pass, you use a > simplified grammar which ignores the contents of functions, and which > just extracts function names and parameters. I've been thinking about that. Problem is that ActionScript is complicated enough to make it challeging to determine the exact function body without doing much parsing: public somenamespaceidentifier function foobar() { var r:RegExp = / }\/ / var s = "\ } \ " var x:XML = <test> } </test> var f = function() { //inner function return {"foo":1,"bar":2 } } } I guess it's doable if both passes use the full tokenizer, though. > Using an AST for the first time is hard work and there's a steep > learning curve (I used the C++ AST library from ANTLR to make this > easier). Any pointers to a pure C AST implementation, by any chance? > I don't think that would be desirable (even if it's possible). As a > programmer, you'll be constantly modifying, adding, or removing node > classes to make life easier. True. But e.g. expression syntax (ActionScript has roughly 50 operators, starting with the usual C++ stuff like '+', '*', '^', ">>" etc.) is pretty straightforward, and should (I think) have an AST implementation pretty close to the source, so it might be worthwhile to have a simplified/automatic way to generate an AST from that. Greetings Matthias _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison