From 334057613e4e3d9a90a601800c76d45e1f4a6015 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 01:14:33 -0500 Subject: [PATCH] xo-reader2: revert c++23 feature, to keep osx clang build --- CMakeLists.txt | 5 +- include/xo/reader2/DDefineSsm.hpp | 2 +- include/xo/reader2/DExpectExprSsm.hpp | 2 +- include/xo/reader2/DExpectFormalArgSsm.hpp | 2 +- .../xo/reader2/DExpectFormalArglistSsm.hpp | 2 +- include/xo/reader2/DExpectSymbolSsm.hpp | 2 +- include/xo/reader2/DExpectTypeSsm.hpp | 2 +- include/xo/reader2/DExprSeqState.hpp | 2 +- include/xo/reader2/DIfElseSsm.hpp | 27 ++------- include/xo/reader2/DLambdaSsm.hpp | 2 +- include/xo/reader2/DProgressSsm.hpp | 2 +- include/xo/reader2/DSyntaxStateMachine.hpp | 56 ++++++++++++------- include/xo/reader2/ParserStateMachine.hpp | 2 + src/reader2/DIfElseSsm.cpp | 12 ++-- 14 files changed, 57 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff842708..79d692ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,7 @@ cmake_minimum_required(VERSION 3.10) -# relying on -# this auto&& -# -set(CMAKE_CXX_STANDARD 23) +#set(CMAKE_CXX_STANDARD 23) project(xo_reader2 VERSION 1.0) enable_language(CXX) diff --git a/include/xo/reader2/DDefineSsm.hpp b/include/xo/reader2/DDefineSsm.hpp index 34918dc9..0e3b1404 100644 --- a/include/xo/reader2/DDefineSsm.hpp +++ b/include/xo/reader2/DDefineSsm.hpp @@ -104,7 +104,7 @@ namespace xo { /** @defgroup scm-definessm-access-methods **/ ///@{ - const char * ssm_classname() const noexcept { return "DDefineSsm"; } + static const char * ssm_classname() { return "DDefineSsm"; } /** identify this nested state machine **/ defexprstatetype defstate() const noexcept { return defstate_; } diff --git a/include/xo/reader2/DExpectExprSsm.hpp b/include/xo/reader2/DExpectExprSsm.hpp index 424afb99..4b407881 100644 --- a/include/xo/reader2/DExpectExprSsm.hpp +++ b/include/xo/reader2/DExpectExprSsm.hpp @@ -38,7 +38,7 @@ namespace xo { /** @defgroup scm-expectexpr-access-methods access methods **/ ///@{ - const char * ssm_classname() const noexcept { return "DExpectExprSsm"; } + static const char * ssm_classname() { return "DExpectExprSsm"; } bool allow_defs() const noexcept { return allow_defs_; } bool cxl_on_rightbrace() const noexcept { return cxl_on_rightbrace_; } diff --git a/include/xo/reader2/DExpectFormalArgSsm.hpp b/include/xo/reader2/DExpectFormalArgSsm.hpp index 5308c701..62f5ae34 100644 --- a/include/xo/reader2/DExpectFormalArgSsm.hpp +++ b/include/xo/reader2/DExpectFormalArgSsm.hpp @@ -71,7 +71,7 @@ namespace xo { /** @defgroup scm-expectformalargssm-methods general methods **/ ///@{ - const char * ssm_classname() const noexcept { return "DExpectFormalArgSsm"; } + static const char * ssm_classname() { return "DExpectFormalArgSsm"; } /** update state on incoming colon token @p tk; * with overall parser state in @p p_psm diff --git a/include/xo/reader2/DExpectFormalArglistSsm.hpp b/include/xo/reader2/DExpectFormalArglistSsm.hpp index 716dfc28..203c7293 100644 --- a/include/xo/reader2/DExpectFormalArglistSsm.hpp +++ b/include/xo/reader2/DExpectFormalArglistSsm.hpp @@ -72,7 +72,7 @@ namespace xo { /** @defgroup scm-expectformalarglistssm-methods general methods **/ ///@{ - const char * ssm_classname() const noexcept { return "DExpectFormalArglistSsm"; } + static const char * ssm_classname() { return "DExpectFormalArglistSsm"; } /** update state on incoming token @p tk, with overall parser state in @p p_psm **/ void on_leftparen_token(const Token & tk, diff --git a/include/xo/reader2/DExpectSymbolSsm.hpp b/include/xo/reader2/DExpectSymbolSsm.hpp index f06cf94b..d1cf3a3c 100644 --- a/include/xo/reader2/DExpectSymbolSsm.hpp +++ b/include/xo/reader2/DExpectSymbolSsm.hpp @@ -46,7 +46,7 @@ namespace xo { static void on_symbol_token(const Token & tk, ParserStateMachine * p_psm); - const char * ssm_classname() const noexcept { return "DExpectSymbolSsm"; } + static const char * ssm_classname() { return "DExpectSymbolSsm"; } /** @defgroup scm-expectsymbol-ssm-facet syntaxstatemachine facet methods **/ ///@{ diff --git a/include/xo/reader2/DExpectTypeSsm.hpp b/include/xo/reader2/DExpectTypeSsm.hpp index 421e3019..6719bfb8 100644 --- a/include/xo/reader2/DExpectTypeSsm.hpp +++ b/include/xo/reader2/DExpectTypeSsm.hpp @@ -35,7 +35,7 @@ namespace xo { static void start(ParserStateMachine * p_psm); - const char * ssm_classname() const noexcept { return "DExpectTypeSsm"; } + static const char * ssm_classname() { return "DExpectTypeSsm"; } /** @defgroup scm-expecttype-ssm-facet syntaxstatemachine facet methods **/ ///@{ diff --git a/include/xo/reader2/DExprSeqState.hpp b/include/xo/reader2/DExprSeqState.hpp index 62ae9f5e..56578161 100644 --- a/include/xo/reader2/DExprSeqState.hpp +++ b/include/xo/reader2/DExprSeqState.hpp @@ -54,7 +54,7 @@ namespace xo { ParserStateMachine * p_psm); public: - const char * ssm_classname() const noexcept { return "DExprSeqState"; } + static const char * ssm_classname() { return "DExprSeqState"; } /** @defgroup scm-exprseq-ssm-facet syntaxstatemachine facet methods **/ ///@{ diff --git a/include/xo/reader2/DIfElseSsm.hpp b/include/xo/reader2/DIfElseSsm.hpp index 2e3533cd..43f6d4b5 100644 --- a/include/xo/reader2/DIfElseSsm.hpp +++ b/include/xo/reader2/DIfElseSsm.hpp @@ -52,7 +52,7 @@ namespace xo { /** @class DIfElseSsm * @brief syntax state machine for parsing a conditional expression **/ - class DIfElseSsm : public DSyntaxStateMachine { + class DIfElseSsm : public DSyntaxStateMachine { public: using Super = DSyntaxStateMachine; using AAllocator = xo::mm::AAllocator; @@ -89,7 +89,9 @@ namespace xo { obj expr_mm, ParserStateMachine * p_psm); - const char * ssm_classname() const noexcept { return "DIfElseSsm"; } + static const char * ssm_classname() { return "DIfElseSsm"; } + + DSyntaxStateMachine * super() { return this; } ///@} /** @defgroup scm-ifelsessm-expression-methods general methods **/ @@ -142,27 +144,6 @@ namespace xo { void on_semicolon_token(const Token & tk, ParserStateMachine * p_psm); -#ifdef OBSOLETE - /** update state for this syntax after parsing a symbol @p sym, - * with overall parser state in @p p_psm - **/ - 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); - - /** update state to consume formal param (name,value) - * from nested ssm - **/ - void on_parsed_formal(const DUniqueString * param_name, - TypeDescr param_type, - ParserStateMachine * p_psm); -#endif - /** update state for this syntax after parsing an expression @p expr, * overall parser state in @p p_psm. **/ diff --git a/include/xo/reader2/DLambdaSsm.hpp b/include/xo/reader2/DLambdaSsm.hpp index 7f29e946..d4147c76 100644 --- a/include/xo/reader2/DLambdaSsm.hpp +++ b/include/xo/reader2/DLambdaSsm.hpp @@ -80,7 +80,7 @@ namespace xo { /** @defgroup scm-lambdassm-methods **/ ///@{ - const char * ssm_classname() const noexcept { return "DLambdaSsm"; } + static const char * ssm_classname() { return "DLambdaSsm"; } static void start(ParserStateMachine * p_psm); diff --git a/include/xo/reader2/DProgressSsm.hpp b/include/xo/reader2/DProgressSsm.hpp index 542707f4..85126bed 100644 --- a/include/xo/reader2/DProgressSsm.hpp +++ b/include/xo/reader2/DProgressSsm.hpp @@ -120,7 +120,7 @@ namespace xo { parserstatemachine * p_psm) const; #endif - const char * ssm_classname() const noexcept { return "DProgressSsm"; } + static const char * ssm_classname() { return "DProgressSsm"; } std::string_view get_expect_str() const noexcept; diff --git a/include/xo/reader2/DSyntaxStateMachine.hpp b/include/xo/reader2/DSyntaxStateMachine.hpp index ee4fca98..f5a835ae 100644 --- a/include/xo/reader2/DSyntaxStateMachine.hpp +++ b/include/xo/reader2/DSyntaxStateMachine.hpp @@ -33,43 +33,51 @@ namespace xo { /** Default implementation for required SyntaxStateMachine facet method **/ - void on_token(this auto&& self, - const Token & tk, + void on_token(const Token & tk, ParserStateMachine * p_psm) { - p_psm->illegal_input_on_token(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = reinterpret_cast(*this); + + p_psm->illegal_input_on_token(Derived::ssm_classname(), tk, self.get_expect_str()); } - void on_parsed_symbol(this auto&& self, - std::string_view sym, + void on_parsed_symbol(std::string_view sym, ParserStateMachine * p_psm) { - p_psm->illegal_input_on_symbol(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = reinterpret_cast(*this); + + p_psm->illegal_input_on_symbol(Derived::ssm_classname(), sym, self.get_expect_str()); } /** Default implementation for required SyntaxStateMachine facet method **/ - void on_parsed_typedescr(this auto&& self, - TypeDescr td, + void on_parsed_typedescr(TypeDescr td, ParserStateMachine * p_psm) { - p_psm->illegal_input_on_typedescr(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = reinterpret_cast(*this); + + p_psm->illegal_input_on_typedescr(Derived::ssm_classname(), td, self.get_expect_str()); } /** Default implementation for required SyntaxStateMachine facet method **/ - void on_parsed_formal(this auto&& self, - const DUniqueString * param_name, + void on_parsed_formal(const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) { - p_psm->illegal_parsed_formal(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = reinterpret_cast(*this); + + p_psm->illegal_parsed_formal(Derived::ssm_classname(), param_name, param_type, self.get_expect_str()); @@ -79,22 +87,26 @@ namespace xo { * * arglist is DArray of obj **/ - void on_parsed_formal_arglist(this auto&& self, - DArray * arglist, + void on_parsed_formal_arglist(DArray * arglist, ParserStateMachine * p_psm) { - p_psm->illegal_parsed_formal_arglist(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = static_cast(*this); + + p_psm->illegal_parsed_formal_arglist(Derived::ssm_classname(), arglist, self.get_expect_str()); } /** Default implementation for required SyntaxStateMachine facet method **/ - void on_parsed_expression(this auto&& self, - obj expr, + void on_parsed_expression(obj expr, ParserStateMachine * p_psm) { - p_psm->illegal_parsed_expression(self.ssm_classname(), + // starting with c++23 can use "this auto&& self" instead + Derived & self = static_cast(*this); + + p_psm->illegal_parsed_expression(Derived::ssm_classname(), expr, self.get_expect_str()); @@ -102,15 +114,17 @@ namespace xo { /** Default implementation for required SyntaxStateMachine facet method **/ - void on_parsed_expression_with_semicolon(this auto&& self, - obj expr, + void on_parsed_expression_with_semicolon(obj expr, ParserStateMachine * p_psm) { + // starting with c++23 can use "this auto&& self" instead + Derived & self = static_cast(*this); + // We don't need a separate entry point, // since the semicolon isn't relevant to problem with syntax // - p_psm->illegal_parsed_expression(self.ssm_classname(), + p_psm->illegal_parsed_expression(Derived::ssm_classname(), expr, self.get_expect_str()); diff --git a/include/xo/reader2/ParserStateMachine.hpp b/include/xo/reader2/ParserStateMachine.hpp index fbf636e3..a57247c7 100644 --- a/include/xo/reader2/ParserStateMachine.hpp +++ b/include/xo/reader2/ParserStateMachine.hpp @@ -261,10 +261,12 @@ namespace xo { **/ DLocalSymtab * local_symtab_ = nullptr; +#ifdef NOT_YET /** global symbol table. * Toplevel definitions go here. **/ DGlobalSymtab * global_symtab_ = nullptr; +#endif /** current output from parser **/ ParserResult result_; diff --git a/src/reader2/DIfElseSsm.cpp b/src/reader2/DIfElseSsm.cpp index 8551e1fe..7efb4a7e 100644 --- a/src/reader2/DIfElseSsm.cpp +++ b/src/reader2/DIfElseSsm.cpp @@ -189,7 +189,7 @@ namespace xo { break; } - Super::on_token(tk, p_psm); + DSyntaxStateMachine::on_token(tk, p_psm); } void @@ -207,7 +207,7 @@ namespace xo { return; } - Super::on_token(tk, p_psm); + DSyntaxStateMachine::on_token(tk, p_psm); } void @@ -225,7 +225,7 @@ namespace xo { return; } - Super::on_token(tk, p_psm); + DSyntaxStateMachine::on_token(tk, p_psm); } void @@ -243,7 +243,7 @@ namespace xo { return; } - Super::on_token(tk, p_psm); + DSyntaxStateMachine::on_token(tk, p_psm); } #ifdef NOT_YET @@ -313,7 +313,7 @@ namespace xo { return; } - Super::on_token(tk, p_psm); + DSyntaxStateMachine::on_token(tk, p_psm); } #ifdef NOT_YET @@ -402,7 +402,7 @@ namespace xo { break; } - Super::on_parsed_expression(expr, p_psm); + DSyntaxStateMachine::on_parsed_expression(expr, p_psm); } void