z-logo
open-access-imgOpen Access
Fast Partial Evaluation of Pattern Matching in Strings
Author(s) -
Mads Sig Ager,
Olivier Danvy,
Henning Korsholm Rohde
Publication year - 2004
Publication title -
brics report series
Language(s) - English
Resource type - Journals
eISSN - 1601-5355
pISSN - 0909-0878
DOI - 10.7146/brics.v11i40.21865
Subject(s) - memoization , backtracking , string (physics) , partial evaluation , quadratic equation , matching (statistics) , computer science , algorithm , time complexity , mathematics , theoretical computer science , programming language , statistics , geometry , parsing , mathematical physics , top down parsing
We show how to obtain all of Knuth, Morris, and Pratt's linear-time string matcher by specializing a quadratic-time string matcher with respect to a pattern string. Although it has been known for 15 years how to obtain this linear matcher by partial evaluation of a quadratic one, how to obtain it in linear time has remained an open problem.Obtaining a linear matcher by partial evaluation of a quadratic one is achieved by performing its backtracking at specialization time and memoizing its results. We show (1) how to rewrite the source matcher such that its static intermediate computations can be shared at specialization time and (2) how to extend the memoization capabilities of a partial evaluator to static functions. Such an extended partial evaluator, if its memoization is implemented efficiently, specializes the rewritten source matcher in linear time. Finally, we show that the method also applies to a variant of Boyer and Moore's string matcher. Supersedes BRICS-RS-03-11 and BRICS-RS-03-20.

The content you want is available to Zendy users.

Already have an account? Click here to sign in.
Having issues? You can contact us here