xo-reader2 stack: misc qol improvements + improve reader2 utest

This commit is contained in:
Roland Conybeare 2026-02-03 13:23:38 -05:00
commit 8f97502677
5 changed files with 52 additions and 1 deletions

View file

@ -0,0 +1,13 @@
/** @file Constant.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DConstant.hpp"
#include "detail/IExpression_DConstant.hpp"
#include "detail/IGCObject_DConstant.hpp"
#include "detail/IPrintable_DConstant.hpp"
/* end Constant.hpp */

View file

@ -253,6 +253,15 @@ namespace xo {
//iface_ = *std::launder(&iface_);
}
/** use this to access non-facet methods,
* _when representation is known at compile time_.
*
* Deliberately disable this for variants
**/
DRepr * operator->()
requires (!std::is_same_v<DataType, DVariantPlaceholder>)
{ return data_; }
#ifdef NOPE
DRepr & operator*() { return *data_; }
#endif

View file

@ -28,7 +28,7 @@ namespace xo {
/** allocate boxed value @p x using memory from @p mm **/
static DInteger * _box(obj<AAllocator> mm, long x);
double value() const noexcept { return value_; }
long value() const noexcept { return value_; }
bool pretty(const ppindentinfo & ppii) const;

View file

@ -0,0 +1,12 @@
/** @file Integer.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DInteger.hpp"
#include "number/IGCObject_DInteger.hpp"
#include "number/IPrintable_DInteger.hpp"
/* end Integer.hpp */

View file

@ -9,6 +9,8 @@
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp>
#include <xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp>
#include <xo/reader2/init_reader2.hpp>
#include <xo/expression2/Constant.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/alloc2/arena/IAllocator_DArena.hpp>
#include <catch2/catch.hpp>
@ -18,11 +20,15 @@ namespace xo {
using xo::scm::syntaxstatetype;
// using xo::scm::DDefineSsm;
using xo::scm::DExpectExprSsm;
using xo::scm::AExpression;
using xo::scm::DConstant;
// using xo::scm::defexprstatetype;
//using xo::scm::ParserResult;
//using xo::scm::parser_result_type;
using xo::scm::Token;
using xo::scm::DString;
using xo::scm::DInteger;
using xo::mm::AGCObject;
using xo::mm::ArenaConfig;
using xo::mm::AAllocator;
using xo::mm::DArena;
@ -244,6 +250,17 @@ namespace xo {
REQUIRE(!result.is_error());
REQUIRE(result.is_expression());
REQUIRE(result.result_expr());
auto expr = obj<AExpression,DConstant>::from(result.result_expr());
REQUIRE(expr);
REQUIRE(expr->value());
auto value_i64 = obj<AGCObject,DInteger>::from(expr->value());
REQUIRE(value_i64);
REQUIRE(value_i64->value() == 1011);
}
//REQUIRE(result.is_error());