xo-interpreter2 stack: + nth() primitive
This commit is contained in:
parent
46637ec16a
commit
31c32cbca7
3 changed files with 60 additions and 2 deletions
|
|
@ -51,6 +51,12 @@ namespace xo {
|
|||
void on_f64_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for i64 token @p tk, with overall parser state in @p p_psm.
|
||||
* delegates to parent ssm via @ref on_quoted_literal
|
||||
**/
|
||||
void on_i64_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state on incoming token @p tk,
|
||||
* with overall parser state in @p p_psm.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "ExpectQListSsm.hpp"
|
||||
#include "ExpectQArraySsm.hpp"
|
||||
#include <xo/object2/Float.hpp>
|
||||
//#include "DExpectFormalArgSsm.hpp"
|
||||
#include <xo/object2/Integer.hpp>
|
||||
//#include "ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp"
|
||||
//#include <xo/expression2/DVariable.hpp>
|
||||
//#include <xo/expression2/detail/IGCObject_DVariable.hpp>
|
||||
|
|
@ -91,6 +91,10 @@ namespace xo {
|
|||
this->on_f64_token(tk, p_psm);
|
||||
return;
|
||||
|
||||
case tokentype::tk_i64:
|
||||
this->on_i64_token(tk, p_psm);
|
||||
return;
|
||||
|
||||
case tokentype::tk_leftparen:
|
||||
this->on_leftparen_token(tk, p_psm);
|
||||
return;
|
||||
|
|
@ -116,7 +120,6 @@ namespace xo {
|
|||
case tokentype::tk_colon:
|
||||
case tokentype::tk_singleassign:
|
||||
case tokentype::tk_string:
|
||||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
|
|
@ -161,6 +164,17 @@ namespace xo {
|
|||
p_psm->on_quoted_literal(literal);
|
||||
}
|
||||
|
||||
void
|
||||
DExpectQLiteralSsm::on_i64_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
auto literal = DInteger::box<AGCObject>(p_psm->expr_alloc(),
|
||||
tk.i64_value());
|
||||
|
||||
p_psm->pop_ssm();
|
||||
p_psm->on_quoted_literal(literal);
|
||||
}
|
||||
|
||||
#ifdef NOT_YET
|
||||
void
|
||||
DExpectQLiteralSsm::_accept_formal(obj<AAllocator> expr_alloc,
|
||||
|
|
|
|||
|
|
@ -1401,6 +1401,44 @@ namespace xo {
|
|||
log && fixture.log_memory_layout(&log);
|
||||
}
|
||||
|
||||
TEST_CASE("SchematikaParser-batch-qlist2", "[reader2][SchematikaParser]")
|
||||
{
|
||||
// top-level recursive function definition
|
||||
|
||||
const auto & testname = Catch::getResultCapture().getCurrentTestName();
|
||||
|
||||
constexpr bool c_debug_flag = false;
|
||||
scope log(XO_DEBUG(c_debug_flag), xtag("test", testname));
|
||||
|
||||
ParserFixture fixture(testname, c_debug_flag);
|
||||
auto & parser = *(fixture.parser_);
|
||||
|
||||
parser.begin_interactive_session();
|
||||
|
||||
/** Walkthrough parsing input equivalent to:
|
||||
*
|
||||
* #q{ (4 7.2) };
|
||||
* ^ ^ ^^ ^ ^ ^^
|
||||
* 0 1 2| 4 5 6|
|
||||
* 3 7
|
||||
**/
|
||||
|
||||
std::vector<Token> tk_v{
|
||||
/* [ 0] */ Token::quote_token(),
|
||||
/* [ 1] */ Token::leftbrace_token(),
|
||||
/* [ 2] */ Token::leftparen_token(),
|
||||
/* [ 3] */ Token::i64_token("4"),
|
||||
/* [ 4] */ Token::f64_token("7.2"),
|
||||
/* [ 5] */ Token::rightparen_token(),
|
||||
/* [ 6] */ Token::rightbrace_token(),
|
||||
/* [ 7] */ Token::semicolon_token(),
|
||||
};
|
||||
|
||||
utest_tokenizer_loop(&parser, tk_v, c_debug_flag);
|
||||
|
||||
log && fixture.log_memory_layout(&log);
|
||||
}
|
||||
|
||||
TEST_CASE("SchematikaParser-batch-qarray", "[reader2][SchematikaParser]")
|
||||
{
|
||||
// top-level recursive function definition
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue