xo-reader2: + op>= support
This commit is contained in:
parent
417ad2ac78
commit
6104515656
21 changed files with 47 additions and 23 deletions
|
|
@ -104,10 +104,12 @@ namespace xo {
|
|||
obj<AGCObject> cmpeq_pm() const;
|
||||
/** polymorphic inequality comparison. Use to implement infix op!= **/
|
||||
obj<AGCObject> cmpne_pm() const;
|
||||
/** polymorphich less-than comparison. Use to implement infix op< **/
|
||||
/** polymorphic less-than comparison. Use to implement infix op< **/
|
||||
obj<AGCObject> cmplt_pm() const;
|
||||
/** polymorphich less-or-equal comparison. Use to implement infix op<= **/
|
||||
/** polymorphic less-or-equal comparison. Use to implement infix op<= **/
|
||||
obj<AGCObject> cmple_pm() const;
|
||||
/** polymorphic greater-or-equal comparison. Use to implement infix op>= **/
|
||||
obj<AGCObject> cmpge_pm() const;
|
||||
|
||||
/** true iff state machine is currently idle (at top-level) **/
|
||||
bool is_at_toplevel() const noexcept;
|
||||
|
|
@ -421,6 +423,7 @@ namespace xo {
|
|||
Binding cmpne_binding_;
|
||||
Binding cmplt_binding_;
|
||||
Binding cmple_binding_;
|
||||
Binding cmpge_binding_;
|
||||
|
||||
/** current output from parser **/
|
||||
ParserResult result_;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_assign:
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace xo {
|
|||
case tokentype::tk_leftbracket:
|
||||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_colon:
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ namespace xo {
|
|||
return optype::op_less_equal;
|
||||
case tokentype::tk_rightangle:
|
||||
return optype::op_great;
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge: // [>=]
|
||||
return optype::op_great_equal;
|
||||
default:
|
||||
assert(false);
|
||||
|
|
@ -291,7 +291,6 @@ namespace xo {
|
|||
case tokentype::tk_rightbracket:
|
||||
case tokentype::tk_leftbrace:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_doublecolon:
|
||||
case tokentype::tk_assign:
|
||||
|
|
@ -306,6 +305,7 @@ namespace xo {
|
|||
case tokentype::tk_cmpne:
|
||||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_cmpge:
|
||||
this->on_operator_token(tk, p_psm);
|
||||
return;
|
||||
|
||||
|
|
@ -1170,10 +1170,16 @@ namespace xo {
|
|||
lhs_, rhs_);
|
||||
|
||||
case optype::op_great:
|
||||
case optype::op_great_equal:
|
||||
assert(false);
|
||||
break;
|
||||
|
||||
case optype::op_great_equal:
|
||||
return assemble_numeric_expr_aux
|
||||
(p_psm->expr_alloc(),
|
||||
TypeRef::prefix_type::from_chars("_cmpge_gco"),
|
||||
p_psm->cmpge_pm(),
|
||||
lhs_, rhs_);
|
||||
|
||||
case optype::op_multiply:
|
||||
return assemble_numeric_expr_aux
|
||||
(p_psm->expr_alloc(),
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_doublecolon:
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ namespace xo {
|
|||
case tokentype::tk_leftangle:
|
||||
case tokentype::tk_rightangle:
|
||||
case tokentype::tk_cmple:
|
||||
case tokentype::tk_greatequal:
|
||||
case tokentype::tk_cmpge:
|
||||
case tokentype::tk_dot:
|
||||
case tokentype::tk_comma:
|
||||
case tokentype::tk_colon:
|
||||
|
|
|
|||
|
|
@ -150,6 +150,12 @@ namespace xo {
|
|||
assert(name);
|
||||
this->cmple_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmpge");
|
||||
assert(name);
|
||||
this->cmpge_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
}
|
||||
|
||||
ParserStateMachine::~ParserStateMachine()
|
||||
|
|
@ -235,6 +241,15 @@ namespace xo {
|
|||
return retval;
|
||||
}
|
||||
|
||||
obj<AGCObject>
|
||||
ParserStateMachine::cmpge_pm() const
|
||||
{
|
||||
obj<AGCObject> retval = global_env_->lookup_value(cmpge_binding_);
|
||||
assert(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool
|
||||
ParserStateMachine::is_at_toplevel() const noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue