Boost logo

Boost Users :

From: Larry Knain (yg-boost-users_at_[hidden])
Date: 2003-09-01 17:27:41


Thanks Hartmut.

I inserted the code change you suggested and it picks up the 2 but there is no
indication of the "missing" list element. I'll do some more reading and see what
I can come up with. (I have a number of CSV files created by various
spreadsheets and DB programs that I need to read that have "missing" list
items and was trying for a more elegant solution in Spirit. I have done this with
the tokenizer by keeping the delimiter tokens.)

HartmutKaiser_at_[hidden] wrote:

> Larry Knain wrote:
>
> > I should have said that this was a first attempt at using
> > Spirit and I was just experimenting
> > with some simple examples.
> >
> > There are three examples in the code. The adjustment was
> > made to the second example which is for CSV. The string to
> > be parsed was originally:
> >
> > char const *plist_csv = "\"string\",\"string with an embedded \\\"\","
> > "12345,0.12345e4";
> > Changed to:
> >
> > char const *plist_csv = "\"string\",\"string with an embedded \\\"\","
> > "12345,0.12345e4,,2";
> > These are at line 104.
>
> If you look at the parser definition, you'll notice, that this
> particular list parser is designed to parse escaped C-strings, integers
> or reals separated by commas. I.e. no empty elements. If you would like
> to make your list_p to match even empty elements, you'd have to make the
> list_csv_item optional:
>
> list_csv =
> list_p(
> !list_csv_item[append(vec_item)],
> // ---------^ note this exclamation sign!
> ','
> )[append(vec_list)]
> ;
>
> > The original parser line was:
> >
> > list_csv_item =
> > confix_p('\"', *c_escape_ch_p, '\"')
> > | longest_d[real_p | int_p]
> > ;
> > Again, I expected the null item to be omitted from my
> > experience with the tokenizer code but
> > I didn't expect the 2 to be omitted. After the initial
> > failure I changed the line to:
> >
> > list_csv_item =
> > confix_p('\"', *c_escape_ch_p, '\"')
> > | longest_d[real_p | int_p|~anychar_p]
> > ;
> >
> > It made no difference. Inserting \"\" between the two commas
> > preceding the 2 did make it
> > get the "null" token and the 2.
>
> Adding the ~anything_p to the list_item parser isn't the correct thing.
> This actually won't match any input at all.
>
> HTH
> Regards Hartmut
>
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


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