xo-reader2: in DExpectFormalArgSsm handle colon token

This commit is contained in:
Roland Conybeare 2026-01-29 10:35:13 -05:00
commit 2ddaa861fa
5 changed files with 43 additions and 30 deletions

View file

@ -7,11 +7,10 @@
#include "ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp"
#include "DExpectSymbolSsm.hpp"
#include "ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp"
#include "DExpectTypeSsm.hpp"
#include "ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp"
#ifdef NOT_YET
#include "expect_type_xs.hpp"
//#include "parserstatemachine.hpp"
//#include "exprstatestack.hpp"
#include "xo/expression/Variable.hpp"
#endif
@ -93,13 +92,15 @@ namespace xo {
ParserStateMachine * p_psm)
{
switch (tk.tk_type()) {
case tokentype::tk_colon:
this->on_colon_token(tk, p_psm);
return;
// all the not-yet-handled cases
case tokentype::tk_leftparen:
case tokentype::tk_lambda:
case tokentype::tk_def:
case tokentype::tk_if:
case tokentype::tk_symbol:
case tokentype::tk_colon:
case tokentype::tk_singleassign:
case tokentype::tk_string:
case tokentype::tk_f64:
@ -142,6 +143,24 @@ namespace xo {
this->get_expect_str());
}
void
DExpectFormalArgSsm::on_colon_token(const Token & tk,
ParserStateMachine * p_psm)
{
if (fstate_ == formalstatetype::formal_1) {
this->fstate_ = formalstatetype::formal_2;
DExpectTypeSsm::start(p_psm);
/* control reenters via DExpectFormalArgSsm::on_parsed_typedescr() */
return;
}
p_psm->illegal_input_on_token("DExpectFormalArgSsm::on_colon_token",
tk,
this->get_expect_str());
}
void
DExpectFormalArgSsm::on_parsed_symbol(std::string_view sym,
ParserStateMachine * p_psm)
@ -201,20 +220,6 @@ namespace xo {
}
}
void
expect_formal_xs::on_colon_token(const token_type & tk,
parserstatemachine * p_psm)
{
if (this->formalxs_type_ == formalstatetype::formal_1) {
this->formalxs_type_ = formalstatetype::formal_2;
expect_type_xs::start(p_psm);
/* control reenters via expect_formal_xs::on_typedescr() */
} else {
exprstate::on_colon_token(tk,
p_psm);
}
}
void
expect_formal_xs::on_typedescr(TypeDescr td,
parserstatemachine * p_psm)