Skip to content

Commit efb055f

Browse files
dart
1 parent b8328fd commit efb055f

File tree

1 file changed

+41
-43
lines changed

1 file changed

+41
-43
lines changed

src/languages/dart.js

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { insertBefore } from '../util/language-util.js';
21
import clike from './clike.js';
32

43
/** @type {import('../types.d.ts').LanguageProto<'dart'>} */
54
export default {
65
id: 'dart',
76
base: clike,
8-
grammar ({ base }) {
7+
grammar () {
98
const keywords = [
109
/\b(?:async|sync|yield)\*/,
1110
/\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extends|extension|external|factory|final|finally|for|get|hide|if|implements|import|in|interface|library|mixin|new|null|on|operator|part|rethrow|return|set|show|static|super|switch|sync|this|throw|try|typedef|var|void|while|with|yield)\b/,
@@ -28,47 +27,6 @@ export default {
2827
},
2928
};
3029

31-
insertBefore(base, 'string', {
32-
'string-literal': {
33-
pattern: /r?(?:("""|''')[\s\S]*?\1|(["'])(?:\\.|(?!\2)[^\\\r\n])*\2(?!\2))/,
34-
greedy: true,
35-
inside: {
36-
'interpolation': {
37-
pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\w+|\{(?:[^{}]|\{[^{}]*\})*\})/,
38-
lookbehind: true,
39-
inside: {
40-
'punctuation': /^\$\{?|\}$/,
41-
'expression': {
42-
pattern: /[\s\S]+/,
43-
inside: 'dart',
44-
},
45-
},
46-
},
47-
'string': /[\s\S]+/,
48-
},
49-
},
50-
'string': undefined,
51-
});
52-
53-
insertBefore(base, 'class-name', {
54-
'metadata': {
55-
pattern: /@\w+/,
56-
alias: 'function',
57-
},
58-
});
59-
60-
insertBefore(base, 'class-name', {
61-
'generics': {
62-
pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
63-
inside: {
64-
'class-name': className,
65-
'keyword': keywords,
66-
'punctuation': /[<>(),.:]/,
67-
'operator': /[?&|]/,
68-
},
69-
},
70-
});
71-
7230
return {
7331
'class-name': [
7432
className,
@@ -83,6 +41,46 @@ export default {
8341
'keyword': keywords,
8442
'operator':
8543
/\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/,
44+
$insertBefore: {
45+
'string': {
46+
'string-literal': {
47+
pattern: /r?(?:("""|''')[\s\S]*?\1|(["'])(?:\\.|(?!\2)[^\\\r\n])*\2(?!\2))/,
48+
greedy: true,
49+
inside: {
50+
'interpolation': {
51+
pattern:
52+
/((?:^|[^\\])(?:\\{2})*)\$(?:\w+|\{(?:[^{}]|\{[^{}]*\})*\})/,
53+
lookbehind: true,
54+
inside: {
55+
'punctuation': /^\$\{?|\}$/,
56+
'expression': {
57+
pattern: /[\s\S]+/,
58+
inside: 'dart',
59+
},
60+
},
61+
},
62+
'string': /[\s\S]+/,
63+
},
64+
},
65+
'string': undefined,
66+
},
67+
'class-name': {
68+
'metadata': {
69+
pattern: /@\w+/,
70+
alias: 'function',
71+
},
72+
'generics': {
73+
pattern:
74+
/<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
75+
inside: {
76+
'class-name': className,
77+
'keyword': keywords,
78+
'punctuation': /[<>(),.:]/,
79+
'operator': /[?&|]/,
80+
},
81+
},
82+
},
83+
},
8684
};
8785
},
8886
};

0 commit comments

Comments
 (0)