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].
[1]
Otto C. Juelich,et al.
On the recursive programming techniques
,
1964,
CACM.
[2]
Peter Norvig,et al.
Techniques for Automatic Memoization with Applications to Context-Free Parsing
,
1991,
CL.
[3]
Richard A. Frost,et al.
Guarded attribute grammars
,
1993,
Softw. Pract. Exp..
[4]
DONALD MICHIE,et al.
“Memo” Functions and Machine Learning
,
1968,
Nature.
[5]
Peter G. Harrison,et al.
Functional Programming
,
1988
.
[6]
Peter E. Lauer,et al.
Functional Programming, Concurrency, Simulation and Automated Reasoning
,
1993,
Lecture Notes in Computer Science.
[7]
John Hughes,et al.
Lazy Memo-functions
,
1985,
FPCA.