I want to go through the AST tree and get the ChildNode equals "IfStatement" but there could be a lot of Childnodes like in code below. Is there some method to do it in recursive way to add childNodes and check the value ?
MyGrammar grammar = new MyGrammar ();
Parser parser = new Parser(grammar);
var result = parser.Parse(textBox.Text);
var IfNode=result.Root.ChildNodes[0].ChildNodes[0].ChildNodes[1].ChildNodes[0].ToString() == "IfStatement";
I am trying something like this but it doesnt work
var IfCheck = result.Root.ChildNodes.FindAll(x => x.ChildNodes.ToString() == "IfStatement");