xo-reader2 stack: + op<= setup

This commit is contained in:
Roland Conybeare 2026-03-12 21:00:16 -05:00
commit 8828fc7bef
3 changed files with 20 additions and 0 deletions

View file

@ -72,6 +72,8 @@ namespace xo {
flags & InstallFlags::f_essential);
ok = ok & install_aux(sink, mm, "_cmplt", &NumericDispatch::cmp_less,
flags & InstallFlags::f_essential);
ok = ok & install_aux(sink, mm, "_cmple", &NumericDispatch::cmp_lessequal,
flags & InstallFlags::f_essential);
return ok;
}

View file

@ -106,6 +106,8 @@ namespace xo {
obj<AGCObject> cmpne_pm() const;
/** polymorphich less-than comparison. Use to implement infix op< **/
obj<AGCObject> cmplt_pm() const;
/** polymorphich less-or-equal comparison. Use to implement infix op<= **/
obj<AGCObject> cmple_pm() const;
/** true iff state machine is currently idle (at top-level) **/
bool is_at_toplevel() const noexcept;
@ -418,6 +420,7 @@ namespace xo {
Binding cmpeq_binding_;
Binding cmpne_binding_;
Binding cmplt_binding_;
Binding cmple_binding_;
/** current output from parser **/
ParserResult result_;

View file

@ -144,6 +144,12 @@ namespace xo {
assert(name);
this->cmplt_binding_ = global_symtab_->lookup_binding(name);
}
{
const DUniqueString * name = stringtable_.lookup("_cmple");
assert(name);
this->cmple_binding_ = global_symtab_->lookup_binding(name);
}
}
ParserStateMachine::~ParserStateMachine()
@ -220,6 +226,15 @@ namespace xo {
return retval;
}
obj<AGCObject>
ParserStateMachine::cmple_pm() const
{
obj<AGCObject> retval = global_env_->lookup_value(cmple_binding_);
assert(retval);
return retval;
}
bool
ParserStateMachine::is_at_toplevel() const noexcept
{