Page 1 of 1

Possible bug in referencing predefined named subroutines

Posted: Fri Mar 29, 2019 5:59 pm
by JParks1982
I'm hoping that someone can help me determine whether or not the following is a software bug, or if I'm doing something wrong (most likely).

I am building a series of regular expressions composed of predefined named subroutines. In this example, I reference the predefined named subroutine 'id' within another predefined named subroutine 'id_alias'. In my non-minimal code, I make many more references to predefined named subroutines from within other predefined named subroutines. I have come up with a minimal example that demonstrates the problem I am about to describe:

Code: Select all

(?(DEFINE)(?'comment'\/\*(?!\*\/)[\/s\/S]*?\*\/|\/\/.*+)
          (?'quoted_string'\"[^\"]*\")
          (?'id'\b[a-zA-Z_]\w*+\b)
          (?'id_alias'(?&id))
)(?&comment)(*SKIP)(*F)|(?&quoted_string)(*SKIP)(*F)|(?&id_alias)
When I attempt to apply this regex in TextPad 8.1.2 (64-bit Edition), I receive the message "Encountered an infinite recursion". This regex works when I test it using the following link:

https://regex101.com/r/gTLkmm/1

Is it not possible to reference predefined named subroutines from within other predefined named subroutines in TextPad?

Posted: Sat Apr 06, 2019 2:33 pm
by ben_josephs
I see similar things. Here's a minimaller example than yours:

Code: Select all

(?(DEFINE)(?'a'a)
          (?'b'(?&a))
)(?&b)|(?&a)
is OK, but

Code: Select all

(?(DEFINE)(?'a'a)
          (?'b'(?&a))
)(?&a)|(?&b)
results in the error message (note the different ordering of the calls).

TextPad uses the Boost regex library. I've seen suggestions on the web that its implementation of subroutines is buggy.

Possible bug in referencing predefined named subroutines

Posted: Mon Apr 08, 2019 3:22 pm
by JParks1982
Thanks for the response. Hmm, I wonder if there are any workarounds? I bought EditPadPro over the weekend thinking that it would allow me to use regex subroutines, but alas, it doesn't. It's really disappointing too since the website https://www.regular-expressions.info/ so heavily touted its "robustness". I may go to the Boost website to see if a corresponding bug report has been logged.

Posted: Mon Apr 08, 2019 8:10 pm
by ben_josephs
The Boost regex library was written by John Maddock. I contacted him about it in the past and found him very responsive and helpful. But that was many years ago...