pomsky
pomsky copied to clipboard
Detect infinite recursion
Is your feature request related to a problem? Please describe.
Pomsky should prevent you from accidentally introducing infinite recursion. Oniguruma actually does this, so Pomsky may produce regexes that are rejected by oniguruma.
Describe the solution you'd like
Pomsky should detect whenever recursion may be infinite. It should at least reject all expressions that are rejected by oniguruma.
This should be rather simple: We need to make sure that the expression can match without matching the recursion keyword.
Let's define a sub-expression as "terminating" if it
- does not contain any recursion, or
- is an alternation where at least one branch is terminating, or
- is a repetition that may repeat 0 times
If the entire expression (after resolving variables) is terminating, there is no infinite recursion.