
On 03/05/2011 2:55, Vitaly Budovski wrote:
boost::uint16_t year; boost::uint8_t month; boost::uint8_t day;
boost::uint8_t hour; boost::uint8_t minute; boost::uint8_t second;
date = ( big_word[ref(year) = _1]>> byte_[ref(month) = _1]>> byte_[ref(day) = _1]>> eps[_val = constructboost::gregorian::date(cref(year), cref(month), cref(day))] ) ;
You are passing references to local objects. Whenever the actual parsing happens, which it's not during grammar construction, the referred objects do not longer exist. You should declare those objects as class members, or even better use Phoenix's locals; and I'm pretty sure that there is a way to do what you want with no temporaries. The attribute of big_word[ref(year) = _1]>> byte_[ref(month) = _1]>> byte_[ref(day) = _1] should be something like tuple< uint16_t, uint8_t, uint8_t >, which one would be able to use to construct a gregorian date. I'm not fluent in Spirit, so I hope one of the experts out there comes up with an example on how to do this. Agustín Bergé.- http://talesofcpp.blogspot.com