On 9/29/05, Joel de Guzman
Aaron Griffin wrote:
Ok, I didn't go to school for computer programming, so I never had experience with a "Compilers" class or anything related to lexing/parsing. But now I'm getting interested in it and have begun looking at some things.
Spirit seems good, but it seems very weighty to work with.
Spirit-2 (core) will fix this impression. I'm working on it. It would help a lot if you add few sentences why you think Spirit "seems very weighty".
I alway love it when developers take an active interest, so thanks alot. As for my "weighty" impression - it has nothing to do with actual functionality or anything, as I haven't actually finished/tested anything beyond a proof-of-concept. I definately like the fact that I can get rid of yacc (yucck!) and generators like that. Maybe it was my days with MFC that made me dislike generated code. Anyway, what makes it feel "weighty" to me may be normal, as I stated before, I'm new to the whole lexer/parser game. I usually just iterate over strings, toss some stringstreams around, things like that. I guess what it is is really that, compared to things like the STL, theres alot more work before you can begin to use it. If you look at things like Xlib, you call 2-4(ish) functions and then loop with XNextEvent. Simple. Want to try out std::transform? std::string s = "something"; std::transform(s.start(),s.end(),s.start(),toupper); With Spirit you have to make sure you generate the proper grammer, add semantic actions in the right place, and make sure you have a handful of things in proper order (nested definition{} with start() and things like that). Now don't get me wrong. I'm not saying this is bad or anything. It may just be the way I design things (yeah, in a bit more of a C way). I can't really propose anything, except that some generic generator functions might make things intersting... for instance, something like: rule<> something = '_' >> range('a','z') >> '_'; rule<> another = ('(' | '[') >> something >> (']' | ')'); parse(start,end, make_grammar(/*start rule*/ something, /*the rest*/ another); ); If I could generate a full parser for something simple in that fashion, that'd be great. Now, I'm not saying the class thing is bad. But for, say, parsing a url or something small, the tradeoff is small. But still, thanks alot for Spirit. And thanks to Simon for explaining the nuances I first noted. I wasn't even thinking in terms of operator precedence.