[spirit] Cannot find assig_a in spirit 2.1

Hi there, I really liked the assign_a actor in classic spirit. Is there something like that in spirit 2.1, aka, spirit::qi? Thanks, Christian

On Fri, Sep 25, 2009 at 1:21 PM, Christian Henning
Hi there, I really liked the assign_a actor in classic spirit. Is there something like that in spirit 2.1, aka, spirit::qi?
That is because something like assign_a is worthless in QI. For example (from the docs), in Spirit.Classic: int i, j; std::string s; r = int_p[assign_a(i)] >> (+alpha_p)[assign_a(s)] >> int_p[assign_a(j,i)]; Can be done in Spirit.QI by: int i, j; std::string s; r = int_[ref(i)=_1] >>(+alpha)[ref(s)=_1] >> int_[ref(j)=_1]; Or even better, this will do the same thing, but will execute even faster: int i, j; std::string s; std::string str("123456 Hello 789"); phrase_parse(str.begin(), str.end(), int_ >> +alpha >> int_, blank, i,s,j); // This will stuff 12345 into i, "Hello" into S, and 789 into j, *very* fast. Spirit2.1 is *so* much better, as you might be seeing. :)

On Fri, Sep 25, 2009 at 1:41 PM, OvermindDL1
On Fri, Sep 25, 2009 at 1:21 PM, Christian Henning
wrote: Hi there, I really liked the assign_a actor in classic spirit. Is there something like that in spirit 2.1, aka, spirit::qi?
That is because something like assign_a is worthless in QI.
For example (from the docs), in Spirit.Classic: int i, j; std::string s; r = int_p[assign_a(i)] >> (+alpha_p)[assign_a(s)] >> int_p[assign_a(j,i)];
Can be done in Spirit.QI by: int i, j; std::string s; r = int_[ref(i)=_1] >>(+alpha)[ref(s)=_1] >> int_[ref(j)=_1];
Or even better, this will do the same thing, but will execute even faster: int i, j; std::string s; std::string str("123456 Hello 789"); phrase_parse(str.begin(), str.end(), int_ >> +alpha >> int_, blank, i,s,j); // This will stuff 12345 into i, "Hello" into S, and 789 into j, *very* fast.
Spirit2.1 is *so* much better, as you might be seeing. :)
Also, I just noticed this is not on the Spirit mailing list. You should post Spirit related questions to the Spirit mailing list, will get more and faster responses.

On Fri, Sep 25, 2009 at 1:58 PM, Christian Henning
Also, I just noticed this is not on the Spirit mailing list. You should post Spirit related questions to the Spirit mailing list, will get more and faster responses.
Response time was very good. ;-)
That is because I happened to be perusing both lists at the time, that
is not that common. :)
On Fri, Sep 25, 2009 at 1:57 PM, Christian Henning
Thanks for the quick reply. This looks very interesting. But the following snippets bombs on my machine using VS2005.
#include
#include namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::qi::ascii;
int _tmain(int argc, _TCHAR* argv[]) { std::string number( "123" );
int i; qi::parse( number.begin() , number.end() , qi::int_ , ascii::blank , i );
return 0; }
I compiled your example in Visual Studio 2005, and got these errors:
1>s:\tmp\testing\parser\spirit_testing\main.cpp(5) : error C2039:
'ascii' : is not a member of 'boost::spirit::qi'
1>s:\tmp\testing\parser\spirit_testing\main.cpp(5) : error C2878:
'ascii' : a namespace or class of this name does not exist
1>s:\tmp\testing\parser\spirit_testing\main.cpp(7) : error C2061:
syntax error : identifier '_TCHAR'
1>s:\tmp\testing\parser\spirit_testing\main.cpp(15) : error C2653:
'ascii' : is not a class or namespace name
1>s:\tmp\testing\parser\spirit_testing\main.cpp(16) : error C2065:
'blank' : undeclared identifier
First of all, ascii is not in qi, it is in spirit, so I fix that and
change your _TCHAR to just char and _tmain to just main (you are not
including windows.h after all) and change parse to phrase_parse (since
you are using a skipper, use just parse if you are not using a
skipper, basically do like my above example shown) and it compiles and
runs fine here and does stuff i with 123.
This was the fixed code:
#include

Thanks for the quick reply. This looks very interesting. But the
following snippets bombs on my machine using VS2005.
#include

AMDG Christian Henning wrote:
Thanks for the quick reply. This looks very interesting. But the following snippets bombs on my machine using VS2005.
#include
#include namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::qi::ascii;
int _tmain(int argc, _TCHAR* argv[]) { std::string number( "123" );
int i; qi::parse( number.begin() , number.end() , qi::int_ , ascii::blank , i );
return 0; }
Try using phrase_parse instead of parse. In Christ, Steven Watanabe

Hi guys, sorry for the late reply. Small vacation. Just changing my code to use phrase_parse fixes my problems. Pretty cool feature in my opinion. But shouldn't it be "parse_phrase" instead of "phrase_parse"? BTW, is the traffic on spirit mailing list enormous? If not, why not have it all on the boost-user list? Thanks for your help, Christian

On Thu, Oct 1, 2009 at 6:41 AM, Christian Henning
BTW, is the traffic on spirit mailing list enormous? If not, why not have it all on the boost-user list?
Well, in comparison to my boost/users list, which had 7 unread threads since last night, the spirit/general list has 5 unread threads, so in comparison to boost, it is still sizable, but it make watching for spirit specific things a lot easier. A lot of boost projects have their own dedicated mailing lists.
participants (3)
-
Christian Henning
-
OvermindDL1
-
Steven Watanabe