Add function for finding token matches
This commit is contained in:
parent
1dfac53904
commit
d95602fecd
@ -243,6 +243,8 @@ public:
|
||||
size_t num_weighted_groups() const { return m_weighted_groups.size(); }
|
||||
size_t num_branch_rules() const { return m_branch_rules.size(); }
|
||||
|
||||
template <typename CONTGROUP_T, typename CONTWGROUP_T>
|
||||
void find_token_matches(token_id_t token, CONTGROUP_T& out_groups, CONTWGROUP_T& out_wgroups) const;
|
||||
};
|
||||
|
||||
class generator_t {
|
||||
@ -494,5 +496,18 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename CONTGROUP_T, typename CONTWGROUP_T>
|
||||
void ruleset_t::find_token_matches(token_id_t token, CONTGROUP_T& out_groups, CONTWGROUP_T& out_wgroups) const {
|
||||
for (auto rule : m_branch_rules) {
|
||||
if (rule.m_match == token) {
|
||||
if (rule.m_weighted) {
|
||||
out_wgroups.push_back(rule.m_group.weighted);
|
||||
} else {
|
||||
out_groups.push_back(rule.m_group.basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fractal
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user