Possible bug in referencing predefined named subroutines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
JParks1982
Posts: 2
Joined: Thu Mar 28, 2019 6:49 pm

Possible bug in referencing predefined named subroutines

Post 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?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
JParks1982
Posts: 2
Joined: Thu Mar 28, 2019 6:49 pm

Possible bug in referencing predefined named subroutines

Post 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.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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...
Post Reply