Efficient parsing with parser combinators

Jan Kurs*, Jan Vrany, Mohammad Ghafari, Mircea Lungu, Oscar Nierstrasz

*Bijbehorende auteur voor dit werk

OnderzoeksoutputAcademicpeer review

2 Citaten (Scopus)
121 Downloads (Pure)


Parser combinators offer a universal and flexible approach to parsing. They follow the structure of an underlying grammar, are modular, well-structured, easy to maintain, and can recognize a large variety of languages including context-sensitive ones. However, these advantages introduce a noticeable performance overhead mainly because the same powerful parsing algorithm is used to recognize even simple languages. Time-wise, parser combinators cannot compete with parsers generated by well-performing parser generators or optimized hand-written code.

Techniques exist to achieve a linear asymptotic performance of parser combinators, yet there is a significant constant multiplier. The multiplier can be lowered to some degree, but this requires advanced meta-programming techniques, such as staging or macros, that depend heavily on the underlying language technology.

In this work we present a language-agnostic solution. We optimize the performance of parsing combinators with specializations of parsing strategies. For each combinator, we analyze the language parsed by the combinator and choose the most efficient parsing strategy. By adapting a parsing strategy for different parser combinators we achieve performance comparable to that of hand-written or optimized parsers while preserving the advantages of parsers combinators. (C) 2017 Elsevier B.V. All rights reserved.

Originele taal-2English
Pagina's (van-tot)57-88
Aantal pagina's32
TijdschriftScience of computer programming
StatusPublished - 1-sep.-2018

Citeer dit