diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d692ba..c936619f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,7 +183,7 @@ xo_add_genfacetimpl( TARGET xo-reader2-facetimpl-printable-ifelsessm FACET_PKG xo_printable2 FACET Printable - REPR Ifelsessm + REPR IfElseSsm INPUT idl/IPrintable_DIfElseSsm.json5 OUTPUT_HPP_DIR include/xo/reader2 OUTPUT_IMPL_SUBDIR ssm @@ -192,6 +192,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-reader2-facetimpl-syntaxstatemachine-sequencessm + FACET_PKG xo_reader2 + FACET SyntaxStateMachine + REPR SequenceSsm + INPUT idl/ISyntaxStateMachine_DSequenceSsm.json5 + OUTPUT_HPP_DIR include/xo/reader2 + OUTPUT_IMPL_SUBDIR ssm + OUTPUT_CPP_DIR src/reader2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-reader2-facetimpl-printable-sequencessm + FACET_PKG xo_printable2 + FACET Printable + REPR SequenceSsm + INPUT idl/IPrintable_DSequenceSsm.json5 + OUTPUT_HPP_DIR include/xo/reader2 + OUTPUT_IMPL_SUBDIR ssm + OUTPUT_CPP_DIR src/reader2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-reader2-facetimpl-syntaxstatemachine-expectsymbolssm diff --git a/idl/IPrintable_DSequenceSsm.json5 b/idl/IPrintable_DSequenceSsm.json5 new file mode 100644 index 00000000..a217b24c --- /dev/null +++ b/idl/IPrintable_DSequenceSsm.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DSequenceSsm", + using_doxygen: true, + repr: "DSequenceSsm", + doc: [ "implement APrintable for DSequenceSsm" ], +} diff --git a/idl/ISyntaxStateMachine_DSequenceSsm.json5 b/idl/ISyntaxStateMachine_DSequenceSsm.json5 new file mode 100644 index 00000000..7538c09b --- /dev/null +++ b/idl/ISyntaxStateMachine_DSequenceSsm.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "\"SyntaxStateMachine.hpp\"", + "\"ssm/ISyntaxStateMachine_Xfer.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/SyntaxStateMachine.json5", + brief: "provide ASyntaxStateMachine interface for DSequenceSsm", + using_doxygen: true, + repr: "DSequenceSsm", + doc: [ "implement ASyntaxStateMachine for DSequenceSsm" ], +} diff --git a/include/xo/reader2/DExpectExprSsm.hpp b/include/xo/reader2/DExpectExprSsm.hpp index 4b407881..6b2fe30f 100644 --- a/include/xo/reader2/DExpectExprSsm.hpp +++ b/include/xo/reader2/DExpectExprSsm.hpp @@ -46,6 +46,12 @@ namespace xo { /** @defgroup scm-expectexpr-methods general methods **/ ///@{ + /** update state for this syntax on incoming leftbrace token @p tk, + * with overall parser state in @p p_psm + **/ + void on_leftbrace_token(const Token & tk, + ParserStateMachine * p_psm); + /** step state machine for this syntax on incoming boolean literal token @p tkk * with overall parser state in @p p_psm **/ diff --git a/include/xo/reader2/DIfElseSsm.hpp b/include/xo/reader2/DIfElseSsm.hpp index 43f6d4b5..5e6d4d8c 100644 --- a/include/xo/reader2/DIfElseSsm.hpp +++ b/include/xo/reader2/DIfElseSsm.hpp @@ -166,27 +166,8 @@ namespace xo { ///@} #ifdef NOT_YET - // ----- inherited from exprstate ----- - - virtual const char * get_expect_str() const override; - - virtual void on_if_token(const token_type & tk, - parserstatemachine * p_psm) override; - virtual void on_then_token(const token_type & tk, - parserstatemachine * p_psm) override; - virtual void on_else_token(const token_type & tk, - parserstatemachine * p_psm) override; - virtual void on_semicolon_token(const token_type & tk, - parserstatemachine * p_psm) override; virtual void on_rightbrace_token(const token_type & tk, parserstatemachine * p_psm) override; - - virtual void on_expr(bp expr, - parserstatemachine * p_psm) override; - virtual void on_expr_with_semicolon(bp expr, - parserstatemachine * p_psm) override; - - virtual void print(std::ostream & os) const override; #endif private: @@ -203,6 +184,8 @@ namespace xo { ifexprstatetype ifstate_ = ifexprstatetype::invalid; /** scaffold ifelse-expression here. * This will eventually be the output of this ssm + * + * TODO: can use DIfElseExpr* here. See xo-object2//DList **/ obj if_expr_; diff --git a/include/xo/reader2/DSequenceSsm.hpp b/include/xo/reader2/DSequenceSsm.hpp index 8d936254..6423ee29 100644 --- a/include/xo/reader2/DSequenceSsm.hpp +++ b/include/xo/reader2/DSequenceSsm.hpp @@ -6,7 +6,7 @@ #pragma once #include "DSyntaxStateMachine.hpp" -//#include "exprstate.hpp" +#include namespace xo { namespace scm { class Sequence; } @@ -15,21 +15,29 @@ namespace xo { namespace scm { class DSequenceSsm : public DSyntaxStateMachine { public: - using Sequence = xo::scm::Sequence; - using Lambda = xo::scm::Lambda; + //using Sequence = xo::scm::Sequence; + //using Lambda = xo::scm::Lambda; + using AAllocator = xo::mm::AAllocator; + using DArena = xo::mm::DArena; + using ppindentinfo = xo::print::ppindentinfo; public: - const char * ssm_classname() const noexcept { return "DSequenceSsm"; } + static const char * ssm_classname() { return "DSequenceSsm"; } -#ifdef NOT_YET /** start parsing a sequence-expr. * input begins with first expression in the sequence. **/ - static void start(parserstatemachine * p_psm); + static void start(ParserStateMachine * p_psm); - /** named ctor idiom **/ - static std::unique_ptr make(); + /** create instance using memory from @p parser_mm **/ + static obj make(DArena & parser_mm, + obj expr_mm); + /** create instance using memory from @p parser_mm **/ + static DSequenceSsm * _make(DArena & parser_mm, + obj expr_mm); + +#ifdef NOT_YET virtual void on_expr(bp expr, parserstatemachine * p_psm) override; virtual void on_expr_with_semicolon(bp expr, @@ -37,18 +45,34 @@ namespace xo { virtual void on_rightbrace_token(const token_type & tk, parserstatemachine * p_psm) override; - - virtual void print(std::ostream & os) const override; - virtual bool pretty_print(const xo::print::ppindentinfo & ppii) const override; #endif - private: - DSequenceSsm(); + /** @defgroup scm-sequencessm-syntaxstatemachine-facet ssm facet **/ + ///@{ + + /** indentifies this state machine **/ + syntaxstatetype ssm_type() const noexcept; + + /** mnemonic for syntax sequence ssm expects given current state **/ + std::string_view get_expect_str() const noexcept; + + ///@} + /** @defgroup scm-sequencessm-printable-facet printable facet **/ + ///@{ + + /** pretty printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: - /** will build SequenceExpr from in-order contents of this array **/ - DArray * expr_v_; - //std::vector> expr_v_; + explicit DSequenceSsm(DSequenceExpr * seq_expr); + + private: + /** scaffold sequence-expression here. + * This will eventually be the output of this ssm + **/ + DSequenceExpr * seq_expr_ = nullptr; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/reader2/SyntaxStateMachine.hpp b/include/xo/reader2/SyntaxStateMachine.hpp index deda9e1d..c9c37ee1 100644 --- a/include/xo/reader2/SyntaxStateMachine.hpp +++ b/include/xo/reader2/SyntaxStateMachine.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SyntaxStateMachine.json5] * 2. jinja2 template for facet .hpp file: @@ -19,4 +19,4 @@ #include "ssm/RSyntaxStateMachine.hpp" -/* end SyntaxStateMachine.hpp */ \ No newline at end of file +/* end SyntaxStateMachine.hpp */ diff --git a/include/xo/reader2/ssm/ASyntaxStateMachine.hpp b/include/xo/reader2/ssm/ASyntaxStateMachine.hpp index b9df6e6d..b6475877 100644 --- a/include/xo/reader2/ssm/ASyntaxStateMachine.hpp +++ b/include/xo/reader2/ssm/ASyntaxStateMachine.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SyntaxStateMachine.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -90,4 +90,4 @@ using ISyntaxStateMachine_ImplType = xo::facet::FacetImplType +#include +#include "DSequenceSsm.hpp" + +namespace xo { namespace scm { class IPrintable_DSequenceSsm; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DSequenceSsm + **/ + class IPrintable_DSequenceSsm { + public: + /** @defgroup scm-printable-dsequencessm-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dsequencessm-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DSequenceSsm & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_Any.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_Any.hpp index e239c46b..9cf16408 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_Any.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SyntaxStateMachine.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -91,4 +91,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISyntaxStateMachine_Any.hpp */ \ No newline at end of file +/* ISyntaxStateMachine_Any.hpp */ diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp index 42616a38..c34a66a5 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DDefineSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp index 53669967..7280b78e 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExpectExprSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp index 99d6c9a9..acf84462 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExpectFormalArgSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp index 570ee3a4..4cf9e3ff 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExpectFormalArglistSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp index 2003db8a..1a33685f 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExpectSymbolSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp index acb752fe..054c03f1 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExpectTypeSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DExprSeqState.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DExprSeqState.hpp index 3c160d00..cd241d52 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DExprSeqState.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DExprSeqState.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DExprSeqState.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DIfElseSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DIfElseSsm.hpp index 462172d2..65f585af 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DIfElseSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DIfElseSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DIfElseSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DLambdaSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DLambdaSsm.hpp index fa0cb0a2..6d931744 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DLambdaSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DLambdaSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DLambdaSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DProgressSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DProgressSsm.hpp index ddd0c06e..27ec4f53 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_DProgressSsm.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DProgressSsm.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISyntaxStateMachine_DProgressSsm.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_DSequenceSsm.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_DSequenceSsm.hpp new file mode 100644 index 00000000..da541414 --- /dev/null +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_DSequenceSsm.hpp @@ -0,0 +1,77 @@ +/** @file ISyntaxStateMachine_DSequenceSsm.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISyntaxStateMachine_DSequenceSsm.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/ISyntaxStateMachine_DSequenceSsm.json5] + **/ + +#pragma once + +#include "SyntaxStateMachine.hpp" +#include "SyntaxStateMachine.hpp" +#include "ssm/ISyntaxStateMachine_Xfer.hpp" +#include "DSequenceSsm.hpp" + +namespace xo { namespace scm { class ISyntaxStateMachine_DSequenceSsm; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::ISyntaxStateMachine_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class ISyntaxStateMachine_DSequenceSsm + **/ + class ISyntaxStateMachine_DSequenceSsm { + public: + /** @defgroup scm-syntaxstatemachine-dsequencessm-type-traits **/ + ///@{ + using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr; + using Copaque = xo::scm::ASyntaxStateMachine::Copaque; + using Opaque = xo::scm::ASyntaxStateMachine::Opaque; + ///@} + /** @defgroup scm-syntaxstatemachine-dsequencessm-methods **/ + ///@{ + // const methods + /** identify a type of syntax state machine **/ + static syntaxstatetype ssm_type(const DSequenceSsm & self) noexcept; + /** text describing expected/allowed input to this ssm in current state **/ + static std::string_view get_expect_str(const DSequenceSsm & self) noexcept; + + // non-const methods + /** operate state machine for incoming token @p tk **/ + static void on_token(DSequenceSsm & self, const Token & tk, ParserStateMachine * p_psm); + /** update stat machine for incoming parsed symbol @p sym **/ + static void on_parsed_symbol(DSequenceSsm & self, std::string_view sym, ParserStateMachine * p_psm); + /** operate state machine for incoming type description @p td **/ + static void on_parsed_typedescr(DSequenceSsm & self, TypeDescr td, ParserStateMachine * p_psm); + /** operate state machine for formal emitted by nested ssm **/ + static void on_parsed_formal(DSequenceSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm); + /** consume formal arglist emitted by nested ssm **/ + static void on_parsed_formal_arglist(DSequenceSsm & self, DArray * arglist, ParserStateMachine * p_psm); + /** update state machine for incoming parsed expression @p expr **/ + static void on_parsed_expression(DSequenceSsm & self, obj expr, ParserStateMachine * p_psm); + /** update state machine for incoming parsed expression @p expr followed by semicolon **/ + static void on_parsed_expression_with_semicolon(DSequenceSsm & self, obj expr, ParserStateMachine * p_psm); + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/reader2/ssm/ISyntaxStateMachine_Xfer.hpp b/include/xo/reader2/ssm/ISyntaxStateMachine_Xfer.hpp index e89357ab..5fffca24 100644 --- a/include/xo/reader2/ssm/ISyntaxStateMachine_Xfer.hpp +++ b/include/xo/reader2/ssm/ISyntaxStateMachine_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SyntaxStateMachine.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -105,4 +105,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISyntaxStateMachine_Xfer.hpp */ \ No newline at end of file +/* end ISyntaxStateMachine_Xfer.hpp */ diff --git a/include/xo/reader2/ssm/RSyntaxStateMachine.hpp b/include/xo/reader2/ssm/RSyntaxStateMachine.hpp index 0e2b8636..b84082d2 100644 --- a/include/xo/reader2/ssm/RSyntaxStateMachine.hpp +++ b/include/xo/reader2/ssm/RSyntaxStateMachine.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SyntaxStateMachine.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -101,4 +101,4 @@ namespace xo { namespace facet { }; } } -/* end RSyntaxStateMachine.hpp */ \ No newline at end of file +/* end RSyntaxStateMachine.hpp */ diff --git a/include/xo/reader2/syntaxstatetype.hpp b/include/xo/reader2/syntaxstatetype.hpp index 2d87aa25..a5b4b563 100644 --- a/include/xo/reader2/syntaxstatetype.hpp +++ b/include/xo/reader2/syntaxstatetype.hpp @@ -18,6 +18,21 @@ namespace xo { enum class syntaxstatetype { invalid = -1, + /** handle define-expression. See @ref DDefineSsm **/ + defexpr, + + /** handle lambda-expression. See @ref DLambdaSsm **/ + lambdaexpr, + + /** handle ifelse-expression. See @ref DIfElseSsm **/ + ifelseexpr, + + /** handle sequence-expression. See @ref DSequenceSsm **/ + sequence, + + /** rhs expression. state exists to achieve 1-token lookahead **/ + progress, + /** toplevel of some translation unit. See @ref DExprSeqState **/ expect_toplevel_expression_sequence, @@ -36,18 +51,6 @@ namespace xo { /** expecting a rhs expression. See @ref DExpectExprSsm **/ expect_rhs_expression, - /** handle define-expression. See @ref DDefineSsm **/ - defexpr, - - /** handle lambda-expression. See @ref DLambdaSsm **/ - lambdaexpr, - - /** handle ifelse-expression. See @ref DIfElseSsm **/ - ifelseexpr, - - /** rhs expression. state exists to achieve 1-token lookahead **/ - progress, - /** comes lasts, counts number of valid enums **/ N }; diff --git a/src/reader2/CMakeLists.txt b/src/reader2/CMakeLists.txt index aebe5d77..d883fa82 100644 --- a/src/reader2/CMakeLists.txt +++ b/src/reader2/CMakeLists.txt @@ -29,6 +29,10 @@ set(SELF_SRCS ISyntaxStateMachine_DIfElseSsm.cpp IPrintable_DIfElseSsm.cpp + DSequenceSsm.cpp + ISyntaxStateMachine_DSequenceSsm.cpp + IPrintable_DSequenceSsm.cpp + DLambdaSsm.cpp ISyntaxStateMachine_DLambdaSsm.cpp IPrintable_DLambdaSsm.cpp diff --git a/src/reader2/DExpectExprSsm.cpp b/src/reader2/DExpectExprSsm.cpp index 3b4b2c36..cddfb865 100644 --- a/src/reader2/DExpectExprSsm.cpp +++ b/src/reader2/DExpectExprSsm.cpp @@ -8,6 +8,7 @@ #include "SyntaxStateMachine.hpp" #include "ssm/ISyntaxStateMachine_DExpectExprSsm.hpp" #include "ssm/ISyntaxStateMachine_DProgressSsm.hpp" +#include "DSequenceSsm.hpp" #include "syntaxstatetype.hpp" #include #include @@ -114,6 +115,10 @@ namespace xo { scope log(XO_DEBUG(p_psm->debug_flag()), xtag("tk", tk)); switch (tk.tk_type()) { + case tokentype::tk_leftbrace: + this->on_leftbrace_token(tk, p_psm); + return; + case tokentype::tk_symbol: this->on_symbol_token(tk, p_psm); return; @@ -148,7 +153,6 @@ namespace xo { case tokentype::tk_rightparen: case tokentype::tk_leftbracket: case tokentype::tk_rightbracket: - case tokentype::tk_leftbrace: case tokentype::tk_rightbrace: case tokentype::tk_leftangle: case tokentype::tk_rightangle: @@ -179,6 +183,15 @@ namespace xo { Super::on_token(tk, p_psm); } + void + DExpectExprSsm::on_leftbrace_token(const Token & tk, + ParserStateMachine * p_psm) + { + (void)tk; + + DSequenceSsm::start(p_psm); + } + void DExpectExprSsm::on_symbol_token(const Token & tk, ParserStateMachine * p_psm) @@ -377,7 +390,8 @@ namespace xo { (ppii, "DExpectExprSsm", refrtag("allow_defs", allow_defs_), - refrtag("cxl_on_rightbrace", cxl_on_rightbrace_) + refrtag("cxl_on_rightbrace", cxl_on_rightbrace_), + refrtag("expect", this->get_expect_str()) ); } @@ -412,16 +426,6 @@ namespace xo { paren_xs::start(p_psm); } - void - expect_expr_xs::on_leftbrace_token(const token_type & /*tk*/, - parserstatemachine * p_psm) - { - scope log(XO_DEBUG(p_psm->debug_flag())); - - /* push lparen_0 to remember to look for subsequent rightparen. */ - sequence_xs::start(p_psm); - } - void expect_expr_xs::on_rightbrace_token(const token_type & tk, parserstatemachine * p_psm) diff --git a/src/reader2/DLambdaSsm.cpp b/src/reader2/DLambdaSsm.cpp index 4866cd66..99351533 100644 --- a/src/reader2/DLambdaSsm.cpp +++ b/src/reader2/DLambdaSsm.cpp @@ -1,4 +1,4 @@ -/** @file lambda_xs.cpp +/** @file DLambdaSsm.cpp * * @author Roland Conybeare, Jan 2026 **/ diff --git a/src/reader2/DSequenceSsm.cpp b/src/reader2/DSequenceSsm.cpp index 285960bd..6a6b8c76 100644 --- a/src/reader2/DSequenceSsm.cpp +++ b/src/reader2/DSequenceSsm.cpp @@ -1,6 +1,8 @@ /* @file DSequenceSsm.cpp */ #include "DSequenceSsm.hpp" +#include "ssm/ISyntaxStateMachine_DSequenceSsm.hpp" +#include "DExpectExprSsm.hpp" #ifdef NOT_YET #include "expect_expr_xs.hpp" @@ -11,31 +13,67 @@ #endif namespace xo { - using xo::scm::DefineExpr; +#ifdef NOT_YET + using xo::scm::DDefineExpr; +#endif + using xo::facet::typeseq; namespace scm { -#ifdef NOT_YET - std::unique_ptr - sequence_xs::make() { - return std::make_unique(sequence_xs()); - } -#endif - void - sequence_xs::start(parserstatemachine * p_psm) { - p_psm->push_exprstate(sequence_xs::make()); + DSequenceSsm::start(ParserStateMachine * p_psm) + { + p_psm->push_ssm(DSequenceSsm::make(p_psm->parser_alloc(), + p_psm->expr_alloc())); /* want to accept anything that starts an expression, - * except that } ends it + * except that rightbrace '}' ends it */ - expect_expr_xs::start(true /*allow_defs*/, + DExpectExprSsm::start(p_psm->parser_alloc(), + true /*allow_defs*/, true /*cxl_on_rightbrace*/, p_psm); } + obj + DSequenceSsm::make(DArena & mm, + obj expr_mm) + { + return obj(_make(mm, expr_mm)); + } + + DSequenceSsm * + DSequenceSsm::_make(DArena & mm, + obj expr_mm) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DSequenceSsm)); + + DSequenceExpr * seq_expr = DSequenceExpr::_make_empty(expr_mm); + + return new (mem) DSequenceSsm(seq_expr); + } + + DSequenceSsm::DSequenceSsm(DSequenceExpr * seq_expr) : seq_expr_{seq_expr} + {} + +#ifdef NOT_YET sequence_xs::sequence_xs() : exprstate(exprstatetype::sequenceexpr) {} +#endif + syntaxstatetype + DSequenceSsm::ssm_type() const noexcept + { + return syntaxstatetype::sequence; + } + + std::string_view + DSequenceSsm::get_expect_str() const noexcept + { + return "expr|semicolon|rightbrace"; + } + +#ifdef NOT_YET void sequence_xs::on_expr(bp expr, parserstatemachine * p_psm) @@ -122,12 +160,16 @@ namespace xo { sequence_xs::print(std::ostream & os) const { os << ""; } +#endif bool - sequence_xs::pretty_print(const xo::print::ppindentinfo & ppii) const + DSequenceSsm::pretty(const xo::print::ppindentinfo & ppii) const { - return ppii.pps()->pretty_struct(ppii, "sequence_xs", - xrefrtag("expr_v.size", expr_v_.size())); + return ppii.pps()->pretty_struct + (ppii, + "SequenceSsm", + xrefrtag("seq_expr.size", seq_expr_->size()), + xrefrtag("expect", this->get_expect_str())); } } /*namespace scm*/ diff --git a/src/reader2/IPrintable_DDefineSsm.cpp b/src/reader2/IPrintable_DDefineSsm.cpp index bb3c2096..dbd0bfc9 100644 --- a/src/reader2/IPrintable_DDefineSsm.cpp +++ b/src/reader2/IPrintable_DDefineSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DDefineSsm.cpp */ \ No newline at end of file +/* end IPrintable_DDefineSsm.cpp */ diff --git a/src/reader2/IPrintable_DExpectExprSsm.cpp b/src/reader2/IPrintable_DExpectExprSsm.cpp index bfeaccd1..7febe575 100644 --- a/src/reader2/IPrintable_DExpectExprSsm.cpp +++ b/src/reader2/IPrintable_DExpectExprSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExpectExprSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExpectExprSsm.cpp */ \ No newline at end of file +/* end IPrintable_DExpectExprSsm.cpp */ diff --git a/src/reader2/IPrintable_DExpectFormalArgSsm.cpp b/src/reader2/IPrintable_DExpectFormalArgSsm.cpp index a38d4d86..13164b15 100644 --- a/src/reader2/IPrintable_DExpectFormalArgSsm.cpp +++ b/src/reader2/IPrintable_DExpectFormalArgSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExpectFormalArgSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExpectFormalArgSsm.cpp */ \ No newline at end of file +/* end IPrintable_DExpectFormalArgSsm.cpp */ diff --git a/src/reader2/IPrintable_DExpectFormalArglistSsm.cpp b/src/reader2/IPrintable_DExpectFormalArglistSsm.cpp index d5df450d..262cb91e 100644 --- a/src/reader2/IPrintable_DExpectFormalArglistSsm.cpp +++ b/src/reader2/IPrintable_DExpectFormalArglistSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExpectFormalArglistSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExpectFormalArglistSsm.cpp */ \ No newline at end of file +/* end IPrintable_DExpectFormalArglistSsm.cpp */ diff --git a/src/reader2/IPrintable_DExpectSymbolSsm.cpp b/src/reader2/IPrintable_DExpectSymbolSsm.cpp index e58d15f9..f03af120 100644 --- a/src/reader2/IPrintable_DExpectSymbolSsm.cpp +++ b/src/reader2/IPrintable_DExpectSymbolSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExpectSymbolSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExpectSymbolSsm.cpp */ \ No newline at end of file +/* end IPrintable_DExpectSymbolSsm.cpp */ diff --git a/src/reader2/IPrintable_DExpectTypeSsm.cpp b/src/reader2/IPrintable_DExpectTypeSsm.cpp index 3fc75136..14c20d53 100644 --- a/src/reader2/IPrintable_DExpectTypeSsm.cpp +++ b/src/reader2/IPrintable_DExpectTypeSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExpectTypeSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExpectTypeSsm.cpp */ \ No newline at end of file +/* end IPrintable_DExpectTypeSsm.cpp */ diff --git a/src/reader2/IPrintable_DExprSeqState.cpp b/src/reader2/IPrintable_DExprSeqState.cpp index 71997ede..36cfbd78 100644 --- a/src/reader2/IPrintable_DExprSeqState.cpp +++ b/src/reader2/IPrintable_DExprSeqState.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DExprSeqState.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DExprSeqState.cpp */ \ No newline at end of file +/* end IPrintable_DExprSeqState.cpp */ diff --git a/src/reader2/IPrintable_DIfElseSsm.cpp b/src/reader2/IPrintable_DIfElseSsm.cpp index f2aebf7c..d0ef4bb3 100644 --- a/src/reader2/IPrintable_DIfElseSsm.cpp +++ b/src/reader2/IPrintable_DIfElseSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DIfElseSsm.cpp */ \ No newline at end of file +/* end IPrintable_DIfElseSsm.cpp */ diff --git a/src/reader2/IPrintable_DLambdaSsm.cpp b/src/reader2/IPrintable_DLambdaSsm.cpp index 93a703aa..4e7a09d8 100644 --- a/src/reader2/IPrintable_DLambdaSsm.cpp +++ b/src/reader2/IPrintable_DLambdaSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DLambdaSsm.cpp */ \ No newline at end of file +/* end IPrintable_DLambdaSsm.cpp */ diff --git a/src/reader2/IPrintable_DProgressSsm.cpp b/src/reader2/IPrintable_DProgressSsm.cpp index c72399c9..bd9dd7e8 100644 --- a/src/reader2/IPrintable_DProgressSsm.cpp +++ b/src/reader2/IPrintable_DProgressSsm.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DProgressSsm.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DProgressSsm.cpp */ \ No newline at end of file +/* end IPrintable_DProgressSsm.cpp */ diff --git a/src/reader2/IPrintable_DSequenceSsm.cpp b/src/reader2/IPrintable_DSequenceSsm.cpp new file mode 100644 index 00000000..8c525ba8 --- /dev/null +++ b/src/reader2/IPrintable_DSequenceSsm.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DSequenceSsm.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DSequenceSsm.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DSequenceSsm.json5] +**/ + +#include "ssm/IPrintable_DSequenceSsm.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DSequenceSsm::pretty(const DSequenceSsm & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DSequenceSsm.cpp */ diff --git a/src/reader2/ISyntaxStateMachine_Any.cpp b/src/reader2/ISyntaxStateMachine_Any.cpp index 18510abb..2cd6f304 100644 --- a/src/reader2/ISyntaxStateMachine_Any.cpp +++ b/src/reader2/ISyntaxStateMachine_Any.cpp @@ -80,4 +80,4 @@ ISyntaxStateMachine_Any::on_parsed_expression_with_semicolon(Opaque, obj syntaxstatetype + { + return self.ssm_type(); + } + + auto + ISyntaxStateMachine_DSequenceSsm::get_expect_str(const DSequenceSsm & self) noexcept -> std::string_view + { + return self.get_expect_str(); + } + + auto + ISyntaxStateMachine_DSequenceSsm::on_token(DSequenceSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void + { + self.on_token(tk, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_symbol(DSequenceSsm & self, std::string_view sym, ParserStateMachine * p_psm) -> void + { + self.on_parsed_symbol(sym, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_typedescr(DSequenceSsm & self, TypeDescr td, ParserStateMachine * p_psm) -> void + { + self.on_parsed_typedescr(td, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_formal(DSequenceSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) -> void + { + self.on_parsed_formal(param_name, param_type, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_formal_arglist(DSequenceSsm & self, DArray * arglist, ParserStateMachine * p_psm) -> void + { + self.on_parsed_formal_arglist(arglist, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_expression(DSequenceSsm & self, obj expr, ParserStateMachine * p_psm) -> void + { + self.on_parsed_expression(expr, p_psm); + } + auto + ISyntaxStateMachine_DSequenceSsm::on_parsed_expression_with_semicolon(DSequenceSsm & self, obj expr, ParserStateMachine * p_psm) -> void + { + self.on_parsed_expression_with_semicolon(expr, p_psm); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISyntaxStateMachine_DSequenceSsm.cpp */ diff --git a/src/reader2/reader2_register_facets.cpp b/src/reader2/reader2_register_facets.cpp index 9dc10aa2..ef584c44 100644 --- a/src/reader2/reader2_register_facets.cpp +++ b/src/reader2/reader2_register_facets.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include @@ -63,6 +65,8 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); diff --git a/src/reader2/syntaxstatetype.cpp b/src/reader2/syntaxstatetype.cpp index e003b27d..aff0a87c 100644 --- a/src/reader2/syntaxstatetype.cpp +++ b/src/reader2/syntaxstatetype.cpp @@ -13,6 +13,16 @@ namespace xo { switch (x) { case syntaxstatetype::invalid: break; + case syntaxstatetype::defexpr: + return "defexpr"; + case syntaxstatetype::lambdaexpr: + return "lambdaexpr"; + case syntaxstatetype::ifelseexpr: + return "ifelseexpr"; + case syntaxstatetype::sequence: + return "sequence"; + case syntaxstatetype::progress: + return "progress"; case syntaxstatetype::expect_toplevel_expression_sequence: return "expect-toplevel-expression-sequence"; case syntaxstatetype::expect_formal_arglist: @@ -25,14 +35,6 @@ namespace xo { return "expect-type"; case syntaxstatetype::expect_rhs_expression: return "expect-rhs-expression"; - case syntaxstatetype::defexpr: - return "defexpr"; - case syntaxstatetype::lambdaexpr: - return "lambdaexpr"; - case syntaxstatetype::ifelseexpr: - return "ifelseexpr"; - case syntaxstatetype::progress: - return "progress"; case syntaxstatetype::N: break; } diff --git a/utest/SchematikaParser.test.cpp b/utest/SchematikaParser.test.cpp index 0d7dbba4..ef487af3 100644 --- a/utest/SchematikaParser.test.cpp +++ b/utest/SchematikaParser.test.cpp @@ -363,7 +363,6 @@ namespace xo { REQUIRE(result.is_incomplete()); } -#ifdef NOT_YET { auto & result = parser.on_token(Token::leftbrace_token()); @@ -376,6 +375,7 @@ namespace xo { REQUIRE(result.is_incomplete()); } +#ifdef NOT_YET { auto & result = parser.on_token(Token::string_token("fooey"));