Skip to content

Commit e8b053f

Browse files
authored
Add support for digit separators (#73)
* Add some number tests without the grammar change * Update grammar + goldens
1 parent 16c07e6 commit e8b053f

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.0 (2024-07-31)
2+
3+
- Added support for digit separators (`_`).
4+
15
## 1.2.9 (2024-04-24)
26

37
- Added support for `macro`, `augment library`, `import augment`, `augment`, `augmented`.

grammars/dart.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dart",
3-
"version": "1.2.9",
3+
"version": "1.3.0",
44
"fileTypes": [
55
"dart"
66
],
@@ -215,7 +215,7 @@
215215
},
216216
{
217217
"name": "constant.numeric.dart",
218-
"match": "(?<!\\$)\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b(?!\\$)"
218+
"match": "(?<!\\$)\\b((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(([0-9][0-9_]*\\.?[0-9_]*)|(\\.[0-9][0-9_]*))((e|E)(\\+|-)?[0-9][0-9_]*)?)\\b(?!\\$)"
219219
},
220220
{
221221
"include": "#class-identifier"

test/goldens/numbers.dart.golden

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
>// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
3+
>// for details. All rights reserved. Use of this source code is governed by a
4+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
5+
>// BSD-style license that can be found in the LICENSE file.
6+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
7+
>
8+
>var a = [
9+
#^^^ storage.type.primitive.dart
10+
# ^ keyword.operator.assignment.dart
11+
> 1,
12+
# ^ constant.numeric.dart
13+
# ^ punctuation.comma.dart
14+
> .0,
15+
# ^ punctuation.dot.dart
16+
# ^ constant.numeric.dart
17+
# ^ punctuation.comma.dart
18+
> 1.2,
19+
# ^^^ constant.numeric.dart
20+
# ^ punctuation.comma.dart
21+
> 0x123,
22+
# ^^^^^ constant.numeric.dart
23+
# ^ punctuation.comma.dart
24+
> 100__000_000__000_000__000_000,
25+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.numeric.dart
26+
# ^ punctuation.comma.dart
27+
> 0x4000_0000_0000_0000,
28+
# ^^^^^^^^^^^^^^^^^^^^^ constant.numeric.dart
29+
# ^ punctuation.comma.dart
30+
> 0.000_000_000_01,
31+
# ^^^^^^^^^^^^^^^^ constant.numeric.dart
32+
# ^ punctuation.comma.dart
33+
> 0x00_14_22_01_23_45,
34+
# ^^^^^^^^^^^^^^^^^^^ constant.numeric.dart
35+
# ^ punctuation.comma.dart
36+
> 555_123_4567,
37+
# ^^^^^^^^^^^^ constant.numeric.dart
38+
# ^ punctuation.comma.dart
39+
>];
40+
# ^ punctuation.terminator.dart

test/test_files/numbers.dart

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
var a = [
6+
1,
7+
.0,
8+
1.2,
9+
0x123,
10+
100__000_000__000_000__000_000,
11+
0x4000_0000_0000_0000,
12+
0.000_000_000_01,
13+
0x00_14_22_01_23_45,
14+
555_123_4567,
15+
];

0 commit comments

Comments
 (0)