Publication

Efficient parsing with parser combinators

Kurs, J., Vrany, J., Ghafari, M., Lungu, M. & Nierstrasz, O., 1-Sep-2018, In : Science of computer programming. 161, p. 57-88 32 p.

Research output: Contribution to journalArticleAcademicpeer-review

Copy link to clipboard

Documents

  • Efficient parsing with parser combinators

    Final publisher's version, 1 MB, PDF document

    Request copy

DOI

  • Jan Kurs
  • Jan Vrany
  • Mohammad Ghafari
  • Mircea Lungu
  • Oscar Nierstrasz

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.

Original languageEnglish
Pages (from-to)57-88
Number of pages32
JournalScience of computer programming
Volume161
Publication statusPublished - 1-Sep-2018

    Keywords

  • Optimizations, Parsing expression grammars, Parser combinators

View graph of relations

ID: 79038542