xo-reader2: accept parsed expression at top level..
This commit is contained in:
parent
56aceac9e8
commit
8452ef040c
5 changed files with 33 additions and 8 deletions
|
|
@ -41,6 +41,12 @@ namespace xo {
|
|||
std::string_view error_src_fn,
|
||||
const DString * error_description);
|
||||
|
||||
/** create ParserResult for parsing success;
|
||||
* parsing yields expression @p expr
|
||||
**/
|
||||
static ParserResult expression(std::string_view ssm,
|
||||
obj<AExpression> expr);
|
||||
|
||||
/** create ParserResult for a parsing error.
|
||||
* Reporting detailed message @p errmsg
|
||||
* from syntax state machine @p ssm
|
||||
|
|
|
|||
|
|
@ -148,6 +148,10 @@ namespace xo {
|
|||
/** @defgroup scm-parserstatemachine-error-entrypoints error entry points **/
|
||||
///@{
|
||||
|
||||
/** capture result expression @p expr **/
|
||||
void capture_result(std::string_view ssm_anme,
|
||||
obj<AExpression> expr);
|
||||
|
||||
/** capture error message @p errmsg from @p ssm_name,
|
||||
* as current state machine output.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -218,18 +218,16 @@ namespace xo {
|
|||
DExprSeqState::on_parsed_expression(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_parsed_expression("DExprSeqState::on_parsed_expression",
|
||||
expr,
|
||||
this->get_expect_str());
|
||||
// toplevel expr sequence accepts an arbitrary number of expressions.
|
||||
|
||||
p_psm->capture_result("DExprSeqState::on_parsed_expression", expr);
|
||||
}
|
||||
|
||||
void
|
||||
DExprSeqState::on_parsed_expression_with_semicolon(obj<AExpression> expr,
|
||||
ParserStateMachine * p_psm)
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
p_psm->illegal_parsed_expression("DExprSeqState::on_parsed_expression_with_semicolon",
|
||||
expr,
|
||||
this->get_expect_str());
|
||||
p_psm->capture_result("DExprSeqState::on_parsed_expression_with_semicolon", expr);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@ namespace xo {
|
|||
error_description_{error_description}
|
||||
{}
|
||||
|
||||
ParserResult
|
||||
ParserResult::expression(std::string_view ssm_name,
|
||||
obj<AExpression> expr)
|
||||
{
|
||||
return ParserResult(parser_result_type::expression,
|
||||
expr,
|
||||
ssm_name,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
ParserResult
|
||||
ParserResult::error(std::string_view ssm_name,
|
||||
const DString * errmsg)
|
||||
|
|
|
|||
|
|
@ -288,6 +288,13 @@ namespace xo {
|
|||
stack_->top().on_semicolon_token(tk, this);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::capture_result(std::string_view ssm_name,
|
||||
obj<AExpression> expr)
|
||||
{
|
||||
this->result_ = ParserResult::expression(ssm_name, expr);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::capture_error(std::string_view ssm_name,
|
||||
const DString * errmsg)
|
||||
|
|
@ -321,7 +328,7 @@ namespace xo {
|
|||
void
|
||||
ParserStateMachine::illegal_input_on_symbol(std::string_view ssm_name,
|
||||
std::string_view sym,
|
||||
std::string_view expect_str)
|
||||
std::string_view expect_str)
|
||||
{
|
||||
// TODO:
|
||||
// - want to write error message using DArena
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue