The parser
namespace qi = boost::spirit::qi;
template<typename T>
class action
{
public:
action(std::vector<std::shared_ptr<part>>& parts) : m_parts{ parts } {}
void operator()(const std::vector<char>& cc, qi::unused_type, qi::unused_type) const
{
std::string s(cc.begin(), cc.end());
if (s.length() > 0) {
auto p = new T(s);
m_parts.push_back(std::shared_ptr<part>(p));
}
}
private:
std::vector<std::shared_ptr<part>>& m_parts;
};
std::vector<std::shared_ptr<part>> parse(const std::string& source) {
namespace ascii = boost::spirit::ascii;
using ascii::char_;
using qi::lit;
std::vector<std::shared_ptr<part>> parts;
auto prop_g = lit("{{=")
>> *char_(' ')
>> (*(char_ - char_("} ")))[action<property_part>(parts)]
>> *char_(' ')
>> "}}"
;
auto text_g = (+(char_ - '{'))[action<text_part>(parts)];
auto g = -text_g >> +(prop_g >> text_g);
qi::parse(source.begin(), source.end(), g);
return parts;
}
causes a fault on the qi::parse call when testing on a Kitkat device. The fault happens before any semantic action is called. The same code works on Xcode 6/iOS 8.4 and VS 2015. We're using Boost 1.59.
We could replace Spirit with Bison implying an extra build step, or use Clang with the Android NDK, getting us off the beaten path.
Can this fault be fixed with build configuration or are there other options we could explore?