Implement ruleset_t::add_token
This commit is contained in:
parent
487c5c5a69
commit
66fe6ba388
@ -30,7 +30,7 @@ enum class token_type_e {
|
||||
};
|
||||
|
||||
struct token_t {
|
||||
token_type_e m_token = token_type_e::empty;
|
||||
token_type_e m_type = token_type_e::empty;
|
||||
mtl::fixed m_value;
|
||||
};
|
||||
|
||||
@ -111,7 +111,6 @@ public:
|
||||
*
|
||||
* @ret @c token_id_t of the newly added token, local to this ruleset
|
||||
*
|
||||
* @exception @c mtl::invalid_argument if the given token type is invalid
|
||||
* @exception @c mtl::length_error if the maximum number of tokens is reached
|
||||
*/
|
||||
token_id_t add_token(token_type_e type, mtl::fixed value = 0);
|
||||
|
||||
@ -8,6 +8,21 @@ namespace log = mtl::log;
|
||||
|
||||
namespace fractal {
|
||||
|
||||
bool ruleset_t::tokens_full() const {
|
||||
return m_tokens.full();
|
||||
}
|
||||
|
||||
token_id_t ruleset_t::add_token(token_type_e type, mtl::fixed value) {
|
||||
if (m_tokens.full()) {
|
||||
throw mtl::length_error();
|
||||
}
|
||||
|
||||
token_t tok { .m_type = type, .m_value = value };
|
||||
|
||||
m_tokens.push_back(tok);
|
||||
return m_tokens.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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user