I used Esprima.Net (https://github.com/Diullei/Esprima.NET) to get AST (Abstract Syntax Key) from a JavaScript code. It returns a List<Dynamic> consisting many child and sub-child nodes. I wonder how best to traverse all these nodes in C# for analysis. Basically I want to get the function name, variable name & function that it is under.
For example, in the following JavaScript code:
var y = 45;
function fTest(d)
{
var key: Argument.Callee;
var cars = 'Hello';
for (i = 0; i < cars.length; i++)
{
text += cars[i];
}
}
I wish to get the following result at the end:
variable: 45
function:parameter:'d'
function:variable:argument.callee
function:variable:'Hello'
funtion:loop:variable:object
I'm having a difficulty to traverse the List<Dynamic> given by Esprima.Net. Any ideas to process or traverse this list in a Tree or any structure so that I can access them? Thanks.