Skip to content
This repository was archived by the owner on Oct 11, 2021. It is now read-only.
This repository was archived by the owner on Oct 11, 2021. It is now read-only.

Detect alternations which are prefix of another #15

@RunDevelopment

Description

@RunDevelopment

Top-level alternations like int|integer are problematic because the word integer integer will never be matched.

In general: Let A and B be a pair of distinct alternatives of the same alternation where A comes before B.
If there ex. a word w in L(A) and x in L(B) \ L(A) such that w is prefix of x, then x can never be matched by B.
In other words: Report if   [ L(B) \ L(A) ] ∩ L(/A[\s\S]*/) != ∅.

Examples:

/a|b/ //ok
/a|aa/ // report that `aa` cannot be matched
/a\b|aa/ // ok
/a|[ab]a/ // report that `aa` cannot be matched
/(?:a|[ab]a)\b/ // ok
/a(a|aa)a/  // report that `aaaa` cannot be matched

Metadata

Metadata

Assignees

No one assigned

    Labels

    new ruleruleIt's about new or existing ruleswontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions