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. I was wondering if anyone has experiences with Spirit *and* CTTL and would be able to list for me some of the pros and cons of each. Spirit is, of course, a boost library and would be easier to find help and things of that nature, but CTTL seems to be a tad more lightweight (I'm not really sure). Thanks for any and all replies.
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.
I was wondering if anyone has experiences with Spirit *and* CTTL and would be able to list for me some of the pros and cons of each. Spirit is, of course, a boost library and would be easier to find help and things of that nature, but CTTL seems to be a tad more lightweight (I'm not really sure).
Thanks for any and all replies.
Don't forget to put a link in: http://cttl.sourceforge.net/ From what I've seen, this is MUCH harder to write grammars in, but that's probably just because i'm not used to it. Compare: Echo's back a Java/C++ program without it's comments: http://cttl.sourceforge.net/example_cpp_comment_strip_cpp.html Description of Spirit's comment matching facilities (amongst other uses), A file that demonstrates it is linked at the bottom. http://www.boost.org/libs/spirit/doc/confix.html
On 9/28/05, Simon Buchan
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.
I was wondering if anyone has experiences with Spirit *and* CTTL and would be able to list for me some of the pros and cons of each. Spirit is, of course, a boost library and would be easier to find help and things of that nature, but CTTL seems to be a tad more lightweight (I'm not really sure).
Thanks for any and all replies.
Don't forget to put a link in: http://cttl.sourceforge.net/
Errrmmm... I could have *sworn* I put that link in there....
From what I've seen, this is MUCH harder to write grammars in, but that's probably just because i'm not used to it. Compare:
Echo's back a Java/C++ program without it's comments: http://cttl.sourceforge.net/example_cpp_comment_strip_cpp.html Description of Spirit's comment matching facilities (amongst other uses), A file that demonstrates it is linked at the bottom. http://www.boost.org/libs/spirit/doc/confix.html
Hmmm, I see now. Of course, you have to ignore all the extraneous stuff in the CTTL example... and semantic actions and things like that. I actually started messing with both spirit and cttl on a similar parser (contrived syntax) and while the spirit one is much easier to write, there's syntactic things that bother me (+ would have been better than >> for sequence operator, overloading [] for semantic actions seems awfully arbitrary, and the requirement for my_grammar::definition seems unnessecary), but I guess that's what I'll have to live with, eh?
Aaron Griffin wrote:
On 9/28/05, Simon Buchan
wrote: 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.
I was wondering if anyone has experiences with Spirit *and* CTTL and would be able to list for me some of the pros and cons of each. Spirit is, of course, a boost library and would be easier to find help and things of that nature, but CTTL seems to be a tad more lightweight (I'm not really sure).
Thanks for any and all replies.
Don't forget to put a link in: http://cttl.sourceforge.net/
Errrmmm... I could have *sworn* I put that link in there....
From what I've seen, this is MUCH harder to write grammars in, but that's probably just because i'm not used to it. Compare:
Echo's back a Java/C++ program without it's comments: http://cttl.sourceforge.net/example_cpp_comment_strip_cpp.html Description of Spirit's comment matching facilities (amongst other uses), A file that demonstrates it is linked at the bottom. http://www.boost.org/libs/spirit/doc/confix.html
Hmmm, I see now. Of course, you have to ignore all the extraneous stuff in the CTTL example... and semantic actions and things like that. I actually started messing with both spirit and cttl on a similar parser (contrived syntax) and while the spirit one is much easier to write, there's syntactic things that bother me (+ would have been better than >> for sequence operator, overloading [] for semantic actions seems awfully arbitrary, and the requirement for my_grammar::definition seems unnessecary), but I guess that's what I'll have to live with, eh?
Pretty much all C++ restrictions (but all with good reasons). The problem with + is mostly precedence, you would need much more brackets, also it matches their use in input/output. op [] is used for pretty much no other reason than it's a postfix expression that takes one expression. (If they used (), you would get problems with the overloaded , op). my_grammar::definition is so you can let the compiler figure out what type to use for the scanner (it's a metaprogramming idiom). my_grammar effectivly is just a name tag for the compiler. As a side bonus, sizeof(my_grammar) is effectively 0 (apart from the minimum object size restriction of 1).
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". Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel de Guzman wrote:
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".
Release Early, Release Often? (Pretty please?) :)
Simon Buchan wrote:
Joel de Guzman wrote:
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".
Release Early, Release Often? (Pretty please?) :)
In an ideal world... ahem... :-) Spirit2 is a complete redesign. My priorities (WRT personal projects) right now are: 1) Get fusion out for boost formal review 2) Get phoenix-2 out 3) Spirit-2 It seems that 2 got ahead of 1. There's a planned Phoenix2 release on Oct 10. Rest assured it's moving. Maintaining 3 non-trivial libraries is not easy. Cheers, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
On Thu, 2005-09-29 at 20:50 +0800, Joel de Guzman wrote:
In an ideal world... ahem... :-) Spirit2 is a complete redesign.
My priorities (WRT personal projects) right now are: 1) Get fusion out for boost formal review 2) Get phoenix-2 out 3) Spirit-2
It seems that 2 got ahead of 1. There's a planned Phoenix2 release on Oct 10. Rest assured it's moving. Maintaining 3 non-trivial libraries is not easy.
This might be a redundant but is there a list of features to expect in Spirit-2? I am working on my dissertation work of creating various parsers. At this time I am not ready to implement the work with Spirit but I was curious as to the timeline and feature set. My work will allow me to create using either Spirit-1 or 2 (fingers crossed). Stephen
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.
"Aaron Griffin"
On 9/29/05, Joel de Guzman
wrote: Aaron Griffin wrote:
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".
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.
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.
Aah, but spirit already does that: parse ( lRtmData.Begin() , lRtmData.End () , *( ( str_p("Altia*AltiaScene*background:") >> '#' >> hex_p[assign(mBackGroundColor)] ) | ( str_p("Altia*AltiaScene*width:" ) >> uint_p[assign(mWindowSize.cx )] ) | ( str_p("Altia*AltiaScene*height:" ) >> uint_p[assign(mWindowSize.cy )] ) | anychar_p ) , space_p ); Just create your grammar in place. In my case I'm assigning to some member variables. I use spirit in this fashion in dozens of places in my applications. Jeff Flinn
On 9/29/05, Jeff Flinn
Aah, but spirit already does that:
parse ( lRtmData.Begin() , lRtmData.End () , *( ( str_p("Altia*AltiaScene*background:") >> '#' >> hex_p[assign(mBackGroundColor)] ) | ( str_p("Altia*AltiaScene*width:" ) >> uint_p[assign(mWindowSize.cx )] ) | ( str_p("Altia*AltiaScene*height:" ) >> uint_p[assign(mWindowSize.cy )] ) | anychar_p ) , space_p );
Well, hot damn! Didn't realise that worked.... but then again, it makes total sense... PS Looks alot like a XrmDb 8)
participants (5)
-
Aaron Griffin
-
Jeff Flinn
-
Joel de Guzman
-
Simon Buchan
-
Stephen Torri