-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.stata.js
125 lines (123 loc) · 3.93 KB
/
source.stata.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
119
120
121
122
123
124
125
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/pschumm/Stata.tmbundle>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.do', '.ado', '.doh', '.ihlp', '.mata', '.matah', '.sthlp'],
names: ['stata'],
patterns: [
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.stata'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.stata'}},
name: 'string.quoted.double.stata'
},
{
begin: '`"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.stata'}},
end: '"\'',
endCaptures: {0: {name: 'punctuation.definition.string.end.stata'}},
name: 'string.quoted.double.compound.stata',
patterns: [{include: '#cdq_string_content'}]
},
{
begin: '/\\*',
beginCaptures: {0: {name: 'punctuation.definition.comment.begin.stata'}},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.end.stata'}},
name: 'comment.block.stata',
patterns: [{include: '#cb_content'}]
},
{
captures: {0: {name: 'punctuation.definition.comment.stata'}},
match: '^\\s*(\\*).*$\\n?',
name: 'comment.line.star.stata'
},
{
captures: {0: {name: 'punctuation.definition.comment.stata'}},
match: '(///).*$\\n?',
name: 'comment.line.triple-slash.stata'
},
{
captures: {0: {name: 'punctuation.definition.comment.stata'}},
match: '(//).*$\\n?',
name: 'comment.line.double-slash.stata'
},
{match: '\\+|\\-|\\*|\\^', name: 'keyword.operator.arithmetic.stata'},
{
match: '(?<![a-zA-Z.])/(?![a-zA-Z.]|$)',
name: 'keyword.operator.arithmetic.stata'
},
{match: '\\&|\\||!|~', name: 'keyword.operator.logical.stata'},
{
match: '<|>|<\\=|>\\=|\\=\\=|!\\=|~\\=',
name: 'keyword.operator.comparison.stata'
},
{match: '\\=', name: 'keyword.operator.assignment.stata'},
{
match: '\\b(while|forv(a|al|alu|alue|alues)?|continue)\\b',
name: 'keyword.control.flow.stata'
},
{
captures: {
1: {name: 'keyword.control.flow.stata'},
2: {name: 'keyword.control.flow.stata'}
},
match:
'\\b(foreach)\\s+[a-zA-Z0-9_]+\\s+(in|of loc(a|al)?|of glo(b|ba|bal)?|of var(l|li|lis|list)?|of new(l|li|lis|list)?|of num(l|li|lis|list)?)\\b'
},
{
captures: {1: {name: 'keyword.control.flow.stata'}},
match: '^\\s*(if|else if|else)\\b'
},
{
captures: {1: {name: 'storage.type.macro.stata'}},
match: '^\\s*(gl(o|ob|oba|obal)?|loc(a|al)?|tempvar|tempname|tempfile)\\b'
},
{
captures: {1: {name: 'storage.type.scalar.stata'}},
match:
'^\\s*(sca(l|la|lar)?(\\s+de(f|fi|fin|fine)?)?)\\s+(?!(drop|dir?|l(i|is|ist)?)\\s+)'
},
{
captures: {
4: {name: 'keyword.control.flow.stata'},
5: {name: 'keyword.control.flow.stata'}
},
match:
'(^|:|{|qui(e|et|etl|etly)?\\s+|n(o|oi|ois|oisi|oisil|oisily)?\\s+)\\s*(by(s|so|sor|sort)?)((\\s|,)[^:]*)?(?=:)'
},
{
captures: {4: {name: 'storage.type.variable.stata'}},
match:
'(^|:|{|qui(e|et|etl|etly)?\\s+|n(o|oi|ois|oisi|oisil|oisily)?\\s+)\\s*((g(e|en|ene|ener|enera|enerat|enerate)?)|replace|egen)\\b'
},
{
begin: '^\\s*mata:?\\s*$',
contentName: 'source.mata',
end: '^\\s*end\\s*$\\n?',
name: 'meta.embedded.block.mata',
patterns: [{include: 'source.mata'}]
}
],
repository: {
cb_content: {
begin: '/\\*',
end: '\\*/',
patterns: [{include: '#cb_content'}]
},
cdq_string_content: {
begin: '`"',
end: '"\'',
patterns: [{include: '#cdq_string_content'}]
}
},
scopeName: 'source.stata'
}
export default grammar