Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
travisdowns opened this issue Apr 26, 2019 · 0 comments

Comments

@travisdowns
Copy link
Owner

travisdowns commented Apr 26, 2019

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.

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

No branches or pull requests

1 participant