hannibal

Parsing Strategy

lally's picture

I've gotta process C++ code, converting it to C++ code (with some constructs transformed in the middle). Last week I started playing with Hannibal, a Spirit-based parser that does some of C++. It does most of the important parts, but making it choke wasn't hard enough -- the source to Boost.Wave's wave tool was able to kill it pretty easily. Hannibal has over 100 rules in it, but still only covers about half the language. Later, it'd be a great starting point for a full C++ grammar.

Strategy
Well, the hannibal-based approach would require lots of grunt analysis and grammar work, when my program's need to understand the text it was processing is very shallow — a poor mix. Instead, take the hack approach: the parser just filters what's important vs what isn't.

lally – Wed, 2006 – 06 – 28 19:20
Syndicate content