On Fri, 6 Feb 2004, Angus Leeming wrote:

> Andre Poenitz wrote:
> 
> > On Thu, Feb 05, 2004 at 05:36:03PM +0000, Angus Leeming wrote:
> >> I've been using Boost.Spirit a lot at work recently and so have
> >> become quite comfortable with Spirit's phoenix library (a better
> >> lambda?)
> > 
> > I've been using plain old for loops for ages and have become quite
> > comfortable with them...
> > 
> > Andre'
> 
> Here's an example of a simple parser written using Boost Spirit to 
> read the data set below and assign the values using phoenix's lambda 
> facility. It's extremely understandable IMO and has all the error 

Um... I don't understand it... OTOH I've never used Boost Spirit,
but that means it's not obvious if you're unfamiliar with that.
Could you give a link for Boost Spirit? (and maybe a few comments?)

This is the data set of course:

> CONCENTRATION
> 
> NNODES 5
> 
> 1 5.5
> 2 6.5
> 3 5.0
> 4 4.5
> 5 4.0
> 

And here's a part of the parser. But I don't understand it, guess I don't
know what for instance 'var' or 'self' mean/do... Is 'expression' a
variable? (what type?)

>         vector<double> & field = ...;
>         string & field_name = ...;
> 
>         expression =
>                 f_str_p(var(self.field_name)) >>
>                 str_p("NNODES") >>
> 
>                 uint_p[resize(var(field), arg1)] >>
> 
>                 for_p(var(index) = 1,
>                       var(index) <= size(var(field)),
>                       var(index)++)
>                 [
>                         limit_d(cref(index), cref(index))[uint_p] >>
>                         real_p[var(field)[var(index)-1] = arg1]
>                 ];

/Christian

-- 
Christian Ridderström                           http://www.md.kth.se/~chr


Reply via email to