xo-interpreter2: + nil + cons
This commit is contained in:
parent
31c32cbca7
commit
cc42c98928
22 changed files with 148 additions and 5 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue