xo-reader2: support if-then-else expressions. + detailed utest

This commit is contained in:
Roland Conybeare 2026-01-27 15:50:10 -05:00
commit c052c5c509
23 changed files with 1354 additions and 150 deletions

View file

@ -0,0 +1,62 @@
/** @file IPrintable_DIfElseSsm.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DIfElseSsm.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DIfElseSsm.json5]
**/
#pragma once
#include "Printable.hpp"
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DIfElseSsm.hpp"
namespace xo { namespace scm { class IPrintable_DIfElseSsm; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DIfElseSsm>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DIfElseSsm,
xo::scm::IPrintable_DIfElseSsm>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DIfElseSsm
**/
class IPrintable_DIfElseSsm {
public:
/** @defgroup scm-printable-difelsessm-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
using Copaque = xo::print::APrintable::Copaque;
using Opaque = xo::print::APrintable::Opaque;
///@}
/** @defgroup scm-printable-difelsessm-methods **/
///@{
// const methods
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DIfElseSsm & self, const ppindentinfo & ppii);
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,73 @@
/** @file ISyntaxStateMachine_DIfElseSsm.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISyntaxStateMachine_DIfElseSsm.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/ISyntaxStateMachine_DIfElseSsm.json5]
**/
#pragma once
#include "SyntaxStateMachine.hpp"
#include "SyntaxStateMachine.hpp"
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
#include "DIfElseSsm.hpp"
namespace xo { namespace scm { class ISyntaxStateMachine_DIfElseSsm; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
xo::scm::DIfElseSsm>
{
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
<xo::scm::DIfElseSsm,
xo::scm::ISyntaxStateMachine_DIfElseSsm>;
};
}
}
namespace xo {
namespace scm {
/** @class ISyntaxStateMachine_DIfElseSsm
**/
class ISyntaxStateMachine_DIfElseSsm {
public:
/** @defgroup scm-syntaxstatemachine-difelsessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
///@}
/** @defgroup scm-syntaxstatemachine-difelsessm-methods **/
///@{
// const methods
/** identify a type of syntax state machine **/
static syntaxstatetype ssm_type(const DIfElseSsm & self) noexcept;
/** text describing expected/allowed input to this ssm in current state **/
static std::string_view get_expect_str(const DIfElseSsm & self) noexcept;
// non-const methods
/** operate state machine for incoming token @p tk **/
static void on_token(DIfElseSsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update stat machine for incoming parsed symbol @p sym **/
static void on_parsed_symbol(DIfElseSsm & self, std::string_view sym, ParserStateMachine * p_psm);
/** operate state machine for incoming type description @p td **/
static void on_parsed_typedescr(DIfElseSsm & self, TypeDescr td, ParserStateMachine * p_psm);
/** update state machine for incoming parsed expression @p expr **/
static void on_parsed_expression(DIfElseSsm & self, obj<AExpression> expr, ParserStateMachine * p_psm);
/** update state machine for incoming parsed expression @p expr followed by semicolon **/
static void on_parsed_expression_with_semicolon(DIfElseSsm & self, obj<AExpression> expr, ParserStateMachine * p_psm);
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */