xo-reader2: DLambdaSsm work towards producing DLambdaExpr [WIP]
This commit is contained in:
parent
15f779d2f8
commit
726f821c4e
8 changed files with 218 additions and 68 deletions
|
|
@ -166,6 +166,8 @@ namespace xo {
|
|||
ParserStateMachine * p_psm);
|
||||
void on_semicolon_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
void on_rightbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
void on_parsed_expression_with_semicolon(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
|
|
@ -183,27 +185,12 @@ namespace xo {
|
|||
void on_typedescr(TypeDescr td,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
void on_semicolon_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
void on_assign_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) final override;
|
||||
void on_leftparen_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
void on_rightparen_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
void on_rightbrace_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
/* entry point for an infix operator token */
|
||||
void on_operator_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) final override;
|
||||
|
||||
void on_bool_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
void on_i64_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
|
||||
void print(std::ostream & os) const override;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,12 +7,25 @@
|
|||
|
||||
#include "DSyntaxStateMachine.hpp"
|
||||
#include <xo/expression2/DSequenceExpr.hpp>
|
||||
#include "syntaxstatetype.hpp"
|
||||
#include <xo/expression2/detail/IExpression_DSequenceExpr.hpp>
|
||||
#include <xo/expression2/DSequenceExpr.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm { class Sequence; }
|
||||
namespace scm { class Lambda; }
|
||||
|
||||
namespace scm {
|
||||
// TODO: need switching between 1a,1b states.
|
||||
// Allow
|
||||
// { }
|
||||
// { 1 }
|
||||
// { 1; }
|
||||
// Reject
|
||||
// { 1 2 }
|
||||
//
|
||||
|
||||
class DSequenceSsm : public DSyntaxStateMachine<DSequenceSsm> {
|
||||
public:
|
||||
//using Sequence = xo::scm::Sequence;
|
||||
|
|
@ -38,15 +51,14 @@ namespace xo {
|
|||
obj<AAllocator> expr_mm);
|
||||
|
||||
#ifdef NOT_YET
|
||||
virtual void on_expr(bp<Expression> expr,
|
||||
parserstatemachine * p_psm) override;
|
||||
virtual void on_expr_with_semicolon(bp<Expression> expr,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
virtual void on_rightbrace_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
#endif
|
||||
|
||||
/** update ssm for incoming rightbrace token '}' **/
|
||||
void on_rightbrace_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** @defgroup scm-sequencessm-syntaxstatemachine-facet ssm facet **/
|
||||
///@{
|
||||
|
||||
|
|
@ -56,6 +68,16 @@ namespace xo {
|
|||
/** mnemonic for syntax sequence ssm expects given current state **/
|
||||
std::string_view get_expect_str() const noexcept;
|
||||
|
||||
/** operate state machine for this syntax on incoming token @p tk
|
||||
* with overall parser state in @p p_psm
|
||||
**/
|
||||
void on_token(const Token & tk,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
/** consume expression @p expr produced by nested ssm; overall parser state in @p p_psm **/
|
||||
void on_parsed_expression(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm);
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-sequencessm-printable-facet printable facet **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -142,6 +142,18 @@ namespace xo {
|
|||
**/
|
||||
void on_parsed_expression_with_semicolon(obj<AExpression> expr);
|
||||
|
||||
/** update state to respond to parsed expression @p expr
|
||||
* (from nested parsing state), with trailing token @p tk.
|
||||
*
|
||||
* Need to distinguish cases like:
|
||||
* 6 // ) ? ; allowed } ?
|
||||
* f(6 // ) allowed ; forbidden } forbidden
|
||||
* 6 + // ) forbidden ; forbidden } forbidden
|
||||
*
|
||||
**/
|
||||
void on_parsed_expression_with_token(obj<AExpression> expr,
|
||||
const Token & tk);
|
||||
|
||||
/** update state to respond to input token @p tk.
|
||||
* record output (if any) in @ref result_
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue