|Ned Batchelder : Blog | Code | Text | Site|
Spirit parser framework
» Home : Blog : September 2004
If you want to generate a parser, there are lots of choices of software to help you. Most follow the classic yacc model: you write a grammar in a dedicated grammar language, run it through a parser generator, and end up with executable code for your parser. Newer tools run the same way: Bison, ANTLR, and Lemon.
So I was interested to find the Spirit Parser Framework, which employs a completely different technology. Grammars are written in highly stylized C++, and executed directly. The grammar syntax is unconventional, because it's all based on C++ operator overloading. Here's part of a SQL parser:
program = +(query) ;
Significant template wizardry is at work behind the scenes, I don't claim to understand it.