Subj : Re: parsing tree of javascript expression using Rhino To : christos.toyas From : Igor Bukanov Date : Wed Nov 24 2004 11:16 am Christos Toyas wrote: > Hi, > > I was wondering if there was a way with Rhino to get back a parsing tree > from a javascript string. Rhino does not have public API for doing that. > > I'd like to know for example what are the used > functions in my javascript string and what are the args > provided to those functions. In Rhino 1.6R1 which currently exists in the form of the third release candidate you can do it via debug API and Context.compileString: import org.mozilla.javascript.*; import org.mozilla.javascript.debug.DebuggableScript; .... Context cx; ..... // Force interpretation mode to make results of // Context.compileString debuggable cx.setOptimizationLevel(-1); Script script = cx.compileString(stringWithScriptText, "someName", 1, null); DebuggableScript dscript = Context.getDebuggableView(script); // Enumerate top level functions for (int i = 0; i != dscript.getFunctionCount(); ++i) { System.out.println("Function: "+dscript.getFunction(i)); System.out.println(" its param count: "+dscript.getFunction(i).getParamCount()); ... } Regards, Igor .