Implement add_group_characteristic

This commit is contained in:
Maddie Busig 2025-04-29 06:05:20 -07:00
parent 8e6413e9ec
commit a67fcac5fc

View File

@ -19,6 +19,26 @@ token_id_t ruleset_t::add_token(token_type_e type, mtl::fixed value) {
return m_tokens.size() - 1; return m_tokens.size() - 1;
} }
group_id_t ruleset_t::add_group_characteristic(const etl::ivector<token_id_t>& tokens, uint32_t factor) {
if (m_group_characteristics.full()) {
throw mtl::length_error();
}
m_group_characteristics.push_back(group_characteristic_t());
group_characteristic_t& chr = m_group_characteristics.back();
chr.m_factor = factor;
for (token_id_t tok : tokens) {
if (!valid_token(tok)) {
throw mtl::invalid_argument();
}
chr.m_token_ids.push_back(tok);
}
return m_group_characteristics.size() - 1;
}
#if 0 #if 0
token_id_t generator_t::add_token(token_type_e type, mtl::fixed value) { token_id_t generator_t::add_token(token_type_e type, mtl::fixed value) {
log::debug << "Adding token with type " << (int)type << endl; log::debug << "Adding token with type " << (int)type << endl;