sebfisch / haskell-regexp

Regular Expression Matching in Haskell
http://sebfisch.github.com/haskell-regexp/
Other
34 stars 5 forks source link

prune inactive parts of marked regexp #19

Open sebfisch opened 14 years ago

sebfisch commented 14 years ago

Currently, a regular expression is not altered during matching, except for shifting marks.

However, inactive parts that can never again become active do not influence the results of empty and final and can be dropped or replaced by noMatch or eps depending on whether they accept the empty word. Inactive parts may become active only if they have active parts to their left or if they are inside an active repetition.

Pruning may improve performance significantly for infinite regular expressions which do not use repetitions, and maybe even for large finite expressions such as (a?){n}a{n} for large n.