xo-reader2: in DExpectFormalArgSsm handle colon token
This commit is contained in:
parent
2a149d371c
commit
2ddaa861fa
5 changed files with 43 additions and 30 deletions
|
|
@ -51,6 +51,9 @@ namespace xo {
|
|||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
/** @defgroupo scm-expectfromalargssm-ctors constructors **/
|
||||
///@{
|
||||
|
||||
DExpectFormalArgSsm();
|
||||
|
||||
/** create empty instance using memory from @p mm **/
|
||||
|
|
@ -62,6 +65,18 @@ namespace xo {
|
|||
/** puah instance of this ssm onto @p p_psm **/
|
||||
static void start(ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-expectformalargssm-methods general methods **/
|
||||
///@{
|
||||
|
||||
/** update state on incoming colon token @p tk;
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expectformalargssm-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
|
|
@ -115,9 +130,6 @@ namespace xo {
|
|||
virtual void on_symbol(const std::string & symbol_name,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
virtual void on_colon_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
// virtual void on_comma_token(...) override;
|
||||
|
||||
#ifdef PROBABLY_NOT
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ namespace xo {
|
|||
|
||||
static DExpectTypeSsm * make(DArena & parser_mm);
|
||||
|
||||
static void start(DArena & parser_mm,
|
||||
//obj<AAllocator> expr_mm,
|
||||
ParserStateMachine * p_psm);
|
||||
static void start(ParserStateMachine * p_psm);
|
||||
|
||||
/** @defgroup scm-expecttype-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -622,8 +622,7 @@ namespace xo {
|
|||
if (defstate_ == defexprstatetype::def_2) {
|
||||
this->defstate_ = defexprstatetype::def_3;
|
||||
|
||||
DExpectTypeSsm::start(p_psm->parser_alloc(),
|
||||
p_psm);
|
||||
DExpectTypeSsm::start(p_psm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -32,11 +32,10 @@ namespace xo {
|
|||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::start(DArena & mm,
|
||||
//obj<AAllocator> expr_mm,
|
||||
ParserStateMachine * p_psm)
|
||||
DExpectTypeSsm::start(ParserStateMachine * p_psm)
|
||||
{
|
||||
DExpectTypeSsm * expect_type_ssm = DExpectTypeSsm::make(mm);
|
||||
DExpectTypeSsm * expect_type_ssm
|
||||
= DExpectTypeSsm::make(p_psm->parser_alloc());
|
||||
|
||||
auto ssm
|
||||
= with_facet<ASyntaxStateMachine>::mkobj(expect_type_ssm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue