Bug in handling of Non-terminal symbols

May 23, 2010 at 9:16 PM

In the code from the GPLEX project, within ShiftReduceParser, there is a one-off bug in the symbol handling. It only manifests when you ask for TRACE_ACTIONS, since it isn't heavily used. The non-terminal symbol table is 0 based, and you attempt to index it using 1 based indices. A little code tweak shown below corrects this.

private string SymbolToString (int symbol) 
	if (symbol < 0)
		// Error was here.
		return nonTerminals [-symbol - 1]; 
		return TerminalToString (symbol);

I've been having a blast hacking on the code, so thanks for putting it out there.

May 27, 2010 at 11:21 AM
Thanks to blackhawk451. Yes it was a bug in an undocumented feature. Version 1.4.1 of gppg, uploaded today, corrects the bugs, upgrades the feature AND documents the feature.