xo-reader2: + SyntaxStateMachine.forward_children method

Support gc traversal with goal of making ParserStateMachine a gc root
This commit is contained in:
Roland Conybeare 2026-03-24 17:43:45 -04:00
commit 263999efdb
92 changed files with 633 additions and 43 deletions

View file

@ -2,6 +2,15 @@ Uses arena allocators for fast+efficient parsing.
Composition of nested state machines.
## SchematikaParser
Parser to convert schematika text to expressions.
### Details
Partial GCObject facet support, so a SchmeatikaParser instance can
be a gc root.
## SyntaxStateMachine
a state machine dedicated to some particular Schematika syntax.

View file

@ -10,13 +10,14 @@
"<xo/type/Type.hpp>",
"<xo/tokenizer2/Token.hpp>",
"<xo/reflect/TypeDescr.hpp>",
"<xo/alloc2/Collector.hpp>"
],
// extra includes in SyntaxStateMachine.hpp, if any
user_hpp_includes: [],
namespace1: "xo",
namespace2: "scm",
// text after includes, before ASyntaxStateMachine
pretext: ["// {pretex} here"],
pretext: ["// {pretext} here"],
facet: "SyntaxStateMachine",
detail_subdir: "ssm",
brief: "specialized state machine for parsing some particular schematika syntax",
@ -26,6 +27,7 @@
],
types: [
{ name: "TypeDescr", doc: [ "reflected c++ type" ], definition: "xo::reflect::TypeDescr" },
{ name: "ACollector", doc: [ "gc interface" ], definition: "xo::mm::ACollector" },
{ name: "AGCObject", doc: [ "gc-aware object" ], definition: "xo::mm::AGCObject" },
// { name: string, doc: [ string ], definition: string },
],
@ -143,6 +145,14 @@
{type: "obj<AGCObject>", name: "lit"},
{type: "ParserStateMachine *", name: "p_psm"},
],
},
{
name: "forward_children",
doc: ["gc support: move immediate children to to-space and sub forwarding pointer"],
return_type: "void",
args: [
{type: "obj<ACollector>", name: "gc"},
],
}
],
router_facet_explicit_content: [ ],

View file

@ -73,6 +73,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DDefineSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -195,6 +196,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-define-gc-support **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc);
///@}
private:
/** @defgroup scm-definessm-member-vars **/

View file

@ -18,6 +18,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DExpectExprSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -190,6 +191,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectexprssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** if true: allow a define-expression here; otherwise reject **/

View file

@ -55,6 +55,7 @@ namespace xo {
class DExpectFormalArglistSsm : public DSyntaxStateMachine<DExpectFormalArglistSsm> {
public:
using Super = DSyntaxStateMachine<DExpectFormalArglistSsm>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -125,6 +126,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectformalarglistssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-expectformalarglistssm-impl-methods **/

View file

@ -58,6 +58,7 @@ namespace xo {
class DExpectQArraySsm : public DSyntaxStateMachine<DExpectQArraySsm> {
public:
using Super = DSyntaxStateMachine<DExpectQArraySsm>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -119,6 +120,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectqarrayssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-expectqarrayssm-member-vars **/

View file

@ -58,6 +58,7 @@ namespace xo {
class DExpectQListSsm : public DSyntaxStateMachine<DExpectQListSsm> {
public:
using Super = DSyntaxStateMachine<DExpectQListSsm>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -119,6 +120,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectqlistssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-expectqlistssm-member-vars **/

View file

@ -15,6 +15,7 @@ namespace xo {
class DExpectQLiteralSsm : public DSyntaxStateMachine<DExpectQLiteralSsm> {
public:
using Super = DSyntaxStateMachine<DExpectQLiteralSsm>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -124,6 +125,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectqliteralssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-expectformalarglistssm-impl-methods **/

View file

@ -21,6 +21,7 @@ namespace xo {
class DExpectSymbolSsm : public DSyntaxStateMachine<DExpectSymbolSsm> {
public:
using Super = DSyntaxStateMachine<DExpectSymbolSsm>;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -74,6 +75,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectsymbolssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/

View file

@ -28,6 +28,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DExpectTypeSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -82,6 +83,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expecttypessm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** temporary shim.

View file

@ -90,6 +90,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DProgressSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -214,6 +215,13 @@ namespace xo {
void print(std::ostream & os) const override;
#endif
/** @defgroup scm-progressssm-gc-support gc support methods **/
///@{
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** populate an expression here, may be followed by an operator **/
obj<AExpression> lhs_;

View file

@ -65,6 +65,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DQuoteSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -145,7 +146,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-quotessm-gc-support gc support methods */
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-parenssm-member-vars **/
///@{

View file

@ -29,8 +29,7 @@ namespace xo {
class DSequenceSsm : public DSyntaxStateMachine<DSequenceSsm> {
public:
using Super = DSyntaxStateMachine<DSequenceSsm>;
//using Sequence = xo::scm::Sequence;
//using Lambda = xo::scm::Lambda;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -87,13 +86,20 @@ namespace xo {
ParserStateMachine * p_psm);
///@}
/** @defgroup scm-sequencessm-printable-facet printable facet **/
/** @defgroup scm-sequencessm-printable-facet printable facet methods **/
///@{
/** pretty printing support **/
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-sequencessm-gcobject-facet gcobject facet methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
explicit DSequenceSsm(DSequenceExpr * seq_expr);

View file

@ -40,6 +40,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DToplevelSeqSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -156,6 +157,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-toplevelseqssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** sequence type. accept rvalue expressions when

View file

@ -32,6 +32,7 @@ namespace xo {
class ParserResult {
public:
using ACollector = xo::mm::ACollector;
using ppindentinfo = xo::print::ppindentinfo;
public:
@ -67,6 +68,9 @@ namespace xo {
/** pretty-printing support **/
bool pretty(const ppindentinfo & ppii) const;
/** gc support: forward gc-eligible children **/
void forward_children(obj<ACollector> gc) noexcept;
public:
/** none|expression|error_description
*

View file

@ -21,6 +21,7 @@ namespace xo {
**/
class ParserStack {
public:
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -42,6 +43,8 @@ namespace xo {
static ParserStack * pop(ParserStack * stack,
DArena & mm);
static constexpr bool is_gc_eligible() { return false; }
DArena::Checkpoint ckp() const noexcept { return ckp_; }
obj<ASyntaxStateMachine> top() const noexcept { return ssm_; }
ParserStack * parent() const noexcept { return parent_; }
@ -51,6 +54,8 @@ namespace xo {
/** pretty-printer support **/
bool pretty(const ppindentinfo & ppii) const;
void forward_children(obj<ACollector> gc) noexcept;
private:
/** stack pointer: top of stack just before this instance created **/
DArena::Checkpoint ckp_;

View file

@ -7,8 +7,8 @@
#include "ParserResult.hpp"
#include "GlobalEnv.hpp"
#include <xo/expression2/DGlobalSymtab.hpp>
#include <xo/expression2/DLocalSymtab.hpp>
#include <xo/expression2/GlobalSymtab.hpp>
#include <xo/expression2/LocalSymtab.hpp>
#include <xo/expression2/DVariable.hpp>
#include <xo/expression2/VarRef.hpp>
#include <xo/tokenizer2/Token.hpp>
@ -38,6 +38,7 @@ namespace xo {
class ParserStateMachine {
public:
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using ArenaConfig = xo::mm::ArenaConfig;
using AGCObject = xo::mm::AGCObject;
@ -66,6 +67,13 @@ namespace xo {
* (e.g. DArenaHashMap for global symtable).
* If not using X1Collector, this can be the
* same as @p expr_alloc.
*
* NOTE:
* When @p expr_alloc supports the Collector facet:
* ParserStateMachine isn't itself in gc-space
* (i.e. isn't expected to belong to @p expr_alloc).
* To update pointers to gc-owned objects, must have forward_children()
* called as part of @p expr_alloc's gc cycle.
**/
ParserStateMachine(const ArenaConfig & config,
const ArenaHashMapConfig & symtab_var_config,
@ -81,6 +89,8 @@ namespace xo {
/** non-trivial dtor for @ref global_symtab_ **/
~ParserStateMachine();
static constexpr bool is_gc_eligible() { return false; }
///@}
/** @defgroup scm-parserstatemachine-accessors accessor methods **/
///@{
@ -90,7 +100,7 @@ namespace xo {
obj<AAllocator> expr_alloc() const noexcept { return expr_alloc_; }
StringTable * stringtable() noexcept { return &stringtable_; }
DGlobalSymtab * global_symtab() const noexcept { return global_symtab_.data(); }
DLocalSymtab * local_symtab() const noexcept { return local_symtab_; }
DLocalSymtab * local_symtab() const noexcept { return local_symtab_.data(); }
DGlobalEnv * global_env() const noexcept { return global_env_.data(); }
const ParserResult & result() const noexcept { return result_; }
@ -175,7 +185,6 @@ namespace xo {
void clear_error_reset();
///@}
/** @defgroup scm-parserstatemachine-inputmethods input methods **/
///@{
@ -339,8 +348,37 @@ namespace xo {
std::string_view sym);
///@}
/** @defgroup scm-parserstatemachine-gcobject-facet gc support **/
///@{
#ifdef OBSOLETE
std::size_t shallow_size() const noexcept;
/** NOTE:
* ParserStateMachine only eligible to be a GC root.
* It's not eligible to reside in gc-owned space
**/
ParserStateMachine * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
#endif
/** update gc-aware exit pointers from this ParserStateMachine **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
#ifdef OBSOLETE
/** @defgroup scm-parserstatemachine-impl-methods implementation methods **/
///@{
/** record gc-mutable state vars so they're updated when gc runs **/
void _add_gc_roots();
///@}
#endif
private:
/** @defgroup scm-parserstatemachine-instance-vars instance variables **/
///@{
/** Table containing interned strings + symbols.
**/
@ -348,6 +386,7 @@ namespace xo {
/** Arena for internal parsing stack.
* Must be owned exclusively because destructively
* modified as parser completes parsing of each sub-expression
*
* Contents will be a stack of ExprState instances
@ -403,7 +442,7 @@ namespace xo {
* if so, along with stringtable_.
* maybe new struct ParserState?
**/
dp<DGlobalSymtab> global_symtab_;
obj<AGCObject,DGlobalSymtab> global_symtab_;
/** symbol table with local bindings.
* non-null during parsing of lambda expressions.
@ -411,7 +450,7 @@ namespace xo {
* Push local symbol table here to remember local params
* during the body of a lambda expression.
**/
DLocalSymtab * local_symtab_ = nullptr;
obj<AGCObject,DLocalSymtab> local_symtab_;
/** global variable bindings (builtin primitives) **/
obj<AGCObject,DGlobalEnv> global_env_;
@ -435,6 +474,8 @@ namespace xo {
/** true to enable debug output **/
bool debug_flag_ = false;
///@}
};
} /*namespace scm*/
} /*namespace xo*/

View file

@ -65,6 +65,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DApplySsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -185,6 +186,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-applyssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup ssm-applyssm-impl-methods **/

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dapplyssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DApplySsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DApplySsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DApplySsm & self, obj<ACollector> gc);
///@}
};

View file

@ -66,6 +66,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DDeftypeSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -167,6 +168,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-deftypessm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-deftypessm-member-vars **/

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-ddeftypessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DDeftypeSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DDeftypeSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DDeftypeSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -48,6 +48,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DExpectFormalArgSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -121,6 +122,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectformalargssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
#ifdef PROBABLY_NOT
virtual void on_rightparen_token(const token_type & tk,

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectformalargssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectFormalArgSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectFormalArgSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectFormalArgSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -62,6 +62,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DExpectListTypeSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -129,6 +130,13 @@ namespace xo {
/** pretty-printing support **/
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectlisttypessm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-expectlisttypessm-instance-vars instance variables **/

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectlisttypessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectListTypeSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectListTypeSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectListTypeSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -63,6 +63,7 @@ namespace xo {
class DExpectQDictSsm : public DSyntaxStateMachine<DExpectQDictSsm> {
public:
using Super = DSyntaxStateMachine<DExpectQDictSsm>;
using ACollector = xo::mm::ACollector;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -154,6 +155,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-expectqdictssm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup ssm-expectqdictssm-member-vars **/

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectqdictssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectQDictSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectQDictSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectQDictSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -55,6 +55,7 @@ namespace xo {
class DIfElseSsm : public DSyntaxStateMachine<DIfElseSsm> {
public:
using Super = DSyntaxStateMachine<DIfElseSsm>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -167,6 +168,13 @@ namespace xo {
parserstatemachine * p_psm) override;
#endif
/** @defgroup scm-ifelsessm-gc-support gc support methods **/
///@{
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
#ifdef NOT_YET
static std::unique_ptr<if_else_xs> make();

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-difelsessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DIfElseSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DIfElseSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DIfElseSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -59,6 +59,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DLambdaSsm>;
using DLocalSymtab = xo::scm::DLocalSymtab;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using TypeDescr = xo::reflect::TypeDescr;
@ -184,6 +185,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-lambdassm-gc-support gc support methods **/
///@{
/** gc support: visit gc-aware child pointers **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dlambdassm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DLambdaSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DLambdaSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DLambdaSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -50,6 +50,7 @@ namespace xo {
public:
using Super = DSyntaxStateMachine<DParenSsm>;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using DArena = xo::mm::DArena;
using ppindentinfo = xo::print::ppindentinfo;
@ -131,6 +132,13 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-parenssm-gc-support gc support methods **/
///@{
/** gc support: visit immediate gc-aware children **/
void forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-parenssm-member-vars **/

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dparenssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
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);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DParenSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -1,4 +1,4 @@
/** @file SchematikaParser.hpp
/** @file DSchematikaParser.hpp
*
* @author Roland Conybeare, Jan 2026
**/
@ -151,13 +151,21 @@ namespace xo {
* | =>
* | >
*
* ----------------------------------------------------------------
* NOTES:
* - SchematikaParser partially supports the gcobject facet so it can be a collector root node.
* It's not actually moveable (since its ParserStateMachine member isn't moveable),
* Only the forward_children method is load-bearing.
*
**/
class SchematikaParser {
class DSchematikaParser {
public:
using token_type = Token;
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
using ArenaConfig = xo::mm::ArenaConfig;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
using ppindentinfo = xo::print::ppindentinfo;
using size_type = std::size_t;
@ -173,12 +181,36 @@ namespace xo {
* with lifetime bounded by this
* SchematikeParser itself
**/
SchematikaParser(const ParserConfig & config,
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc);
DSchematikaParser(const ParserConfig & config,
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc);
/** non-trivial dtor because of @ref psm_ **/
~SchematikaParser() = default;
~DSchematikaParser() = default;
/** create parser in initial state.
*
* @p mm allocate SchematikaParser instance from here.
* (likely the same as aux_alloc)
* @p config parser configuration
* @p expr_alloc allocator for schematika expressions.
* Probably shared with execution.
* @p aux_alloc aux allocator for non-copyable memory
* with lifetime bounded by this
* SchematikeParser itself
**/
static DSchematikaParser * _make(obj<AAllocator> mm,
const ParserConfig & config,
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc);
/** like _make(mm,config,expr_alloc,aux_alloc),
* but as fop
**/
static obj<AGCObject,DSchematikaParser> make(obj<AAllocator> mm,
const ParserConfig & config,
obj<AAllocator> expr_alloc,
obj<AAllocator> aux_alloc);
/** scm-schematikaparser-access-methods **/
///@{
@ -248,7 +280,7 @@ namespace xo {
void reset_to_idle_toplevel();
///@}
/** scm-schematikaparser-pretty-methods **/
/** @defgroup scm-schematikaparser-pretty-methods **/
///@{
/** print human-readable representation on stream @p os **/
@ -257,18 +289,32 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-schematikaparser-gcobject-methods **/
///@{
std::size_t shallow_size() const noexcept;
/** not implemented (SchematikaParser not designed to be copyable) **/
DSchematikaParser * shallow_copy(obj<AAllocator> mm) const noexcept;
/** forward gc-aware children **/
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup scm-schematikaparser-member-variables member variables **/
///@{
/** state machine **/
ParserStateMachine psm_;
/** debug flag (also stored in psm_) **/
bool debug_flag_ = false;
}; /*SchematikaParser*/
///@}
}; /*DSchematikaParser*/
inline std::ostream &
operator<< (std::ostream & os,
const SchematikaParser * x) {
const DSchematikaParser * x) {
if (x) {
x->print(os);
} else {
@ -284,8 +330,8 @@ namespace xo {
* to handle ParserResult instances
**/
template <>
struct ppdetail<xo::scm::SchematikaParser*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::SchematikaParser* p) {
struct ppdetail<xo::scm::DSchematikaParser*> {
static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::DSchematikaParser* p) {
if (p)
return p->pretty(ppii);
else
@ -295,4 +341,4 @@ namespace xo {
}
} /*namespace xo*/
/* end SchematikaParser.hpp */
/* end DSchematikaParser.hpp */

View file

@ -19,11 +19,12 @@
#include <xo/type/Type.hpp>
#include <xo/tokenizer2/Token.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/facet/obj.hpp>
#include <xo/facet/facet_implementation.hpp>
#include <xo/facet/typeseq.hpp>
// {pretex} here
// {pretext} here
namespace xo {
namespace scm {
@ -45,6 +46,8 @@ public:
using Opaque = void *;
/** reflected c++ type **/
using TypeDescr = xo::reflect::TypeDescr;
/** gc interface **/
using ACollector = xo::mm::ACollector;
/** gc-aware object **/
using AGCObject = xo::mm::AGCObject;
///@}
@ -52,6 +55,11 @@ public:
/** @defgroup scm-syntaxstatemachine-methods **/
///@{
// const methods
/** An uninitialized ASyntaxStateMachine instance will have zero vtable pointer (per {linux,osx} abi).
* Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example
* obj<AFacet> will have non-null vtable (via IFacet_Any) with all methods terminating.
**/
bool _has_null_vptr() const noexcept { return *reinterpret_cast<const void * const *>(this) == nullptr; }
/** RTTI: unique id# for actual runtime data representation **/
virtual typeseq _typeseq() const noexcept = 0;
/** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/
@ -82,6 +90,8 @@ public:
virtual void on_parsed_expression_with_token(Opaque data, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm) = 0;
/** update state machine for nested quoted literal @p lit **/
virtual void on_quoted_literal(Opaque data, obj<AGCObject> lit, ParserStateMachine * p_psm) = 0;
/** gc support: move immediate children to to-space and sub forwarding pointer **/
virtual void forward_children(Opaque data, obj<ACollector> gc) = 0;
///@}
}; /*ASyntaxStateMachine*/

View file

@ -45,6 +45,7 @@ namespace scm {
/** integer identifying a type **/
using typeseq = xo::facet::typeseq;
using TypeDescr = ASyntaxStateMachine::TypeDescr;
using ACollector = ASyntaxStateMachine::ACollector;
using AGCObject = ASyntaxStateMachine::AGCObject;
///@}
@ -74,6 +75,7 @@ namespace scm {
[[noreturn]] void on_parsed_expression(Opaque, obj<AExpression>, ParserStateMachine *) override;
[[noreturn]] void on_parsed_expression_with_token(Opaque, obj<AExpression>, const Token &, ParserStateMachine *) override;
[[noreturn]] void on_quoted_literal(Opaque, obj<AGCObject>, ParserStateMachine *) override;
[[noreturn]] void forward_children(Opaque, obj<ACollector>) override;
///@}

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-ddefinessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DDefineSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DDefineSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DDefineSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectexprssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectExprSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectExprSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectExprSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectformalarglistssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectFormalArglistSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectFormalArglistSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectFormalArglistSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectqarrayssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectQArraySsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectQArraySsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectQArraySsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectqlistssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectQListSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectQListSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectQListSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectqliteralssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectQLiteralSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectQLiteralSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectQLiteralSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpectsymbolssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectSymbolSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectSymbolSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectSymbolSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dexpecttypessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DExpectTypeSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DExpectTypeSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DExpectTypeSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dprogressssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DProgressSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DProgressSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DProgressSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dquotessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DQuoteSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DQuoteSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DQuoteSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dsequencessm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DSequenceSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DSequenceSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DSequenceSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
/** @defgroup scm-syntaxstatemachine-dtoplevelseqssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using ACollector = xo::scm::ASyntaxStateMachine::ACollector;
using AGCObject = xo::scm::ASyntaxStateMachine::AGCObject;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
@ -75,6 +76,8 @@ namespace xo {
static void on_parsed_expression_with_token(DToplevelSeqSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
/** update state machine for nested quoted literal @p lit **/
static void on_quoted_literal(DToplevelSeqSsm & self, obj<AGCObject> lit, ParserStateMachine * p_psm);
/** gc support: move immediate children to to-space and sub forwarding pointer **/
static void forward_children(DToplevelSeqSsm & self, obj<ACollector> gc);
///@}
};

View file

@ -18,6 +18,7 @@
#include <xo/type/Type.hpp>
#include <xo/tokenizer2/Token.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/alloc2/Collector.hpp>
namespace xo {
namespace scm {
@ -33,6 +34,7 @@ namespace scm {
/** integer identifying a type **/
using typeseq = ASyntaxStateMachine::typeseq;
using TypeDescr = ASyntaxStateMachine::TypeDescr;
using ACollector = ASyntaxStateMachine::ACollector;
using AGCObject = ASyntaxStateMachine::AGCObject;
///@}
@ -87,6 +89,9 @@ namespace scm {
void on_quoted_literal(Opaque data, obj<AGCObject> lit, ParserStateMachine * p_psm) override {
return I::on_quoted_literal(_dcast(data), lit, p_psm);
}
void forward_children(Opaque data, obj<ACollector> gc) override {
return I::forward_children(_dcast(data), gc);
}
///@}

View file

@ -32,6 +32,7 @@ public:
using DataPtr = Object::DataPtr;
using typeseq = xo::reflect::typeseq;
using TypeDescr = ASyntaxStateMachine::TypeDescr;
using ACollector = ASyntaxStateMachine::ACollector;
using AGCObject = ASyntaxStateMachine::AGCObject;
///@}
@ -92,6 +93,9 @@ public:
void on_quoted_literal(obj<AGCObject> lit, ParserStateMachine * p_psm) {
return O::iface()->on_quoted_literal(O::data(), lit, p_psm);
}
void forward_children(obj<ACollector> gc) {
return O::iface()->forward_children(O::data(), gc);
}
///@}
/** @defgroup scm-syntaxstatemachine-member-vars **/

View file

@ -5,8 +5,10 @@
#include "ApplySsm.hpp"
#include "ExpectExprSsm.hpp"
#include <xo/facet/FacetRegistry.hpp>
#include <xo/object2/Array.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/Arena.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/reflectutil/typeseq.hpp>
//#include "parserstatemachine.hpp"
@ -394,6 +396,13 @@ namespace xo {
refrtag("fn_expr", fn_expr, fn_expr_present));
}
void
DApplySsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&fn_expr_);
gc.forward_inplace(&args_expr_v_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,7 +9,7 @@
#include "DExpectExprSsm.hpp"
#include "ssm/ISyntaxStateMachine_DDefineSsm.hpp"
#include "ssm/IPrintable_DDefineSsm.hpp"
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
#include <xo/expression2/DefineExpr.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/facet/FacetRegistry.hpp>
@ -689,6 +689,14 @@ namespace xo {
refrtag("expect", this->get_expect_str()),
refrtag("def_expr", expr));
}
// ----- gc support -----
void
DDefineSsm::forward_children(obj<ACollector> gc)
{
gc.forward_inplace(&def_expr_.data_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -270,6 +270,12 @@ namespace xo {
refrtag("deftypestate", deftype_xst_),
refrtag("expect", this->get_expect_str()));
}
void
DDeftypeSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
static_assert(!DUniqueString::is_gc_eligible());
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -624,6 +624,12 @@ namespace xo {
}
#endif
void
DExpectExprSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
// all members POD, skip
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -264,6 +264,12 @@ namespace xo {
}
}
void
DExpectFormalArgSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
static_assert(!DUniqueString::is_gc_eligible());
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -4,25 +4,15 @@
*/
#include "ExpectFormalArglistSsm.hpp"
//#include "ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp"
#include "ExpectFormalArgSsm.hpp"
//#include "ssm/ISyntaxStateMachine_DExpectFormalArgSsm.hpp"
#include <xo/expression2/DVariable.hpp>
#include <xo/expression2/detail/IGCObject_DVariable.hpp>
#include <xo/expression2/Variable.hpp>
#include <xo/object2/Array.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/arena/IAllocator_DArena.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/indentlog/scope.hpp>
#ifdef NOT_YET
#include "parserstatemachine.hpp"
#include "exprstatestack.hpp"
#include "expect_formal_xs.hpp"
#include "expect_symbol_xs.hpp"
#include "xo/expression/Variable.hpp"
#include "xo/indentlog/print/vector.hpp"
#endif
namespace xo {
using xo::print::APrintable;
using xo::print::ppstate;
@ -367,6 +357,12 @@ namespace xo {
}
}
void
DExpectFormalArglistSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(&argl_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -7,6 +7,7 @@
#include "ExpectTypeSsm.hpp"
#include "syntaxstatetype.hpp"
#include <xo/type/ListType.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <string_view>
namespace xo {
@ -202,6 +203,12 @@ namespace xo {
"DExpectListTypeSsm");
}
void
DExpectListTypeSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&elt_type_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,6 +6,7 @@
#include "ExpectQArraySsm.hpp"
#include "ExpectQLiteralSsm.hpp"
#include <xo/object2/Array.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -218,6 +219,12 @@ namespace xo {
refrtag("expect", this->get_expect_str()),
refrtag("array", array_pr));
}
void
DExpectQArraySsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(&array_);
}
}
}

View file

@ -5,6 +5,8 @@
#include "ExpectQDictSsm.hpp"
#include "ExpectQLiteralSsm.hpp"
#include <xo/stringtable2/String.hpp>
#include <xo/alloc2/GCObject.hpp>
namespace xo {
using xo::print::APrintable;
@ -264,6 +266,13 @@ namespace xo {
}
void
DExpectQDictSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(const_cast<DString **>(&key_));
gc.forward_inplace(&dict_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,6 +6,7 @@
#include "ExpectQListSsm.hpp"
#include "ExpectQLiteralSsm.hpp"
#include <xo/object2/List.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -213,6 +214,13 @@ namespace xo {
refrtag("expect", this->get_expect_str()),
refrtag("list", list_pr));
}
void
DExpectQListSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(&start_);
gc.forward_inplace(&end_);
}
}
}

View file

@ -255,6 +255,12 @@ namespace xo {
"DExpectQLiteralSsm",
refrtag("expect", this->get_expect_str()));
}
void
DExpectQLiteralSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
// cxl_on_rightparen_, cxl_on_rightbracket_: POD, skip
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -145,6 +145,12 @@ namespace xo {
//refrtag("member", member_)
);
}
void
DExpectSymbolSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
// no gc-aware members
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -197,6 +197,12 @@ namespace xo {
"DExpectTypeSsm");
}
void
DExpectTypeSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
// corrected_: POD, skip
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,6 +9,7 @@
#include "DExpectExprSsm.hpp"
#include <xo/expression2/detail/IPrintable_DIfElseExpr.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
@ -507,5 +508,10 @@ namespace xo {
refrtag("if_expr", expr));
}
void
DIfElseSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&if_expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -16,6 +16,7 @@
//#include <xo/expression2/detail/IExpression_DVariable.hpp>
//#include <xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/arena/DArena.hpp>
@ -472,6 +473,14 @@ namespace xo {
}
}
void
DLambdaSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(&local_symtab_);
gc.forward_pivot_inplace(&body_);
gc.forward_pivot_inplace(&parent_symtab_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,6 +6,7 @@
#include "ParenSsm.hpp"
#include "ExpectExprSsm.hpp"
#include "syntaxstatetype.hpp"
#include <xo/alloc2/GCObject.hpp>
#include <string_view>
namespace xo {
@ -457,6 +458,11 @@ namespace xo {
refrtag("expect", this->get_expect_str()));
}
void
DParenSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -22,6 +22,7 @@
#include <xo/procedure2/init_primitives.hpp> // for xo::scm::Primitives
#include <xo/procedure2/detail/IGCObject_DPrimitive_gco_2_gco_gco.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/facet/FacetRegistry.hpp>
#include <xo/reflectutil/typeseq.hpp>
@ -1242,6 +1243,13 @@ case optype::op_assign:
return obj<AExpression>();
}
void
DProgressSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&lhs_);
gc.forward_pivot_inplace(&rhs_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -211,6 +211,12 @@ namespace xo {
refrtag("expect", this->get_expect_str()));
}
void
DQuoteSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_pivot_inplace(&expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -3,12 +3,13 @@
#include "DSequenceSsm.hpp"
#include "ssm/ISyntaxStateMachine_DSequenceSsm.hpp"
#include "DExpectExprSsm.hpp"
#include <xo/expression2/SequenceExpr.hpp>
#include <xo/alloc2/GCObject.hpp>
#ifdef NOT_YET
#include "expect_expr_xs.hpp"
#include "let1_xs.hpp"
#include "xo/expression/DefineExpr.hpp"
#include "xo/expression/Sequence.hpp"
#include "xo/expression/pretty_expression.hpp"
#endif
@ -256,6 +257,12 @@ namespace xo {
refrtag("expect", this->get_expect_str()));
}
void
DSequenceSsm::forward_children(obj<ACollector> gc) noexcept
{
gc.forward_inplace(&seq_expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -517,6 +517,12 @@ namespace xo {
"DToplevelSeqSsm",
refrtag("seqtype", seqtype_));
}
void
DToplevelSeqSsm::forward_children(obj<ACollector> /*gc*/) noexcept
{
// seqtype_: POD, skip
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -95,6 +95,12 @@ ISyntaxStateMachine_Any::on_quoted_literal(Opaque, obj<AGCObject>, ParserStateMa
_fatal();
}
auto
ISyntaxStateMachine_Any::forward_children(Opaque, obj<ACollector>) -> void
{
_fatal();
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DDefineSsm::forward_children(DDefineSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectExprSsm::forward_children(DExpectExprSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectFormalArglistSsm::forward_children(DExpectFormalArglistSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQArraySsm::forward_children(DExpectQArraySsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQListSsm::forward_children(DExpectQListSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQLiteralSsm::forward_children(DExpectQLiteralSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectSymbolSsm::forward_children(DExpectSymbolSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectTypeSsm::forward_children(DExpectTypeSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DParenSsm::forward_children(DParenSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DProgressSsm::forward_children(DProgressSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DQuoteSsm::forward_children(DQuoteSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DSequenceSsm::forward_children(DSequenceSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DToplevelSeqSsm::forward_children(DToplevelSeqSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DApplySsm::forward_children(DApplySsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DDeftypeSsm::forward_children(DDeftypeSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectFormalArgSsm::forward_children(DExpectFormalArgSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectListTypeSsm::forward_children(DExpectListTypeSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQDictSsm::forward_children(DExpectQDictSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DIfElseSsm::forward_children(DIfElseSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -77,6 +77,11 @@ namespace xo {
{
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DLambdaSsm::forward_children(DLambdaSsm & self, obj<ACollector> gc) -> void
{
self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,6 +6,7 @@
#include "Metatype.hpp"
#include "TypeVarRef.hpp"
#include <xo/reflect/Reflect.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
@ -89,10 +90,12 @@ namespace xo {
std::size_t
DTypeVarRef::forward_children(obj<ACollector> gc) noexcept
{
{
auto e = FacetRegistry::instance().variant<AGCObject,AType>(type_);
gc.forward_inplace(e.iface(), (void **)&type_.data_);
}
gc.forward_pivot_inplace(&type_);
//{
// auto e = FacetRegistry::instance().variant<AGCObject,AType>(type_);
// gc.forward_inplace(e.iface(), (void **)&type_.data_);
//}
return this->shallow_size();
}