--- 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 --- 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) --- a/crates/jrsonnet-rowan-parser/src/precedence.rs +++ b/crates/jrsonnet-rowan-parser/src/precedence.rs @@ -22,7 +22,7 @@ impl UnaryOperatorKind { pub fn binding_power(&self) -> ((), u8) { match self { - Self::Minus | Self::Not | Self::BitNot => ((), 20), + Self::Minus | Self::Not | Self::BitNot | Self::Plus => ((), 20), } } } --- 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 --- 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