xo-interpreter2 stack: bugfix: top-level i64 token -> DInteger
This commit is contained in:
parent
e6fdd2b436
commit
854a8dcc48
3 changed files with 122 additions and 4 deletions
|
|
@ -6,6 +6,8 @@
|
|||
#include <xo/interpreter2/VirtualSchematikaMachine.hpp>
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/number/IGCObject_DFloat.hpp>
|
||||
#include <xo/object2/DInteger.hpp>
|
||||
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||
|
||||
#ifdef NOT_YET
|
||||
#include <xo/reader2/SchematikaParser.hpp>
|
||||
|
|
@ -27,6 +29,7 @@ namespace xo {
|
|||
using xo::scm::VsmConfig;
|
||||
using xo::scm::VsmResultExt;
|
||||
using xo::scm::DFloat;
|
||||
using xo::scm::DInteger;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::mm::MemorySizeInfo;
|
||||
using xo::facet::FacetRegistry;
|
||||
|
|
@ -62,6 +65,25 @@ namespace xo {
|
|||
VsmConfig cfg;
|
||||
VirtualSchematikaMachine vsm(cfg);
|
||||
|
||||
auto visitor = [&log](const MemorySizeInfo & info) {
|
||||
log && log(xtag("resource", info.resource_name_),
|
||||
xtag("used", info.used_),
|
||||
xtag("alloc", info.allocated_),
|
||||
xtag("commit", info.committed_),
|
||||
xtag("resv", info.reserved_));
|
||||
};
|
||||
|
||||
FacetRegistry::instance().visit_pools(visitor);
|
||||
vsm.visit_pools(visitor);
|
||||
}
|
||||
|
||||
TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]")
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
VsmConfig cfg;
|
||||
VirtualSchematikaMachine vsm(cfg);
|
||||
|
||||
bool eof_flag = false;
|
||||
|
||||
vsm.begin_interactive_session();
|
||||
|
|
@ -90,6 +112,43 @@ namespace xo {
|
|||
vsm.visit_pools(visitor);
|
||||
}
|
||||
|
||||
TEST_CASE("VirtualSchematikaMachine-const2", "[interpreter2][VSM]")
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
VsmConfig cfg;
|
||||
VirtualSchematikaMachine vsm(cfg);
|
||||
|
||||
bool eof_flag = false;
|
||||
|
||||
vsm.begin_interactive_session();
|
||||
VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("1011;"), eof_flag);
|
||||
|
||||
REQUIRE(res.is_value());
|
||||
REQUIRE(res.value());
|
||||
|
||||
log && log(xtag("res.tseq", res.value()->_typeseq()));
|
||||
|
||||
auto x = obj<AGCObject,DInteger>::from(*res.value());
|
||||
|
||||
REQUIRE(x);
|
||||
REQUIRE(x.data()->value() == 1011);
|
||||
|
||||
REQUIRE(res.remaining_.size() == 1);
|
||||
REQUIRE(*res.remaining_.lo() == '\n');
|
||||
|
||||
auto visitor = [&log](const MemorySizeInfo & info) {
|
||||
log && log(xtag("resource", info.resource_name_),
|
||||
xtag("used", info.used_),
|
||||
xtag("alloc", info.allocated_),
|
||||
xtag("commit", info.committed_),
|
||||
xtag("resv", info.reserved_));
|
||||
};
|
||||
|
||||
FacetRegistry::instance().visit_pools(visitor);
|
||||
vsm.visit_pools(visitor);
|
||||
}
|
||||
|
||||
} /*namespace ut*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,19 @@
|
|||
|
||||
#include <xo/expression2/DConstant.hpp>
|
||||
#include <xo/expression2/detail/IExpression_DConstant.hpp>
|
||||
|
||||
#include <xo/object2/DString.hpp>
|
||||
#include <xo/object2/string/IGCObject_DString.hpp>
|
||||
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/number/IGCObject_DFloat.hpp>
|
||||
#include <xo/object2/DBoolean.hpp>
|
||||
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||
|
||||
#include <xo/object2/DInteger.hpp>
|
||||
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||
|
||||
#include <xo/object2/DBoolean.hpp>
|
||||
#include <xo/object2/boolean/IGCObject_DBoolean.hpp>
|
||||
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -336,8 +341,8 @@ namespace xo {
|
|||
switch (seqtype_) {
|
||||
case exprseqtype::toplevel_interactive:
|
||||
{
|
||||
auto i64o = DFloat::box<AGCObject>(p_psm->expr_alloc(),
|
||||
tk.i64_value());
|
||||
auto i64o = DInteger::box<AGCObject>(p_psm->expr_alloc(),
|
||||
tk.i64_value());
|
||||
auto expr = DConstant::make(p_psm->expr_alloc(), i64o);
|
||||
|
||||
DProgressSsm::start(p_psm->parser_alloc(),
|
||||
|
|
|
|||
|
|
@ -197,6 +197,60 @@ namespace xo {
|
|||
//REQUIRE(result.error_description());
|
||||
}
|
||||
|
||||
TEST_CASE("SchematikaParser-interactive-integer", "[reader2][SchematikaParser]")
|
||||
{
|
||||
const auto & testname = Catch::getResultCapture().getCurrentTestName();
|
||||
|
||||
constexpr bool c_debug_flag = true;
|
||||
scope log(XO_DEBUG(c_debug_flag), xtag("test", testname));
|
||||
|
||||
ArenaConfig config;
|
||||
config.name_ = "test-arena";
|
||||
config.size_ = 16 * 1024;
|
||||
|
||||
DArena expr_arena = DArena::map(config);
|
||||
obj<AAllocator> expr_alloc = with_facet<AAllocator>::mkobj(&expr_arena);
|
||||
|
||||
SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/);
|
||||
|
||||
parser.begin_interactive_session();
|
||||
|
||||
/** Walkthrough parsing input equivalent to:
|
||||
*
|
||||
* 1011 ;
|
||||
*
|
||||
**/
|
||||
|
||||
{
|
||||
auto & result = parser.on_token(Token::i64_token("1011"));
|
||||
|
||||
log && log("after integer token:");
|
||||
log && log(xtag("parser", &parser));
|
||||
log && log(xtag("result", result));
|
||||
|
||||
REQUIRE(parser.has_incomplete_expr() == true);
|
||||
REQUIRE(!result.is_error());
|
||||
REQUIRE(result.is_incomplete());
|
||||
}
|
||||
|
||||
{
|
||||
auto & result = parser.on_token(Token::semicolon_token());
|
||||
|
||||
log && log("after semicolon token:");
|
||||
log && log(xtag("parser", &parser));
|
||||
log && log(xtag("result", result));
|
||||
|
||||
REQUIRE(parser.has_incomplete_expr() == false);
|
||||
REQUIRE(!result.is_error());
|
||||
REQUIRE(result.is_expression());
|
||||
REQUIRE(result.result_expr());
|
||||
}
|
||||
|
||||
//REQUIRE(result.is_error());
|
||||
//// illegal input on token
|
||||
//REQUIRE(result.error_description());
|
||||
}
|
||||
|
||||
TEST_CASE("SchematikaParser-interactive-lambda", "[reader2][SchematikaParser]")
|
||||
{
|
||||
constexpr bool c_debug_flag = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue