xo-reader2: accept parsed expression at top level..
This commit is contained in:
parent
c33cfd7ae7
commit
15e1e50659
5 changed files with 33 additions and 8 deletions
|
|
@ -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