Skip to content

Conversation

@iabyn
Copy link
Contributor

@iabyn iabyn commented Dec 2, 2025

These two commits contain minor improvements to the debugging output produced by the regex engine.

  • This set of changes does not require a perldelta entry.

(This commit makes no practical changes in behaviour except for
debugging output.)

Currently, one of the regex engine stack states is EVAL_postponed_AB.

When executing something like /(??{'A'})B/ where A and represent
general subpatterns, the engine executes the eval code, which returns
the string 'A', which is compiled into a subpattern. Then the engine
pushes an EVAL_postponed_AB state and runs the subpattern until it
reaches an END op. Then it pushes *another* EVAL_postponed_AB state and
runs the B part of the pattern until the final END. Then before
returning success, it pops EVAL_postponed_AB off the stack (twice),
executing any cleanup required. Similarly during failure, the
EVAL_postponed_AB_fail action will be executed once or twice (depending
on whether it failed during A or B).

This commit splits that state into two,

    EVAL_postponed_A
    EVAL_postponed_B

The first is pushed before running A, the second before running B.
The actions currently remain the same and share the same code; i.e. this
commit just does the equivalent of:

-        case EVAL_postponed_AB:
+        case EVAL_postponed_A:
+        case EVAL_postponed_B:
            ... cleanup code ....

But it makes the code easier to understand, makes debugging output
clearer, and will allow in future for the cleanup behaviours to differ
between A and B.

This commit also fixes up a few debugging messages and code comments
which were still referring to 'EVAL_AB', which was renamed to
EVAL_postponed_AB some years ago.
Copy link
Contributor

@khwilliamson khwilliamson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd commit message doesn't make sense When executing something like /(??{'A'})B/ where A and represent

Otherwise lgtm

@iabyn iabyn closed this Dec 2, 2025
@iabyn iabyn deleted the davem/re_debug branch December 2, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants