diff --git a/LLama/Grammar/GrammarParser.cs b/LLama/Grammar/GrammarParser.cs index a11d1040..4122e58f 100644 --- a/LLama/Grammar/GrammarParser.cs +++ b/LLama/Grammar/GrammarParser.cs @@ -372,25 +372,17 @@ namespace LLama.Grammar public ParseState Parse(string input) { - try - { - byte[] byteArray = Encoding.UTF8.GetBytes(input); - ReadOnlySpan src = new ReadOnlySpan(byteArray); - ParseState state = new ParseState(); - ReadOnlySpan pos = ParseSpace(src, true); - - while (!pos.IsEmpty) - { - pos = ParseRule(state, pos); - } + byte[] byteArray = Encoding.UTF8.GetBytes(input); + ReadOnlySpan src = new ReadOnlySpan(byteArray); + ParseState state = new ParseState(); + ReadOnlySpan pos = ParseSpace(src, true); - return state; - } - catch(Exception err) + while (!pos.IsEmpty) { - Console.Error.WriteLine($"{nameof(Parse)}: error parsing grammar: {err.Message}"); - throw; + pos = ParseRule(state, pos); } + + return state; } } }