Implement add_branch_rule_weighted

This commit is contained in:
Madeline Busig 2025-04-29 06:19:58 -07:00
parent 925efc1ebc
commit 7a73162798

View File

@ -81,6 +81,21 @@ branch_rule_id_t ruleset_t::add_branch_rule(token_id_t match, group_id_t group)
return m_branch_rules.size() - 1;
}
branch_rule_id_t ruleset_t::add_branch_rule_weighted(token_id_t match, weighted_group_id_t wgroup) {
if (!valid_token(match) || !valid_weighted_group(wgroup)) {
throw mtl::invalid_argument();
}
branch_rule_t rule {
.m_match = match,
.m_weighted = true,
.m_group = { .weighted = wgroup }
};
m_branch_rules.push_back(rule);
return m_branch_rules.size() - 1;
}
#if 0
token_id_t generator_t::add_token(token_type_e type, mtl::fixed value) {
log::debug << "Adding token with type " << (int)type << endl;