Implement ruleset_t::add_token
This commit is contained in:
parent
f1b6870dfd
commit
0f3e857586
@ -30,7 +30,7 @@ enum class token_type_e {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct token_t {
|
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;
|
mtl::fixed m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,7 +111,6 @@ public:
|
|||||||
*
|
*
|
||||||
* @ret @c token_id_t of the newly added token, local to this ruleset
|
* @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
|
* @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);
|
token_id_t add_token(token_type_e type, mtl::fixed value = 0);
|
||||||
|
|||||||
@ -8,6 +8,21 @@ namespace log = mtl::log;
|
|||||||
|
|
||||||
namespace fractal {
|
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
|
#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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user