Utilizing Esprima.Net (https://github.com/Diullei/Esprima.NET), I extracted the AST (Abstract Syntax Tree) from a piece of JavaScript code. The output is a collection of nodes containing various child and sub-child elements. I am pondering the most efficient way to navigate through these nodes in C# for analysis purposes, specifically aiming to extract function names, variable names, and their corresponding functions.
Consider the following snippet of JavaScript:
var y = 45;
function fTest(d)
{
var key: Argument.Callee;
var cars = 'Hello';
for (i = 0; i < cars.length; i++)
{
text += cars[i];
}
}
My desired outcome would be:
variable: 45
function:parameter:'d'
function:variable:argument.callee
function:variable:'Hello'
funtion:loop:variable:object
I am encountering difficulties navigating the List<Dynamic>
provided by Esprima.Net. Does anyone have suggestions on how to process or traverse this list in a tree or some other structure that allows easy access? Thank you.