xo-expression xo-reader: type unifier + misc improvements

This commit is contained in:
Roland Conybeare 2025-07-26 17:28:41 -04:00
commit 75b74918b7
31 changed files with 1005 additions and 76 deletions

View file

@ -12,15 +12,20 @@
namespace xo {
namespace scm {
/**
* lambda ( name(1) : type(1), ..., ) body-expr ;
* ^ ^ ^ ^
* | | | |
* lm_0 lm_1 lm_2 lm_3
* @text
*
* lambda ( name(1) : type(1), ..., ) : type body-expr ;
* ^ ^ ^ ^ ^ ^
* | | | | lm_4 lm_5
* | | | lm_3
* lm_0 lm_1 lm_2
*
* lm_0 --on_lambda_token()--> lm_1
* lm_1 --on_formal_arglist()--> lm_2
* lm_2 --on_expr()--> lm_3
* lm_3 --on_semicolon_token()--> (done)
* lm_5 --on_semicolon_token()--> (done)
*
* @endtext
**/
enum class lambdastatetype {
invalid = -1,
@ -29,6 +34,8 @@ namespace xo {
lm_1,
lm_2,
lm_3,
lm_4,
lm_5,
n_lambdastatetype
};
@ -60,12 +67,18 @@ namespace xo {
virtual void on_lambda_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_typedescr(TypeDescr td,
parserstatemachine * p_psm) override;
virtual void on_formal_arglist(const std::vector<rp<Variable>> & argl,
parserstatemachine * p_psm) override;
virtual void on_expr(bp<Expression> expr,
parserstatemachine * p_psm) override;
virtual void on_expr_with_semicolon(bp<Expression> expr,
parserstatemachine * p_psm) override;
virtual void on_leftbrace_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_colon_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_semicolon_token(const token_type & tk,
parserstatemachine * p_psm) override;
@ -81,6 +94,9 @@ namespace xo {
/** lambda environment (for formal parameters) **/
rp<LocalEnv> local_env_;
/** explicit return type (if supplied) **/
TypeDescr explicit_return_td_ = nullptr;
/** body expression **/
rp<Expression> body_;