Boost logo

Boost Users :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2005-09-29 11:01:46


"Aaron Griffin" <aaronmgriffin_at_[hidden]> wrote in message
news:d64a48980509290831600ee2ef_at_mail.gmail.com...
> On 9/29/05, Joel de Guzman <joel_at_[hidden]> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net