This project has moved and is read-only. For the latest updates, please go here.

Get children within ast nodes

Apr 4, 2013 at 3:37 PM
Edited Apr 4, 2013 at 3:40 PM
Hello there,

Irony is a really powerful tool, congratulations for your job!

I've wrote a grammar for my needs, the tree is perfectly built. But the AST nodes doesn't have their children list filled up, so I need to add this code to every AstNode class:
        public override void Init(AstContext context, ParseTreeNode treeNode)
            foreach (var childNode in treeNode.ChildNodes)
                ChildNodes.Add(childNode.AstNode as AstNode);
            base.Init(context, treeNode);
Am I doing it right ?

BTW, I've learned to use it following the tutorial on CodeProject, which is very interesting but its not up to date so a lot of classes don't exist anymore, is there any other documentation more up to date ?

Apr 4, 2013 at 5:52 PM
AstNode class has following method, use it in your own subclasses:
AstNode AddChild(string role, ParseTreeNode childParseNode)
About documentation. The only actual documentation is an Irony sourcecode, AFAIK.