difftreelog
fix(rowan) unary plus
in: master
5 files changed
crates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -131,7 +131,7 @@
| 'ERROR_NO_OPERATOR!'
UnaryOperator =
- '-' | '!' | '~'
+ '-' | '!' | '~' | '+'
SliceDescEnd=Expr
SliceDescStep=Expr
crates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/generated/nodes.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/nodes.rs
@@ -977,6 +977,7 @@
Minus,
Not,
BitNot,
+ Plus,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2494,7 +2495,7 @@
impl UnaryOperatorKind {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- MINUS | NOT | BIT_NOT => true,
+ MINUS | NOT | BIT_NOT | PLUS => true,
_ => false,
}
}
@@ -2503,6 +2504,7 @@
MINUS => Self::Minus,
NOT => Self::Not,
BIT_NOT => Self::BitNot,
+ PLUS => Self::Plus,
_ => return None,
};
Some(res)
crates/jrsonnet-rowan-parser/src/precedence.rsdiffbeforeafterboth1use crate::nodes::{BinaryOperatorKind, UnaryOperatorKind};23impl BinaryOperatorKind {4 pub fn binding_power(&self) -> (u8, u8) {5 match self {6 Self::MetaObjectApply => (22, 23),7 Self::Mul | Self::Div | Self::Modulo => (20, 21),8 Self::Plus | Self::Minus => (18, 19),9 Self::Lhs | Self::Rhs => (16, 17),10 Self::Lt | Self::Gt | Self::Le | Self::Ge | Self::InKw => (14, 15),11 Self::Eq | Self::Ne => (12, 13),12 Self::BitAnd => (10, 11),13 Self::BitXor => (8, 9),14 Self::BitOr => (6, 7),15 Self::And => (4, 5),16 Self::NullCoaelse | Self::Or => (2, 3),17 Self::ErrorNoOperator => (0, 1),18 }19 }20}2122impl UnaryOperatorKind {23 pub fn binding_power(&self) -> ((), u8) {24 match self {25 Self::Minus | Self::Not | Self::BitNot => ((), 20),26 }27 }28}crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snap
@@ -1,12 +1,13 @@
---
source: crates/jrsonnet-rowan-parser/src/tests.rs
-expression: "+ 2\n"
+assertion_line: 60
+expression: "* 2\n"
---
SOURCE_FILE@0..4
EXPR@0..0
ERROR_MISSING_TOKEN@0..0
ERROR_CUSTOM@0..3
- PLUS@0..1 "+"
+ MUL@0..1 "*"
WHITESPACE@1..2 " "
FLOAT@2..3 "2"
WHITESPACE@3..4 "\n"
@@ -15,5 +16,5 @@
LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 0..3 }
===
· ╭── missing expression
-1 │ + 2
+1 │ * 2
· ╰───── unexpected tokens after end
crates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/tests.rs
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -85,7 +85,7 @@
a +
"#
no_lhs => r#"
- + 2
+ * 2
"#
no_operator => "
2 2