I have a peg parser with some sub-parsers:
peg"""
final <- (A / B / C)*
A <- ...
B <- ...
C <- ...
"""
And I want to process the captures from A/B/etc but I don't see a way associating a capture with the parser that produced it.
replace exists but the callback only knows the match number and count.
eventParser has a way of hooking into subparsers but does not have access to the captures, just the full match.
I could break up the grammar into its subparsers but that would require scanning the same string multiple times.
Is there something in the API that I'm missing?
Ideally there would be a way of passing the captures to a Nim function directly in the peg grammar syntax similar to strscans or a function that takes a peg and a callback that contains a table associating subparser names to captures.