I have a `peg` parser with some sub-parsers:
    
    
    peg"""
       final <- (A / B / C)*
       A <- ...
       B <- ...
       C <- ...
       """
    
    
    Run

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](https://github.com/nim-lang/Nim/blob/2b56b38235c7cdb60a952ee4ec684a053eeee47c/lib/pure/pegs.nim#L1297-L1299)
 exists but the callback only knows the match number and count.

[eventParser](https://github.com/nim-lang/Nim/blob/2b56b38235c7cdb60a952ee4ec684a053eeee47c/lib/pure/pegs.nim#L950)
 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.

Reply via email to