xo-reader2: + DExpectExprSsm + use from DDefineSsm
This commit is contained in:
parent
124d848a57
commit
55149f0890
15 changed files with 465 additions and 24 deletions
|
|
@ -138,6 +138,32 @@ xo_add_genfacetimpl(
|
|||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-reader2-facetimpl-syntaxstatemachine-expectexprssm
|
||||
FACET_PKG xo_reader2
|
||||
FACET SyntaxStateMachine
|
||||
REPR ExpectExprSsm
|
||||
INPUT idl/ISyntaxStateMachine_DExpectExprSsm.json5
|
||||
OUTPUT_HPP_DIR include/xo/reader2
|
||||
OUTPUT_IMPL_SUBDIR ssm
|
||||
OUTPUT_CPP_DIR src/reader2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-reader2-facetimpl-printable-expectexprssm
|
||||
FACET_PKG xo_printable2
|
||||
FACET Printable
|
||||
REPR ExpectExprSsm
|
||||
INPUT idl/IPrintable_DExpectExprSsm.json5
|
||||
OUTPUT_HPP_DIR include/xo/reader2
|
||||
OUTPUT_IMPL_SUBDIR ssm
|
||||
OUTPUT_CPP_DIR src/reader2
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
xo_add_genfacet_all(xo-reader2-genfacet-all)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
|
|||
13
idl/IPrintable_DExpectExprSsm.json5
Normal file
13
idl/IPrintable_DExpectExprSsm.json5
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
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 DExpectExprSsm",
|
||||
using_doxygen: true,
|
||||
repr: "DExpectExprSsm",
|
||||
doc: [ "implement APrintable for DExpectExprSsm" ],
|
||||
}
|
||||
13
idl/ISyntaxStateMachine_DExpectExprSsm.json5
Normal file
13
idl/ISyntaxStateMachine_DExpectExprSsm.json5
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [ "\"SyntaxStateMachine.hpp\"",
|
||||
"\"ssm/ISyntaxStateMachine_Xfer.hpp\"" ],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/SyntaxStateMachine.json5",
|
||||
brief: "provide ASyntaxStateMachine interface for DExpectExprSsm",
|
||||
using_doxygen: true,
|
||||
repr: "DExpectExprSsm",
|
||||
doc: [ "implement ASyntaxStateMachine for DExpectExprSsm" ],
|
||||
}
|
||||
|
|
@ -32,7 +32,16 @@ namespace xo {
|
|||
bool allow_defs,
|
||||
bool cxl_on_rightparen,
|
||||
ParserStateMachine * p_psm);
|
||||
static void start(DArena & parser_mm,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** @defgroup scm-expectexpr-access-methods access methods **/
|
||||
///@{
|
||||
|
||||
bool allow_defs() const noexcept { return allow_defs_; }
|
||||
bool cxl_on_rightbrace() const noexcept { return cxl_on_rightbrace_; }
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-expectexpr-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
|
|
|
|||
62
include/xo/reader2/ssm/IPrintable_DExpectExprSsm.hpp
Normal file
62
include/xo/reader2/ssm/IPrintable_DExpectExprSsm.hpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/** @file IPrintable_DExpectExprSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DExpectExprSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DExpectExprSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Printable.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DExpectExprSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DExpectExprSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DExpectExprSsm>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DExpectExprSsm,
|
||||
xo::scm::IPrintable_DExpectExprSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DExpectExprSsm
|
||||
**/
|
||||
class IPrintable_DExpectExprSsm {
|
||||
public:
|
||||
/** @defgroup scm-printable-dexpectexprssm-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dexpectexprssm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DExpectExprSsm & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/** @file ISyntaxStateMachine_DExpectExprSsm.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DExpectExprSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DExpectExprSsm.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_Xfer.hpp"
|
||||
#include "DExpectExprSsm.hpp"
|
||||
|
||||
namespace xo { namespace scm { class ISyntaxStateMachine_DExpectExprSsm; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::ASyntaxStateMachine,
|
||||
xo::scm::DExpectExprSsm>
|
||||
{
|
||||
using ImplType = xo::scm::ISyntaxStateMachine_Xfer
|
||||
<xo::scm::DExpectExprSsm,
|
||||
xo::scm::ISyntaxStateMachine_DExpectExprSsm>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class ISyntaxStateMachine_DExpectExprSsm
|
||||
**/
|
||||
class ISyntaxStateMachine_DExpectExprSsm {
|
||||
public:
|
||||
/** @defgroup scm-syntaxstatemachine-dexpectexprssm-type-traits **/
|
||||
///@{
|
||||
using TypeDescr = xo::scm::ASyntaxStateMachine::TypeDescr;
|
||||
using Copaque = xo::scm::ASyntaxStateMachine::Copaque;
|
||||
using Opaque = xo::scm::ASyntaxStateMachine::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-syntaxstatemachine-dexpectexprssm-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** identify a type of syntax state machine **/
|
||||
static syntaxstatetype ssm_type(const DExpectExprSsm & self) noexcept;
|
||||
/** text describing expected/allowed input to this ssm in current state **/
|
||||
static std::string_view get_expect_str(const DExpectExprSsm & self) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** operate state machine for incoming symbol-token @p tk **/
|
||||
static void on_symbol_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming define-keyword-token @p tk **/
|
||||
static void on_def_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming if-keyword-token @p tk **/
|
||||
static void on_if_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming colon-token @p tk **/
|
||||
static void on_colon_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update state machine for incoming singleassign-token @p tk **/
|
||||
static void on_singleassign_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
/** update stat machine for incoming parsed symbol @p sym **/
|
||||
static void on_parsed_symbol(DExpectExprSsm & self, std::string_view sym, ParserStateMachine * p_psm);
|
||||
/** operate state machine for incoming type description @p td **/
|
||||
static void on_parsed_typedescr(DExpectExprSsm & self, TypeDescr td, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -27,6 +27,9 @@ namespace xo {
|
|||
/** expecting a type. See @ref DExpectTypeSsm **/
|
||||
expect_type,
|
||||
|
||||
/** expecting a rhs expression. See @ref DExpectExprSsm **/
|
||||
expect_rhs_expression,
|
||||
|
||||
/** handle define-expression. See @ref DDefineSsm **/
|
||||
defexpr,
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ set(SELF_SRCS
|
|||
IPrintable_DExpectTypeSsm.cpp
|
||||
|
||||
DExpectExprSsm.cpp
|
||||
ISyntaxStateMachine_DExpectExprSsm.cpp
|
||||
IPrintable_DExpectExprSsm.cpp
|
||||
|
||||
reader2_register_facets.cpp
|
||||
reader2_register_types.cpp
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "DDefineSsm.hpp"
|
||||
#include "DExpectSymbolSsm.hpp"
|
||||
#include "DExpectTypeSsm.hpp"
|
||||
#include "DExpectExprSsm.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DDefineSsm.hpp"
|
||||
#include "ssm/IPrintable_DDefineSsm.hpp"
|
||||
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
||||
|
|
@ -554,9 +555,8 @@ namespace xo {
|
|||
{
|
||||
this->defstate_ = defexprstatetype::def_5;
|
||||
|
||||
// TODO: DExpectExprSsm::start(...)
|
||||
log && log("STUB: DExpectExprSsm not implemented");
|
||||
|
||||
DExpectExprSsm::start(p_psm->parser_alloc(),
|
||||
p_psm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
#include "DExpectExprSsm.hpp"
|
||||
#include "ParserStateMachine.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DExpectExprSsm.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
|
||||
#ifdef NOT_YET
|
||||
#include "exprstatestack.hpp"
|
||||
|
|
@ -24,43 +28,64 @@ namespace xo {
|
|||
using xo::scm::Constant;
|
||||
#endif
|
||||
|
||||
using xo::reflect::typeseq;
|
||||
using xo::facet::with_facet;
|
||||
|
||||
namespace scm {
|
||||
|
||||
#ifdef NOT_YET
|
||||
std::unique_ptr<expect_expr_xs>
|
||||
expect_expr_xs::make(bool allow_defs,
|
||||
DExpectExprSsm::DExpectExprSsm(bool allow_defs,
|
||||
bool cxl_on_rightbrace)
|
||||
: allow_defs_{allow_defs},
|
||||
cxl_on_rightbrace_{cxl_on_rightbrace}
|
||||
{
|
||||
}
|
||||
|
||||
DExpectExprSsm *
|
||||
DExpectExprSsm::make(DArena & mm,
|
||||
bool allow_defs,
|
||||
bool cxl_on_rightbrace)
|
||||
{
|
||||
return std::make_unique<expect_expr_xs>(expect_expr_xs(allow_defs,
|
||||
cxl_on_rightbrace));
|
||||
void * mem = mm.alloc(typeseq::id<DExpectExprSsm>(),
|
||||
sizeof(DExpectExprSsm));
|
||||
|
||||
return new (mem) DExpectExprSsm(allow_defs,
|
||||
cxl_on_rightbrace);
|
||||
}
|
||||
|
||||
void
|
||||
expect_expr_xs::start(bool allow_defs,
|
||||
DExpectExprSsm::start(DArena & mm,
|
||||
bool allow_defs,
|
||||
bool cxl_on_rightbrace,
|
||||
parserstatemachine * p_psm)
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->push_exprstate(expect_expr_xs::make(allow_defs,
|
||||
cxl_on_rightbrace));
|
||||
DExpectExprSsm * exp_expr
|
||||
= DExpectExprSsm::make(mm,
|
||||
allow_defs,
|
||||
cxl_on_rightbrace);
|
||||
obj<ASyntaxStateMachine> ssm
|
||||
= with_facet<ASyntaxStateMachine>::mkobj(exp_expr);
|
||||
|
||||
p_psm->push_ssm(ssm);
|
||||
}
|
||||
|
||||
void
|
||||
expect_expr_xs::start(parserstatemachine * p_psm) {
|
||||
start(false /*!allow_defs*/,
|
||||
DExpectExprSsm::start(DArena & mm,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
start(mm,
|
||||
false /*!allow_defs*/,
|
||||
false /*!cxl_on_rightbrace*/,
|
||||
p_psm);
|
||||
}
|
||||
|
||||
expect_expr_xs::expect_expr_xs(bool allow_defs,
|
||||
bool cxl_on_rightbrace)
|
||||
: exprstate(exprstatetype::expect_rhs_expression),
|
||||
allow_defs_{allow_defs},
|
||||
cxl_on_rightbrace_{cxl_on_rightbrace}
|
||||
{}
|
||||
syntaxstatetype
|
||||
DExpectExprSsm::ssm_type() const noexcept
|
||||
{
|
||||
return syntaxstatetype::expect_rhs_expression;
|
||||
}
|
||||
|
||||
const char *
|
||||
expect_expr_xs::get_expect_str() const
|
||||
std::string_view
|
||||
DExpectExprSsm::get_expect_str() const noexcept
|
||||
{
|
||||
if (allow_defs_) {
|
||||
return "def|lambda|lparen|lbrace|literal|var";
|
||||
|
|
@ -69,6 +94,80 @@ namespace xo {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_symbol_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectExprSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_def_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectExprSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_if_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectExprSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectExprSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_singleassign_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectExprSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_symbol("DExpectExprSsm",
|
||||
sym,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectExprSsm::on_parsed_typedescr(TypeDescr td,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_typedescr("DExpectExprSsm",
|
||||
td,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
bool
|
||||
DExpectExprSsm::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DExpectExprSsm",
|
||||
refrtag("allow_defs", allow_defs_),
|
||||
refrtag("cxl_on_rightbrace", cxl_on_rightbrace_));
|
||||
}
|
||||
|
||||
#ifdef NOT_YET
|
||||
void
|
||||
expect_expr_xs::on_def_token(const token_type & tk,
|
||||
parserstatemachine * p_psm)
|
||||
|
|
|
|||
28
src/reader2/IPrintable_DExpectExprSsm.cpp
Normal file
28
src/reader2/IPrintable_DExpectExprSsm.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DExpectExprSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DExpectExprSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DExpectExprSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/IPrintable_DExpectExprSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DExpectExprSsm::pretty(const DExpectExprSsm & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DExpectExprSsm.cpp */
|
||||
69
src/reader2/ISyntaxStateMachine_DExpectExprSsm.cpp
Normal file
69
src/reader2/ISyntaxStateMachine_DExpectExprSsm.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/** @file ISyntaxStateMachine_DExpectExprSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DExpectExprSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DExpectExprSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/ISyntaxStateMachine_DExpectExprSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::ssm_type(const DExpectExprSsm & self) noexcept -> syntaxstatetype
|
||||
{
|
||||
return self.ssm_type();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::get_expect_str(const DExpectExprSsm & self) noexcept -> std::string_view
|
||||
{
|
||||
return self.get_expect_str();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_symbol_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_symbol_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_def_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_def_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_if_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_if_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_colon_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_colon_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_singleassign_token(DExpectExprSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_singleassign_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_parsed_symbol(DExpectExprSsm & self, std::string_view sym, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_symbol(sym, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectExprSsm::on_parsed_typedescr(DExpectExprSsm & self, TypeDescr td, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_typedescr(td, p_psm);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ISyntaxStateMachine_DExpectExprSsm.cpp */
|
||||
|
|
@ -17,6 +17,9 @@
|
|||
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp>
|
||||
#include <xo/reader2/ssm/IPrintable_DExpectTypeSsm.hpp>
|
||||
|
||||
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp>
|
||||
#include <xo/reader2/ssm/IPrintable_DExpectExprSsm.hpp>
|
||||
|
||||
#include <xo/reader2/ssm/ASyntaxStateMachine.hpp>
|
||||
#include <xo/printable2/detail/APrintable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
|
@ -45,10 +48,14 @@ namespace xo {
|
|||
FacetRegistry::register_impl<ASyntaxStateMachine, DExpectTypeSsm>();
|
||||
FacetRegistry::register_impl<APrintable, DExpectTypeSsm>();
|
||||
|
||||
FacetRegistry::register_impl<ASyntaxStateMachine, DExpectExprSsm>();
|
||||
FacetRegistry::register_impl<APrintable, DExpectExprSsm>();
|
||||
|
||||
log && log(xtag("DExprSeqState.tseq", typeseq::id<DExprSeqState>()));
|
||||
log && log(xtag("DDefineSsm.tseq", typeseq::id<DDefineSsm>()));
|
||||
log && log(xtag("DExpectSymbolSsm.tseq", typeseq::id<DExpectSymbolSsm>()));
|
||||
log && log(xtag("DExpectTypeSsm.tseq", typeseq::id<DExpectTypeSsm>()));
|
||||
log && log(xtag("DExpectExprSsm.tseq", typeseq::id<DExpectExprSsm>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ namespace xo {
|
|||
return "expect-symbol";
|
||||
case syntaxstatetype::expect_type:
|
||||
return "expect-type";
|
||||
case syntaxstatetype::expect_rhs_expression:
|
||||
return "expect-rhs-expression";
|
||||
case syntaxstatetype::defexpr:
|
||||
return "defexpr";
|
||||
case syntaxstatetype::N:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <xo/reader2/SchematikaParser.hpp>
|
||||
#include <xo/reader2/DDefineSsm.hpp>
|
||||
#include <xo/reader2/DExpectExprSsm.hpp>
|
||||
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectExprSsm.hpp>
|
||||
#include <xo/reader2/ssm/ISyntaxStateMachine_DDefineSsm.hpp>
|
||||
#include <xo/reader2/init_reader2.hpp>
|
||||
#include <xo/alloc2/arena/IAllocator_DArena.hpp>
|
||||
|
|
@ -15,10 +17,12 @@ namespace xo {
|
|||
using xo::scm::ASyntaxStateMachine;
|
||||
using xo::scm::syntaxstatetype;
|
||||
using xo::scm::DDefineSsm;
|
||||
using xo::scm::DExpectExprSsm;
|
||||
using xo::scm::defexprstatetype;
|
||||
using xo::scm::ParserResult;
|
||||
using xo::scm::parser_result_type;
|
||||
//using xo::scm::ParserResult;
|
||||
//using xo::scm::parser_result_type;
|
||||
using xo::scm::Token;
|
||||
using xo::scm::DString;
|
||||
using xo::mm::ArenaConfig;
|
||||
using xo::mm::AAllocator;
|
||||
using xo::mm::DArena;
|
||||
|
|
@ -150,12 +154,39 @@ namespace xo {
|
|||
log && log(xtag("parser", &parser));
|
||||
log && log(xtag("result", result));
|
||||
|
||||
auto exp_ssm
|
||||
= obj<ASyntaxStateMachine,DExpectExprSsm>::from(parser.top_ssm());
|
||||
|
||||
REQUIRE(exp_ssm);
|
||||
REQUIRE(exp_ssm.data()->ssm_type() == syntaxstatetype::expect_rhs_expression);
|
||||
REQUIRE(exp_ssm.data()->allow_defs() == false);
|
||||
REQUIRE(exp_ssm.data()->cxl_on_rightbrace() == false);
|
||||
}
|
||||
|
||||
#ifdef NOT_YET
|
||||
{
|
||||
// future-proofing for Token only holding a string_view
|
||||
const DString * str = DString::from_cstr(expr_alloc, "3.141593");
|
||||
|
||||
auto & result = parser.on_token(Token::f64_token(std::string(*str)));
|
||||
|
||||
REQUIRE(parser.has_incomplete_expr() == true);
|
||||
|
||||
log && log("after typename symbol token:");
|
||||
log && log(xtag("parser", &parser));
|
||||
log && log(xtag("result", result));
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
#ifdef NOT_YET
|
||||
auto def_ssm
|
||||
= obj<ASyntaxStateMachine,DDefineSsm>::from(parser.top_ssm());
|
||||
|
||||
REQUIRE(def_ssm);
|
||||
REQUIRE(def_ssm.data()->ssm_type() == syntaxstatetype::defexpr);
|
||||
REQUIRE(def_ssm.data()->defstate() == defexprstatetype::def_5);
|
||||
#endif
|
||||
}
|
||||
|
||||
// define-expressions not properly implemented
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue