xo-reader2: progress+apply works up to lparen introducing formals

This commit is contained in:
Roland Conybeare 2026-02-11 18:07:55 -05:00
commit 18ae5739c2
14 changed files with 396 additions and 30 deletions

View file

@ -0,0 +1,12 @@
/** @file ApplySsm.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DApplySsm.hpp"
#include "ssm/ISyntaxStateMachine_DApplySsm.hpp"
#include "ssm/IPrintable_DApplySsm.hpp"
/* end ApplySsm.hpp */

View file

@ -89,10 +89,11 @@ namespace xo {
static DApplySsm * make(DArena & parser_mm,
obj<AExpression> fn_expr);
#ifdef NOT_YET
/**
* Start apply. Will trigger this after input like
* "fn("
* or
* "makefn()()"
*
* apply_xs remains on expr stack until closing right paren
* fn(arg1-expr, arg2-expr, ...)
@ -100,9 +101,8 @@ namespace xo {
* @p fnex expression in function position
* @p p_psm parser state machine
**/
static void start(rp<Expression> fnex,
parserstatemachine * p_psm);
#endif
static void start(obj<AExpression> fnex,
ParserStateMachine * p_psm);
///@}
/** @defgroup scm-applyssm-access methods **/
@ -124,6 +124,8 @@ namespace xo {
/** mnemonic for expected remaining syntax for current parsing state **/
std::string_view get_expect_str() const noexcept;
///@}
#ifdef NOT_YET
virtual void on_expr(bp<Expression> expr,
@ -143,6 +145,14 @@ namespace xo {
static std::unique_ptr<apply_xs> make();
#endif
/** @defgroup ssm-applyssm-printable-facet printable facet **/
///@{
/** pretty-printing support **/
bool pretty(const ppindentinfo & ppii) const;
///@}
private:
/** current state of parser for this apply expression **/
applyexprstatetype applystate_ = applyexprstatetype::apply_0;

View file

@ -0,0 +1,13 @@
/** @file SequenceSsm.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DSequenceSsm.hpp"
#include "ssm/ISyntaxStateMachine_DSequenceSsm.hpp"
#include "ssm/IPrintable_DSequenceSsm.hpp"
/* end SequenceSsm.hpp */

View file

@ -0,0 +1,62 @@
/** @file IPrintable_DApplySsm.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DApplySsm.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DApplySsm.json5]
**/
#pragma once
#include "Printable.hpp"
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DApplySsm.hpp"
namespace xo { namespace scm { class IPrintable_DApplySsm; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DApplySsm>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DApplySsm,
xo::scm::IPrintable_DApplySsm>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DApplySsm
**/
class IPrintable_DApplySsm {
public:
/** @defgroup scm-printable-dapplyssm-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
using Copaque = xo::print::APrintable::Copaque;
using Opaque = xo::print::APrintable::Opaque;
///@}
/** @defgroup scm-printable-dapplyssm-methods **/
///@{
// const methods
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DApplySsm & self, const ppindentinfo & ppii);
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,77 @@
/** @file ISyntaxStateMachine_DApplySsm.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISyntaxStateMachine_DApplySsm.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/ISyntaxStateMachine_DApplySsm.json5]
**/
#pragma once
#include "SyntaxStateMachine.hpp"
#include "SyntaxStateMachine.hpp"
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
#include "DApplySsm.hpp"
namespace xo { namespace scm { class ISyntaxStateMachine_DApplySsm; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
xo::scm::DApplySsm>
{
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
<xo::scm::DApplySsm,
xo::scm::ISyntaxStateMachine_DApplySsm>;
};
}
}
namespace xo {
namespace scm {
/** @class ISyntaxStateMachine_DApplySsm
**/
class ISyntaxStateMachine_DApplySsm {
public:
/** @defgroup scm-syntaxstatemachine-dapplyssm-type-traits **/
///@{
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
///@}
/** @defgroup scm-syntaxstatemachine-dapplyssm-methods **/
///@{
// const methods
/** identify a type of syntax state machine **/
static syntaxstatetype ssm_type(const DApplySsm & self) noexcept;
/** text describing expected/allowed input to this ssm in current state **/
static std::string_view get_expect_str(const DApplySsm & self) noexcept;
// non-const methods
/** operate state machine for incoming token @p tk **/
static void on_token(DApplySsm & self, const Token & tk, ParserStateMachine * p_psm);
/** update stat machine for incoming parsed symbol @p sym **/
static void on_parsed_symbol(DApplySsm & self, std::string_view sym, ParserStateMachine * p_psm);
/** operate state machine for incoming type description @p td **/
static void on_parsed_typedescr(DApplySsm & self, TypeDescr td, ParserStateMachine * p_psm);
/** operate state machine for formal emitted by nested ssm **/
static void on_parsed_formal(DApplySsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
/** consume formal arglist emitted by nested ssm **/
static void on_parsed_formal_arglist(DApplySsm & self, DArray * arglist, ParserStateMachine * p_psm);
/** update state machine for incoming parsed expression @p expr **/
static void on_parsed_expression(DApplySsm & self, obj<AExpression> expr, ParserStateMachine * p_psm);
/** update state machine @p p_psm for incoming parsed expression @p expr followed by token @p tk **/
static void on_parsed_expression_with_token(DApplySsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */