xo-reader2: allow formals w/out explicit type
This commit is contained in:
parent
121fb2dfad
commit
27c5f66e74
39 changed files with 307 additions and 32 deletions
|
|
@ -79,6 +79,12 @@ namespace xo {
|
|||
void on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state on incoming rightparen token @p tk;
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_rightparen_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expectformalargssm-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ namespace xo {
|
|||
class DExpectFormalArglistSsm : public DSyntaxStateMachine<DExpectFormalArglistSsm> {
|
||||
public:
|
||||
using Super = DSyntaxStateMachine<DExpectFormalArglistSsm>;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using DArena = xo::mm::DArena;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
|
@ -108,6 +109,14 @@ namespace xo {
|
|||
void on_parsed_formal(const DUniqueString * param_name,
|
||||
TypeDescr param_type,
|
||||
ParserStateMachine * p_psm);
|
||||
/** update state to consume parsed formal (name,type) emitted
|
||||
* by nested ssm, that's followed immediately by token @p tk.
|
||||
* overall parser state in @p *p_psm
|
||||
**/
|
||||
void on_parsed_formal_with_token(const DUniqueString * param_name,
|
||||
TypeDescr param_type,
|
||||
const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expectformalarglistssm-printable-facet printable facet methods **/
|
||||
|
|
@ -117,6 +126,21 @@ namespace xo {
|
|||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** @defgroup scm-expectformalarglistssm-impl-methods **/
|
||||
///@{
|
||||
|
||||
/** update local state to include parsed formal (param_name, param_type).
|
||||
* If stack memory needed, get from @p parser_alloc.
|
||||
* Lifetime until formal arglist completely parsed
|
||||
**/
|
||||
void _accept_formal(obj<AAllocator> expr_alloc,
|
||||
DArena & parser_alloc,
|
||||
const DUniqueString * param_name,
|
||||
TypeDescr param_type);
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** parsing state-machine state **/
|
||||
formalarglstatetype fastate_ = formalarglstatetype::argl_0;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,23 @@ namespace xo {
|
|||
self.get_expect_str());
|
||||
}
|
||||
|
||||
/** Default implementation for required SyntaxStateMachine facet method
|
||||
**/
|
||||
void on_parsed_formal_with_token(const DUniqueString * param_name,
|
||||
TypeDescr param_type,
|
||||
const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
// starting with c++23 can use "this auto&& self" instead
|
||||
Derived & self = reinterpret_cast<Derived&>(*this);
|
||||
|
||||
p_psm->illegal_parsed_formal_with_token(Derived::ssm_classname(),
|
||||
param_name,
|
||||
param_type,
|
||||
tk,
|
||||
self.get_expect_str());
|
||||
}
|
||||
|
||||
/** Default implementation for required SyntaxStateMachine facet method
|
||||
*
|
||||
* arglist is DArray of obj<AGCObejct,DVariable>
|
||||
|
|
|
|||
|
|
@ -149,12 +149,20 @@ namespace xo {
|
|||
**/
|
||||
void on_parsed_typedescr(TypeDescr td);
|
||||
|
||||
/** update state to consume param (name, value) emitted by
|
||||
/** update state to consume param (name, type) emitted by
|
||||
* nested (expired) parsing state
|
||||
**/
|
||||
void on_parsed_formal(const DUniqueString * param_name,
|
||||
TypeDescr param_type);
|
||||
|
||||
/** update state to consume formal parameter (name, type)
|
||||
* emitted by nested (now expired) parsing state,
|
||||
* with trailing token @p tk
|
||||
**/
|
||||
void on_parsed_formal_with_token(const DUniqueString * param_name,
|
||||
TypeDescr param_type,
|
||||
const Token & tk);
|
||||
|
||||
/** update state to consume formal arugment list
|
||||
* emitted by nested (expired) parsing state
|
||||
**/
|
||||
|
|
@ -231,6 +239,15 @@ namespace xo {
|
|||
TypeDescr param_type,
|
||||
std::string_view expect_str);
|
||||
|
||||
/** report illegal parsed formal (param_name, param_type) from nested ssm;
|
||||
* presented with immediately-following input token @p tk.
|
||||
**/
|
||||
void illegal_parsed_formal_with_token(std::string_view ssm_name,
|
||||
const DUniqueString * param_name,
|
||||
TypeDescr param_type,
|
||||
const Token & tk,
|
||||
std::string_view expect_str);
|
||||
|
||||
/** @p arglist stores obj<AGCObject,DVariable> pointers.
|
||||
**/
|
||||
void illegal_parsed_formal_arglist(std::string_view ssm_name,
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ public:
|
|||
virtual void on_parsed_typedescr(Opaque data, TypeDescr td, ParserStateMachine * p_psm) = 0;
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
virtual void on_parsed_formal(Opaque data, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) = 0;
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
virtual void on_parsed_formal_with_token(Opaque data, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm) = 0;
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
virtual void on_parsed_formal_arglist(Opaque data, DArray * arglist, ParserStateMachine * p_psm) = 0;
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ namespace scm {
|
|||
[[noreturn]] void on_parsed_symbol(Opaque, std::string_view, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_typedescr(Opaque, TypeDescr, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_formal(Opaque, const DUniqueString *, TypeDescr, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_formal_with_token(Opaque, const DUniqueString *, TypeDescr, const Token &, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_formal_arglist(Opaque, DArray *, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_expression(Opaque, obj<AExpression>, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_parsed_expression_with_token(Opaque, obj<AExpression>, const Token &, ParserStateMachine *) override;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
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);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DApplySsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DApplySsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DDefineSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DDefineSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DDefineSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DDefineSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DExpectExprSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DExpectExprSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DExpectExprSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DExpectExprSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DExpectFormalArgSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DExpectFormalArgSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DExpectFormalArgSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DExpectFormalArgSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DExpectFormalArglistSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DExpectFormalArglistSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DExpectFormalArglistSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DExpectFormalArglistSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DExpectSymbolSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DExpectSymbolSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DExpectSymbolSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DExpectSymbolSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DExpectTypeSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DExpectTypeSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DExpectTypeSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DExpectTypeSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DIfElseSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DIfElseSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DIfElseSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DIfElseSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DLambdaSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DLambdaSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DLambdaSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DLambdaSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DParenSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DParenSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DParenSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DParenSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DProgressSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DProgressSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DProgressSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DProgressSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
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);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DSequenceSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DSequenceSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace xo {
|
|||
static void on_parsed_typedescr(DToplevelSeqSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DToplevelSeqSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal_with_token(DToplevelSeqSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** consume formal arglist emitted by nested ssm **/
|
||||
static void on_parsed_formal_arglist(DToplevelSeqSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ namespace scm {
|
|||
void on_parsed_formal(Opaque data, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) override {
|
||||
return I::on_parsed_formal(_dcast(data), param_name, param_type, p_psm);
|
||||
}
|
||||
void on_parsed_formal_with_token(Opaque data, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm) override {
|
||||
return I::on_parsed_formal_with_token(_dcast(data), param_name, param_type, tk, p_psm);
|
||||
}
|
||||
void on_parsed_formal_arglist(Opaque data, DArray * arglist, ParserStateMachine * p_psm) override {
|
||||
return I::on_parsed_formal_arglist(_dcast(data), arglist, p_psm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ public:
|
|||
void on_parsed_formal(const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_parsed_formal(O::data(), param_name, param_type, p_psm);
|
||||
}
|
||||
void on_parsed_formal_with_token(const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_parsed_formal_with_token(O::data(), param_name, param_type, tk, p_psm);
|
||||
}
|
||||
void on_parsed_formal_arglist(DArray * arglist, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_parsed_formal_arglist(O::data(), arglist, p_psm);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue