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

Creating the AST

Jul 31, 2013 at 10:01 AM

My project requires creating a DSL for creating SSIS packages. I am exploring Irony.Net for the same but currently stuck at the point where I need to create the AST from the ParseTree. Following is the snapshot of the code:
// ETLGrammar is my custom defined grammar
ETLGrammar grammar = new ETLGrammar();
LanguageData compiler = new LanguageData(grammar);
Parser _parser = new Parser(compiler);
ParseTree programTree = _parser.Parse(sourceCode);

//How to create the AST from the Parse Tree
I am new to Irony and what I have noticed the programTree.Root.AstNode is null and so is the case for all the child nodes as well.

Help in this matter is highly appreciated.

Thanks and Regards
Saptarshi Chaudhuri
Aug 1, 2013 at 3:43 AM
To build AST tree you need to do 2 things:
  1. specify Ast node types for all non-terminals in your grammar (except Transient ones)
  2. Set CreateAst flag in language flags
    See expression evaluator for an example