xo-reader2: + DExpectTypeSsm + extend DDefineSsm [WIP]

This commit is contained in:
Roland Conybeare 2026-01-21 01:24:17 -05:00
commit 7b62bd7f5c
13 changed files with 442 additions and 10 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include "SyntaxStateMachine.hpp"
#include <xo/indentlog/print/ppindentinfo.hpp>
namespace xo {
namespace scm {
@ -21,6 +22,10 @@ namespace xo {
* @endpre
**/
class DExpectTypeSsm {
public:
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
public:
DExpectTypeSsm();
@ -30,11 +35,6 @@ namespace xo {
//obj<AAllocator> expr_mm,
ParserStateMachine * p_psm);
virtual const char * get_expect_str() const override;
virtual void on_symbol_token(const token_type & tk,
parserstatemachine * p_psm) override;
/** @defgroup scm-expecttype-ssm-facet syntaxstatemachine facet methods **/
///@{
@ -52,13 +52,45 @@ namespace xo {
void on_symbol_token(const Token & tk,
ParserStateMachine * p_psm);
/** operate state machine for this syntax on incoming define-token @p tk
* with overall parser state in @p p_psm
**/
void on_def_token(const Token & tk,
ParserStateMachine * p_psm);
/** operate state machine for this syntax on incoming if-token @p tk
* with overall parser state in @p p_psm
**/
void on_if_token(const Token & tk,
ParserStateMachine * p_psm);
/** operate state machine for this syntax on incoming colon-token @p tk
* with overall parser state in @p p_psm
**/
void on_colon_token(const Token & tk,
ParserStateMachine * p_psm);
/** Never called.
* Operate state machine for this syntax after symbol
* emitted from nested ssm.
* Impossible path for DExpectTypeSsm until such time as it relies
* on nested ssms. Currently using on_symbol_token
* entry point instead.
**/
void on_parsed_symbol(std::string_view sym,
ParserStateMachine * p_psm);
///@}
/** @defgroup scm-expecttype-printable-facet printable facet methods **/
///@{
bool pretty(const ppindentinfo & ppii) const;
///@}
private:
static std::unique_ptr<expect_type_xs> make();
};
} /*namespace scm*/
} /*namespace xo*/
/* end expect_type_xs.hpp */
/* end DExpectTypeSsm.hpp */

View file

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

View file

@ -0,0 +1,72 @@
/** @file ISyntaxStateMachine_DExpectTypeSsm.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISyntaxStateMachine_DExpectTypeSsm.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/ISyntaxStateMachine_DExpectTypeSsm.json5]
**/
#pragma once
#include "SyntaxStateMachine.hpp"
#include "SyntaxStateMachine.hpp"
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
#include "DExpectTypeSsm.hpp"
namespace xo { namespace scm { class ISyntaxStateMachine_DExpectTypeSsm; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
xo::scm::DExpectTypeSsm>
{
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
<xo::scm::DExpectTypeSsm,
xo::scm::ISyntaxStateMachine_DExpectTypeSsm>;
};
}
}
namespace xo {
namespace scm {
/** @class ISyntaxStateMachine_DExpectTypeSsm
**/
class ISyntaxStateMachine_DExpectTypeSsm {
public:
/** @defgroup scm-syntaxstatemachine-dexpecttypessm-type-traits **/
///@{
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
///@}
/** @defgroup scm-syntaxstatemachine-dexpecttypessm-methods **/
///@{
// const methods
/** identify a type of syntax state machine **/
static syntaxstatetype ssm_type(const DExpectTypeSsm & self) noexcept;
/** text describing expected/allowed input to this ssm in current state **/
static std::string_view get_expect_str(const DExpectTypeSsm & self) noexcept;
// non-const methods
/** operate state machine for incoming symbol-token @p tk **/
static void on_symbol_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for incoming define-keyword-token @p tk **/
static void on_def_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for incoming if-keyword-token @p tk **/
static void on_if_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for incoming colon-token @p tk **/
static void on_colon_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update stat machine for incoming parsed symbol @p sym **/
static void on_parsed_symbol(DExpectTypeSsm & self, std::string_view sym, ParserStateMachine * p_psm);
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */