-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New operator refactor #38
Conversation
# Conflicts: # src/expr.rs # src/main.rs # src/operator.rs # src/params.rs
@@ -122,16 +121,31 @@ fn find_binary_operators( | |||
} | |||
seq!(idx in 0..100 { | |||
if let Some(&op) = BINARY_OPERATORS.get(idx) { | |||
let op_idx: OpIndex = OpIndex::new(idx + UNARY_OPERATORS.len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to specify the type here, especially we are using OpIndex::new
so the type is very clear
let op_idx: OpIndex = OpIndex::new(idx + UNARY_OPERATORS.len()); | |
let op_idx = OpIndex::new(idx + UNARY_OPERATORS.len()); |
if let Some(&op) = UNARY_OPERATORS.get(op_idx) { | ||
seq!(idx in 0..10 { | ||
if let Some(&op) = UNARY_OPERATORS.get(idx) { | ||
let op_idx: OpIndex = OpIndex::new(idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let op_idx: OpIndex = OpIndex::new(idx); | |
let op_idx = OpIndex::new(idx); |
name: "<", | ||
prec: 5, | ||
apply: apply_lt, | ||
can_apply: can_apply_binary_always, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can either implement a Default trait for BinaryOp
, or define a OP_EMPTY
constant, and then we can do ..OP_EMPTY,
instead of having to specify can_apply_binary_always
and the bool flags in every struct.
commutative: false, | ||
right_assoc: false, | ||
}; | ||
pub const OP_BIT_SHL_WRAP: BinaryOp = BinaryOp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just be
pub const OP_BIT_SHL_WRAP: BinaryOp = BinaryOp {
apply: apply_bit_shl_wrap,
..OP_BIT_SHL,
};
@@ -50,46 +44,46 @@ pub const LITERALS: &[Num] = &[ | |||
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, | |||
]; | |||
/// If not 0, include all numbers in 1..=MAX_LITERAL in addition to LITERALS. | |||
pub const MAX_LITERAL: Num = 0; | |||
pub const MAX_LITERAL: Num = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this an intentional change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, my bad, I didn't see that I changed it (will address the changes in the next PR).
No description provided.