EOEcient parsing combinators
Abstract:
This paper describes a set of space and time eOEcient parsing combinators that can return the position of the ��rst illegal token in case of failure. These combinators are intended for non-ambiguous grammars, e.g., grammars for programming languages, where an arbitrary lookahead might be needed. The arbitrary lookahead is implemented by backtracking. The possibility to backtrack means that the parser must hold on to its input as long as it has alternative rules to try. This prevent garbage collection of the input, increasing the memory demands. However, sometimes it is possible to guarantee that backtracking cannot give a better result than the current rule, e.g., when a key word in the grammar has been recognised. The novel part in this set of parsing combinators is the possibility to remove the backtracking capability if it is not needed. This has previously only been done for parsing combinators that cannot report the position of errors. The input that is held onto only to allow backtracking is dropped by applying a cut combinator. This combinator was introduction in a continuation based implementation of parsing combinators.
Citations
| 1128 | Monads for functional programming – Wadler - 1992 |
| 393 | Comprehending monads – Wadler - 1992 |
| 215 | Report on the Programming Language Haskell, A Non-strict, Purely Functional Language – Hudak, Jones, et al. - 1992 |
| 97 | Recursive Programming Techniques – Burge - 1975 |
| 82 | Higher-order functions for parsing – Hutton - 1992 |
| 77 | How to replace failure by a list of successes – Wadler - 1985 |
| 16 | Predictive parser combinators need four values to report errors – Partridge, Wright - 1996 |

