Skip to content

Commit

Permalink
Update grammar to v0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Jun 16, 2024
1 parent ecb6894 commit 3b3b9e4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/analysis/src/utils/visitors/expr_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ impl SyntaxNodeVisitor for ExpressionEvaluator<'_> {
| BinaryOperator::Sum
| BinaryOperator::Diff
| BinaryOperator::BitAnd
| BinaryOperator::BitOr => left_path,
| BinaryOperator::BitOr
| BinaryOperator::BitXor => left_path,
BinaryOperator::And
| BinaryOperator::Or
| BinaryOperator::Equal
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ encoding_rs_io = "0.1"

[dependencies.tree-sitter-witcherscript]
git = "https://github.com/SpontanCombust/tree-sitter-witcherscript.git"
tag = "v0.10.1"
tag = "v0.11.0"
31 changes: 20 additions & 11 deletions crates/core/src/tokens/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum BinaryOperator {
Diff,
BitAnd,
BitOr,
BitXor,
And,
Or,
Equal,
Expand All @@ -79,6 +80,7 @@ impl BinaryOperatorNode<'_> {
"binary_op_and" => BinaryOperator::And,
"binary_op_bitor" => BinaryOperator::BitOr,
"binary_op_bitand" => BinaryOperator::BitAnd,
"binary_op_bitxor" => BinaryOperator::BitXor,
"binary_op_eq" => BinaryOperator::Equal,
"binary_op_neq" => BinaryOperator::NotEqual,
"binary_op_gt" => BinaryOperator::Greater,
Expand Down Expand Up @@ -115,6 +117,7 @@ impl<'script> TryFrom<AnyNode<'script>> for BinaryOperatorNode<'script> {
"binary_op_and" |
"binary_op_bitor" |
"binary_op_bitand" |
"binary_op_bitxor" |
"binary_op_eq" |
"binary_op_neq" |
"binary_op_gt" |
Expand All @@ -138,9 +141,10 @@ pub enum AssignmentOperator {
Direct,
Mult,
Div,
Mod,
Sum,
Diff
Diff,
BitAnd,
BitOr
}

pub type AssignmentOperatorNode<'script> = SyntaxNode<'script, AssignmentOperator>;
Expand All @@ -153,7 +157,8 @@ impl AssignmentOperatorNode<'_> {
"assign_op_diff" => AssignmentOperator::Diff,
"assign_op_mult" => AssignmentOperator::Mult,
"assign_op_div" => AssignmentOperator::Div,
"assign_op_mod" => AssignmentOperator::Mod,
"assign_op_bitand" => AssignmentOperator::BitAnd,
"assign_op_bitor" => AssignmentOperator::BitOr,
_ => panic!("Unknown assignment operator: {} {}", self.tree_node.kind(), self.range().debug())
}
}
Expand All @@ -180,7 +185,8 @@ impl<'script> TryFrom<AnyNode<'script>> for AssignmentOperatorNode<'script> {
"assign_op_diff" |
"assign_op_mult" |
"assign_op_div" |
"assign_op_mod" => Ok(value.into()),
"assign_op_bitand" |
"assign_op_bitor" => Ok(value.into()),
_ => Err(())
}
}
Expand Down Expand Up @@ -254,8 +260,8 @@ impl OperatorTraits for BinaryOperator {
match self {
BinaryOperator::Equal |
BinaryOperator::NotEqual |
BinaryOperator::Lesser |
BinaryOperator::LesserOrEqual |
BinaryOperator::Lesser |
BinaryOperator::LesserOrEqual |
BinaryOperator::Greater |
BinaryOperator::GreaterOrEqual => true,
_ => false
Expand All @@ -267,10 +273,9 @@ impl OperatorTraits for AssignmentOperator {
fn is_arithmetic(&self) -> bool {
match self {
AssignmentOperator::Mult |
AssignmentOperator::Div |
AssignmentOperator::Mod |
AssignmentOperator::Sum |
AssignmentOperator::Diff => true,
AssignmentOperator::Div |
AssignmentOperator::Sum |
AssignmentOperator::Diff => true,
_ => false
}
}
Expand All @@ -280,7 +285,11 @@ impl OperatorTraits for AssignmentOperator {
}

fn is_bitwise(&self) -> bool {
false
match self {
AssignmentOperator::BitAnd |
AssignmentOperator::BitOr => true,
_ => false
}
}

fn is_relational(&self) -> bool {
Expand Down

0 comments on commit 3b3b9e4

Please sign in to comment.