Skip to content

Commit e1fa2ea

Browse files
authored
enh(dart) add support for digit-separators (#4081)
1 parent bc9dfb9 commit e1fa2ea

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Core Grammars:
1313
- enh(erlang) OTP 27 doc attribute [nixxquality][]
1414
- enh(erlang) OTP 27 Sigil type [nixxquality][]
1515
- enh(erlang) OTP25/27 maybe statement [nixxquality][]
16+
- enh(dart) Support digit-separators in number literals [Sam Rawlins][]
1617

1718
New Grammars:
1819

@@ -33,6 +34,7 @@ CONTRIBUTORS
3334
[BaliBalo]: https://github.com/BaliBalo
3435
[William Wilkinson]: https://github.com/wilkinson4
3536
[nixxquality]: https://github.com/nixxquality
37+
[srawlins]: https://github.com/srawlins
3638

3739

3840
## Version 11.10.0

src/languages/dart.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ export default function(hljs) {
2525
keywords: 'true false null this is new super'
2626
};
2727

28+
const NUMBER = {
29+
className: 'number',
30+
relevance: 0,
31+
variants: [
32+
{ match: /\b[0-9][0-9_]*(\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\b/ },
33+
{ match: /\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\b/ }
34+
]
35+
};
36+
2837
const STRING = {
2938
className: 'string',
3039
variants: [
@@ -87,7 +96,7 @@ export default function(hljs) {
8796
]
8897
};
8998
BRACED_SUBST.contains = [
90-
hljs.C_NUMBER_MODE,
99+
NUMBER,
91100
STRING
92101
];
93102

@@ -248,7 +257,7 @@ export default function(hljs) {
248257
hljs.UNDERSCORE_TITLE_MODE
249258
]
250259
},
251-
hljs.C_NUMBER_MODE,
260+
NUMBER,
252261
{
253262
className: 'meta',
254263
begin: '@[A-Za-z]+'

0 commit comments

Comments
 (0)