Bug in GrammarBuilder fixed. All test cases pass.