Generating AST

Oct 11, 2010 at 1:08 AM

Hi! Great job. I have one question: I`d like to use your project to get an AST tree. I add #define AST but there`s one problem (ParseFileAST method):

 parser_rt = p.compilation_unit(); 

compilation_unit returns void. I dont understad how it works and what sholud I do to get AST ?

Thanks in advance.

Coordinator
Oct 12, 2010 at 5:57 PM

You just have to set the output option in the grammar file, cs.g.  Then p.compilation_unit() will return you the AST.

options
{
....
output=AST;
....
}

HTH

Mar 24, 2011 at 3:05 PM

Brilliant!

Jun 9, 2015 at 2:12 PM
the AST is not a "real ast". I get 88 Tokens and than 87 tree items where none has parent or child.

How do I get a real AST ? I expected something like NameSpaceNode has Classes, Class Node has Methods etc