zevv / npeg

PEGs for Nim, another take
MIT License
330 stars 22 forks source link

FR: Deferred code block captures #66

Closed turbo closed 1 year ago

turbo commented 1 year ago

Note that for code block captures, the Nim code gets executed during parsing, even if the match is part of a pattern that fails and is later backtracked.

It'd be cool to have some sort of API that defers code block execution until after parsing or at least beyond where backtracking is possible. Right now I'm using npeg for validation and to construct a tree, but I have to basically dispatch magic strings (using push) from the code block, and then re-parse those later to perform the checks I need. A simplified example would be: count how many times this rule has fired the code block. This count will currently include partial paths.

zevv commented 1 year ago

Yeah, it's a nuisance, this is essentially what issue #14 is about; For some reason, this issue never was urgent enough to get this in motion. I'm marking this one as a dup issue for now.

duplicate of #14