Skip to content

Don't create new substates for captures that aren't referenced by a backref #1

@travisdowns

Description

@travisdowns

In principle we only need to "record" (i.e., create new subNFA graphs) for captures that are actually used by some later backreference. I.e., in (.)(.)(.)\1\3 we currently record all three groups but only 1 and 3 are actually used. In principle it could be written with 2 as a non-capturing group like (.)(?:.)(.)\1\2 but we don't want to rely on the user for that.

Since number of unique backreferences is limited (to nine, i.e. \1 through \9), but the number of capture groups is unlimited, the behavior is important since if limited the captures based on found backreferences we can claim we are in P regardless of the regex.

This is as simple as scanning the regex after parsing and limiting the captures to those with at least one corresponding backreference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions