"var1=key; var2=key2".replace(peg"{\ident}'='{\ident}", "$1<-$2$2")
Which does the job, but what if I want to pass $1 and $2 to a proc and do something with them? I guess what I am missing is Ruby's block syntax to process matches, like for the gsub method:
http://robots.thoughtbot.com/rubys-gsub-with-a-block
Is there any way to achieve this in Nimrod?
However, with the current limits I couldn't find any way to create a parser easily straight from a peg in Nimrod, due to the limits in the number of captures among other things. Am I overlooking something really obvious here?
I am currently experimenting with the pegs module and implemented the callback replace which was proposed here. If you are interested you may want to checkout my PR for that: https://github.com/nim-lang/Nim/pull/4136
BTW: I know that this is a zombie topic but peg did just came up in a different topic and I think there is much to few coverage for this module anyway!