Norvig [1991] has shown that a process with properties that are similar to those of Earley's algorithm can be generated by a simple top-down backtracking parser when augmented by memoization. Unfortunately, Norvig's approach cannot be implemented directly in pure functional programming languages such as Miranda, Haskell, LML, etc, owing to the fact that such languages do not provide any form of mutable object. This restriction is a necessary condition for referential transparency, a property of programs that simplifies reasoning about them and which is widely regarded as one of the main advantages of the pure functional programming style. In this note, we show how Norvig's approach can be adapted and used to achieve polynomial complexity of non-deterministic top-down backtracking parsers that are implemented as executable specifications in pure functional programming languages. The technique that we present uses a slight variation of an approach to implementing memoization in pure functional languages that is described in Field and Harrison [1988].
Read full abstract