xo-reader2: DefineSsm handles colon token after lhs var
example: def foo : f64 = 3.14;
This commit is contained in:
parent
121fba491f
commit
3cca1b8255
5 changed files with 35 additions and 3 deletions
|
|
@ -105,6 +105,9 @@ namespace xo {
|
||||||
/** operate state machine for incoming if-token @p tk **/
|
/** operate state machine for incoming if-token @p tk **/
|
||||||
void on_if_token(const Token & tk);
|
void on_if_token(const Token & tk);
|
||||||
|
|
||||||
|
/** operate state machine for incoming colon-token @p tk **/
|
||||||
|
void on_colon_token(const Token & tk);
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
/** @defgroup scm-parserstatemachine-error-entrypoints error entry points **/
|
/** @defgroup scm-parserstatemachine-error-entrypoints error entry points **/
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ namespace xo {
|
||||||
DDefineSsm::on_def_token(const Token & tk,
|
DDefineSsm::on_def_token(const Token & tk,
|
||||||
ParserStateMachine * p_psm)
|
ParserStateMachine * p_psm)
|
||||||
{
|
{
|
||||||
if (this->defstate_ == defexprstatetype::def_0) {
|
if (defstate_ == defexprstatetype::def_0) {
|
||||||
this->defstate_ = defexprstatetype::def_1;
|
this->defstate_ = defexprstatetype::def_1;
|
||||||
|
|
||||||
DExpectSymbolSsm::start(p_psm->parser_alloc(), p_psm);
|
DExpectSymbolSsm::start(p_psm->parser_alloc(), p_psm);
|
||||||
|
|
@ -502,6 +502,13 @@ namespace xo {
|
||||||
DDefineSsm::on_colon_token(const Token & tk,
|
DDefineSsm::on_colon_token(const Token & tk,
|
||||||
ParserStateMachine * p_psm)
|
ParserStateMachine * p_psm)
|
||||||
{
|
{
|
||||||
|
if (defstate_ == defexprstatetype::def_2) {
|
||||||
|
this->defstate_ = defexprstatetype::def_3;
|
||||||
|
|
||||||
|
// expect_type_xs::start(p_psm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p_psm->illegal_input_on_token("DDefineSsm::on_colon_token",
|
p_psm->illegal_input_on_token("DDefineSsm::on_colon_token",
|
||||||
tk,
|
tk,
|
||||||
this->get_expect_str());
|
this->get_expect_str());
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,10 @@ namespace xo {
|
||||||
this->on_if_token(tk);
|
this->on_if_token(tk);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case tokentype::tk_colon:
|
||||||
|
this->on_colon_token(tk);
|
||||||
|
break;
|
||||||
|
|
||||||
// all the not-yet handled cases
|
// all the not-yet handled cases
|
||||||
case tokentype::tk_invalid:
|
case tokentype::tk_invalid:
|
||||||
case tokentype::tk_bool:
|
case tokentype::tk_bool:
|
||||||
|
|
@ -157,7 +161,6 @@ namespace xo {
|
||||||
case tokentype::tk_greatequal:
|
case tokentype::tk_greatequal:
|
||||||
case tokentype::tk_dot:
|
case tokentype::tk_dot:
|
||||||
case tokentype::tk_comma:
|
case tokentype::tk_comma:
|
||||||
case tokentype::tk_colon:
|
|
||||||
case tokentype::tk_doublecolon:
|
case tokentype::tk_doublecolon:
|
||||||
case tokentype::tk_semicolon:
|
case tokentype::tk_semicolon:
|
||||||
case tokentype::tk_singleassign:
|
case tokentype::tk_singleassign:
|
||||||
|
|
@ -208,6 +211,14 @@ namespace xo {
|
||||||
stack_->top().on_if_token(tk, this);
|
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
|
void
|
||||||
ParserStateMachine::capture_error(std::string_view ssm_name,
|
ParserStateMachine::capture_error(std::string_view ssm_name,
|
||||||
const DString * errmsg)
|
const DString * errmsg)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,17 @@ namespace xo {
|
||||||
log && log(xtag("result", result));
|
log && log(xtag("result", result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto & result = parser.on_token(Token::colon_token());
|
||||||
|
|
||||||
|
REQUIRE(parser.has_incomplete_expr() == true);
|
||||||
|
REQUIRE(result.is_incomplete());
|
||||||
|
|
||||||
|
log && log("after colon token:");
|
||||||
|
log && log(xtag("parser", &parser));
|
||||||
|
log && log(xtag("result", result));
|
||||||
|
}
|
||||||
|
|
||||||
// define-expressions not properly implemented
|
// define-expressions not properly implemented
|
||||||
|
|
||||||
//REQUIRE(result.error_description());
|
//REQUIRE(result.error_description());
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ namespace xo {
|
||||||
/** token representing comma @c "," **/
|
/** token representing comma @c "," **/
|
||||||
static Token comma() { return Token(tokentype::tk_comma); }
|
static Token comma() { return Token(tokentype::tk_comma); }
|
||||||
/** token representing colon @c ":" **/
|
/** token representing colon @c ":" **/
|
||||||
static Token colon() { return Token(tokentype::tk_colon); }
|
static Token colon_token() { return Token(tokentype::tk_colon); }
|
||||||
/** token representing double-colo @c "::" **/
|
/** token representing double-colo @c "::" **/
|
||||||
static Token doublecolon() { return Token(tokentype::tk_doublecolon); }
|
static Token doublecolon() { return Token(tokentype::tk_doublecolon); }
|
||||||
/** token representing semicolon @c ";" **/
|
/** token representing semicolon @c ";" **/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue