xo-reader2: + DExpectExprSsm + use from DDefineSsm
This commit is contained in:
parent
b84447e4f8
commit
8b148285b1
15 changed files with 465 additions and 24 deletions
|
|
@ -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
xo-reader2/src/reader2/IPrintable_DExpectExprSsm.cpp
Normal file
28
xo-reader2/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 */
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue