I am thinking to parse the .js file and figure out the context and the function call. Anyone got good any idea about how to implement this?
I am not sure what you are talking about exactly. Can you try to explain what you are trying to do in another way.
Joined: Jun 21, 2003
Here is other description of my question:
In my .js file, there is a function call: aFunction(). This function call could happen anywhere, e.g. inside a for(; , inside a equality statement, etc. The problem is with this function call.
We have to expend this function to take care of the synchronization issue. The function call will send a request to server and it takes some time to return. The probem is that the subsequent code depends on the result. Hence someone in our company figured out a way to handle this: expend the function so the subsequent code can wait until the function returns. I am not sure how he handle this yet. His original solution is to write an engine to parse the .js sourcecode, figure out this function calls and expend the function into another .js file. The problem with this solution is the parsing was based on regualar expression. It's hard to maintain.
My intention is to use some parser generator, e.g. ANTLR, to generat lexical parser and hope that is the right direction. Anyone got better idea how to implement this?
What I think you should do is breathe deeply, step away from the keyboard, and figure out what it is you are really trying to accomplish. Then figure out, using the traditional request-response HTTP cycle, what the best way to accomplish it might be.
The Servlets forum might be a good place to start once you figure out what it is you really need to accomplish.
If I understand you correctly: 1. You have some kind of frame or popup 2. You have a function, that submits request into this frame or popup. 3. You want this function to wait, until that request is returned, and than do some proccesing. 4. You know the name of the function to be "extended"
if you could break submiting request and proccesing the result onto 2 separate functions, than everything is easy.
Now, let say you have function, and you want to "extend it" to make it not return until some flag is set. The only way to do that, is to do some loop, which will really kill you page perfomance, and may cause a popup alert on some browser version. If you are up to that than:
Joined: Jun 21, 2003
I think Yuriy got my idea right. However my problem is how to parse the "aFunction" out in the original source code, given that it can be used in many different forms, e.g., var e = aFunction(), for(aFunction(); , etc.?