×

Elkhound: A fast, practical GLR parser generator. (English) Zbl 1125.68354

Duesterwald, Evelyn (ed.), Compiler construction. 13th international conference, CC 2004, held as part of the joint European conferences on theory and practice of software, ETAPS 2004, Barcelona, Spain, March 29 – April 2, 2004. Proceedings. Berlin: Springer (ISBN 3-540-21297-3/pbk). Lecture Notes in Computer Science 2985, 73-88 (2004).
Summary: The Generalized LR (GLR) parsing algorithm is attractive for use in parsing programming languages because it is asymptotically efficient for typical grammars, and can parse with any context-free grammar, including ambiguous grammars. However, adoption of GLR has been slowed by high constant-factor overheads and the lack of a general, user-defined action interface.
In this paper we present algorithmic and implementation enhancements to GLR to solve these problems. First, we present a hybrid algorithm that chooses between GLR and ordinary LR on a token-by-token basis, thus achieving competitive performance for determinstic input fragments. Second, we describe a design for an action interface and a new worklist algorithm that can guarantee bottom-up execution of actions for acyclic grammars. These ideas are implemented in the Elkhound GLR parser generator.
To demonstrate the effectiveness of these techniques, we describe our experience using Elkhound to write a parser for C++, a language notorious for being difficult to parse. Our C++ parser is small (3500 lines), efficient and maintainable, employing a range of disambiguation strategies.
For the entire collection see [Zbl 1047.68723].

MSC:

68N20 Theory of compilers and interpreters
68Q42 Grammars and rewriting systems

Software:

Elkhound; ATERM
PDFBibTeX XMLCite
Full Text: DOI