git.delta.rocks / jrsonnet / refs/commits / 42f993d5b82c

difftreelog

fix(rowan) unary plus

msnwnxvoYaroslav Bolyukin2026-05-08parent: #5b43fa8.patch.diff
in: master

5 files changed

modifiedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
131| 'ERROR_NO_OPERATOR!'131| 'ERROR_NO_OPERATOR!'
132132
133UnaryOperator =133UnaryOperator =
134 '-' | '!' | '~'134 '-' | '!' | '~' | '+'
135135
136SliceDescEnd=Expr136SliceDescEnd=Expr
137SliceDescStep=Expr137SliceDescStep=Expr
modifiedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
977 Minus,977 Minus,
978 Not,978 Not,
979 BitNot,979 BitNot,
980 Plus,
980}981}
981982
982#[derive(Debug, Clone, PartialEq, Eq, Hash)]983#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2494impl UnaryOperatorKind {2495impl UnaryOperatorKind {
2495 fn can_cast(kind: SyntaxKind) -> bool {2496 fn can_cast(kind: SyntaxKind) -> bool {
2496 match kind {2497 match kind {
2497 MINUS | NOT | BIT_NOT => true,2498 MINUS | NOT | BIT_NOT | PLUS => true,
2498 _ => false,2499 _ => false,
2499 }2500 }
2500 }2501 }
2503 MINUS => Self::Minus,2504 MINUS => Self::Minus,
2504 NOT => Self::Not,2505 NOT => Self::Not,
2505 BIT_NOT => Self::BitNot,2506 BIT_NOT => Self::BitNot,
2507 PLUS => Self::Plus,
2506 _ => return None,2508 _ => return None,
2507 };2509 };
2508 Some(res)2510 Some(res)
modifiedcrates/jrsonnet-rowan-parser/src/precedence.rsdiffbeforeafterboth
22impl UnaryOperatorKind {22impl UnaryOperatorKind {
23 pub fn binding_power(&self) -> ((), u8) {23 pub fn binding_power(&self) -> ((), u8) {
24 match self {24 match self {
25 Self::Minus | Self::Not | Self::BitNot => ((), 20),25 Self::Minus | Self::Not | Self::BitNot | Self::Plus => ((), 20),
26 }26 }
27 }27 }
28}28}
modifiedcrates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__no_lhs.snapdiffbeforeafterboth
1---1---
2source: crates/jrsonnet-rowan-parser/src/tests.rs2source: crates/jrsonnet-rowan-parser/src/tests.rs
3assertion_line: 60
3expression: "+ 2\n"4expression: "* 2\n"
4---5---
5SOURCE_FILE@0..46SOURCE_FILE@0..4
6 EXPR@0..07 EXPR@0..0
7 ERROR_MISSING_TOKEN@0..08 ERROR_MISSING_TOKEN@0..0
8 ERROR_CUSTOM@0..39 ERROR_CUSTOM@0..3
9 PLUS@0..1 "+"10 MUL@0..1 "*"
10 WHITESPACE@1..2 " "11 WHITESPACE@1..2 " "
11 FLOAT@2..3 "2"12 FLOAT@2..3 "2"
12 WHITESPACE@3..4 "\n"13 WHITESPACE@3..4 "\n"
15LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 0..3 }16LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 0..3 }
16===17===
17 · ╭── missing expression18 · ╭── missing expression
181 │ + 2191 │ * 2
19 · ╰───── unexpected tokens after end20 · ╰───── unexpected tokens after end
2021
modifiedcrates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth
84 no_rhs => r#"84 no_rhs => r#"
85 a +85 a +
86 "#86 "#
87 no_lhs => r#"87 no_lhs => r#"
88 + 288 * 2
89 "#89 "#
90 no_operator => "90 no_operator => "
91 2 291 2 2
92 "92 "