xo-reader: + DDefineSsm + utest
This commit is contained in:
parent
301a7c7623
commit
b5d2f3efab
21 changed files with 219 additions and 28 deletions
|
|
@ -3,6 +3,8 @@
|
|||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ParserStateMachine.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
|
|
@ -67,8 +69,24 @@ namespace xo {
|
|||
**/
|
||||
class DDefineSsm {
|
||||
public:
|
||||
using DArena = xo::mm::DArena;
|
||||
|
||||
public:
|
||||
/** @defgroup scm-define-ssm-facet constructors **/
|
||||
///@{
|
||||
|
||||
DDefineSsm();
|
||||
|
||||
/** create instance using memory from @p parser_mm **/
|
||||
static DDefineSsm * make(DArena & parser_mm);
|
||||
|
||||
/** start nested parser for a define-expression,
|
||||
* on top of parser state machine @p p_psm
|
||||
**/
|
||||
static void start(DArena & parser_mm,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-define-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
|
|
@ -83,7 +101,14 @@ namespace xo {
|
|||
/** update state for this syntax on incoming token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_if_token(const Token & tk, ParserStateMachine * p_psm);
|
||||
void on_def_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax on incoming token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_if_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ namespace xo {
|
|||
**/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** update state for this syntax on incoming token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_def_token(const Token & tk, ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax on incoming token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ namespace xo {
|
|||
obj<AExpression> result_expr() const { return result_expr_; }
|
||||
const DString * error_description() const { return error_description_; }
|
||||
|
||||
bool is_incomplete() const { return result_type_ == parser_result_type::none; }
|
||||
bool is_expression() const { return result_type_ == parser_result_type::expression; }
|
||||
bool is_error() const { return result_type_ == parser_result_type::error; }
|
||||
|
||||
private:
|
||||
parser_result_type result_type_ = parser_result_type::none;
|
||||
obj<AExpression> result_expr_;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ namespace xo {
|
|||
/** @defgroup scm-parserstatemachine-bookkeeping bookkeeping methods **/
|
||||
///@{
|
||||
|
||||
/** allocator for parsing stack and ssm's **/
|
||||
DArena & parser_alloc() noexcept { return parser_alloc_; }
|
||||
|
||||
/** establish toplevel @p ssm. Must have empty stack **/
|
||||
void establish_toplevel_ssm(obj<ASyntaxStateMachine> ssm);
|
||||
|
||||
|
|
@ -75,6 +78,9 @@ namespace xo {
|
|||
**/
|
||||
void on_token(const Token & tk);
|
||||
|
||||
/** update state for incoming define-token @p tk **/
|
||||
void on_def_token(const Token & tk);
|
||||
|
||||
/** update state for incoming if-token @p tk **/
|
||||
void on_if_token(const Token & tk);
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ namespace xo {
|
|||
/** put parser into state for beginning of a translation unit
|
||||
* (i.e. input stream)
|
||||
**/
|
||||
void begin_translation_unit();
|
||||
void begin_batch_session();
|
||||
|
||||
/** include next token @p tk and increment parser state.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/SyntaxStateMachine.json5]
|
||||
* 2. jinja2 template for facet .hpp file:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/SyntaxStateMachine.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -54,6 +54,8 @@ public:
|
|||
virtual std::string_view get_expect_str(Copaque data) const noexcept = 0;
|
||||
|
||||
// nonconst methods
|
||||
/** update state machine for incoming define-keyworkd-token @p tk **/
|
||||
virtual void on_def_token(Opaque data, const Token & tk, ParserStateMachine * ps_psm) = 0;
|
||||
/** update state machine for incoming if-keyword-token @p tk **/
|
||||
virtual void on_if_token(Opaque data, const Token & tk, ParserStateMachine * p_psm) = 0;
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/SyntaxStateMachine.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -59,6 +59,7 @@ namespace scm {
|
|||
[[noreturn]] std::string_view get_expect_str(Copaque) const noexcept override { _fatal(); }
|
||||
|
||||
// nonconst methods
|
||||
[[noreturn]] void on_def_token(Opaque, const Token &, ParserStateMachine *) override;
|
||||
[[noreturn]] void on_if_token(Opaque, const Token &, ParserStateMachine *) override;
|
||||
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/ISyntaxStateMachine_DExprSeqState.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -53,6 +53,8 @@ namespace xo {
|
|||
static std::string_view get_expect_str(const DExprSeqState & self) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** update state machine for incoming define-keyworkd-token @p tk **/
|
||||
static void on_def_token(DExprSeqState & self, const Token & tk, ParserStateMachine * ps_psm);
|
||||
/** update state machine for incoming if-keyword-token @p tk **/
|
||||
static void on_if_token(DExprSeqState & self, const Token & tk, ParserStateMachine * p_psm);
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/SyntaxStateMachine.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -50,6 +50,9 @@ namespace scm {
|
|||
}
|
||||
|
||||
// non-const methods
|
||||
void on_def_token(Opaque data, const Token & tk, ParserStateMachine * ps_psm) override {
|
||||
return I::on_def_token(_dcast(data), tk, ps_psm);
|
||||
}
|
||||
void on_if_token(Opaque data, const Token & tk, ParserStateMachine * p_psm) override {
|
||||
return I::on_if_token(_dcast(data), tk, p_psm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/SyntaxStateMachine.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -55,6 +55,9 @@ public:
|
|||
}
|
||||
|
||||
// non-const methods (still const in router!)
|
||||
void on_def_token(const Token & tk, ParserStateMachine * ps_psm) {
|
||||
return O::iface()->on_def_token(O::data(), tk, ps_psm);
|
||||
}
|
||||
void on_if_token(const Token & tk, ParserStateMachine * p_psm) {
|
||||
return O::iface()->on_if_token(O::data(), tk, p_psm);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue