xo-interpreter2: + nil + cons

This commit is contained in:
Roland Conybeare 2026-03-11 16:19:40 -05:00
commit cc42c98928
22 changed files with 148 additions and 5 deletions

View file

@ -171,6 +171,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_let:

View file

@ -546,6 +546,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -150,6 +150,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -18,6 +18,7 @@
#include <xo/object2/Boolean.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/object2/Float.hpp>
#include <xo/object2/List.hpp>
#include <xo/stringtable2/String.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/facet_implementation.hpp>
@ -155,6 +156,10 @@ namespace xo {
this->on_bool_token(tk, p_psm);
return;
case tokentype::tk_nil:
this->on_nil_token(tk, p_psm);
return;
case tokentype::tk_if:
this->on_if_token(tk, p_psm);
return;
@ -372,6 +377,23 @@ namespace xo {
p_psm);
}
void
DExpectExprSsm::on_nil_token(const Token & tk,
ParserStateMachine * p_psm)
{
(void)tk;
auto nil = DList::nil();
auto expr = DConstant::make(p_psm->expr_alloc(), nil);
// DProgressSsm responsible for resolving cases like
// nil ++ nil;
DProgressSsm::start(p_psm->parser_alloc(),
expr,
p_psm);
}
void
DExpectExprSsm::on_f64_token(const Token & tk,
ParserStateMachine * p_psm)

View file

@ -135,6 +135,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -165,6 +165,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -127,6 +127,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -122,6 +122,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -122,6 +122,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -140,6 +140,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -101,6 +101,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -107,6 +107,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -186,6 +186,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_let:

View file

@ -163,6 +163,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_then:
case tokentype::tk_else:

View file

@ -132,6 +132,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -309,6 +309,7 @@ namespace xo {
this->on_operator_token(tk, p_psm);
return;
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
break;

View file

@ -133,6 +133,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_then:

View file

@ -114,6 +114,7 @@ namespace xo {
case tokentype::tk_slash:
case tokentype::tk_cmpeq:
case tokentype::tk_cmpne:
case tokentype::tk_nil:
case tokentype::tk_type:
case tokentype::tk_lambda:
case tokentype::tk_let:

View file

@ -17,6 +17,7 @@
#include <xo/expression2/Constant.hpp>
#include <xo/stringtable2/String.hpp>
#include <xo/object2/List.hpp>
#include <xo/object2/Float.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/object2/Boolean.hpp>
@ -152,6 +153,10 @@ namespace xo {
this->on_bool_token(tk, p_psm);
return;
case tokentype::tk_nil:
this->on_nil_token(tk, p_psm);
return;
case tokentype::tk_leftparen:
this->on_leftparen_token(tk, p_psm);
return;
@ -378,7 +383,7 @@ namespace xo {
break;
}
Super::on_token(tk, p_psm);
Super::illegal_token(tk, p_psm);
}
void
@ -404,7 +409,32 @@ namespace xo {
break;
}
Super::on_token(tk, p_psm);
Super::illegal_token(tk, p_psm);
}
void
DToplevelSeqSsm::on_nil_token(const Token & tk,
ParserStateMachine * p_psm)
{
switch (seqtype_) {
case exprseqtype::toplevel_interactive:
{
auto dvalue = DList::nil();
auto expr = DConstant::make(p_psm->expr_alloc(), dvalue);
DProgressSsm::start(p_psm->parser_alloc(),
expr,
p_psm);
return;
}
case exprseqtype::toplevel_batch:
break;
case exprseqtype::N:
assert(false);
break;
}
Super::illegal_token(tk, p_psm);
}
void
@ -431,7 +461,7 @@ namespace xo {
break;
}
Super::on_token(tk, p_psm);
Super::illegal_token(tk, p_psm);
}
void
@ -454,7 +484,7 @@ namespace xo {
break;
}
Super::on_token(tk, p_psm);
Super::illegal_token(tk, p_psm);
}
void