xo-reader2: + DExpectTypeSsm + extend DDefineSsm [WIP]
This commit is contained in:
parent
c87975ab18
commit
7b62bd7f5c
13 changed files with 442 additions and 10 deletions
|
|
@ -23,6 +23,10 @@ set(SELF_SRCS
|
|||
ISyntaxStateMachine_DExpectSymbolSsm.cpp
|
||||
IPrintable_DExpectSymbolSsm.cpp
|
||||
|
||||
DExpectTypeSsm.cpp
|
||||
ISyntaxStateMachine_DExpectTypeSsm.cpp
|
||||
IPrintable_DExpectTypeSsm.cpp
|
||||
|
||||
reader2_register_facets.cpp
|
||||
reader2_register_types.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "DDefineSsm.hpp"
|
||||
#include "DExpectSymbolSsm.hpp"
|
||||
#include "DExpectTypeSsm.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DDefineSsm.hpp"
|
||||
#include "ssm/IPrintable_DDefineSsm.hpp"
|
||||
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
||||
|
|
@ -505,7 +506,9 @@ namespace xo {
|
|||
if (defstate_ == defexprstatetype::def_2) {
|
||||
this->defstate_ = defexprstatetype::def_3;
|
||||
|
||||
// expect_type_xs::start(p_psm);
|
||||
DExpectTypeSsm::start(p_psm->parser_alloc(),
|
||||
p_psm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,20 @@
|
|||
**/
|
||||
|
||||
#include "DExpectTypeSsm.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include <string_view>
|
||||
#include <xo/reflect/Reflect.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/reflectutil/typeseq.hpp>
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::with_facet;
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TypeDescr;
|
||||
using xo::reflect::typeseq;
|
||||
|
||||
namespace scm {
|
||||
DExpectTypeSsm::DExpectTypeSsm()
|
||||
{}
|
||||
|
|
@ -22,7 +34,7 @@ namespace xo {
|
|||
void
|
||||
DExpectTypeSsm::start(DArena & mm,
|
||||
//obj<AAllocator> expr_mm,
|
||||
PArserStateMachine * p_psm)
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
DExpectTypeSsm * expect_type_ssm = DExpectTypeSsm::make(mm);
|
||||
|
||||
|
|
@ -38,6 +50,94 @@ namespace xo {
|
|||
return syntaxstatetype::expect_type;
|
||||
}
|
||||
|
||||
std::string_view
|
||||
DExpectTypeSsm::get_expect_str() const noexcept
|
||||
{
|
||||
return "typename";
|
||||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::on_def_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DExpectTypeSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::on_if_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DxpectTypeSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_token("DxpectTypeSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::on_symbol_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
TypeDescr td = nullptr;
|
||||
|
||||
/* TODO: replace with typetable lookup */
|
||||
|
||||
if (tk.text() == "bool")
|
||||
td = Reflect::require<bool>();
|
||||
else if (tk.text() == "str")
|
||||
td = Reflect::require<std::string>();
|
||||
else if (tk.text() == "f64")
|
||||
td = Reflect::require<double>();
|
||||
else if(tk.text() == "f32")
|
||||
td = Reflect::require<float>();
|
||||
else if(tk.text() == "i16")
|
||||
td = Reflect::require<std::int16_t>();
|
||||
else if(tk.text() == "i32")
|
||||
td = Reflect::require<std::int32_t>();
|
||||
else if(tk.text() == "i64")
|
||||
td = Reflect::require<std::int64_t>();
|
||||
|
||||
if (!td) {
|
||||
p_psm->illegal_input_on_token("DExpectTypeSsm",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
p_psm->pop_ssm();
|
||||
|
||||
log && log("STUB: missing on_typedescr() call");
|
||||
|
||||
//p_psm->on_typedescr(td);
|
||||
}
|
||||
|
||||
void
|
||||
DExpectTypeSsm::on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_input_on_symbol("ExpectTypeSsm",
|
||||
sym,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
bool
|
||||
DExpectTypeSsm::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DExpectTypeSsm");
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
28
src/reader2/IPrintable_DExpectTypeSsm.cpp
Normal file
28
src/reader2/IPrintable_DExpectTypeSsm.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DExpectTypeSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DExpectTypeSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DExpectTypeSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/IPrintable_DExpectTypeSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DExpectTypeSsm::pretty(const DExpectTypeSsm & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DExpectTypeSsm.cpp */
|
||||
59
src/reader2/ISyntaxStateMachine_DExpectTypeSsm.cpp
Normal file
59
src/reader2/ISyntaxStateMachine_DExpectTypeSsm.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/** @file ISyntaxStateMachine_DExpectTypeSsm.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DExpectTypeSsm.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ISyntaxStateMachine_DExpectTypeSsm.json5]
|
||||
**/
|
||||
|
||||
#include "ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::ssm_type(const DExpectTypeSsm & self) noexcept -> syntaxstatetype
|
||||
{
|
||||
return self.ssm_type();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::get_expect_str(const DExpectTypeSsm & self) noexcept -> std::string_view
|
||||
{
|
||||
return self.get_expect_str();
|
||||
}
|
||||
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::on_symbol_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_symbol_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::on_def_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_def_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::on_if_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_if_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::on_colon_token(DExpectTypeSsm & self, const Token & tk, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_colon_token(tk, p_psm);
|
||||
}
|
||||
auto
|
||||
ISyntaxStateMachine_DExpectTypeSsm::on_parsed_symbol(DExpectTypeSsm & self, std::string_view sym, ParserStateMachine * p_psm) -> void
|
||||
{
|
||||
self.on_parsed_symbol(sym, p_psm);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ISyntaxStateMachine_DExpectTypeSsm.cpp */
|
||||
|
|
@ -14,6 +14,9 @@
|
|||
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectSymbolSsm.hpp>
|
||||
#include <xo/reader2/ssm/IPrintable_DExpectSymbolSsm.hpp>
|
||||
|
||||
#include <xo/reader2/ssm/ISyntaxStateMachine_DExpectTypeSsm.hpp>
|
||||
#include <xo/reader2/ssm/IPrintable_DExpectTypeSsm.hpp>
|
||||
|
||||
#include <xo/reader2/ssm/ASyntaxStateMachine.hpp>
|
||||
#include <xo/printable2/detail/APrintable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
|
@ -39,9 +42,13 @@ namespace xo {
|
|||
FacetRegistry::register_impl<ASyntaxStateMachine, DExpectSymbolSsm>();
|
||||
FacetRegistry::register_impl<APrintable, DExpectSymbolSsm>();
|
||||
|
||||
FacetRegistry::register_impl<ASyntaxStateMachine, DExpectTypeSsm>();
|
||||
FacetRegistry::register_impl<APrintable, DExpectTypeSsm>();
|
||||
|
||||
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>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue