Is your feature request related to a problem? Please describe.
The existing Grammar::parse_input method is useful for parsing input text according to a Grammar. But the current API builds "one use" parsers. This limitation forces some redundant work to be repeated when parsing multiple input texts.
// each of these builds completely new `GrammarMatching` and other parsing tables,
// which are then freed before the next `parse_input`, wasting computation
grammar.parse_input(input_1);
grammar.parse_input(input_2);
grammar.parse_input(input_3);
Describe the solution you'd like
Instead, a single GrammarParser could be available which would reuse parser data efficiently:
let parser = grammar.input_parser();
// common immutable parser data is shared between calls
parser.parse_input(input_1);
parser.parse_input(input_2);
parser.parse_input(input_3);
Describe alternatives you've considered
Maybe this just doesn't matter! I am not sure if this new API would even make much of a performance difference. I am not sure "how much faster" would warrant a new API method. 1% faster? 5% faster? 50% faster?
Is your feature request related to a problem? Please describe.
The existing
Grammar::parse_input
method is useful for parsing input text according to aGrammar
. But the current API builds "one use" parsers. This limitation forces some redundant work to be repeated when parsing multiple input texts.Describe the solution you'd like
Instead, a single
GrammarParser
could be available which would reuse parser data efficiently:Describe alternatives you've considered
Maybe this just doesn't matter! I am not sure if this new API would even make much of a performance difference. I am not sure "how much faster" would warrant a new API method. 1% faster? 5% faster? 50% faster?