More binary op
This commit is contained in:
@@ -62,6 +62,8 @@ pub enum BinaryOp {
|
|||||||
GreaterThan,
|
GreaterThan,
|
||||||
LessThanOrEqual,
|
LessThanOrEqual,
|
||||||
GreaterThanOrEqual,
|
GreaterThanOrEqual,
|
||||||
|
And,
|
||||||
|
Or,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ macro_call_px = { "!" ~ "(" ~ macro_inner_v* ~ ")" }
|
|||||||
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ ","? ~ "}" }
|
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ ","? ~ "}" }
|
||||||
index_px = { "[" ~ expr ~ "]" }
|
index_px = { "[" ~ expr ~ "]" }
|
||||||
binary_px = { bin_op ~ expr }
|
binary_px = { bin_op ~ expr }
|
||||||
bin_op = { "<=" | ">=" | "==" | "!=" | "+" | "-" | "*" | "/" | "%" | "<" | ">" }
|
bin_op = { "<=" | ">=" | "==" | "!=" | "&&" | "||" | "+" | "-" | "*" | "/" | "%" | "<" | ">" }
|
||||||
struct_field_decl = { identifier ~ ":" ~ expr }
|
struct_field_decl = { identifier ~ ":" ~ expr }
|
||||||
|
|
||||||
prefix = {
|
prefix = {
|
||||||
|
|||||||
@@ -498,6 +498,8 @@ impl From<pest::iterators::Pair<'_, Rule>> for Postfix {
|
|||||||
">" => BinaryOp::GreaterThan,
|
">" => BinaryOp::GreaterThan,
|
||||||
"<=" => BinaryOp::LessThanOrEqual,
|
"<=" => BinaryOp::LessThanOrEqual,
|
||||||
">=" => BinaryOp::GreaterThanOrEqual,
|
">=" => BinaryOp::GreaterThanOrEqual,
|
||||||
|
"&&" => BinaryOp::And,
|
||||||
|
"||" => BinaryOp::Or,
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
unimplemented!("Binary operator not implemented yet: {}", op_pair.as_str())
|
unimplemented!("Binary operator not implemented yet: {}", op_pair.as_str())
|
||||||
|
|||||||
@@ -238,6 +238,8 @@ impl GetRust for Postfix {
|
|||||||
BinaryOp::GreaterThan => ">",
|
BinaryOp::GreaterThan => ">",
|
||||||
BinaryOp::LessThanOrEqual => "<=",
|
BinaryOp::LessThanOrEqual => "<=",
|
||||||
BinaryOp::GreaterThanOrEqual => ">=",
|
BinaryOp::GreaterThanOrEqual => ">=",
|
||||||
|
BinaryOp::And => "&&",
|
||||||
|
BinaryOp::Or => "||",
|
||||||
};
|
};
|
||||||
format!(" {} {}", op_str, rhs.get_rust())
|
format!(" {} {}", op_str, rhs.get_rust())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user