ASTNodeCreator Sample?

Jan 31, 2012 at 10:23 AM
Edited Feb 1, 2012 at 3:22 AM


I am trying to "flatten" the parsing as it takes place using the ASTNodeCreator delegate, rather than, say, walking the tree after construction.

    public class SqlDialect : Grammar

        readonly IList<Element> _details = new List<Element>();

        public SqlDialect(IList<Element> details) : base(caseSensitive: false) 

            _details = details;

            var id_simple = TerminalFactory.CreateSqlExtIdentifier(this, "id_simple"); 
            var domainIdentifier = new NonTerminal(Constants.Domain, (c, n) => 
                                            _details.Add(new Element() 
                                                NodeType = NodeType.domain, 
                                                Value = n.Token.Value.ToString()
  	               			    var astNode = new NullAstNode();
	                                    astNode.Init(c, n);

I obviously haven't quite got it right in terms of using the delegate since there is a parse error (Object Reference Not Set to an instance of an Object). suggests looking at the ExpressionEvaluator but the version I have downloaded only uses the Type NodeType overload and not the AstNodeCreator delegate overload. I have checked the other sample grammars and couldn't see any there either. FYI, I'm not doing anything at all in the NullAstNode

I was wondering if someone could point my in the right direction with a sample or perhaps if this is not the best option indicate the better way. Perhaps there is a better extension point I should be using?

Many thx


Jan 31, 2012 at 1:22 PM
Edited Jan 31, 2012 at 1:23 PM

So I decided to flatten it after creation.