Subj : Re: Need to walk the JavaScript parse tree To : Brendan Eich From : Lyle Coder Date : Mon May 12 2003 03:43 pm Hi, Basically I want to see statements like window.location = foo and then change the foo with the address of another web server (for some bizare reason). The only way to do this is via understanding the grammar Thanks Lyle Brendan Eich wrote: > Lyle Coder wrote: > >> After a JavaScript section has been parsed, I need to walk the parse >> tree and re-generate the JavaScript (create a new string that contains >> the original program). The reason I do this is because I look for >> certain key words and perform some operation on them >> > > What kinds of operations? What keywords? > >> What is the best way to do this? >> > > Can't tell without more info, see above. > >> I am current looking at the function >> CompileTokenStream, which calls "Statements". The result is a >> JSParseNode. I assume I can walk that some how and re-create the >> original JS program? >> >> > > If you're reading the code, keep reading. But you shouldn't overlook > the JS_FRIEND_API declaration of js_ParseTokenStream in jsparse.h. > > /be > > >> Thanks >> Lyle >> >> > .