xo-interpreter2 stack: bugfix: top-level i64 token -> DInteger
This commit is contained in:
parent
3f19001c94
commit
6621d3900e
2 changed files with 63 additions and 4 deletions
|
|
@ -12,14 +12,19 @@
|
||||||
|
|
||||||
#include <xo/expression2/DConstant.hpp>
|
#include <xo/expression2/DConstant.hpp>
|
||||||
#include <xo/expression2/detail/IExpression_DConstant.hpp>
|
#include <xo/expression2/detail/IExpression_DConstant.hpp>
|
||||||
|
|
||||||
#include <xo/object2/DString.hpp>
|
#include <xo/object2/DString.hpp>
|
||||||
#include <xo/object2/string/IGCObject_DString.hpp>
|
#include <xo/object2/string/IGCObject_DString.hpp>
|
||||||
|
|
||||||
#include <xo/object2/DFloat.hpp>
|
#include <xo/object2/DFloat.hpp>
|
||||||
#include <xo/object2/number/IGCObject_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/DInteger.hpp>
|
||||||
|
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||||
|
|
||||||
|
#include <xo/object2/DBoolean.hpp>
|
||||||
#include <xo/object2/boolean/IGCObject_DBoolean.hpp>
|
#include <xo/object2/boolean/IGCObject_DBoolean.hpp>
|
||||||
|
|
||||||
#include <xo/gc/GCObject.hpp>
|
#include <xo/gc/GCObject.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -336,8 +341,8 @@ namespace xo {
|
||||||
switch (seqtype_) {
|
switch (seqtype_) {
|
||||||
case exprseqtype::toplevel_interactive:
|
case exprseqtype::toplevel_interactive:
|
||||||
{
|
{
|
||||||
auto i64o = DFloat::box<AGCObject>(p_psm->expr_alloc(),
|
auto i64o = DInteger::box<AGCObject>(p_psm->expr_alloc(),
|
||||||
tk.i64_value());
|
tk.i64_value());
|
||||||
auto expr = DConstant::make(p_psm->expr_alloc(), i64o);
|
auto expr = DConstant::make(p_psm->expr_alloc(), i64o);
|
||||||
|
|
||||||
DProgressSsm::start(p_psm->parser_alloc(),
|
DProgressSsm::start(p_psm->parser_alloc(),
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,60 @@ namespace xo {
|
||||||
//REQUIRE(result.error_description());
|
//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]")
|
TEST_CASE("SchematikaParser-interactive-lambda", "[reader2][SchematikaParser]")
|
||||||
{
|
{
|
||||||
constexpr bool c_debug_flag = true;
|
constexpr bool c_debug_flag = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue