TY - JOUR
AU - Ager, Mads Sig
AU - Danvy, Olivier
AU - Rohde, Henning Korsholm
PY - 2003/05/06
Y2 - 2024/04/25
TI - Fast Partial Evaluation of Pattern Matching in Strings
JF - BRICS Report Series
JA - BRICS
VL - 10
IS - 20
SE - Articles
DO - 10.7146/brics.v10i20.21790
UR - https://tidsskrift.dk/brics/article/view/21790
SP -
AB - We show how to obtain all of Knuth, Morris, and Pratt's linear-time string matcher by partial evaluation of 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 <em>in linear time</em> has remained an open problem.<br /> <br />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.<br /><br />Supersedes BRICS-RS-03-11 and is superseded by BRICS-RS-04-40.
ER -