Boost logo

Boost Users :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-08-30 05:59:52


Larry Knain <yg-boost-users_at_[hidden]> 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.
>
> The original parser line was:
>
> list_csv_item =
> confix_p('\"', *c_escape_ch_p, '\"')
> | longest_d[real_p | int_p]

Try this:

    list_csv_item =
            confix_p('\"', *c_escape_ch_p, '\"')
        | longest_d[real_p | int_p]
        | eps_p
        ;

    list_csv =
        (
            list_csv_item[append(vec_item)] % ','
        )[append(vec_list)]

I guess the list_p was not designed to work with null entries. For such
simple tasks, the % operator will do just fine.

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
PS> If you have further questions, please post it to:
Spirit-general mailing list
Spirit-general_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Thanks!

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