Quote:Original post by theOcelot
I might get on board with a simpler Spirit type library. But I bet that at the beginning, Spirit was meant to be a simple, clean little library too, but to do the kind of stuff it does is just flat-out complicated. You'd have to have a rather cut-down feature list.
Yes, you're right ... In the sketch of a parser library that I tried to explain above, I
am cutting down features. Namely, I'm saying that the output of each parser object -- where by "parser object" I mean the things that you compose together to construct your target grammar -- has to be a dynamically allocated instantiation of a class that derives from a base class that all of the parser objects take as a template parameter. You would be given a class hierarchy of parser object templates, would construct your grammar by composing instantiations of them, would provide a class hierarchy of output tree nodes, and would tell the parser objects how to create output tree nodes by supplying an appropriate boost::function object when instantiating a parser object. It would be verbose, yes, but, you know, so is spirit.
Spirit is a remarkable achievement and it has no drawbacks if your development box happens to be a very fast computer. But spirit is trying consciously to be a template metaprogramming library -- this was obviously one of the constraints that its designer put on it. What I'm saying is that if you don't mind using old-fashioned polymorphism/inheritance you could write something similar that may not be as clever but that would compile faster.
[Edited by - jwezorek on March 13, 2010 5:02:44 AM]