xo-reader2 stack: + #q token + QuoteSsm [WIP - not functional]
This commit is contained in:
parent
34e863d4ea
commit
7b70296eb1
26 changed files with 712 additions and 0 deletions
|
|
@ -293,6 +293,26 @@ xo_add_genfacetimpl(
|
|||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-reader2-facetimpl-syntaxstatemachine-quotessm
|
||||
FACET_PKG xo_reader2
|
||||
FACET SyntaxStateMachine
|
||||
REPR QuoteSsm
|
||||
INPUT idl/ISyntaxStateMachine_DQuoteSsm.json5
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-reader2-facetimpl-printable-quotessm
|
||||
FACET_PKG xo_printable2
|
||||
FACET Printable
|
||||
REPR QuoteSsm
|
||||
INPUT idl/IPrintable_DQuoteSsm.json5
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
xo_add_genfacet_all(xo-reader2-genfacet-all)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
|
|||
16
idl/IPrintable_DQuoteSsm.json5
Normal file
16
idl/IPrintable_DQuoteSsm.json5
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
output_cpp_dir: "src/reader2",
|
||||
output_hpp_dir: "include/xo/reader2",
|
||||
output_impl_subdir: "ssm",
|
||||
includes: [ "<xo/printable2/Printable.hpp>",
|
||||
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
|
||||
local_types: [],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/Printable.json5",
|
||||
brief: "provide APrintable interface for DQuoteSsm",
|
||||
using_doxygen: true,
|
||||
repr: "DQuoteSsm",
|
||||
doc: [ "implement APrintable for DQuoteSsm" ],
|
||||
}
|
||||
16
idl/ISyntaxStateMachine_DQuoteSsm.json5
Normal file
16
idl/ISyntaxStateMachine_DQuoteSsm.json5
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
output_cpp_dir: "src/reader2",
|
||||
output_hpp_dir: "include/xo/reader2",
|
||||
output_impl_subdir: "ssm",
|
||||
includes: [ "\"SyntaxStateMachine.hpp\"",
|
||||
"\"ssm/ISyntaxStateMachine_Xfer.hpp\"" ],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/SyntaxStateMachine.json5",
|
||||
brief: "provide ASyntaxStateMachine interface for DQuoteSsm",
|
||||
using_doxygen: true,
|
||||
repr: "DQuoteSsm",
|
||||
doc: [ "implement ASyntaxStateMachine for DQuoteSsm" ],
|
||||
}
|
||||
166
include/xo/reader2/DQuoteSsm.hpp
Normal file
166
include/xo/reader2/DQuoteSsm.hpp
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/** @file DQuoteSsm.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DSyntaxStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <string_view>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/**
|
||||
* @pre
|
||||
*
|
||||
* #q{ quote-expr }
|
||||
* ^ ^ ^ ^ ^
|
||||
* | | | | (done)
|
||||
* | | | |
|
||||
* | | | quote_3:expect_rightbrace
|
||||
* | | quote_2:expect_parsed_expression
|
||||
* | quote_1:expect_leftbrace
|
||||
* quote_0
|
||||
*
|
||||
* quote_0 --on_quote_token()--> quote_1
|
||||
* quote_1 --on_leftbrace_token()--> quote_2
|
||||
* quote_2 --on_parsed_expression()--> quote_3 [will be constant expression]
|
||||
* quote_3 --on_rightparen_token()--> (done)
|
||||
*
|
||||
* @endpre
|
||||
**/
|
||||
|
||||
class QuoteXst {
|
||||
public:
|
||||
enum class code {
|
||||
invalid = -1,
|
||||
|
||||
quote_0,
|
||||
quote_1,
|
||||
quote_2,
|
||||
quote_3,
|
||||
|
||||
N,
|
||||
};
|
||||
|
||||
explicit QuoteXst(code x) : code_{x} {}
|
||||
|
||||
/** @return string representation for enum @p x **/
|
||||
static const char * _descr(code x);
|
||||
|
||||
code code() const noexcept { return code_; }
|
||||
|
||||
enum code code_;
|
||||
};
|
||||
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, QuoteXst x) {
|
||||
os << QuoteXst::_descr(x.code_);
|
||||
return os;
|
||||
}
|
||||
|
||||
class DQuoteSsm : public DSyntaxStateMachine<DQuoteSsm> {
|
||||
public:
|
||||
using Super = DSyntaxStateMachine<DQuoteSsm>;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using DArena = xo::mm::DArena;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
/** @defgroup scm-parenssm-ctors **/
|
||||
///@{
|
||||
|
||||
DQuoteSsm();
|
||||
|
||||
/** create instance using memory from @p parser_mm
|
||||
**/
|
||||
static DQuoteSsm * _make(DArena & parser_mm);
|
||||
|
||||
/** create fop pointing with new DQuoteSsm using memory from @p parser_mm **/
|
||||
static obj<ASyntaxStateMachine,DQuoteSsm> make(DArena & parser_mm);
|
||||
|
||||
/** push DQuoteSsm instance onto @p p_psm stack **/
|
||||
static void start(ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-access-methods **/
|
||||
///@{
|
||||
|
||||
/** identify this nested state machine **/
|
||||
static const char * ssm_classname() { return "DQuoteSsm"; }
|
||||
|
||||
/** internal state **/
|
||||
QuoteXst quotestate() const noexcept { return quote_xst_; }
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-admin-methods admin methods **/
|
||||
///@{
|
||||
|
||||
/** update ssm state for incoming leftparen token @p tk,
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_leftbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm state for incoming rightparen token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_rightbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
/** identifies this ssm **/
|
||||
syntaxstatetype ssm_type() const noexcept;
|
||||
|
||||
/** text describing expected/allowed input to this ssm in current state. **/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** update ssm for token @p tk, with overall state in @p p_psm **/
|
||||
void on_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm for expression @p expr (emitted by nested ssm),
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_expression(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update ssm for expression @p expr (emitted by nested ssm)
|
||||
* that's immediately followed by token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_expression_with_token(obj<AExpression> expr,
|
||||
const Token & tk,
|
||||
ParserStateMachine * p_psmn);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-parenssm-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** @defgroup scm-parenssm-member-vars **/
|
||||
///@{
|
||||
|
||||
/** identify quote-expression state **/
|
||||
QuoteXst quote_xst_;
|
||||
/** scaffold expression (representing parenthesized value) here **/
|
||||
obj<AExpression> expr_;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DQuoteSsm.hpp */
|
||||
12
include/xo/reader2/QuoteSsm.hpp
Normal file
12
include/xo/reader2/QuoteSsm.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/** @file QuoteSsm.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DQuoteSsm.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DQuoteSsm.hpp"
|
||||
#include "ssm/IPrintable_DQuoteSsm.hpp"
|
||||
|
||||
/* end QuoteSsm.hpp */
|
||||
62
include/xo/reader2/ssm/IPrintable_DQuoteSsm.hpp
Normal file
62
include/xo/reader2/ssm/IPrintable_DQuoteSsm.hpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/** @file IPrintable_DQuoteSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DQuoteSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DQuoteSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Printable.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DQuoteSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DQuoteSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DQuoteSsm>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DQuoteSsm,
|
||||
xo::scm::IPrintable_DQuoteSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DQuoteSsm
|
||||
**/
|
||||
class IPrintable_DQuoteSsm {
|
||||
public:
|
||||
/** @defgroup scm-printable-dquotessm-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dquotessm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DQuoteSsm & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
79
include/xo/reader2/ssm/ISyntaxStateMachine_DQuoteSsm.hpp
Normal file
79
include/xo/reader2/ssm/ISyntaxStateMachine_DQuoteSsm.hpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/** @file ISyntaxStateMachine_DQuoteSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DQuoteSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DQuoteSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
|
||||
#include "DQuoteSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class ISyntaxStateMachine_DQuoteSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
|
||||
xo::scm::DQuoteSsm>
|
||||
{
|
||||
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
|
||||
<xo::scm::DQuoteSsm,
|
||||
xo::scm::ISyntaxStateMachine_DQuoteSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class ISyntaxStateMachine_DQuoteSsm
|
||||
**/
|
||||
class ISyntaxStateMachine_DQuoteSsm {
|
||||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dquotessm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-syntaxstatemachine-dquotessm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** identify a type of syntax state machine **/
|
||||
static syntaxstatetype ssm_type(const DQuoteSsm & self) noexcept;
|
||||
/** text describing expected/allowed input to this ssm in current state **/
|
||||
static std::string_view get_expect_str(const DQuoteSsm & self) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** operate state machine for incoming token @p tk **/
|
||||
static void on_token(DQuoteSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DQuoteSsm & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DQuoteSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
/** operate state machine for formal emitted by nested ssm **/
|
||||
static void on_parsed_formal(DQuoteSsm & 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(DQuoteSsm & 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(DQuoteSsm & self, DArray * arglist, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming parsed expression @p expr **/
|
||||
static void on_parsed_expression(DQuoteSsm & 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(DQuoteSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -39,6 +39,9 @@ namespace xo {
|
|||
/** expression enclosed in parentheses. See @ref DParenSsm **/
|
||||
paren,
|
||||
|
||||
/** quoted literal using #q{..} syntax. See @ref DQuoteSsm **/
|
||||
quote,
|
||||
|
||||
/** toplevel of some translation unit. See @ref DToplevelSeqSsm **/
|
||||
expect_toplevel_expression_sequence,
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ set(SELF_SRCS
|
|||
ISyntaxStateMachine_DProgressSsm.cpp
|
||||
IPrintable_DProgressSsm.cpp
|
||||
|
||||
DQuoteSsm.cpp
|
||||
ISyntaxStateMachine_DQuoteSsm.cpp
|
||||
IPrintable_DQuoteSsm.cpp
|
||||
)
|
||||
|
||||
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ namespace xo {
|
|||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ namespace xo {
|
|||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_if:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ namespace xo {
|
|||
case tokentype::tk_singleassign:
|
||||
case tokentype::tk_colon:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_rightbrace:
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ namespace xo {
|
|||
case tokentype::tk_bool:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ namespace xo {
|
|||
case tokentype::tk_bool:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ namespace xo {
|
|||
case tokentype::tk_singleassign:
|
||||
case tokentype::tk_colon:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ namespace xo {
|
|||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_string:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ namespace xo {
|
|||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ namespace xo {
|
|||
case tokentype::tk_bool:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ namespace xo {
|
|||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_if:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ namespace xo {
|
|||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_def:
|
||||
case tokentype::tk_if:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
|
|
|
|||
218
src/reader2/DQuoteSsm.cpp
Normal file
218
src/reader2/DQuoteSsm.cpp
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/** @file DQuoterSsm.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "QuoteSsm.hpp"
|
||||
#include "ExpectExprSsm.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
//#include <string_view>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::with_facet;
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
extern const char *
|
||||
QuoteXst::_descr(enum QuoteXst::code x)
|
||||
{
|
||||
switch(x) {
|
||||
case code::invalid: return "invalid";
|
||||
case code::quote_0: return "quote_0";
|
||||
case code::quote_1: return "quote_1";
|
||||
case code::quote_2: return "quote_2";
|
||||
case code::quote_3: return "quote_3";
|
||||
case code::N: break;
|
||||
}
|
||||
|
||||
return "?QuoteXst";
|
||||
}
|
||||
|
||||
DQuoteSsm::DQuoteSsm()
|
||||
: quote_xst_(QuoteXst::code::quote_0),
|
||||
expr_{}
|
||||
{}
|
||||
|
||||
DQuoteSsm *
|
||||
DQuoteSsm::_make(DArena & mm)
|
||||
{
|
||||
void * mem = mm.alloc_for<DQuoteSsm>();
|
||||
|
||||
return new (mem) DQuoteSsm();
|
||||
}
|
||||
|
||||
obj<ASyntaxStateMachine,DQuoteSsm>
|
||||
DQuoteSsm::make(DArena & mm)
|
||||
{
|
||||
return obj<ASyntaxStateMachine,DQuoteSsm>(_make(mm));
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::start(ParserStateMachine * p_psm)
|
||||
{
|
||||
DArena::Checkpoint ckp = p_psm->parser_alloc().checkpoint();
|
||||
|
||||
auto paren_ssm = DQuoteSsm::make(p_psm->parser_alloc());
|
||||
|
||||
p_psm->push_ssm(ckp, paren_ssm);
|
||||
}
|
||||
|
||||
syntaxstatetype
|
||||
DQuoteSsm::ssm_type() const noexcept
|
||||
{
|
||||
return syntaxstatetype::paren;
|
||||
}
|
||||
|
||||
std::string_view
|
||||
DQuoteSsm::get_expect_str() const noexcept
|
||||
{
|
||||
switch (this->quote_xst_.code()) {
|
||||
case QuoteXst::code::invalid:
|
||||
case QuoteXst::code::N:
|
||||
break;
|
||||
case QuoteXst::code::quote_0: return "#q";
|
||||
case QuoteXst::code::quote_1: return "leftbrace";
|
||||
case QuoteXst::code::quote_2: return "qliteral";
|
||||
case QuoteXst::code::quote_3: return "rightbrace";
|
||||
}
|
||||
|
||||
assert(false);
|
||||
|
||||
return "?quotexst";
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::on_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
switch (tk.tk_type()) {
|
||||
|
||||
case tokentype::tk_leftbrace:
|
||||
this->on_leftbrace_token(tk, p_psm);
|
||||
return;
|
||||
|
||||
case tokentype::tk_rightbrace:
|
||||
this->on_rightbrace_token(tk, p_psm);
|
||||
return;
|
||||
|
||||
// all the not-yet handled cases
|
||||
case tokentype::tk_symbol:
|
||||
case tokentype::tk_def:
|
||||
case tokentype::tk_colon:
|
||||
case tokentype::tk_singleassign:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_string:
|
||||
case tokentype::tk_f64:
|
||||
case tokentype::tk_i64:
|
||||
case tokentype::tk_bool:
|
||||
case tokentype::tk_if:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_lessequal:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
case tokentype::tk_yields:
|
||||
case tokentype::tk_plus:
|
||||
case tokentype::tk_minus:
|
||||
case tokentype::tk_star:
|
||||
case tokentype::tk_slash:
|
||||
case tokentype::tk_cmpeq:
|
||||
case tokentype::tk_cmpne:
|
||||
case tokentype::tk_type:
|
||||
case tokentype::tk_lambda:
|
||||
case tokentype::tk_then:
|
||||
case tokentype::tk_else:
|
||||
case tokentype::tk_let:
|
||||
case tokentype::tk_in:
|
||||
case tokentype::tk_end:
|
||||
case tokentype::N:
|
||||
break;
|
||||
}
|
||||
|
||||
Super::on_token(tk, p_psm);
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::on_leftbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
if (quote_xst_.code() == QuoteXst::code::quote_0) {
|
||||
this->quote_xst_ = QuoteXst(QuoteXst::code::quote_1);
|
||||
|
||||
assert(false);
|
||||
//DExpectQLiteralSsm::start(p_psm);
|
||||
//return;
|
||||
}
|
||||
|
||||
Super::on_token(tk, p_psm);
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::on_rightbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
if (quote_xst_.code() == QuoteXst::code::quote_3) {
|
||||
// quoted literal (reported as constant expr) successfully parsed
|
||||
|
||||
p_psm->pop_ssm();
|
||||
p_psm->on_parsed_expression(this->expr_);
|
||||
return;
|
||||
}
|
||||
|
||||
Super::on_token(tk, p_psm);
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::on_parsed_expression(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
if (quote_xst_.code() == QuoteXst::code::quote_2) {
|
||||
this->quote_xst_ = QuoteXst(QuoteXst::code::quote_3);
|
||||
this->expr_ = expr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Super::on_parsed_expression(expr, p_psm);
|
||||
}
|
||||
|
||||
void
|
||||
DQuoteSsm::on_parsed_expression_with_token(obj<AExpression> expr,
|
||||
const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
if (quote_xst_.code() == QuoteXst::code::quote_2) {
|
||||
this->quote_xst_ = QuoteXst(QuoteXst::code::quote_3);
|
||||
this->expr_ = expr;
|
||||
|
||||
this->on_token(tk, p_psm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Super::on_parsed_expression(expr, p_psm);
|
||||
}
|
||||
|
||||
bool
|
||||
DQuoteSsm::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppii.pps()->pretty_struct(ppii,
|
||||
"DParenSsm",
|
||||
refrtag("quote_xst", quote_xst_),
|
||||
refrtag("expect", this->get_expect_str()));
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DQuoteSsm.cpp */
|
||||
|
|
@ -92,6 +92,7 @@ namespace xo {
|
|||
case tokentype::tk_bool:
|
||||
case tokentype::tk_semicolon:
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_leftparen:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ namespace xo {
|
|||
|
||||
// all the not-yet handled cases
|
||||
case tokentype::tk_invalid:
|
||||
case tokentype::tk_quote:
|
||||
case tokentype::tk_rightparen:
|
||||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
|
|
|
|||
28
src/reader2/IPrintable_DQuoteSsm.cpp
Normal file
28
src/reader2/IPrintable_DQuoteSsm.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DQuoteSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DQuoteSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DQuoteSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/IPrintable_DQuoteSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DQuoteSsm::pretty(const DQuoteSsm & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DQuoteSsm.cpp */
|
||||
74
src/reader2/ISyntaxStateMachine_DQuoteSsm.cpp
Normal file
74
src/reader2/ISyntaxStateMachine_DQuoteSsm.cpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/** @file ISyntaxStateMachine_DQuoteSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DQuoteSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DQuoteSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/ISyntaxStateMachine_DQuoteSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::ssm_type(const DQuoteSsm & self) noexcept -> syntaxstatetype
|
||||
{
|
||||
return self.ssm_type();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::get_expect_str(const DQuoteSsm & self) noexcept -> std::string_view
|
||||
{
|
||||
return self.get_expect_str();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_token(DQuoteSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_symbol(DQuoteSsm & self, std::string_view sym, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_symbol(sym, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_typedescr(DQuoteSsm & self, TypeDescr td, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_typedescr(td, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_formal(DQuoteSsm & self, const DUniqueString * param_name, TypeDescr param_type, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_formal(param_name, param_type, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_formal_with_token(DQuoteSsm & self, const DUniqueString * param_name, TypeDescr param_type, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_formal_with_token(param_name, param_type, tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_formal_arglist(DQuoteSsm & self, DArray * arglist, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_formal_arglist(arglist, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_expression(DQuoteSsm & self, obj<AExpression> expr, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_expression(expr, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DQuoteSsm::on_parsed_expression_with_token(DQuoteSsm & self, obj<AExpression> expr, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_expression_with_token(expr, tk, p_psm);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ISyntaxStateMachine_DQuoteSsm.cpp */
|
||||
|
|
@ -27,6 +27,8 @@ namespace xo {
|
|||
return "progress";
|
||||
case syntaxstatetype::paren:
|
||||
return "paren";
|
||||
case syntaxstatetype::quote:
|
||||
return "quote";
|
||||
case syntaxstatetype::expect_toplevel_expression_sequence:
|
||||
return "expect-toplevel-expression-sequence";
|
||||
case syntaxstatetype::expect_formal_arglist:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue