Pragmatic parsing in Common Lisp; or, putting defmacro on steroids
ACM SIGPLAN Lisp Pointers
Template meta-programming for Haskell
Proceedings of the 2002 ACM SIGPLAN workshop on Haskell
Journal of Functional Programming
Removing left recursion from context-free grammars
NAACL 2000 Proceedings of the 1st North American chapter of the Association for Computational Linguistics conference
Why it's nice to be quoted: quasiquoting for haskell
Haskell '07 Proceedings of the ACM SIGPLAN workshop on Haskell workshop
Combinator Parsing: A Short Tutorial
Language Engineering and Rigorous Software Development
Invertible syntax descriptions: unifying parsing and pretty printing
Proceedings of the third ACM Haskell symposium on Haskell
Explicitly recursive grammar combinators: a better model for shallow parser DSLs
PADL'11 Proceedings of the 13th international conference on Practical aspects of declarative languages
Feat: functional enumeration of algebraic types
Proceedings of the 2012 Haskell Symposium
FliPpr: a prettier invertible printing system
ESOP'13 Proceedings of the 22nd European conference on Programming Languages and Systems
Hi-index | 0.00 |
We present a novel method of embedding context-free grammars in Haskell, and to automatically generate parsers and pretty-printers from them. We have implemented this method in a library called BNFC-meta (from the BNF Converter, which it is built on). The library builds compiler front ends using metaprogramming instead of conventional code generation. Parsers are built from labelled BNF grammars that are defined directly in Haskell modules. Our solution combines features of parser generators (static grammar checks, a highly specialised grammar DSL) and adds several features that are otherwise exclusive to combinatory libraries such as the ability to reuse, parameterise and generate grammars inside Haskell. To allow writing grammars in concrete syntax, BNFC-meta provides a quasi-quoter that can parse grammars (embedded in Haskell files) at compile time and use metaprogramming to replace them with their abstract syntax. We also generate quasi-quoters so that the languages we define with BNFC-meta can be embedded in the same way. With a minimal change to the grammar, we support adding anti-quotation to the generated quasi-quoters, which allows users of the defined language to mix concrete and abstract syntax almost seamlessly. Unlike previous methods of achieving anti-quotation, the method used by BNFC-meta is simple, efficient and avoids polluting the abstract syntax types.