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

Non-terminal XXX has uninitialized Rule property

Jan 3, 2011 at 3:34 AM

Hello All,

I have a grammar put together and I'm trying to test it in Grammar Explorer.  GE keeps giving me this error:

Non-terminal TemplateIdentifier has uninitialized Rule property

...'TemplateIdentifier' is defined earlier in the code like this:

var TemplateIdentifier = new NonTerminal("TemplateIdentifier");

...'identifier' is defined earlier in the code like this:

IdentifierTerminal identifier = new IdentifierTerminal("identifier");

...and my Rule is defined like this:

TemplateIdentifier.Rule = identifier;

...what am I doing wrong?

Jan 4, 2011 at 6:55 PM

what this error means is that non-terminal has its Rule property set to null. You might be resetting it somewhere. Step through the grammar constructor with debugger and try to identify where it happens. Specifically, check that TemplateIdentifier.Rule != null on constructor exit. 


Jan 4, 2011 at 7:35 PM

Nope, it gets through the constructor with a value and continues into Grammar Explorer with a value (identifier, which is also not null).

Can I email you this grammar and you can take a look?...for laughs if nothing else? :)


Jan 4, 2011 at 10:20 PM

sure, send it, I'll have a look


Jan 4, 2011 at 11:48 PM

oh man, that's really funny... if you read carefully the error message, it says:

Non-terminal TemplateIdentifer has uninitialized Rule property.

Notice misspelled name, "...fer" instead of "fier". You actually have a different thing there with this misspelled name, a few lines below the commented out and correctly named one. You apparently (just as I did a few times) was doing search on the correctly named element, trying to find all its occurrences, and not hitting the troubled one... 

I think you can take it from here

good luck


Jan 5, 2011 at 12:43 AM

Oh man…maybe I need to increase the font size on my screen :)

That’s what I did, I even got rid of ‘TemplateIdentifier’ totally and still the error was there and I was thinking ‘is it being cached somewhere?’ and doing ‘clean project, clean project’ and making sure the files were gone.


Thanks for pointing it out, Roman…I can now move on to some new errors :)