pomsky icon indicating copy to clipboard operation
pomsky copied to clipboard

Detect infinite recursion

Open Aloso opened this issue 2 years ago • 1 comments

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.

Aloso avatar Nov 05 '23 20:11 Aloso

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

  1. does not contain any recursion, or
  2. is an alternation where at least one branch is terminating, or
  3. is a repetition that may repeat 0 times

If the entire expression (after resolving variables) is terminating, there is no infinite recursion.

Aloso avatar May 29 '24 08:05 Aloso