-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
source.tea.js
118 lines (116 loc) · 3.96 KB
/
source.tea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `apache-2.0`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
dependencies: ['source.js', 'text.html.basic', 'text.xml'],
extensions: ['.tea'],
names: ['tea'],
patterns: [
{begin: '<%', end: '%>', patterns: [{include: '#language'}]},
{include: 'text.html.basic'},
{include: 'source.js'},
{include: 'text.xml'}
],
repository: {
functions: {
patterns: [
{
match:
'\\b(setLocale|getLocale|getAvailableLocales|nullFormat|getNullFormat|getDateFormat|getAvailableTimeZones|getDataFormatTimeZone|numberFormat|getNumberFormat|getNumberFormatInfinity|getNumberFormatNaN|currentDate|startsWith|endsWith|find|findFirst|substring|toLowerCase|toUpperCase|trim|trimLeading|trimTrailing|replace|replaceFirst|replaceLast|shortOrdinal|ordinal|cardinal)\\b(?=\\()',
name: 'support.function.tea'
}
]
},
language: {
patterns: [
{include: '#strings'},
{include: '#functions'},
{
begin: '\\b(template)\\s+([a-zA-Z_$]\\w*)?\\s*(\\()',
beginCaptures: {
1: {name: 'storage.type.template.tea'},
2: {name: 'entity.name.class.tea'}
},
end: '(\\))',
name: 'meta.template.tea',
patterns: [
{
captures: {
1: {name: 'storage.type.tea'},
2: {name: 'variable.parameter.template.tea'}
},
match: '\\s*([a-zA-Z_$][\\w.]*)\\s+(\\w*)(?:,\\s*)?'
}
]
},
{
begin: '\\b(call)\\s+(.*?)\\(.*?',
beginCaptures: {
1: {name: 'keyword.other.tea'},
2: {name: 'entity.name.function.tea'}
},
end: '\\)',
name: 'meta.template-call.tea',
patterns: [{include: '#functions'}, {include: '#strings'}]
},
{
match: '\\?:|\\?\\.|\\b(break|else|foreach|if|in|reverse)\\b',
name: 'keyword.control.tea'
},
{match: '#|##|\\.\\.|\\.\\.\\.|&|\\*\\.', name: 'keyword.operator.tea'},
{match: '(\\-|\\+|\\*|%)', name: 'keyword.operator.arithmetic.tea'},
{match: '(=)', name: 'keyword.operator.assignment.tea'},
{
match: '(==|!=|<|>|<=|>=|<=>|\\b(and|not|or|isa)\\b)',
name: 'keyword.operator.comparison.tea'
},
{match: '(!)', name: 'keyword.operator.logical.tea'},
{match: '\\b(call|as|define)\\b', name: 'keyword.other.tea'},
{match: '\\b(true)\\b', name: 'constant.language.boolean.true.tea'},
{match: '\\b(false)\\b', name: 'constant.language.boolean.false.tea'},
{match: '\\b(null)\\b', name: 'constant.language.null.tea'},
{
match: '\\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\\.[0-9]+)?))\\b',
name: 'constant.numeric.tea'
},
{match: '(//).*$\\n?', name: 'comment.line.double-slash.tea'},
{begin: '/\\*', end: '\\*/', name: 'comment.block.tea'},
{match: '\\;', name: 'punctuation.terminator.statement.tea'}
]
},
strings: {
patterns: [
{
begin: '"',
end: '"',
name: 'string.quoted.double.tea',
patterns: [
{
match:
'\\\\(x[[:xdigit:]]{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.tea'
}
]
},
{
begin: "'",
end: "'",
name: 'string.quoted.single.tea',
patterns: [
{
match:
'\\\\(x[[:xdigit:]]{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)',
name: 'constant.character.escape.tea'
}
]
}
]
}
},
scopeName: 'source.tea'
}
export default grammar