The .subparse method may be what you are looking for. It captures at the beginning of the data and matches as much as it can. You can use the adverb :c to tell you where to start, and then look at the Match object to see where it stopped.
my $position = 0; my $match = Some::Grammar.subparse( $data, :c($position) );
If you keep track of where you are, you can switch grammars, try again when the buffer receives more data, etc.
In addition, you did not present the specific problem you are trying to solve.
brian d foy
source share