template <typename R1, typename R2> inline bool is_ci_equal(R1 const &var, R2 const &target) { //BOOST_STATIC_ASSERT((boost::is_same<typename R1::value_type, typename R2::value_type>::value)); BOOST_STATIC_ASSERT((sizeof(typename R1::value_type) == sizeof(typename R2::value_type))); if (var.size() == target.size()) { return std::equal(var.begin(), var.end(), target.begin(), ci_equal<typename R1::value_type>()); } return false; }
void check_equal_ranges(const std::string& string1, const R1& range1, const std::string& string2, const R2& range2) { auto r1_it = range1.begin(); auto r2_it = range2.begin(); auto r1_end = range1.end(); auto r2_end = range2.end(); for (; r1_it != r1_end && r2_it != r2_end; ++r1_it, ++r2_it) { BOOST_CHECK_MESSAGE( *r1_it == *r2_it, string1 << " (" << *r1_it << ") == " << string2 << " ("<< *r2_it << ")"); } BOOST_CHECK_MESSAGE(r1_it == r1_end, "Reached end of " << string1); BOOST_CHECK_MESSAGE(r2_it == r2_end, "Reached end of " << string2); }
QList<char> productionRules(QVector<double> params) { switch((int)params[0]) { case 0: return T1().symbol({0,0}) + T2().symbol({0,0}); break; case -1: return T2().symbol({0,0}); break; default: return r3.productionRules({params[0] - 1, 0}) + r2.productionRules({params[0],0}); } }
template <typename R1, typename R2> inline bool is_ci_less(R1 const &var, R2 const &target) { BOOST_STATIC_ASSERT((boost::is_same<typename R1::value_type, typename R2::value_type>::value)); return std::lexicographical_compare(var.begin(), var.end(), target.begin(), target.end(), ci_less<typename R1::value_type>()); }
QList<char> start(QVector<double> params) { return r1.productionRules({params[0] + 3,0 }) + r2.productionRules({params[0] + 2,0}) + r3.productionRules({params[0] + 3, 0}) + T1().symbol({0,0}) + T2().symbol({0,0}); }