On Fri, Feb 06, 2004 at 09:48:28AM +0000, Angus Leeming wrote: > 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 > handling power of a fully fledged parser. Which it is. > > Maybe one day lyxlex will die... > > Angus > > > > CONCENTRATION > > NNODES 5 > > 1 5.5 > 2 6.5 > 3 5.0 > 4 4.5 > 5 4.0 > > 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] > ];
Looks quite impressive. Andre'