Closed xrstf closed 7 months ago
No, there is no way to reuse such a rule as regex in Go code, since PEG and regex are two distinct things. The only idea, that comes to mind is to have multiple entry points for your grammar and instead of using regex, use the PEG parser in the places, where you currently use regex.
See -alternate-entrypoints=RULE[,RULE...]
flag.
Thanks, then I'll just leave copious amounts of comments to prevent me from f*ing up in the future 😁
My grammer has rules like
I would like to make this regular expression available as Go variable. From what I can see, Pigeon disects the pattern and generates some custom stuff. I tried to define a regexp in the initializer
but this does not yield the expected result.
Is there a way to maintain the regexp just once in my codebase, instead of leaving a comment like