Premium
A prettier compiler‐compiler: Generating higher‐order parsers in C
Author(s) -
Breuer Peter T.,
Bowen Jonathan P.
Publication year - 1995
Publication title -
software: practice and experience
Language(s) - English
Resource type - Journals
SCImago Journal Rank - 0.437
H-Index - 70
eISSN - 1097-024X
pISSN - 0038-0644
DOI - 10.1002/spe.4380251106
Subject(s) - computer science , programming language , compiler , parsing , compiler construction , compiler correctness
Top‐down (LL) context‐sensitive parsers with integrated synthesis and use of attributes are easy to express in functional programming languages, but the elegant functional programming model can also serve as an exact prototype for a more efficient implementation of the technology in ANSI C. The result is a compiler‐compiler that takes unlimited lookahead and backtracking, the extended BNF notation, and parameterized grammars with (higher‐order) meta‐parameters to the world of C programming. This article reports on the utility in question three years after public release. Precc generates standard ANSI C and is ‘plug compatible’ with lex ‐ generated lexical analyzers prepared for the UNIX yacc compiler‐compiler. In contrast to yacc , however, the generated code is modular, which allows parts of scripts to be compiled separately and linked together incrementally. The constructed code is relatively efficient, as is demonstrated by the example Occam parser treated in depth here, but the main advantages we claim are ease of use, separation of specification and implementation concerns, and maintainability.