benlangfeld/ruby_speech — pull request #34 by sfgeorge (2014-10-17 07:50:45+00:00)
Title: [BUGFIX] Ensure that Rulerefs n-levels deep are expanded

When grammars are interpreted _inline_ by RubySpeech itself, the intention was to expand all internal rulerefs to other, literal elements.

The problem: If a nesting exists in which a referenced rule references yet another rule, the expansion would be incomplete and inline matching would fail.

This fixes the issue by ensuring that rulerefs continue to be expanded until no more exist.

**Note:** As the pending test in 33b368c highlights, **this code introduces the possibility for an infinite loop** if someone improperly constructs a Rule that references itself. That's an invalid operation, but certainly RubySpeech should not run away forever and never come back. Soliciting feedback here on whether to short-circuit and error if a certain threshold \# of dereferences is exceeded.

* [x] Ensure that Rulerefs n-levels deep are expanded
* [x] Improve invalid ruleref error message
* [ ] Ensure self-referencial Rules don't cause infinite loops