I'm wondering how good is the Boost Spirit Library.
I have begun to read the documentation, but it seems to be a very huge framework, and ask for a lot of time to be master. I really don't want to waste my time on a framework which is no开发者_如何学Ct so wonderful as it could be.
I would like to have some opinions on this framework from user who very well known it.
My opinion is surely biased, so please take it with a grain of salt.
Spirit is a huge framework allowing to create very fast parsers and generators with C++. The created parsers and generators integrate nicely with your own data structures. Spirit requires some understanding of its underpinnings to be used efficiently. The documentation is fairly readable and explains things in easy terms. There are literally hundreds of examples available, which I suggest to consider part of the documentation. Understanding those examples is integral part of learning how to use Spirit. Simple tasks are easy to solve, more complex tasks tend to require some thinking and experimentation to get right (but that's probably not specific to Spirit). Spirit has an active community, a responsive and helpful mailing list, and a cool website with tons of additional information. Generally, if you're stuck, it's straightforward to get help.
You pay for all this niceness with increased compile times and huge compiler template error messages if you make an error. But once it compiles it usually works on the spot.
Old question that I came across while searching for some information on Spirit, but I figured I'd put my 2 cents in here for future readers.
At first I was pretty well daunted by the learning curve of Spirit, to the point that I almost gave up. But I'm very glad I kept going. The performance of this parser is just sick. I was previously using PCRE to parse HTTP headers with some simple regular expressions. That's a fairly simple operation and PCRE is pretty fast, so I didn't expect to see much of an improvement - if any - in the speed.
Boy was I surprised to see that it increased the performance by over 2000%. With Spirit I can parse 100,000 sets of HTTP headers in a little more than 1/4th of a second.
And the kicker is the code is so clean and compact compared to the equivalent code with PCRE. My original function that was 80 lines of PCRE gobbledygoop is now a cute little 14-line Spirit grammar, and a Fusion adapter to push the outputs directly to my class structure.
Difficult to learn, and the build times can get pretty bad, but the payoff is fantastic.
精彩评论