Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-08-21 13:58:29


Paul Hamilton <paul_at_[hidden]> wrote:
> I want to parse "," separated lists of strings.
>
> I have:
>
> char const* plist_wo_item = "x, y, z";
> rule<> list_wo_item;
> std::vector<std::string> vec_list;
>
> list_wo_item =
> (*anychar_p)[append (vec_list)] >> *( ',' >>
> (*anychar_p)[append (vec_list)])
> ;
>
> parse_info<> result = parse (plist_wo_item, list_wo_item);
> if (!result.hit)
> return false;
>
> This only places 1 item into vec_list.
>
> What Am I doing wrong?

*anychar_p eats everything, including the comma. Try *(anychar_p - ',') instead.

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk