xo-reader2: skeleton DExpectExprSsm.*
This commit is contained in:
parent
8189197d63
commit
b84447e4f8
3 changed files with 416 additions and 0 deletions
113
xo-reader2/include/xo/reader2/DExpectExprSsm.hpp
Normal file
113
xo-reader2/include/xo/reader2/DExpectExprSsm.hpp
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/** @file DExpectExprSsm.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ParserStateMachine.hpp"
|
||||
#include "syntaxstatetype.hpp"
|
||||
//#include <xo/arena/DArena.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/indentlog/print/ppindentinfo.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
class DExpectExprSsm {
|
||||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using DArena = xo::mm::DArena;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
explicit DExpectExprSsm(bool allow_defs,
|
||||
bool cxl_on_rightparen);
|
||||
|
||||
static DExpectExprSsm * make(DArena & parser_mm,
|
||||
bool allow_defs,
|
||||
bool cxl_on_rightparen);
|
||||
|
||||
static void start(DArena & parser_mm,
|
||||
bool allow_defs,
|
||||
bool cxl_on_rightparen,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** @defgroup scm-expectexpr-ssm-facet syntaxstatemachine facet methods **/
|
||||
///@{
|
||||
|
||||
/** identifies the ssm implemented here **/
|
||||
syntaxstatetype ssm_type() const noexcept;
|
||||
|
||||
/** text describing expected/allowed input to this ssm in current state.
|
||||
* Intended to drive error mesages
|
||||
**/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** operate state machine for this syntax on incoming symbol-token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_symbol_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_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);
|
||||
|
||||
/** update state for this syntax on incoming colon token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_colon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax on incoming singleassign token @p tk,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_singleassign_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax after parsing a symbol @p sym;
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_symbol(std::string_view sym,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** update state for this syntax after parsing a type-description @p td,
|
||||
* overall parser state in @p p_psm
|
||||
**/
|
||||
void on_parsed_typedescr(TypeDescr td,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-define-printable-facet printable facet methods **/
|
||||
///@{
|
||||
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** if true: allow a define-expression here; otherwise reject **/
|
||||
bool allow_defs_ = false;
|
||||
/** if true: expecting either:
|
||||
* 1a. expression
|
||||
* 1b. right brace '}', in which case no expression
|
||||
* if false: expecting only:
|
||||
* 2a. expression
|
||||
**/
|
||||
bool cxl_on_rightbrace_ = false;
|
||||
|
||||
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DExpectExprSsm.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue