Bug in Colorizing solved

Oct 14, 2012 at 4:16 PM
Edited Oct 14, 2012 at 4:19 PM

Hi Roman,

Making the change below resolved a runtime exception that occurred regularly while building incremental enhancements to a grammar:

// in AstNode.cs:

    protected AstNode AddChild(NodeUseType useType, string role, ParseTreeNode childParseNode) {
      var child = (AstNode)childParseNode.AstNode;

// old code:
//      if (child == null)
//        child = new NullNode(childParseNode.Term); //put a stub to throw an exception with clear message on attempt to evaluate. 
// new code:
      if (child == null) {//put a stub to throw an exception with clear message on attempt to evaluate. 
        child = new NullNode(); 
        child.Init(null,childParseNode);  
      }
// [edit] End of change
child.Role = role; child.Parent = this; ChildNodes.Add(child); return child; }

The error was occurring a couple of different ways, but most often when Span was null attempting to locate the source Terminal. I believe this change also makes the constructor NullNode(BnfTerm term) redundant.

Coordinator
Oct 16, 2012 at 5:17 PM

thanks, will look into this

Roman

Apr 5, 2013 at 8:48 AM
I was trying this out because I am having the same issue in the grammar explorer, but I get:

Error 3 'Irony.Interpreter.Ast.NullNode' does not contain a constructor that takes 0 arguments

When calling

child = new NullNode();

any help? I'm new to Irony, so this can be obvious.
Coordinator
Apr 5, 2013 at 4:46 PM
NullNode is supposed to be singleton, global single instance