K
krbyxtrm
hi,
i have problem implemting a string parser that parser comman delimited
string:
"str1,str2,str3"
INTO:
1. str1
2. str2
3. str3
*also strings are of any string (no specific string/keyword)
I have this code below, what it does so far is to parse specific
string: "x1", "x2", "y1", "y2"
but what i need is a parser for any kind of string (comma delimited)
bool
parse_string(char const* str, vector<string>&v)
(
return parse(str,
(
(str_p("x1"[push_back_a(v)]) |
str_p("x2")[push_back_a(v)] )
),
space_p).full;
)
example use: INPUT: "x1,y2,y1,y2"
OUTPUT:
x1
y2
y1
y2
what i need is:
example: INPUT: "this,is,a,test"
OUTPUT:
this
is
a
test
ps. i need to implement this using BOOST.Spirit
i have problem implemting a string parser that parser comman delimited
string:
"str1,str2,str3"
INTO:
1. str1
2. str2
3. str3
*also strings are of any string (no specific string/keyword)
I have this code below, what it does so far is to parse specific
string: "x1", "x2", "y1", "y2"
but what i need is a parser for any kind of string (comma delimited)
bool
parse_string(char const* str, vector<string>&v)
(
return parse(str,
(
(str_p("x1"[push_back_a(v)]) |
str_p("x2")[push_back_a(v)] )
str_p("y2")[push_back_a(v)] ) )>> *(',' >> (str_p("y1")[push_back_a(v)] |
),
space_p).full;
)
example use: INPUT: "x1,y2,y1,y2"
OUTPUT:
x1
y2
y1
y2
what i need is:
example: INPUT: "this,is,a,test"
OUTPUT:
this
is
a
test
ps. i need to implement this using BOOST.Spirit