-
Notifications
You must be signed in to change notification settings - Fork 243
Description
I saw an interesting request which made me thinking. While PCRE is perfectly capable of matching complex patterns, it could only return with a fixed set of captures. For example, it can parse a table with columns, but it cannot return with the column list, since the number of columns is not fixed.
The feature would look like this: (*push:<ID>PATTERN). The character range with its ID is pushed onto a stack. When the engine backtracks, the item is popped as well.
Since allocating new items may fail, this construct may break matching. By default, there is no stack, so using this construct always aborts the match. The user application must allocate the stack (with its allocation limit), and add it to match data. The cost is an extra pointer in match data for those applications, which does not use this feature.
What do you think?