xo-reader: refactor: + parserstatemachine; use for def_expr
This commit is contained in:
parent
6a71f718bd
commit
034dac7dfd
11 changed files with 69 additions and 18 deletions
|
|
@ -70,7 +70,7 @@ namespace xo {
|
|||
|
||||
static const define_xs * from(const exprstate * x) { return dynamic_cast<const define_xs *>(x); }
|
||||
|
||||
static void start(exprstatestack * p_stack);
|
||||
static void start(parserstatemachine * p_psm);
|
||||
|
||||
defexprstatetype defxs_type() const { return defxs_type_; }
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ namespace xo {
|
|||
exprstatestack * p_stack,
|
||||
rp<Expression> * p_emit_expr) override;
|
||||
virtual void on_def_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_colon_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
virtual void on_semicolon_token(const token_type & tk,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace xo {
|
|||
// ----- token input methods -----
|
||||
|
||||
virtual void on_def_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_symbol_token(const token_type & tk,
|
||||
exprstatestack * p_stack,
|
||||
rp<Expression> * p_emit_expr) override;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ namespace xo {
|
|||
return os;
|
||||
}
|
||||
|
||||
class parserstatemachine;
|
||||
class exprstatestack;
|
||||
|
||||
class formal_arg;
|
||||
|
|
@ -120,7 +121,7 @@ namespace xo {
|
|||
|
||||
/** handle incoming 'def' token **/
|
||||
virtual void on_def_token(const token_type & tk,
|
||||
exprstatestack * p_stack);
|
||||
parserstatemachine * p_psm);
|
||||
/** handle incoming 'lambda' token **/
|
||||
virtual void on_lambda_token(const token_type & tk,
|
||||
exprstatestack * p_stack,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace xo {
|
|||
rp<Expression> * /*p_emit_expr*/) override;
|
||||
|
||||
virtual void on_def_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_symbol_token(const token_type & tk,
|
||||
exprstatestack * p_stack,
|
||||
rp<Expression> * p_emit_expr) override;
|
||||
|
|
|
|||
36
include/xo/reader/parserstatemachine.hpp
Normal file
36
include/xo/reader/parserstatemachine.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* file parserstatemachine.hpp
|
||||
*
|
||||
* author: Roland Conybeare, Aug 2024
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "exprstate.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class parserstatemachine
|
||||
* @brief public parser state.
|
||||
*
|
||||
* Schematica parser state; sent to subsidiary single-feature state machines.
|
||||
* For example entry points for the lambda feature (@ref lambda_xs)
|
||||
* will accept a non-const parserstatemachine pointer argument
|
||||
**/
|
||||
class parserstatemachine {
|
||||
public:
|
||||
using Expression = xo::ast::Expression;
|
||||
|
||||
public:
|
||||
parserstatemachine(exprstatestack * p_stack,
|
||||
rp<Expression> * p_emit_expr)
|
||||
: p_stack_{p_stack}, p_emit_expr_{p_emit_expr} {}
|
||||
|
||||
public:
|
||||
exprstatestack * p_stack_;
|
||||
rp<Expression> * p_emit_expr_;
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
/* end parserstatemachine.hpp */
|
||||
|
|
@ -66,7 +66,7 @@ namespace xo {
|
|||
rp<Expression> * /*p_emit_expr*/) override;
|
||||
|
||||
virtual void on_def_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_colon_token(const token_type & tk,
|
||||
exprstatestack * p_stack) override;
|
||||
virtual void on_semicolon_token(const token_type & tk,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue