xo-reader2: bugfix genfacet paths + move DParenSsm
This commit is contained in:
parent
f4532235c0
commit
a3a5311250
10 changed files with 8 additions and 8 deletions
150
include/xo/reader2/paren/DParenSsm.hpp
Normal file
150
include/xo/reader2/paren/DParenSsm.hpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/** @file DParenSsm.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DSyntaxStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <string_view>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/**
|
||||
* @pre
|
||||
*
|
||||
* ( x * x )
|
||||
* ^ ^ ^ ^
|
||||
* | | | (done)
|
||||
* | | |
|
||||
* | | lparen_2
|
||||
* | lparen_1:expect expr
|
||||
* lparen_0
|
||||
*
|
||||
* lparen_0 --on_leftparen_token()--> lparen_1
|
||||
* lparen_1 --on_parsed_expression()--> lparen_2
|
||||
* lparen_2 --on_rightparen_token()--> (done)
|
||||
*
|
||||
* @endpre
|
||||
**/
|
||||
|
||||
enum class parenexprstatetype {
|
||||
invalid = -1,
|
||||
|
||||
lparen_0,
|
||||
lparen_1,
|
||||
lparen_2,
|
||||
|
||||
N,
|
||||
};
|
||||
|
||||
extern const char * parenexprstatetype_descr(parenexprstatetype x);
|
||||
|
||||
std::ostream &
|
||||
operator<<(std::ostream & os, parenexprstatetype x);
|
||||
|
||||
class DParenSsm : public DSyntaxStateMachine<DParenSsm> {
|
||||
public:
|
||||
using Super = DSyntaxStateMachine<DParenSsm>;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using DArena = xo::mm::DArena;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
/** @defgroup scm-parenssm-ctors **/
|
||||
///@{
|
||||
|
||||
DParenSsm();
|
||||
|
||||
/** create instance using memory from @p parser_mm
|
||||
**/
|
||||
static DParenSsm * _make(DArena & parser_mm);
|
||||
|
||||
/** create fop pointing with new DParenSsm using memory from @p parser_mm **/
|
||||
static obj<ASyntaxStateMachine,DParenSsm> make(DArena & parser_mm);
|
||||
|
||||
/** push DParenSsm instance onto @p p_psm stack **/
|
||||
static void start(ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-access-methods **/
|
||||
///@{
|
||||
|
||||
/** identify this nested state machine **/
|
||||
static const char * ssm_classname() { return "DParenSsm"; }
|
||||
|
||||
/** internal state **/
|
||||
parenexprstatetype parenstate() const noexcept { return parenstate_; }
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-admin-methods admin methods **/
|
||||
///@{
|
||||
|
||||
/** update ssm state for incoming leftparen token @p tk,
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_leftparen_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm state for incoming rightparen token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_rightparen_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
/** identifies this ssm **/
|
||||
syntaxstatetype ssm_type() const noexcept;
|
||||
|
||||
/** text describing expected/allowed input to this ssm in current state. **/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** update ssm for token @p tk, with overall state in @p p_psm **/
|
||||
void on_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm for expression @p expr (emitted by nested ssm),
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_expression(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm for expression @p expr (emitted by nested ssm)
|
||||
* that's immediately followed by token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_expression_with_token(obj<AExpression> expr,
|
||||
const Token & tk,
|
||||
ParserStateMachine * p_psmn);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** @defgroup scm-parenssm-member-vars **/
|
||||
///@{
|
||||
|
||||
/** identify paren-expression state **/
|
||||
parenexprstatetype parenstate_;
|
||||
/** scaffold expression (representing parenthesized value) here **/
|
||||
obj<AExpression> expr_;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DParenSsm.hpp */
|
||||
62
include/xo/reader2/paren/IPrintable_DParenSsm.hpp
Normal file
62
include/xo/reader2/paren/IPrintable_DParenSsm.hpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/** @file IPrintable_DParenSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DParenSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DParenSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Printable.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DParenSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DParenSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DParenSsm>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DParenSsm,
|
||||
xo::scm::IPrintable_DParenSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DParenSsm
|
||||
**/
|
||||
class IPrintable_DParenSsm {
|
||||
public:
|
||||
/** @defgroup scm-printable-dparenssm-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dparenssm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DParenSsm & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
84
include/xo/reader2/paren/ISyntaxStateMachine_DParenSsm.hpp
Normal file
84
include/xo/reader2/paren/ISyntaxStateMachine_DParenSsm.hpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/** @file ISyntaxStateMachine_DParenSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DParenSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DParenSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
|
||||
#include "DParenSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class ISyntaxStateMachine_DParenSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
|
||||
xo::scm::DParenSsm>
|
||||
{
|
||||
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
|
||||
<xo::scm::DParenSsm,
|
||||
xo::scm::ISyntaxStateMachine_DParenSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class ISyntaxStateMachine_DParenSsm
|
||||
**/
|
||||
class ISyntaxStateMachine_DParenSsm {
|
||||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dparenssm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-syntaxstatemachine-dparenssm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** identify a type of syntax state machine **/
|
||||
static syntaxstatetype ssm_type(const DParenSsm & self) noexcept;
|
||||
/** text describing expected/allowed input to this ssm in current state **/
|
||||
static std::string_view get_expect_str(const DParenSsm & self) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** operate state machine for incoming token @p tk **/
|
||||
static void on_token(DParenSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DParenSsm & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DParenSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** update state machine for type emitted by nested ssm **/
|
||||
static void on_parsed_type(DParenSsm & self, obj<AType> type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DParenSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DParenSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DParenSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for nested parsed expression @p expr **/
|
||||
static void on_parsed_expression(DParenSsm & self, obj<AExpression> expr, ParserStateMachine * p_psm);
|
||||
/** update state machine @p p_psm for incoming parsed expression @p expr followed by token @p tk **/
|
||||
static void on_parsed_expression_with_token(DParenSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update state machine for nested quoted literal @p lit **/
|
||||
static void on_quoted_literal(DParenSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
Loading…
Add table
Add a link
Reference in a new issue