Closed GoogleCodeExporter closed 9 years ago
Sorry for the poor document, you could dump AST with a visitor
import PyV8
import json
class Visitor(object):
def onProgram(self, prog):
self.ast = prog.toAST()
self.json = json.loads(prog.toJSON())
with PyV8.JSContext() as c:
with PyV8.JSEngine() as e:
s = e.compile("""document.write("<h2>Table of Factorials</h2>");
for(i = 1, fact = 1; i < 10; i++, fact *= i) {
document.write(i + "! = " + fact);
document.write("<br>");
}
""")
visitor = Visitor()
s.visit(visitor)
print json.dumps(visitor.json, sort_keys=True, indent=4, separators=(',', ': '))
please check TestAST for more detail
https://code.google.com/p/pyv8/source/browse/trunk/PyV8.py#2298
Original comment by flier...@gmail.com
on 15 Apr 2013 at 2:09
Thanks for the help!!! It helped me alot :)..
Original comment by little.cherub13
on 16 Apr 2013 at 8:17
Is it possible to obtain the call graph from the AST generated using Pyv8.
Original comment by audiotun...@gmail.com
on 17 Apr 2013 at 5:17
Is it possible to manipulate the abstract syntax tree generated using pyv8. How
to do it?? Which are the functions to be used?
Original comment by pooja.ba...@gmail.com
on 17 Apr 2013 at 5:41
Original issue reported on code.google.com by
little.cherub13
on 12 Apr 2013 at 8:43