-
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
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
module.exports = grammar({
name: 'vala',
rules: {
source_file: $ => seq(repeat($.using_directive), repeat($.namespace_member)),
using_directive: $ => seq(
'using',
$.symbol,
repeat(seq(',', $.symbol)),
';'
),
symbol: $ => seq(optional('global::'), $.identifier, repeat(seq('.', $.identifier))),
identifier: $ => /[A-Za-z_]\w*/,
namespace_member: $ => seq(
repeat($.attribute),
choice(
$.namespace_declaration,
$.field_declaration
)
),
attribute: $ => seq(
'[',
$.identifier,
optional(seq('(', $.attribute_argument, repeat(seq(',', $.attribute_argument)), ')')),
']'
),
attribute_argument: $ => seq(
$.identifier,
'=',
$.expression
),
expression: $ => choice(
$.assignment_expression,
$.arithmetic_expression,
$.literal,
$.multiplicative_expression,
$.symbol
),
assignment_operator: $ => choice('=', '+=', '-=', '|=', '&=', '^=', '/=', '*=', '%=', '<<=', '>>='),
assignment_expression: $ => prec.left(0, seq($.expression, $.assignment_operator, $.expression)),
arithmetic_expression: $ => prec.left(0, seq($.expression, choice('+', '-'), $.expression)),
multiplicative_expression: $ => prec.left(1, seq($.expression, choice('*', '/'), $.expression)),
character: $ => /'\S'/,
integer: $ => /[1-9]\d*|0[0-7]*/,
real: $ => /\d+(\.\d+)?([eE][+-]?\d+)?/,
regex: $ => /\/([^\\\/\n]|\\[\\\/A-z0|\[\]^$?.(){}+\-*])+\/[gmxsu]*/,
string: $ => /".*"/,
template_string: $ => seq(
/@"[^\n]*/,
repeat(seq(
optional(seq('$(', $.expression, ')')),
/[^\n]*/
)),
'"'
),
verbatim_string: $=> /"""(.|\n)*"""/,
literal: $ => choice(
'true',
'false',
'null',
$.character,
$.integer,
$.real,
$.regex,
$.string,
$.template_string,
$.verbatim_string
),
type: $ =>
choice(
seq('void', repeat('*')),
seq(
optional('dynamic'),
optional('unowned'),
$.symbol,
optional($.type_arguments),
optional('*'),
optional('?'),
repeat($.array_type)
)
),
type_weak: $ =>
choice(
seq('void', repeat('*')),
seq(
optional('dynamic'),
optional('unowned'),
optional('weak'),
$.symbol,
optional($.type_arguments),
optional('*'),
optional('?'),
repeat($.array_type)
)
),
type_arguments: $ => seq(
'<',
$.type,
repeat(seq(',', $.type)),
'>'
),
array_type: $ =>
seq(
'[',
optional($.array_size),
']',
optional('?')
),
array_size: $ => seq(
$.expression,
repeat(seq(',', $.expression))
),
member_declaration_modifier: $ => choice(
'async',
'class',
'extern',
'inline',
'static',
'abstract',
'virtual',
'override',
'new'
),
access_modifier: $ => choice(
'private',
'protected',
'internal',
'public'
),
namespace_declaration: $ => seq(
'namespace',
$.symbol,
'{',
repeat($.using_directive),
repeat($.namespace_member),
'}'
),
field_declaration: $ => seq(
optional($.access_modifier),
repeat($.member_declaration_modifier),
$.type_weak,
$.identifier,
optional(seq('=', $.expression)),
';'
)
}
});