sebfisch / haskell-regexp

Regular Expression Matching in Haskell

Home Page:http://sebfisch.github.com/haskell-regexp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

single traversal

sebfisch opened this issue · comments

Currently, the combination of the functions next and acivateFirst leads to quadratic run-time for certain regular expressions. For example, in a****** activateFirst is called on every sub-expression and traverses each anew. Also, if all symbols in a?a?a?a?a? are activated, then step is called recursively on every sub-expression and calls activateFirst each time on the right child.

Write a single function that traverses an expression only once.

This may prevent the later use of parallelism because one probably needs to do a left-to-right walkthrough.

Implemented in simple version: 6c889ab.

The implementation does not thread things through the tree and, hence, does not prevent later parallelisation. The evilRegExp example runs an order of magnitude faster (half a second for n=1000). Correctness not yet tested for other examples.

implemented together with the generalisation to semirings.