xo-reader2: handle parsed typedescr + use in DDefineSsm
This commit is contained in:
parent
7b62bd7f5c
commit
7d33440ecb
26 changed files with 231 additions and 37 deletions
|
|
@ -71,6 +71,7 @@ namespace xo {
|
|||
**/
|
||||
class DDefineSsm {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using DArena = xo::mm::DArena;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
|
@ -139,6 +140,12 @@ namespace xo {
|
|||
void on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax after parsing a type-description @p td,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-define-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace xo {
|
|||
class DExpectSymbolSsm {
|
||||
public:
|
||||
using DArena = xo::mm::DArena;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
|
|
@ -57,8 +58,29 @@ namespace xo {
|
|||
**/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** update state for this syntax after parsing a symbol @p sym;
|
||||
* overall parser state in @p p_psm.
|
||||
*
|
||||
* NOTE:
|
||||
* might not be obvious that this is unreachable.
|
||||
* DExpectSymbolSsm converts a symbol token,
|
||||
* and delivers it to parent ssm using this entry point.
|
||||
* This method would only be called if consecutive
|
||||
* DExpectSymbolSsm instances on parser stack;
|
||||
* which scenario never occurs in Schematika syntax
|
||||
**/
|
||||
void on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax after parsing a type-description @p td
|
||||
* in nested state machine.
|
||||
* (provided to satisfy ASyntaxStateMachine api. not reachable)
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax on incoming token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
* overall parser state in @p p_psm.
|
||||
**/
|
||||
void on_def_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
|
@ -75,21 +97,6 @@ namespace xo {
|
|||
void on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax after parsing a symbol @p sym;
|
||||
* overall parser state in @p p_psm.
|
||||
*
|
||||
* NOTE:
|
||||
* might not be obvious that this is unreachable.
|
||||
* DExpectSymbolSsm converts a symbol token,
|
||||
* and delivers it to parent ssm using this entry point.
|
||||
* This method would only be called if consecutive
|
||||
* DExpectSymbolSsm instances on parser stack;
|
||||
* which scenario never occurs in Schematika syntax
|
||||
**/
|
||||
void on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expectsymbol-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace xo {
|
|||
**/
|
||||
class DExpectTypeSsm {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using DArena = xo::mm::DArena;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ namespace xo {
|
|||
void on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** Never called.
|
||||
/** (Never called).
|
||||
* Operate state machine for this syntax after symbol
|
||||
* emitted from nested ssm.
|
||||
* Impossible path for DExpectTypeSsm until such time as it relies
|
||||
|
|
@ -80,6 +81,14 @@ namespace xo {
|
|||
void on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** operate state machine for this syntax on receiving type-description
|
||||
* from nested parser.
|
||||
* Currently (jan 2026) impossible path for DExpectTypeSsm.
|
||||
* Active path is via on_symbol_token()
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expecttype-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace xo {
|
|||
**/
|
||||
class DExprSeqState {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
|
|
@ -90,6 +91,12 @@ namespace xo {
|
|||
**/
|
||||
void on_parsed_symbol(std::string_view sym, ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax on parsed type-description @p td
|
||||
* from nested ssm.
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td, ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-exprseq-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace xo {
|
|||
**/
|
||||
class ParserStateMachine {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ArenaConfig = xo::mm::ArenaConfig;
|
||||
using DArena = xo::mm::DArena;
|
||||
|
|
@ -88,9 +89,16 @@ namespace xo {
|
|||
/** @defgroup scm-parserstatemachine-inputmethods input methods **/
|
||||
///@{
|
||||
|
||||
/** update state to respond to prsed symbol @p sym **/
|
||||
/** update state to respond to parsed symbol @p sym
|
||||
* (from nested parsing state)
|
||||
**/
|
||||
void on_parsed_symbol(std::string_view sym);
|
||||
|
||||
/** update state to respond to parsed type-description @p td
|
||||
* (from nested parsing state)
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td);
|
||||
|
||||
/** update state to respond to input token @p tk.
|
||||
* record output (if any) in @ref result_
|
||||
**/
|
||||
|
|
@ -109,7 +117,6 @@ namespace xo {
|
|||
void on_colon_token(const Token & tk);
|
||||
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-parserstatemachine-error-entrypoints error entry points **/
|
||||
///@{
|
||||
|
||||
|
|
@ -136,6 +143,15 @@ namespace xo {
|
|||
void illegal_input_on_symbol(std::string_view ssm_name,
|
||||
std::string_view sym,
|
||||
std::string_view expect_str);
|
||||
|
||||
/** report illegal input arriving in syntax state machine (ssm) @p ssm_name
|
||||
* receiving assembled type-description @p td.
|
||||
* @p expect_str sketches expected input in current ssm state
|
||||
**/
|
||||
void illegal_input_on_typedescr(std::string_view ssm_name,
|
||||
TypeDescr td,
|
||||
std::string_view expect_str);
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "ParserStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/tokenizer2/Token.hpp>
|
||||
#include <xo/reflect/TypeDescr.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
|
@ -41,6 +42,8 @@ public:
|
|||
using typeseq = xo::facet::typeseq;
|
||||
using Copaque = const void *;
|
||||
using Opaque = void *;
|
||||
/** reflected c++ type **/
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-syntaxstatemachine-methods **/
|
||||
|
|
@ -64,6 +67,8 @@ public:
|
|||
virtual void on_colon_token(Opaque data, const Token & tk, ParserStateMachine * p_psm) = 0;
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
virtual void on_parsed_symbol(Opaque data, std::string_view sym, ParserStateMachine * p_psm) = 0;
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
virtual void on_parsed_typedescr(Opaque data, TypeDescr td, ParserStateMachine * p_psm) = 0;
|
||||
///@}
|
||||
}; /*ASyntaxStateMachine*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DExpectTypeSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace scm {
|
|||
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
using TypeDescr = ASyntaxStateMachine::TypeDescr;
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-syntaxstatemachine-any-methods **/
|
||||
|
|
@ -64,6 +65,7 @@ namespace scm {
|
|||
[[noreturn]] void on_if_token(Opaque, const Token &, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_colon_token(Opaque, const Token &, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_symbol(Opaque, std::string_view, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_typedescr(Opaque, TypeDescr, ParserStateMachine *) override;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace xo {
|
|||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-ddefinessm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
|
|
@ -63,6 +64,8 @@ namespace xo {
|
|||
static void on_colon_token(DDefineSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DDefineSsm & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DDefineSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace xo {
|
|||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dexpectsymbolssm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
|
|
@ -63,6 +64,8 @@ namespace xo {
|
|||
static void on_colon_token(DExpectSymbolSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DExpectSymbolSsm & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DExpectSymbolSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DExpectTypeSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -41,6 +41,7 @@ namespace xo {
|
|||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dexpecttypessm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
|
|
@ -63,6 +64,8 @@ namespace xo {
|
|||
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);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DExpectTypeSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace xo {
|
|||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dexprseqstate-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
|
|
@ -63,6 +64,8 @@ namespace xo {
|
|||
static void on_colon_token(DExprSeqState & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DExprSeqState & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DExprSeqState & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "ParserStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/tokenizer2/Token.hpp>
|
||||
#include <xo/reflect/TypeDescr.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
@ -30,6 +31,7 @@ namespace scm {
|
|||
using Impl = ISyntaxStateMachine_DRepr;
|
||||
/** integer identifying a type **/
|
||||
using typeseq = ASyntaxStateMachine::typeseq;
|
||||
using TypeDescr = ASyntaxStateMachine::TypeDescr;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-syntaxstatemachine-xfer-methods **/
|
||||
|
|
@ -65,6 +67,9 @@ namespace scm {
|
|||
void on_parsed_symbol(Opaque data, std::string_view sym, ParserStateMachine * p_psm) override {
|
||||
return I::on_parsed_symbol(_dcast(data), sym, p_psm);
|
||||
}
|
||||
void on_parsed_typedescr(Opaque data, TypeDescr td, ParserStateMachine * p_psm) override {
|
||||
return I::on_parsed_typedescr(_dcast(data), td, p_psm);
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public:
|
|||
using ObjectType = Object;
|
||||
using DataPtr = Object::DataPtr;
|
||||
using typeseq = xo::reflect::typeseq;
|
||||
using TypeDescr = ASyntaxStateMachine::TypeDescr;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-syntaxstatemachine-router-ctors **/
|
||||
|
|
@ -70,6 +71,9 @@ public:
|
|||
void on_parsed_symbol(std::string_view sym, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_parsed_symbol(O::data(), sym, p_psm);
|
||||
}
|
||||
void on_parsed_typedescr(TypeDescr td, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_parsed_typedescr(O::data(), td, p_psm);
|
||||
}
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-syntaxstatemachine-member-vars **/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue