xo-reader2: refactor: push token dispatch to satellite SSMs
This commit is contained in:
parent
b6ff615057
commit
e4cfb57bef
32 changed files with 590 additions and 816 deletions
|
|
@ -162,163 +162,7 @@ namespace xo {
|
|||
));
|
||||
}
|
||||
|
||||
switch (tk.tk_type()) {
|
||||
case tokentype::tk_symbol:
|
||||
this->on_symbol_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_def:
|
||||
this->on_def_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_if:
|
||||
this->on_if_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_colon:
|
||||
this->on_colon_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_singleassign:
|
||||
this->on_singleassign_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_string:
|
||||
this->on_string_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_f64:
|
||||
this->on_f64_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_i64:
|
||||
this->on_i64_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_bool:
|
||||
this->on_bool_token(tk);
|
||||
break;
|
||||
|
||||
case tokentype::tk_semicolon:
|
||||
this->on_semicolon_token(tk);
|
||||
break;
|
||||
|
||||
// all the not-yet handled cases
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
case tokentype::tk_rightbrace:
|
||||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_lessequal:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
case tokentype::tk_yields:
|
||||
case tokentype::tk_plus:
|
||||
case tokentype::tk_minus:
|
||||
case tokentype::tk_star:
|
||||
case tokentype::tk_slash:
|
||||
case tokentype::tk_cmpeq:
|
||||
case tokentype::tk_cmpne:
|
||||
case tokentype::tk_type:
|
||||
case tokentype::tk_lambda:
|
||||
case tokentype::tk_then:
|
||||
case tokentype::tk_else:
|
||||
case tokentype::tk_let:
|
||||
case tokentype::tk_in:
|
||||
case tokentype::tk_end:
|
||||
case tokentype::N:
|
||||
throw std::runtime_error(tostr("ParserStateMachin::on_token:",
|
||||
"NOT IMPLEMENTED",
|
||||
xtag("token", tk)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_symbol_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_symbol_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_def_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_def_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_if_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_if_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_colon_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_colon_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_singleassign_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_singleassign_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_string_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_string_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_f64_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_f64_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_i64_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_i64_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_bool_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_bool_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::on_semicolon_token(const Token & tk)
|
||||
{
|
||||
scope log(XO_DEBUG(debug_flag_), xtag("tk", tk));
|
||||
|
||||
stack_->top().on_semicolon_token(tk, this);
|
||||
stack_->top().on_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue