A packrat parser provides the power and flexibility of top-down parsing with backtracking and unlimited lookahead, but nevertheless guarantees linear parse time. Packrat parsing is a novel technique for implementing parsers in a lazy functional programming language. Keywords: compiler-compiler parsers yacc infinite-lookahead top-down parsing grammars Occam 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. In contrast to yacc, however, the generated code is modular, which allows parts of scripts to be compiled separately and linked together incrementally. Precc generates standard ANSI C and is ‘plug compatible’ with lex-generated lexical analyzers prepared for the UNIX yacc compiler-compiler. This article reports on the utility in question three years after public release. 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. Top-down (LL) context-sensitive parsers with integrated synthesis and use of attributes are easy to expressin 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |