Skip to content

Commit 5fdec74

Browse files
authored
Update tree-sitter-r for hexadecimal with decimal support (#495)
* Update tree-sitter-r for hexadecimal with decimal support * CHANGELOG bullet
1 parent 83e9e18 commit 5fdec74

7 files changed

Lines changed: 136 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
- Updated bundled tree-sitter-r, which comes with a few small fixes:
4+
5+
- Hexadecimal constants with decimals are no longer parsed as two separate values (#495).
6+
37
# Development version
48

59
# 0.9.0

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ tower-lsp = { branch = "bugfix/patches", git = "https://github.com/lionel-/tower
7474
tracing = { version = "0.1.40", default-features = false, features = ["std"] }
7575
tracing-subscriber = "0.3.19"
7676
tree-sitter = "0.24.7"
77-
tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "48210371b9eb10eab1bd626aa39857a922d56120" }
77+
tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "ceee38d8260856c1ace9012348916a3d2965e5e5" }
7878
url = "2.5.3"
7979
uuid = { version = "1.11.0", features = ["v4"] }
8080
workspace = { path = "./crates/workspace" }

crates/air_r_parser/tests/snapshots/ok/value/double_value.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@
2121
0x0p+0
2222
0x0p-0
2323
0x0p+123
24-
0x0p-123
24+
0x0p-123
25+
# Decimal point
26+
0x.
27+
0x1.
28+
0x.1
29+
0x1.1
30+
# Decimal point with exponent
31+
0x.p1
32+
0x1.p1
33+
0x.1p1
34+
0x1.1p1

crates/air_r_parser/tests/snapshots/ok/value/double_value.R.snap

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ expression: snapshot
2929
0x0p-0
3030
0x0p+123
3131
0x0p-123
32+
# Decimal point
33+
0x.
34+
0x1.
35+
0x.1
36+
0x1.1
37+
# Decimal point with exponent
38+
0x.p1
39+
0x1.p1
40+
0x.1p1
41+
0x1.1p1
3242
```
3343

3444

@@ -92,17 +102,41 @@ RRoot {
92102
RDoubleValue {
93103
value_token: R_DOUBLE_LITERAL@186..195 "0x0p-123" [Newline("\n")] [],
94104
},
105+
RDoubleValue {
106+
value_token: R_DOUBLE_LITERAL@195..215 "0x." [Newline("\n"), Comments("# Decimal point"), Newline("\n")] [],
107+
},
108+
RDoubleValue {
109+
value_token: R_DOUBLE_LITERAL@215..220 "0x1." [Newline("\n")] [],
110+
},
111+
RDoubleValue {
112+
value_token: R_DOUBLE_LITERAL@220..225 "0x.1" [Newline("\n")] [],
113+
},
114+
RDoubleValue {
115+
value_token: R_DOUBLE_LITERAL@225..231 "0x1.1" [Newline("\n")] [],
116+
},
117+
RDoubleValue {
118+
value_token: R_DOUBLE_LITERAL@231..267 "0x.p1" [Newline("\n"), Comments("# Decimal point with ..."), Newline("\n")] [],
119+
},
120+
RDoubleValue {
121+
value_token: R_DOUBLE_LITERAL@267..274 "0x1.p1" [Newline("\n")] [],
122+
},
123+
RDoubleValue {
124+
value_token: R_DOUBLE_LITERAL@274..281 "0x.1p1" [Newline("\n")] [],
125+
},
126+
RDoubleValue {
127+
value_token: R_DOUBLE_LITERAL@281..289 "0x1.1p1" [Newline("\n")] [],
128+
},
95129
],
96-
eof_token: EOF@195..195 "" [] [],
130+
eof_token: EOF@289..289 "" [] [],
97131
}
98132
```
99133

100134
## CST
101135

102136
```
103-
0: R_ROOT@0..195
137+
0: R_ROOT@0..289
104138
0: (empty)
105-
1: R_EXPRESSION_LIST@0..195
139+
1: R_EXPRESSION_LIST@0..289
106140
0: R_DOUBLE_VALUE@0..1
107141
0: R_DOUBLE_LITERAL@0..1 "1" [] []
108142
1: R_DOUBLE_VALUE@1..5
@@ -139,6 +173,22 @@ RRoot {
139173
0: R_DOUBLE_LITERAL@177..186 "0x0p+123" [Newline("\n")] []
140174
17: R_DOUBLE_VALUE@186..195
141175
0: R_DOUBLE_LITERAL@186..195 "0x0p-123" [Newline("\n")] []
142-
2: EOF@195..195 "" [] []
176+
18: R_DOUBLE_VALUE@195..215
177+
0: R_DOUBLE_LITERAL@195..215 "0x." [Newline("\n"), Comments("# Decimal point"), Newline("\n")] []
178+
19: R_DOUBLE_VALUE@215..220
179+
0: R_DOUBLE_LITERAL@215..220 "0x1." [Newline("\n")] []
180+
20: R_DOUBLE_VALUE@220..225
181+
0: R_DOUBLE_LITERAL@220..225 "0x.1" [Newline("\n")] []
182+
21: R_DOUBLE_VALUE@225..231
183+
0: R_DOUBLE_LITERAL@225..231 "0x1.1" [Newline("\n")] []
184+
22: R_DOUBLE_VALUE@231..267
185+
0: R_DOUBLE_LITERAL@231..267 "0x.p1" [Newline("\n"), Comments("# Decimal point with ..."), Newline("\n")] []
186+
23: R_DOUBLE_VALUE@267..274
187+
0: R_DOUBLE_LITERAL@267..274 "0x1.p1" [Newline("\n")] []
188+
24: R_DOUBLE_VALUE@274..281
189+
0: R_DOUBLE_LITERAL@274..281 "0x.1p1" [Newline("\n")] []
190+
25: R_DOUBLE_VALUE@281..289
191+
0: R_DOUBLE_LITERAL@281..289 "0x1.1p1" [Newline("\n")] []
192+
2: EOF@289..289 "" [] []
143193
144194
```

crates/air_r_parser/tests/snapshots/ok/value/integer_value.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@
1919
0x0p+0L
2020
0x0p-0L
2121
0x0p+123L
22-
0x0p-123L
22+
0x0p-123L
23+
# Decimal point
24+
0x.L
25+
0x1.L
26+
0x.1L
27+
0x1.1L
28+
# Decimal point with exponent
29+
0x.p1L
30+
0x1.p1L
31+
0x.1p1L
32+
0x1.1p1L

crates/air_r_parser/tests/snapshots/ok/value/integer_value.R.snap

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ expression: snapshot
2727
0x0p-0L
2828
0x0p+123L
2929
0x0p-123L
30+
# Decimal point
31+
0x.L
32+
0x1.L
33+
0x.1L
34+
0x1.1L
35+
# Decimal point with exponent
36+
0x.p1L
37+
0x1.p1L
38+
0x.1p1L
39+
0x1.1p1L
3040
```
3141

3242

@@ -84,17 +94,41 @@ RRoot {
8494
RIntegerValue {
8595
value_token: R_INTEGER_LITERAL@190..200 "0x0p-123L" [Newline("\n")] [],
8696
},
97+
RIntegerValue {
98+
value_token: R_INTEGER_LITERAL@200..221 "0x.L" [Newline("\n"), Comments("# Decimal point"), Newline("\n")] [],
99+
},
100+
RIntegerValue {
101+
value_token: R_INTEGER_LITERAL@221..227 "0x1.L" [Newline("\n")] [],
102+
},
103+
RIntegerValue {
104+
value_token: R_INTEGER_LITERAL@227..233 "0x.1L" [Newline("\n")] [],
105+
},
106+
RIntegerValue {
107+
value_token: R_INTEGER_LITERAL@233..240 "0x1.1L" [Newline("\n")] [],
108+
},
109+
RIntegerValue {
110+
value_token: R_INTEGER_LITERAL@240..277 "0x.p1L" [Newline("\n"), Comments("# Decimal point with ..."), Newline("\n")] [],
111+
},
112+
RIntegerValue {
113+
value_token: R_INTEGER_LITERAL@277..285 "0x1.p1L" [Newline("\n")] [],
114+
},
115+
RIntegerValue {
116+
value_token: R_INTEGER_LITERAL@285..293 "0x.1p1L" [Newline("\n")] [],
117+
},
118+
RIntegerValue {
119+
value_token: R_INTEGER_LITERAL@293..302 "0x1.1p1L" [Newline("\n")] [],
120+
},
87121
],
88-
eof_token: EOF@200..200 "" [] [],
122+
eof_token: EOF@302..302 "" [] [],
89123
}
90124
```
91125

92126
## CST
93127

94128
```
95-
0: R_ROOT@0..200
129+
0: R_ROOT@0..302
96130
0: (empty)
97-
1: R_EXPRESSION_LIST@0..200
131+
1: R_EXPRESSION_LIST@0..302
98132
0: R_INTEGER_VALUE@0..2
99133
0: R_INTEGER_LITERAL@0..2 "1L" [] []
100134
1: R_INTEGER_VALUE@2..7
@@ -127,6 +161,22 @@ RRoot {
127161
0: R_INTEGER_LITERAL@180..190 "0x0p+123L" [Newline("\n")] []
128162
15: R_INTEGER_VALUE@190..200
129163
0: R_INTEGER_LITERAL@190..200 "0x0p-123L" [Newline("\n")] []
130-
2: EOF@200..200 "" [] []
164+
16: R_INTEGER_VALUE@200..221
165+
0: R_INTEGER_LITERAL@200..221 "0x.L" [Newline("\n"), Comments("# Decimal point"), Newline("\n")] []
166+
17: R_INTEGER_VALUE@221..227
167+
0: R_INTEGER_LITERAL@221..227 "0x1.L" [Newline("\n")] []
168+
18: R_INTEGER_VALUE@227..233
169+
0: R_INTEGER_LITERAL@227..233 "0x.1L" [Newline("\n")] []
170+
19: R_INTEGER_VALUE@233..240
171+
0: R_INTEGER_LITERAL@233..240 "0x1.1L" [Newline("\n")] []
172+
20: R_INTEGER_VALUE@240..277
173+
0: R_INTEGER_LITERAL@240..277 "0x.p1L" [Newline("\n"), Comments("# Decimal point with ..."), Newline("\n")] []
174+
21: R_INTEGER_VALUE@277..285
175+
0: R_INTEGER_LITERAL@277..285 "0x1.p1L" [Newline("\n")] []
176+
22: R_INTEGER_VALUE@285..293
177+
0: R_INTEGER_LITERAL@285..293 "0x.1p1L" [Newline("\n")] []
178+
23: R_INTEGER_VALUE@293..302
179+
0: R_INTEGER_LITERAL@293..302 "0x1.1p1L" [Newline("\n")] []
180+
2: EOF@302..302 "" [] []
131181
132182
```

0 commit comments

Comments
 (0)