xo-reader: work on apply expression parsing

This commit is contained in:
Roland Conybeare 2025-07-24 07:50:34 -05:00
commit 190a21e2f7
4 changed files with 16 additions and 3 deletions

View file

@ -158,6 +158,17 @@ namespace xo {
return ref_tag_impl<false, tagstyle::raw, std::decay_t<Name>, std::decay_t<Value>>(n, v);
}
// ----- xrefrtag -----
/** 'reference raw tag'. Like @ref refrtag, but precede with a single space
**/
template <typename Name, typename Value>
auto
xrefrtag(Name && n, Value && v)
{
return ref_tag_impl<true, tagstyle::raw, std::decay_t<Name>, std::decay_t<Value>>(n, v);
}
// ----- operator<< on tag_impl -----
template <bool PrefixSpace, tagstyle TagStyle, typename Name, typename Value>

View file

@ -107,6 +107,7 @@ namespace xo {
if (this->applyxs_type_ == applyexprstatetype::apply_3) {
this->applyxs_type_ = applyexprstatetype::apply_2;
expect_expr_xs::start(p_psm);
} else {
constexpr const char * c_self_name = "apply_xs::on_comma_token";
const char * exp = this->get_expect_str();
@ -125,6 +126,7 @@ namespace xo {
if (this->applyxs_type_ == applyexprstatetype::apply_1) {
this->applyxs_type_ = applyexprstatetype::apply_2;
expect_expr_xs::start(p_psm);
} else {
constexpr const char * c_self_name = "apply_xs::on_leftparen_token";
const char * exp = this->get_expect_str();

View file

@ -153,7 +153,7 @@ namespace xo {
{
scope log(XO_DEBUG(p_psm->debug_flag()));
log && log("defxs_type", defxs_type_);
log && log(xtag("defxs_type", defxs_type_), xtag("env_stack_size", p_psm->env_stack_size()));
if (this->defxs_type_ == defexprstatetype::def_1) {
this->defxs_type_ = defexprstatetype::def_2;
@ -178,7 +178,7 @@ namespace xo {
// For interactive top-level defs we want to evaluate as we go,
// so need incremental bindings.
if (p_psm->env_stack_size() == 2) {
if (p_psm->env_stack_size() == 1) {
/* remember variable binding in lexical context,
* so we can refer to it later
*/

View file

@ -64,7 +64,7 @@ namespace xo {
/* stack_ is non-empty */
log && log(xtag("top", psm_.xs_stack_.top_exprstate()));
log && log(xrefrtag("top", psm_.xs_stack_.top_exprstate()));
psm_.xs_stack_.top_exprstate().on_input(tk, &psm_);