xo-reader2: + DExpectTypeSsm [WIP] [NOBUILD]

This commit is contained in:
Roland Conybeare 2026-01-20 22:39:01 -05:00
commit 823e3d7fb3
3 changed files with 111 additions and 0 deletions

View file

@ -0,0 +1,64 @@
/** @file expect_type_xs.hpp
*
* @author Roland Conybeare, Aug 2024
**/
#pragma once
#include "SyntaxStateMachine.hpp"
namespace xo {
namespace scm {
/** @class DExpectTypeSsm
* @brief syntax state-machine for accepting a Schemtika typename-expression
*
* Jan 2026
* Placeholder implementation at present.
* Only types are a handful of baked-in values
*
* @pre
*
* @endpre
**/
class DExpectTypeSsm {
public:
DExpectTypeSsm();
static DExpectTypeSsm * make(DArena & parser_mm);
static void start(DArena & parser_mm,
//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 **/
///@{
/** identifies the ssm implemented here **/
syntaxstatetype ssm_type() const noexcept;
/** text describing expected/allowed input to this ssm in current state.
* Intended to drive error messages.
**/
std::string_view get_expect_str() const noexcept;
/** operate state machien for this syntax on incoming symbol-token @p tk
* with overall parser state in @p p_psm
**/
void on_symbol_token(const Token & tk,
ParserStateMachine * p_psm);
///@}
private:
static std::unique_ptr<expect_type_xs> make();
};
} /*namespace scm*/
} /*namespace xo*/
/* end expect_type_xs.hpp */

View file

@ -24,6 +24,9 @@ namespace xo {
/** expecting a s symbol. See @ref DExpectSymbolSsm **/
expect_symbol,
/** expecting a type. See @ref DExpectTypeSsm **/
expect_type,
/** handle define-expression. See @ref DDefineSsm **/
defexpr,

View file

@ -0,0 +1,44 @@
/** @file DExpectTypeSsm.cpp
*
* @author Roland Conybeare, Aug 2024
**/
#include "DExpectTypeSsm.hpp"
namespace xo {
namespace scm {
DExpectTypeSsm::DExpectTypeSsm()
{}
DExpectTypeSsm *
DExpectTypeSsm::make(DArena & mm)
{
void * mem = mm.alloc(typeseq::id<DArena>(),
sizeof(DArena));
return new (mem) DExpectTypeSsm();
}
void
DExpectTypeSsm::start(DArena & mm,
//obj<AAllocator> expr_mm,
PArserStateMachine * p_psm)
{
DExpectTypeSsm * expect_type_ssm = DExpectTypeSsm::make(mm);
auto ssm
= with_facet<ASyntaxStateMachine>::mkobj(expect_type_ssm);
p_psm->push_ssm(ssm);
}
syntaxstatetype
DExpectTypeSsm::ssm_type() const noexcept
{
return syntaxstatetype::expect_type;
}
} /*namespace scm*/
} /*namespace xo*/
/* end DExpectTypeSsm.cpp */