plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
3fcabcb
— Peter John
2022-11-10T19:23:55+05:30
remove indentation
Generated files not shown: src/parser.c
- binding.gyp +1 -2
- grammar.js +50 -41
- src/grammar.json +476 -115
- src/node-types.json +316 -39
- src/scanner.cc +0 -408
- test/corpus/class_definitions.txt +81 -69
- test/corpus/enum_definitions.txt +74 -56
- test/corpus/functions.txt +100 -0
- test/corpus/traits.txt +65 -0
binding.gyp
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"sources": [
|
|
10
10
|
"bindings/node/binding.cc",
|
|
11
|
-
"src/parser.c"
|
|
11
|
+
"src/parser.c"
|
|
12
|
-
"src/scanner.cc",
|
|
13
12
|
],
|
|
14
13
|
"cflags_c": [
|
|
15
14
|
"-std=c99",
|
grammar.js
CHANGED
|
@@ -4,73 +4,58 @@ const BIN_DIGITS = token(sep1(/[01]/, /_+/));
|
|
|
4
4
|
|
|
5
5
|
module.exports = grammar({
|
|
6
6
|
name: 'pine',
|
|
7
|
-
|
|
7
|
+
conflicts: $ => [
|
|
8
|
-
$._newline,
|
|
9
|
-
$.
|
|
8
|
+
[$.fun_field],
|
|
10
|
-
$._dedent,
|
|
11
|
-
$._string_start,
|
|
12
|
-
$._string_content,
|
|
13
|
-
$._string_end,
|
|
14
|
-
|
|
15
|
-
// Mark comments as external tokens so that the external scanner is always
|
|
16
|
-
// invoked, even if no external token is expected. This allows for better
|
|
17
|
-
// error recovery, because the external scanner can maintain the overall
|
|
18
|
-
// structure by returning dedent tokens whenever a dedent occurs, even
|
|
19
|
-
// if no dedent is expected.
|
|
20
|
-
$.comment,
|
|
21
|
-
|
|
22
|
-
// Allow the external scanner to check for the validity of closing brackets
|
|
23
|
-
// so that it can avoid returning dedent tokens between brackets.
|
|
24
|
-
']',
|
|
25
|
-
')',
|
|
26
|
-
'}',
|
|
27
9
|
],
|
|
28
10
|
rules: {
|
|
29
11
|
source_file: $ => seq(
|
|
30
12
|
seq("package", $.package),
|
|
31
13
|
repeat($.import_statement),
|
|
32
|
-
repeat($.class_definition),
|
|
33
|
-
repeat($.
|
|
14
|
+
repeat($.definitions),
|
|
34
15
|
),
|
|
35
16
|
|
|
36
17
|
import_statement: $ => seq('import', $.url),
|
|
37
18
|
|
|
38
19
|
definitions: $ => choice(
|
|
39
20
|
$.class_definition,
|
|
21
|
+
$.trait_definition,
|
|
40
22
|
$.enum_definition,
|
|
23
|
+
$.fun_definition,
|
|
41
24
|
),
|
|
42
25
|
|
|
43
26
|
class_definition: $ => seq(
|
|
27
|
+
field('traits', optional(repeat($.trait_name))),
|
|
44
28
|
'class',
|
|
45
29
|
field('name', $.definition_name),
|
|
46
30
|
field('generics', optional($.generic_list)),
|
|
31
|
+
field('fields', seq('(', commaSep1($.type_field), ')')),
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
trait_definition: $ => seq(
|
|
35
|
+
'trait',
|
|
36
|
+
field('name', $.definition_name),
|
|
47
|
-
field('
|
|
37
|
+
field('generics', optional($.generic_list)),
|
|
48
|
-
':',
|
|
49
|
-
field('fields', seq($.
|
|
38
|
+
field('fields', seq('(', commaSep1($.trait_field), ')')),
|
|
50
|
-
repeat($.class_field),
|
|
51
|
-
$._dedent
|
|
52
|
-
))),
|
|
53
39
|
),
|
|
54
40
|
|
|
55
41
|
enum_definition: $ => seq(
|
|
56
42
|
'enum',
|
|
57
43
|
field('name', $.definition_name),
|
|
58
|
-
field('types', $.
|
|
44
|
+
field('types', seq('(', commaSep1($.type_field), ')')),
|
|
59
|
-
':',
|
|
60
|
-
field('fields', seq($.
|
|
45
|
+
field('fields', seq('{', commaSep1($.enum_field), '}')),
|
|
61
|
-
repeat($.enum_field),
|
|
62
|
-
$._dedent
|
|
63
|
-
))),
|
|
64
46
|
),
|
|
65
47
|
|
|
66
|
-
type: $ => seq($.definition_name, optional('?')),
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
fun_definition: $ => seq(
|
|
69
|
-
'
|
|
49
|
+
'fun',
|
|
70
|
-
|
|
50
|
+
field('name', choice($.identifier, $._extension)),
|
|
51
|
+
field('params', seq('(', optional(commaSep1($.param)), ')')),
|
|
71
|
-
'
|
|
52
|
+
'=>',
|
|
53
|
+
field('returns', optional(commaSep1($.type))),
|
|
54
|
+
'{', '}',
|
|
72
55
|
),
|
|
73
56
|
|
|
57
|
+
trait_name: $ => seq("@", $.definition_name),
|
|
58
|
+
|
|
74
59
|
trait_list: $ => seq(
|
|
75
60
|
'(',
|
|
76
61
|
commaSep1($.identifier),
|
|
@@ -83,12 +68,34 @@ module.exports = grammar({
|
|
|
83
68
|
'>'
|
|
84
69
|
),
|
|
85
70
|
|
|
71
|
+
type: $ => seq($.definition_name, optional('?')),
|
|
72
|
+
|
|
73
|
+
param: $ => seq(
|
|
74
|
+
field('name', $.variable_name),
|
|
75
|
+
':',
|
|
76
|
+
field('type', $.type)
|
|
77
|
+
),
|
|
78
|
+
|
|
86
|
-
|
|
79
|
+
type_field: $ => seq(
|
|
80
|
+
'val',
|
|
87
81
|
field('name', $.variable_name),
|
|
88
82
|
':',
|
|
89
83
|
field('type', $.type)
|
|
90
84
|
),
|
|
91
85
|
|
|
86
|
+
fun_field: $ => seq(
|
|
87
|
+
'fun',
|
|
88
|
+
field('name', $.identifier),
|
|
89
|
+
field('params', seq('(', optional(commaSep1($.param)), ')')),
|
|
90
|
+
'=>',
|
|
91
|
+
field('returns', optional(commaSep1($.type))),
|
|
92
|
+
),
|
|
93
|
+
|
|
94
|
+
trait_field: $ => choice(
|
|
95
|
+
$.type_field,
|
|
96
|
+
$.fun_field,
|
|
97
|
+
),
|
|
98
|
+
|
|
92
99
|
enum_field: $ => seq($.enum_field_name, '(', commaSep1($._primary_expression), ')'),
|
|
93
100
|
|
|
94
101
|
_primary_expression: $ => choice(
|
|
@@ -96,6 +103,8 @@ module.exports = grammar({
|
|
|
96
103
|
$._string_literal,
|
|
97
104
|
),
|
|
98
105
|
|
|
106
|
+
_extension: $ => seq($.identifier, '.', $.identifier),
|
|
107
|
+
|
|
99
108
|
url: $ => sep1(/[a-zA-Z_][a-zA-Z_0-9]*/, '/'),
|
|
100
109
|
package: $ => $.identifier,
|
|
101
110
|
identifier: $ => /[a-zA-Z_][a-zA-Z_0-9]*/,
|
src/grammar.json
CHANGED
|
@@ -28,14 +28,7 @@
|
|
|
28
28
|
"type": "REPEAT",
|
|
29
29
|
"content": {
|
|
30
30
|
"type": "SYMBOL",
|
|
31
|
-
"name": "class_definition"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"type": "REPEAT",
|
|
36
|
-
"content": {
|
|
37
|
-
"type": "SYMBOL",
|
|
38
|
-
"name": "
|
|
31
|
+
"name": "definitions"
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
34
|
]
|
|
@@ -60,15 +53,42 @@
|
|
|
60
53
|
"type": "SYMBOL",
|
|
61
54
|
"name": "class_definition"
|
|
62
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"type": "SYMBOL",
|
|
58
|
+
"name": "trait_definition"
|
|
59
|
+
},
|
|
63
60
|
{
|
|
64
61
|
"type": "SYMBOL",
|
|
65
62
|
"name": "enum_definition"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "SYMBOL",
|
|
66
|
+
"name": "fun_definition"
|
|
66
67
|
}
|
|
67
68
|
]
|
|
68
69
|
},
|
|
69
70
|
"class_definition": {
|
|
70
71
|
"type": "SEQ",
|
|
71
72
|
"members": [
|
|
73
|
+
{
|
|
74
|
+
"type": "FIELD",
|
|
75
|
+
"name": "traits",
|
|
76
|
+
"content": {
|
|
77
|
+
"type": "CHOICE",
|
|
78
|
+
"members": [
|
|
79
|
+
{
|
|
80
|
+
"type": "REPEAT",
|
|
81
|
+
"content": {
|
|
82
|
+
"type": "SYMBOL",
|
|
83
|
+
"name": "trait_name"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "BLANK"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
72
92
|
{
|
|
73
93
|
"type": "STRING",
|
|
74
94
|
"value": "class"
|
|
@@ -99,13 +119,72 @@
|
|
|
99
119
|
},
|
|
100
120
|
{
|
|
101
121
|
"type": "FIELD",
|
|
102
|
-
"name": "
|
|
122
|
+
"name": "fields",
|
|
123
|
+
"content": {
|
|
124
|
+
"type": "SEQ",
|
|
125
|
+
"members": [
|
|
126
|
+
{
|
|
127
|
+
"type": "STRING",
|
|
128
|
+
"value": "("
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "SEQ",
|
|
132
|
+
"members": [
|
|
133
|
+
{
|
|
134
|
+
"type": "SYMBOL",
|
|
135
|
+
"name": "type_field"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "REPEAT",
|
|
139
|
+
"content": {
|
|
140
|
+
"type": "SEQ",
|
|
141
|
+
"members": [
|
|
142
|
+
{
|
|
143
|
+
"type": "STRING",
|
|
144
|
+
"value": ","
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"type": "SYMBOL",
|
|
148
|
+
"name": "type_field"
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "STRING",
|
|
157
|
+
"value": ")"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
"trait_definition": {
|
|
165
|
+
"type": "SEQ",
|
|
166
|
+
"members": [
|
|
167
|
+
{
|
|
168
|
+
"type": "STRING",
|
|
169
|
+
"value": "trait"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"type": "FIELD",
|
|
173
|
+
"name": "name",
|
|
174
|
+
"content": {
|
|
175
|
+
"type": "SYMBOL",
|
|
176
|
+
"name": "definition_name"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"type": "FIELD",
|
|
181
|
+
"name": "generics",
|
|
103
182
|
"content": {
|
|
104
183
|
"type": "CHOICE",
|
|
105
184
|
"members": [
|
|
106
185
|
{
|
|
107
186
|
"type": "SYMBOL",
|
|
108
|
-
"name": "
|
|
187
|
+
"name": "generic_list"
|
|
109
188
|
},
|
|
110
189
|
{
|
|
111
190
|
"type": "BLANK"
|
|
@@ -113,10 +192,6 @@
|
|
|
113
192
|
]
|
|
114
193
|
}
|
|
115
194
|
},
|
|
116
|
-
{
|
|
117
|
-
"type": "STRING",
|
|
118
|
-
"value": ":"
|
|
119
|
-
},
|
|
120
195
|
{
|
|
121
196
|
"type": "FIELD",
|
|
122
197
|
"name": "fields",
|
|
@@ -124,24 +199,37 @@
|
|
|
124
199
|
"type": "SEQ",
|
|
125
200
|
"members": [
|
|
126
201
|
{
|
|
127
|
-
"type": "
|
|
202
|
+
"type": "STRING",
|
|
128
|
-
"
|
|
203
|
+
"value": "("
|
|
129
204
|
},
|
|
130
205
|
{
|
|
131
206
|
"type": "SEQ",
|
|
132
207
|
"members": [
|
|
208
|
+
{
|
|
209
|
+
"type": "SYMBOL",
|
|
210
|
+
"name": "trait_field"
|
|
211
|
+
},
|
|
133
212
|
{
|
|
134
213
|
"type": "REPEAT",
|
|
135
214
|
"content": {
|
|
215
|
+
"type": "SEQ",
|
|
216
|
+
"members": [
|
|
217
|
+
{
|
|
218
|
+
"type": "STRING",
|
|
219
|
+
"value": ","
|
|
220
|
+
},
|
|
221
|
+
{
|
|
136
|
-
|
|
222
|
+
"type": "SYMBOL",
|
|
137
|
-
|
|
223
|
+
"name": "trait_field"
|
|
224
|
+
}
|
|
225
|
+
]
|
|
138
226
|
}
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"type": "SYMBOL",
|
|
142
|
-
"name": "_dedent"
|
|
143
227
|
}
|
|
144
228
|
]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"type": "STRING",
|
|
232
|
+
"value": ")"
|
|
145
233
|
}
|
|
146
234
|
]
|
|
147
235
|
}
|
|
@@ -167,14 +255,44 @@
|
|
|
167
255
|
"type": "FIELD",
|
|
168
256
|
"name": "types",
|
|
169
257
|
"content": {
|
|
258
|
+
"type": "SEQ",
|
|
259
|
+
"members": [
|
|
260
|
+
{
|
|
261
|
+
"type": "STRING",
|
|
262
|
+
"value": "("
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"type": "SEQ",
|
|
266
|
+
"members": [
|
|
267
|
+
{
|
|
170
|
-
|
|
268
|
+
"type": "SYMBOL",
|
|
171
|
-
|
|
269
|
+
"name": "type_field"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"type": "REPEAT",
|
|
273
|
+
"content": {
|
|
274
|
+
"type": "SEQ",
|
|
275
|
+
"members": [
|
|
276
|
+
{
|
|
277
|
+
"type": "STRING",
|
|
278
|
+
"value": ","
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"type": "SYMBOL",
|
|
282
|
+
"name": "type_field"
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"type": "STRING",
|
|
291
|
+
"value": ")"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
172
294
|
}
|
|
173
295
|
},
|
|
174
|
-
{
|
|
175
|
-
"type": "STRING",
|
|
176
|
-
"value": ":"
|
|
177
|
-
},
|
|
178
296
|
{
|
|
179
297
|
"type": "FIELD",
|
|
180
298
|
"name": "fields",
|
|
@@ -182,52 +300,182 @@
|
|
|
182
300
|
"type": "SEQ",
|
|
183
301
|
"members": [
|
|
184
302
|
{
|
|
185
|
-
"type": "
|
|
303
|
+
"type": "STRING",
|
|
186
|
-
"
|
|
304
|
+
"value": "{"
|
|
187
305
|
},
|
|
188
306
|
{
|
|
189
307
|
"type": "SEQ",
|
|
190
308
|
"members": [
|
|
309
|
+
{
|
|
310
|
+
"type": "SYMBOL",
|
|
311
|
+
"name": "enum_field"
|
|
312
|
+
},
|
|
191
313
|
{
|
|
192
314
|
"type": "REPEAT",
|
|
193
315
|
"content": {
|
|
316
|
+
"type": "SEQ",
|
|
317
|
+
"members": [
|
|
318
|
+
{
|
|
319
|
+
"type": "STRING",
|
|
320
|
+
"value": ","
|
|
321
|
+
},
|
|
322
|
+
{
|
|
194
|
-
|
|
323
|
+
"type": "SYMBOL",
|
|
195
|
-
|
|
324
|
+
"name": "enum_field"
|
|
325
|
+
}
|
|
326
|
+
]
|
|
196
327
|
}
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"type": "STRING",
|
|
333
|
+
"value": "}"
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
"fun_definition": {
|
|
341
|
+
"type": "SEQ",
|
|
342
|
+
"members": [
|
|
343
|
+
{
|
|
344
|
+
"type": "STRING",
|
|
345
|
+
"value": "fun"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "FIELD",
|
|
349
|
+
"name": "name",
|
|
350
|
+
"content": {
|
|
351
|
+
"type": "CHOICE",
|
|
352
|
+
"members": [
|
|
353
|
+
{
|
|
354
|
+
"type": "SYMBOL",
|
|
355
|
+
"name": "identifier"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"type": "SYMBOL",
|
|
359
|
+
"name": "_extension"
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"type": "FIELD",
|
|
366
|
+
"name": "params",
|
|
367
|
+
"content": {
|
|
368
|
+
"type": "SEQ",
|
|
369
|
+
"members": [
|
|
370
|
+
{
|
|
371
|
+
"type": "STRING",
|
|
372
|
+
"value": "("
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"type": "CHOICE",
|
|
376
|
+
"members": [
|
|
377
|
+
{
|
|
378
|
+
"type": "SEQ",
|
|
379
|
+
"members": [
|
|
380
|
+
{
|
|
381
|
+
"type": "SYMBOL",
|
|
382
|
+
"name": "param"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"type": "REPEAT",
|
|
386
|
+
"content": {
|
|
387
|
+
"type": "SEQ",
|
|
388
|
+
"members": [
|
|
389
|
+
{
|
|
390
|
+
"type": "STRING",
|
|
391
|
+
"value": ","
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"type": "SYMBOL",
|
|
395
|
+
"name": "param"
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
]
|
|
197
401
|
},
|
|
402
|
+
{
|
|
403
|
+
"type": "BLANK"
|
|
404
|
+
}
|
|
405
|
+
]
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"type": "STRING",
|
|
409
|
+
"value": ")"
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"type": "STRING",
|
|
416
|
+
"value": "=>"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"type": "FIELD",
|
|
420
|
+
"name": "returns",
|
|
421
|
+
"content": {
|
|
422
|
+
"type": "CHOICE",
|
|
423
|
+
"members": [
|
|
424
|
+
{
|
|
425
|
+
"type": "SEQ",
|
|
426
|
+
"members": [
|
|
198
427
|
{
|
|
199
428
|
"type": "SYMBOL",
|
|
200
|
-
"name": "
|
|
429
|
+
"name": "type"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"type": "REPEAT",
|
|
433
|
+
"content": {
|
|
434
|
+
"type": "SEQ",
|
|
435
|
+
"members": [
|
|
436
|
+
{
|
|
437
|
+
"type": "STRING",
|
|
438
|
+
"value": ","
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"type": "SYMBOL",
|
|
442
|
+
"name": "type"
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
}
|
|
201
446
|
}
|
|
202
447
|
]
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"type": "BLANK"
|
|
203
451
|
}
|
|
204
452
|
]
|
|
205
453
|
}
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"type": "STRING",
|
|
457
|
+
"value": "{"
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"type": "STRING",
|
|
461
|
+
"value": "}"
|
|
206
462
|
}
|
|
207
463
|
]
|
|
208
464
|
},
|
|
209
|
-
"
|
|
465
|
+
"trait_name": {
|
|
210
466
|
"type": "SEQ",
|
|
211
467
|
"members": [
|
|
212
468
|
{
|
|
213
|
-
"type": "
|
|
469
|
+
"type": "STRING",
|
|
214
|
-
"
|
|
470
|
+
"value": "@"
|
|
215
471
|
},
|
|
216
472
|
{
|
|
217
|
-
"type": "CHOICE",
|
|
218
|
-
"members": [
|
|
219
|
-
{
|
|
220
|
-
|
|
473
|
+
"type": "SYMBOL",
|
|
221
|
-
"value": "?"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
|
|
474
|
+
"name": "definition_name"
|
|
225
|
-
}
|
|
226
|
-
]
|
|
227
475
|
}
|
|
228
476
|
]
|
|
229
477
|
},
|
|
230
|
-
"
|
|
478
|
+
"trait_list": {
|
|
231
479
|
"type": "SEQ",
|
|
232
480
|
"members": [
|
|
233
481
|
{
|
|
@@ -265,12 +513,12 @@
|
|
|
265
513
|
}
|
|
266
514
|
]
|
|
267
515
|
},
|
|
268
|
-
"
|
|
516
|
+
"generic_list": {
|
|
269
517
|
"type": "SEQ",
|
|
270
518
|
"members": [
|
|
271
519
|
{
|
|
272
520
|
"type": "STRING",
|
|
273
|
-
"value": "
|
|
521
|
+
"value": "<"
|
|
274
522
|
},
|
|
275
523
|
{
|
|
276
524
|
"type": "SEQ",
|
|
@@ -299,51 +547,63 @@
|
|
|
299
547
|
},
|
|
300
548
|
{
|
|
301
549
|
"type": "STRING",
|
|
302
|
-
"value": "
|
|
550
|
+
"value": ">"
|
|
303
551
|
}
|
|
304
552
|
]
|
|
305
553
|
},
|
|
306
|
-
"
|
|
554
|
+
"type": {
|
|
307
555
|
"type": "SEQ",
|
|
308
556
|
"members": [
|
|
309
557
|
{
|
|
310
|
-
"type": "
|
|
558
|
+
"type": "SYMBOL",
|
|
311
|
-
"
|
|
559
|
+
"name": "definition_name"
|
|
312
560
|
},
|
|
313
561
|
{
|
|
314
|
-
"type": "
|
|
562
|
+
"type": "CHOICE",
|
|
315
563
|
"members": [
|
|
316
564
|
{
|
|
317
|
-
"type": "
|
|
565
|
+
"type": "STRING",
|
|
318
|
-
"
|
|
566
|
+
"value": "?"
|
|
319
567
|
},
|
|
320
568
|
{
|
|
321
|
-
"type": "REPEAT",
|
|
322
|
-
"content": {
|
|
323
|
-
"type": "SEQ",
|
|
324
|
-
"members": [
|
|
325
|
-
{
|
|
326
|
-
|
|
569
|
+
"type": "BLANK"
|
|
327
|
-
"value": ","
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
"type": "SYMBOL",
|
|
331
|
-
"name": "identifier"
|
|
332
|
-
}
|
|
333
|
-
]
|
|
334
|
-
}
|
|
335
570
|
}
|
|
336
571
|
]
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
},
|
|
575
|
+
"param": {
|
|
576
|
+
"type": "SEQ",
|
|
577
|
+
"members": [
|
|
578
|
+
{
|
|
579
|
+
"type": "FIELD",
|
|
580
|
+
"name": "name",
|
|
581
|
+
"content": {
|
|
582
|
+
"type": "SYMBOL",
|
|
583
|
+
"name": "variable_name"
|
|
584
|
+
}
|
|
337
585
|
},
|
|
338
586
|
{
|
|
339
587
|
"type": "STRING",
|
|
340
|
-
"value": "
|
|
588
|
+
"value": ":"
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"type": "FIELD",
|
|
592
|
+
"name": "type",
|
|
593
|
+
"content": {
|
|
594
|
+
"type": "SYMBOL",
|
|
595
|
+
"name": "type"
|
|
596
|
+
}
|
|
341
597
|
}
|
|
342
598
|
]
|
|
343
599
|
},
|
|
344
|
-
"
|
|
600
|
+
"type_field": {
|
|
345
601
|
"type": "SEQ",
|
|
346
602
|
"members": [
|
|
603
|
+
{
|
|
604
|
+
"type": "STRING",
|
|
605
|
+
"value": "val"
|
|
606
|
+
},
|
|
347
607
|
{
|
|
348
608
|
"type": "FIELD",
|
|
349
609
|
"name": "name",
|
|
@@ -366,6 +626,127 @@
|
|
|
366
626
|
}
|
|
367
627
|
]
|
|
368
628
|
},
|
|
629
|
+
"fun_field": {
|
|
630
|
+
"type": "SEQ",
|
|
631
|
+
"members": [
|
|
632
|
+
{
|
|
633
|
+
"type": "STRING",
|
|
634
|
+
"value": "fun"
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"type": "FIELD",
|
|
638
|
+
"name": "name",
|
|
639
|
+
"content": {
|
|
640
|
+
"type": "SYMBOL",
|
|
641
|
+
"name": "identifier"
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
"type": "FIELD",
|
|
646
|
+
"name": "params",
|
|
647
|
+
"content": {
|
|
648
|
+
"type": "SEQ",
|
|
649
|
+
"members": [
|
|
650
|
+
{
|
|
651
|
+
"type": "STRING",
|
|
652
|
+
"value": "("
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
"type": "CHOICE",
|
|
656
|
+
"members": [
|
|
657
|
+
{
|
|
658
|
+
"type": "SEQ",
|
|
659
|
+
"members": [
|
|
660
|
+
{
|
|
661
|
+
"type": "SYMBOL",
|
|
662
|
+
"name": "param"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"type": "REPEAT",
|
|
666
|
+
"content": {
|
|
667
|
+
"type": "SEQ",
|
|
668
|
+
"members": [
|
|
669
|
+
{
|
|
670
|
+
"type": "STRING",
|
|
671
|
+
"value": ","
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
"type": "SYMBOL",
|
|
675
|
+
"name": "param"
|
|
676
|
+
}
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"type": "BLANK"
|
|
684
|
+
}
|
|
685
|
+
]
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
"type": "STRING",
|
|
689
|
+
"value": ")"
|
|
690
|
+
}
|
|
691
|
+
]
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"type": "STRING",
|
|
696
|
+
"value": "=>"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"type": "FIELD",
|
|
700
|
+
"name": "returns",
|
|
701
|
+
"content": {
|
|
702
|
+
"type": "CHOICE",
|
|
703
|
+
"members": [
|
|
704
|
+
{
|
|
705
|
+
"type": "SEQ",
|
|
706
|
+
"members": [
|
|
707
|
+
{
|
|
708
|
+
"type": "SYMBOL",
|
|
709
|
+
"name": "type"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"type": "REPEAT",
|
|
713
|
+
"content": {
|
|
714
|
+
"type": "SEQ",
|
|
715
|
+
"members": [
|
|
716
|
+
{
|
|
717
|
+
"type": "STRING",
|
|
718
|
+
"value": ","
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"type": "SYMBOL",
|
|
722
|
+
"name": "type"
|
|
723
|
+
}
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
]
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"type": "BLANK"
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
]
|
|
736
|
+
},
|
|
737
|
+
"trait_field": {
|
|
738
|
+
"type": "CHOICE",
|
|
739
|
+
"members": [
|
|
740
|
+
{
|
|
741
|
+
"type": "SYMBOL",
|
|
742
|
+
"name": "type_field"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"type": "SYMBOL",
|
|
746
|
+
"name": "fun_field"
|
|
747
|
+
}
|
|
748
|
+
]
|
|
749
|
+
},
|
|
369
750
|
"enum_field": {
|
|
370
751
|
"type": "SEQ",
|
|
371
752
|
"members": [
|
|
@@ -421,6 +802,23 @@
|
|
|
421
802
|
}
|
|
422
803
|
]
|
|
423
804
|
},
|
|
805
|
+
"_extension": {
|
|
806
|
+
"type": "SEQ",
|
|
807
|
+
"members": [
|
|
808
|
+
{
|
|
809
|
+
"type": "SYMBOL",
|
|
810
|
+
"name": "identifier"
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
"type": "STRING",
|
|
814
|
+
"value": "."
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"type": "SYMBOL",
|
|
818
|
+
"name": "identifier"
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
},
|
|
424
822
|
"url": {
|
|
425
823
|
"type": "SEQ",
|
|
426
824
|
"members": [
|
|
@@ -974,50 +1372,13 @@
|
|
|
974
1372
|
"value": "\\s"
|
|
975
1373
|
}
|
|
976
1374
|
],
|
|
977
|
-
"conflicts": [
|
|
1375
|
+
"conflicts": [
|
|
978
|
-
|
|
1376
|
+
[
|
|
979
|
-
|
|
1377
|
+
"fun_field"
|
|
980
|
-
|
|
1378
|
+
]
|
|
981
|
-
"type": "SYMBOL",
|
|
982
|
-
"name": "_newline"
|
|
983
|
-
},
|
|
984
|
-
{
|
|
985
|
-
"type": "SYMBOL",
|
|
986
|
-
"name": "_indent"
|
|
987
|
-
},
|
|
988
|
-
{
|
|
989
|
-
"type": "SYMBOL",
|
|
990
|
-
"name": "_dedent"
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
"type": "SYMBOL",
|
|
994
|
-
"name": "_string_start"
|
|
995
|
-
},
|
|
996
|
-
{
|
|
997
|
-
"type": "SYMBOL",
|
|
998
|
-
"name": "_string_content"
|
|
999
|
-
},
|
|
1000
|
-
{
|
|
1001
|
-
"type": "SYMBOL",
|
|
1002
|
-
"name": "_string_end"
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
"type": "SYMBOL",
|
|
1006
|
-
"name": "comment"
|
|
1007
|
-
},
|
|
1008
|
-
{
|
|
1009
|
-
"type": "STRING",
|
|
1010
|
-
"value": "]"
|
|
1011
|
-
},
|
|
1012
|
-
{
|
|
1013
|
-
"type": "STRING",
|
|
1014
|
-
"value": ")"
|
|
1015
|
-
},
|
|
1016
|
-
{
|
|
1017
|
-
"type": "STRING",
|
|
1018
|
-
"value": "}"
|
|
1019
|
-
}
|
|
1020
1379
|
],
|
|
1380
|
+
"precedences": [],
|
|
1381
|
+
"externals": [],
|
|
1021
1382
|
"inline": [],
|
|
1022
1383
|
"supertypes": []
|
|
1023
1384
|
}
|
src/node-types.json
CHANGED
|
@@ -33,7 +33,19 @@
|
|
|
33
33
|
"required": true,
|
|
34
34
|
"types": [
|
|
35
35
|
{
|
|
36
|
+
"type": "(",
|
|
37
|
+
"named": false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": ")",
|
|
41
|
+
"named": false
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": ",",
|
|
45
|
+
"named": false
|
|
46
|
+
},
|
|
47
|
+
{
|
|
36
|
-
"type": "
|
|
48
|
+
"type": "type_field",
|
|
37
49
|
"named": true
|
|
38
50
|
}
|
|
39
51
|
]
|
|
@@ -59,11 +71,11 @@
|
|
|
59
71
|
]
|
|
60
72
|
},
|
|
61
73
|
"traits": {
|
|
62
|
-
"multiple":
|
|
74
|
+
"multiple": true,
|
|
63
75
|
"required": false,
|
|
64
76
|
"types": [
|
|
65
77
|
{
|
|
66
|
-
"type": "
|
|
78
|
+
"type": "trait_name",
|
|
67
79
|
"named": true
|
|
68
80
|
}
|
|
69
81
|
]
|
|
@@ -71,29 +83,30 @@
|
|
|
71
83
|
}
|
|
72
84
|
},
|
|
73
85
|
{
|
|
74
|
-
"type": "
|
|
86
|
+
"type": "definitions",
|
|
75
87
|
"named": true,
|
|
76
|
-
"fields": {
|
|
88
|
+
"fields": {},
|
|
77
|
-
|
|
89
|
+
"children": {
|
|
78
|
-
|
|
90
|
+
"multiple": false,
|
|
79
|
-
|
|
91
|
+
"required": true,
|
|
80
|
-
|
|
92
|
+
"types": [
|
|
81
|
-
|
|
93
|
+
{
|
|
82
|
-
|
|
94
|
+
"type": "class_definition",
|
|
83
|
-
|
|
95
|
+
"named": true
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "enum_definition",
|
|
99
|
+
"named": true
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "fun_definition",
|
|
103
|
+
"named": true
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "trait_definition",
|
|
107
|
+
"named": true
|
|
84
|
-
|
|
108
|
+
}
|
|
85
|
-
|
|
109
|
+
]
|
|
86
|
-
},
|
|
87
|
-
"type": {
|
|
88
|
-
"multiple": false,
|
|
89
|
-
"required": true,
|
|
90
|
-
"types": [
|
|
91
|
-
{
|
|
92
|
-
"type": "type",
|
|
93
|
-
"named": true
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
110
|
}
|
|
98
111
|
},
|
|
99
112
|
{
|
|
@@ -104,9 +117,21 @@
|
|
|
104
117
|
"multiple": true,
|
|
105
118
|
"required": true,
|
|
106
119
|
"types": [
|
|
120
|
+
{
|
|
121
|
+
"type": ",",
|
|
122
|
+
"named": false
|
|
123
|
+
},
|
|
107
124
|
{
|
|
108
125
|
"type": "enum_field",
|
|
109
126
|
"named": true
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "{",
|
|
130
|
+
"named": false
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "}",
|
|
134
|
+
"named": false
|
|
110
135
|
}
|
|
111
136
|
]
|
|
112
137
|
},
|
|
@@ -121,11 +146,23 @@
|
|
|
121
146
|
]
|
|
122
147
|
},
|
|
123
148
|
"types": {
|
|
124
|
-
"multiple":
|
|
149
|
+
"multiple": true,
|
|
125
150
|
"required": true,
|
|
126
151
|
"types": [
|
|
127
152
|
{
|
|
153
|
+
"type": "(",
|
|
154
|
+
"named": false
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": ")",
|
|
158
|
+
"named": false
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"type": ",",
|
|
162
|
+
"named": false
|
|
163
|
+
},
|
|
164
|
+
{
|
|
128
|
-
"type": "
|
|
165
|
+
"type": "type_field",
|
|
129
166
|
"named": true
|
|
130
167
|
}
|
|
131
168
|
]
|
|
@@ -179,6 +216,114 @@
|
|
|
179
216
|
]
|
|
180
217
|
}
|
|
181
218
|
},
|
|
219
|
+
{
|
|
220
|
+
"type": "fun_definition",
|
|
221
|
+
"named": true,
|
|
222
|
+
"fields": {
|
|
223
|
+
"name": {
|
|
224
|
+
"multiple": true,
|
|
225
|
+
"required": true,
|
|
226
|
+
"types": [
|
|
227
|
+
{
|
|
228
|
+
"type": ".",
|
|
229
|
+
"named": false
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"type": "identifier",
|
|
233
|
+
"named": true
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
"params": {
|
|
238
|
+
"multiple": true,
|
|
239
|
+
"required": true,
|
|
240
|
+
"types": [
|
|
241
|
+
{
|
|
242
|
+
"type": "(",
|
|
243
|
+
"named": false
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"type": ")",
|
|
247
|
+
"named": false
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"type": ",",
|
|
251
|
+
"named": false
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"type": "param",
|
|
255
|
+
"named": true
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
"returns": {
|
|
260
|
+
"multiple": true,
|
|
261
|
+
"required": false,
|
|
262
|
+
"types": [
|
|
263
|
+
{
|
|
264
|
+
"type": ",",
|
|
265
|
+
"named": false
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"type": "type",
|
|
269
|
+
"named": true
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"type": "fun_field",
|
|
277
|
+
"named": true,
|
|
278
|
+
"fields": {
|
|
279
|
+
"name": {
|
|
280
|
+
"multiple": false,
|
|
281
|
+
"required": true,
|
|
282
|
+
"types": [
|
|
283
|
+
{
|
|
284
|
+
"type": "identifier",
|
|
285
|
+
"named": true
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
"params": {
|
|
290
|
+
"multiple": true,
|
|
291
|
+
"required": true,
|
|
292
|
+
"types": [
|
|
293
|
+
{
|
|
294
|
+
"type": "(",
|
|
295
|
+
"named": false
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"type": ")",
|
|
299
|
+
"named": false
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"type": ",",
|
|
303
|
+
"named": false
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"type": "param",
|
|
307
|
+
"named": true
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
},
|
|
311
|
+
"returns": {
|
|
312
|
+
"multiple": true,
|
|
313
|
+
"required": false,
|
|
314
|
+
"types": [
|
|
315
|
+
{
|
|
316
|
+
"type": ",",
|
|
317
|
+
"named": false
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"type": "type",
|
|
321
|
+
"named": true
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
182
327
|
{
|
|
183
328
|
"type": "generic_list",
|
|
184
329
|
"named": true,
|
|
@@ -268,6 +413,32 @@
|
|
|
268
413
|
]
|
|
269
414
|
}
|
|
270
415
|
},
|
|
416
|
+
{
|
|
417
|
+
"type": "param",
|
|
418
|
+
"named": true,
|
|
419
|
+
"fields": {
|
|
420
|
+
"name": {
|
|
421
|
+
"multiple": false,
|
|
422
|
+
"required": true,
|
|
423
|
+
"types": [
|
|
424
|
+
{
|
|
425
|
+
"type": "variable_name",
|
|
426
|
+
"named": true
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
"type": {
|
|
431
|
+
"multiple": false,
|
|
432
|
+
"required": true,
|
|
433
|
+
"types": [
|
|
434
|
+
{
|
|
435
|
+
"type": "type",
|
|
436
|
+
"named": true
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
271
442
|
{
|
|
272
443
|
"type": "source_file",
|
|
273
444
|
"named": true,
|
|
@@ -277,11 +448,7 @@
|
|
|
277
448
|
"required": true,
|
|
278
449
|
"types": [
|
|
279
450
|
{
|
|
280
|
-
"type": "class_definition",
|
|
281
|
-
"named": true
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"type": "
|
|
451
|
+
"type": "definitions",
|
|
285
452
|
"named": true
|
|
286
453
|
},
|
|
287
454
|
{
|
|
@@ -296,22 +463,74 @@
|
|
|
296
463
|
}
|
|
297
464
|
},
|
|
298
465
|
{
|
|
466
|
+
"type": "trait_definition",
|
|
467
|
+
"named": true,
|
|
468
|
+
"fields": {
|
|
469
|
+
"fields": {
|
|
470
|
+
"multiple": true,
|
|
471
|
+
"required": true,
|
|
472
|
+
"types": [
|
|
473
|
+
{
|
|
474
|
+
"type": "(",
|
|
475
|
+
"named": false
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"type": ")",
|
|
479
|
+
"named": false
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"type": ",",
|
|
483
|
+
"named": false
|
|
484
|
+
},
|
|
485
|
+
{
|
|
299
|
-
|
|
486
|
+
"type": "trait_field",
|
|
487
|
+
"named": true
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
},
|
|
491
|
+
"generics": {
|
|
492
|
+
"multiple": false,
|
|
493
|
+
"required": false,
|
|
494
|
+
"types": [
|
|
495
|
+
{
|
|
496
|
+
"type": "generic_list",
|
|
497
|
+
"named": true
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
"name": {
|
|
502
|
+
"multiple": false,
|
|
503
|
+
"required": true,
|
|
504
|
+
"types": [
|
|
505
|
+
{
|
|
506
|
+
"type": "definition_name",
|
|
507
|
+
"named": true
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
"type": "trait_field",
|
|
300
515
|
"named": true,
|
|
301
516
|
"fields": {},
|
|
302
517
|
"children": {
|
|
303
|
-
"multiple":
|
|
518
|
+
"multiple": false,
|
|
304
519
|
"required": true,
|
|
305
520
|
"types": [
|
|
306
521
|
{
|
|
307
|
-
"type": "
|
|
522
|
+
"type": "fun_field",
|
|
523
|
+
"named": true
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"type": "type_field",
|
|
308
527
|
"named": true
|
|
309
528
|
}
|
|
310
529
|
]
|
|
311
530
|
}
|
|
312
531
|
},
|
|
313
532
|
{
|
|
314
|
-
"type": "
|
|
533
|
+
"type": "trait_name",
|
|
315
534
|
"named": true,
|
|
316
535
|
"fields": {},
|
|
317
536
|
"children": {
|
|
@@ -326,20 +545,46 @@
|
|
|
326
545
|
}
|
|
327
546
|
},
|
|
328
547
|
{
|
|
329
|
-
"type": "
|
|
548
|
+
"type": "type",
|
|
330
549
|
"named": true,
|
|
331
550
|
"fields": {},
|
|
332
551
|
"children": {
|
|
333
|
-
"multiple":
|
|
552
|
+
"multiple": false,
|
|
334
553
|
"required": true,
|
|
335
554
|
"types": [
|
|
336
555
|
{
|
|
337
|
-
"type": "
|
|
556
|
+
"type": "definition_name",
|
|
338
557
|
"named": true
|
|
339
558
|
}
|
|
340
559
|
]
|
|
341
560
|
}
|
|
342
561
|
},
|
|
562
|
+
{
|
|
563
|
+
"type": "type_field",
|
|
564
|
+
"named": true,
|
|
565
|
+
"fields": {
|
|
566
|
+
"name": {
|
|
567
|
+
"multiple": false,
|
|
568
|
+
"required": true,
|
|
569
|
+
"types": [
|
|
570
|
+
{
|
|
571
|
+
"type": "variable_name",
|
|
572
|
+
"named": true
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
},
|
|
576
|
+
"type": {
|
|
577
|
+
"multiple": false,
|
|
578
|
+
"required": true,
|
|
579
|
+
"types": [
|
|
580
|
+
{
|
|
581
|
+
"type": "type",
|
|
582
|
+
"named": true
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
},
|
|
343
588
|
{
|
|
344
589
|
"type": "url",
|
|
345
590
|
"named": true,
|
|
@@ -369,6 +614,10 @@
|
|
|
369
614
|
"type": ",",
|
|
370
615
|
"named": false
|
|
371
616
|
},
|
|
617
|
+
{
|
|
618
|
+
"type": ".",
|
|
619
|
+
"named": false
|
|
620
|
+
},
|
|
372
621
|
{
|
|
373
622
|
"type": "/",
|
|
374
623
|
"named": false
|
|
@@ -381,6 +630,10 @@
|
|
|
381
630
|
"type": "<",
|
|
382
631
|
"named": false
|
|
383
632
|
},
|
|
633
|
+
{
|
|
634
|
+
"type": "=>",
|
|
635
|
+
"named": false
|
|
636
|
+
},
|
|
384
637
|
{
|
|
385
638
|
"type": ">",
|
|
386
639
|
"named": false
|
|
@@ -389,6 +642,10 @@
|
|
|
389
642
|
"type": "?",
|
|
390
643
|
"named": false
|
|
391
644
|
},
|
|
645
|
+
{
|
|
646
|
+
"type": "@",
|
|
647
|
+
"named": false
|
|
648
|
+
},
|
|
392
649
|
{
|
|
393
650
|
"type": "\\u",
|
|
394
651
|
"named": false
|
|
@@ -425,6 +682,10 @@
|
|
|
425
682
|
"type": "float_literal",
|
|
426
683
|
"named": true
|
|
427
684
|
},
|
|
685
|
+
{
|
|
686
|
+
"type": "fun",
|
|
687
|
+
"named": false
|
|
688
|
+
},
|
|
428
689
|
{
|
|
429
690
|
"type": "hex_literal",
|
|
430
691
|
"named": true
|
|
@@ -445,12 +706,28 @@
|
|
|
445
706
|
"type": "package",
|
|
446
707
|
"named": false
|
|
447
708
|
},
|
|
709
|
+
{
|
|
710
|
+
"type": "trait",
|
|
711
|
+
"named": false
|
|
712
|
+
},
|
|
448
713
|
{
|
|
449
714
|
"type": "true",
|
|
450
715
|
"named": false
|
|
451
716
|
},
|
|
717
|
+
{
|
|
718
|
+
"type": "val",
|
|
719
|
+
"named": false
|
|
720
|
+
},
|
|
452
721
|
{
|
|
453
722
|
"type": "variable_name",
|
|
454
723
|
"named": true
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"type": "{",
|
|
727
|
+
"named": false
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"type": "}",
|
|
731
|
+
"named": false
|
|
455
732
|
}
|
|
456
733
|
]
|
src/scanner.cc
DELETED
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
#include <tree_sitter/parser.h>
|
|
2
|
-
#include <vector>
|
|
3
|
-
#include <cwctype>
|
|
4
|
-
#include <cstring>
|
|
5
|
-
#include <cassert>
|
|
6
|
-
#include <stdio.h>
|
|
7
|
-
namespace {
|
|
8
|
-
|
|
9
|
-
using std::vector;
|
|
10
|
-
using std::iswspace;
|
|
11
|
-
using std::memcpy;
|
|
12
|
-
|
|
13
|
-
enum TokenType {
|
|
14
|
-
NEWLINE,
|
|
15
|
-
INDENT,
|
|
16
|
-
DEDENT,
|
|
17
|
-
STRING_START,
|
|
18
|
-
STRING_CONTENT,
|
|
19
|
-
STRING_END,
|
|
20
|
-
COMMENT,
|
|
21
|
-
CLOSE_PAREN,
|
|
22
|
-
CLOSE_BRACKET,
|
|
23
|
-
CLOSE_BRACE,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
struct Delimiter {
|
|
27
|
-
enum {
|
|
28
|
-
SingleQuote = 1 << 0,
|
|
29
|
-
DoubleQuote = 1 << 1,
|
|
30
|
-
BackQuote = 1 << 2,
|
|
31
|
-
Raw = 1 << 3,
|
|
32
|
-
Format = 1 << 4,
|
|
33
|
-
Triple = 1 << 5,
|
|
34
|
-
Bytes = 1 << 6,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
Delimiter() : flags(0) {}
|
|
38
|
-
|
|
39
|
-
bool is_format() const {
|
|
40
|
-
return flags & Format;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
bool is_raw() const {
|
|
44
|
-
return flags & Raw;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
bool is_triple() const {
|
|
48
|
-
return flags & Triple;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
bool is_bytes() const {
|
|
52
|
-
return flags & Bytes;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
int32_t end_character() const {
|
|
56
|
-
if (flags & SingleQuote) return '\'';
|
|
57
|
-
if (flags & DoubleQuote) return '"';
|
|
58
|
-
if (flags & BackQuote) return '`';
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void set_format() {
|
|
63
|
-
flags |= Format;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
void set_raw() {
|
|
67
|
-
flags |= Raw;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
void set_triple() {
|
|
71
|
-
flags |= Triple;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
void set_bytes() {
|
|
75
|
-
flags |= Bytes;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
void set_end_character(int32_t character) {
|
|
79
|
-
switch (character) {
|
|
80
|
-
case '\'':
|
|
81
|
-
flags |= SingleQuote;
|
|
82
|
-
break;
|
|
83
|
-
case '"':
|
|
84
|
-
flags |= DoubleQuote;
|
|
85
|
-
break;
|
|
86
|
-
case '`':
|
|
87
|
-
flags |= BackQuote;
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
assert(false);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
char flags;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
struct Scanner {
|
|
98
|
-
Scanner() {
|
|
99
|
-
assert(sizeof(Delimiter) == sizeof(char));
|
|
100
|
-
deserialize(NULL, 0);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
unsigned serialize(char *buffer) {
|
|
104
|
-
size_t i = 0;
|
|
105
|
-
|
|
106
|
-
size_t delimiter_count = delimiter_stack.size();
|
|
107
|
-
if (delimiter_count > UINT8_MAX) delimiter_count = UINT8_MAX;
|
|
108
|
-
buffer[i++] = delimiter_count;
|
|
109
|
-
|
|
110
|
-
if (delimiter_count > 0) {
|
|
111
|
-
memcpy(&buffer[i], delimiter_stack.data(), delimiter_count);
|
|
112
|
-
}
|
|
113
|
-
i += delimiter_count;
|
|
114
|
-
|
|
115
|
-
vector<uint16_t>::iterator
|
|
116
|
-
iter = indent_length_stack.begin() + 1,
|
|
117
|
-
end = indent_length_stack.end();
|
|
118
|
-
|
|
119
|
-
for (; iter != end && i < TREE_SITTER_SERIALIZATION_BUFFER_SIZE; ++iter) {
|
|
120
|
-
buffer[i++] = *iter;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return i;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
void deserialize(const char *buffer, unsigned length) {
|
|
127
|
-
delimiter_stack.clear();
|
|
128
|
-
indent_length_stack.clear();
|
|
129
|
-
indent_length_stack.push_back(0);
|
|
130
|
-
|
|
131
|
-
if (length > 0) {
|
|
132
|
-
size_t i = 0;
|
|
133
|
-
|
|
134
|
-
size_t delimiter_count = (uint8_t)buffer[i++];
|
|
135
|
-
delimiter_stack.resize(delimiter_count);
|
|
136
|
-
if (delimiter_count > 0) {
|
|
137
|
-
memcpy(delimiter_stack.data(), &buffer[i], delimiter_count);
|
|
138
|
-
}
|
|
139
|
-
i += delimiter_count;
|
|
140
|
-
|
|
141
|
-
for (; i < length; i++) {
|
|
142
|
-
indent_length_stack.push_back(buffer[i]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
void advance(TSLexer *lexer) {
|
|
148
|
-
lexer->advance(lexer, false);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
void skip(TSLexer *lexer) {
|
|
152
|
-
lexer->advance(lexer, true);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
bool scan(TSLexer *lexer, const bool *valid_symbols) {
|
|
156
|
-
bool error_recovery_mode = valid_symbols[STRING_CONTENT] && valid_symbols[INDENT];
|
|
157
|
-
bool within_brackets = valid_symbols[CLOSE_BRACE] || valid_symbols[CLOSE_PAREN] || valid_symbols[CLOSE_BRACKET];
|
|
158
|
-
|
|
159
|
-
if (valid_symbols[STRING_CONTENT] && !delimiter_stack.empty() && !error_recovery_mode) {
|
|
160
|
-
Delimiter delimiter = delimiter_stack.back();
|
|
161
|
-
int32_t end_character = delimiter.end_character();
|
|
162
|
-
bool has_content = false;
|
|
163
|
-
while (lexer->lookahead) {
|
|
164
|
-
if ((lexer->lookahead == '{' || lexer->lookahead == '}') && delimiter.is_format()) {
|
|
165
|
-
lexer->mark_end(lexer);
|
|
166
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
167
|
-
return has_content;
|
|
168
|
-
} else if (lexer->lookahead == '\\') {
|
|
169
|
-
if (delimiter.is_raw()) {
|
|
170
|
-
lexer->advance(lexer, false);
|
|
171
|
-
} else if (delimiter.is_bytes()) {
|
|
172
|
-
lexer->mark_end(lexer);
|
|
173
|
-
lexer->advance(lexer, false);
|
|
174
|
-
if (lexer->lookahead == 'N' || lexer->lookahead == 'u' || lexer->lookahead == 'U') {
|
|
175
|
-
// In bytes string, \N{...}, \uXXXX and \UXXXXXXXX are not escape sequences
|
|
176
|
-
// https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
|
|
177
|
-
lexer->advance(lexer, false);
|
|
178
|
-
} else {
|
|
179
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
180
|
-
return has_content;
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
lexer->mark_end(lexer);
|
|
184
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
185
|
-
return has_content;
|
|
186
|
-
}
|
|
187
|
-
} else if (lexer->lookahead == end_character) {
|
|
188
|
-
if (delimiter.is_triple()) {
|
|
189
|
-
lexer->mark_end(lexer);
|
|
190
|
-
lexer->advance(lexer, false);
|
|
191
|
-
if (lexer->lookahead == end_character) {
|
|
192
|
-
lexer->advance(lexer, false);
|
|
193
|
-
if (lexer->lookahead == end_character) {
|
|
194
|
-
if (has_content) {
|
|
195
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
196
|
-
} else {
|
|
197
|
-
lexer->advance(lexer, false);
|
|
198
|
-
lexer->mark_end(lexer);
|
|
199
|
-
delimiter_stack.pop_back();
|
|
200
|
-
lexer->result_symbol = STRING_END;
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
203
|
-
} else {
|
|
204
|
-
lexer->mark_end(lexer);
|
|
205
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
lexer->mark_end(lexer);
|
|
210
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
if (has_content) {
|
|
215
|
-
lexer->result_symbol = STRING_CONTENT;
|
|
216
|
-
} else {
|
|
217
|
-
lexer->advance(lexer, false);
|
|
218
|
-
delimiter_stack.pop_back();
|
|
219
|
-
lexer->result_symbol = STRING_END;
|
|
220
|
-
}
|
|
221
|
-
lexer->mark_end(lexer);
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
} else if (lexer->lookahead == '\n' && has_content && !delimiter.is_triple()) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
advance(lexer);
|
|
228
|
-
has_content = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
lexer->mark_end(lexer);
|
|
233
|
-
|
|
234
|
-
bool found_end_of_line = false;
|
|
235
|
-
uint32_t indent_length = 0;
|
|
236
|
-
int32_t first_comment_indent_length = -1;
|
|
237
|
-
for (;;) {
|
|
238
|
-
if (lexer->lookahead == '\n') {
|
|
239
|
-
found_end_of_line = true;
|
|
240
|
-
indent_length = 0;
|
|
241
|
-
skip(lexer);
|
|
242
|
-
} else if (lexer->lookahead == ' ') {
|
|
243
|
-
indent_length++;
|
|
244
|
-
skip(lexer);
|
|
245
|
-
} else if (lexer->lookahead == '\r') {
|
|
246
|
-
indent_length = 0;
|
|
247
|
-
skip(lexer);
|
|
248
|
-
} else if (lexer->lookahead == '\t') {
|
|
249
|
-
indent_length += 8;
|
|
250
|
-
skip(lexer);
|
|
251
|
-
} else if (lexer->lookahead == '#') {
|
|
252
|
-
if (first_comment_indent_length == -1) {
|
|
253
|
-
first_comment_indent_length = (int32_t)indent_length;
|
|
254
|
-
}
|
|
255
|
-
while (lexer->lookahead && lexer->lookahead != '\n') {
|
|
256
|
-
skip(lexer);
|
|
257
|
-
}
|
|
258
|
-
skip(lexer);
|
|
259
|
-
indent_length = 0;
|
|
260
|
-
} else if (lexer->lookahead == '\\') {
|
|
261
|
-
skip(lexer);
|
|
262
|
-
if (lexer->lookahead == '\r') {
|
|
263
|
-
skip(lexer);
|
|
264
|
-
}
|
|
265
|
-
if (lexer->lookahead == '\n') {
|
|
266
|
-
skip(lexer);
|
|
267
|
-
} else {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
} else if (lexer->lookahead == '\f') {
|
|
271
|
-
indent_length = 0;
|
|
272
|
-
skip(lexer);
|
|
273
|
-
} else if (lexer->lookahead == 0) {
|
|
274
|
-
indent_length = 0;
|
|
275
|
-
found_end_of_line = true;
|
|
276
|
-
break;
|
|
277
|
-
} else {
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (found_end_of_line) {
|
|
283
|
-
if (!indent_length_stack.empty()) {
|
|
284
|
-
uint16_t current_indent_length = indent_length_stack.back();
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
valid_symbols[INDENT] &&
|
|
288
|
-
indent_length > current_indent_length
|
|
289
|
-
) {
|
|
290
|
-
indent_length_stack.push_back(indent_length);
|
|
291
|
-
lexer->result_symbol = INDENT;
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
(valid_symbols[DEDENT] || (!valid_symbols[NEWLINE] && !within_brackets)) &&
|
|
297
|
-
indent_length < current_indent_length &&
|
|
298
|
-
|
|
299
|
-
// Wait to create a dedent token until we've consumed any comments
|
|
300
|
-
// whose indentation matches the current block.
|
|
301
|
-
first_comment_indent_length < (int32_t)current_indent_length
|
|
302
|
-
) {
|
|
303
|
-
indent_length_stack.pop_back();
|
|
304
|
-
lexer->result_symbol = DEDENT;
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (valid_symbols[NEWLINE] && !error_recovery_mode) {
|
|
310
|
-
lexer->result_symbol = NEWLINE;
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if (first_comment_indent_length == -1 && valid_symbols[STRING_START]) {
|
|
316
|
-
Delimiter delimiter;
|
|
317
|
-
|
|
318
|
-
bool has_flags = false;
|
|
319
|
-
while (lexer->lookahead) {
|
|
320
|
-
if (lexer->lookahead == 'f' || lexer->lookahead == 'F') {
|
|
321
|
-
delimiter.set_format();
|
|
322
|
-
} else if (lexer->lookahead == 'r' || lexer->lookahead == 'R') {
|
|
323
|
-
delimiter.set_raw();
|
|
324
|
-
} else if (lexer->lookahead == 'b' || lexer->lookahead == 'B') {
|
|
325
|
-
delimiter.set_bytes();
|
|
326
|
-
} else if (lexer->lookahead != 'u' && lexer->lookahead != 'U') {
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
has_flags = true;
|
|
330
|
-
advance(lexer);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (lexer->lookahead == '`') {
|
|
334
|
-
delimiter.set_end_character('`');
|
|
335
|
-
advance(lexer);
|
|
336
|
-
lexer->mark_end(lexer);
|
|
337
|
-
} else if (lexer->lookahead == '\'') {
|
|
338
|
-
delimiter.set_end_character('\'');
|
|
339
|
-
advance(lexer);
|
|
340
|
-
lexer->mark_end(lexer);
|
|
341
|
-
if (lexer->lookahead == '\'') {
|
|
342
|
-
advance(lexer);
|
|
343
|
-
if (lexer->lookahead == '\'') {
|
|
344
|
-
advance(lexer);
|
|
345
|
-
lexer->mark_end(lexer);
|
|
346
|
-
delimiter.set_triple();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
} else if (lexer->lookahead == '"') {
|
|
350
|
-
delimiter.set_end_character('"');
|
|
351
|
-
advance(lexer);
|
|
352
|
-
lexer->mark_end(lexer);
|
|
353
|
-
if (lexer->lookahead == '"') {
|
|
354
|
-
advance(lexer);
|
|
355
|
-
if (lexer->lookahead == '"') {
|
|
356
|
-
advance(lexer);
|
|
357
|
-
lexer->mark_end(lexer);
|
|
358
|
-
delimiter.set_triple();
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (delimiter.end_character()) {
|
|
364
|
-
delimiter_stack.push_back(delimiter);
|
|
365
|
-
lexer->result_symbol = STRING_START;
|
|
366
|
-
return true;
|
|
367
|
-
} else if (has_flags) {
|
|
368
|
-
return false;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
vector<uint16_t> indent_length_stack;
|
|
376
|
-
vector<Delimiter> delimiter_stack;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
extern "C" {
|
|
382
|
-
|
|
383
|
-
void *tree_sitter_pine_external_scanner_create() {
|
|
384
|
-
return new Scanner();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
bool tree_sitter_pine_external_scanner_scan(void *payload, TSLexer *lexer,
|
|
388
|
-
const bool *valid_symbols) {
|
|
389
|
-
Scanner *scanner = static_cast<Scanner *>(payload);
|
|
390
|
-
return scanner->scan(lexer, valid_symbols);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
unsigned tree_sitter_pine_external_scanner_serialize(void *payload, char *buffer) {
|
|
394
|
-
Scanner *scanner = static_cast<Scanner *>(payload);
|
|
395
|
-
return scanner->serialize(buffer);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
void tree_sitter_pine_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {
|
|
399
|
-
Scanner *scanner = static_cast<Scanner *>(payload);
|
|
400
|
-
scanner->deserialize(buffer, length);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
void tree_sitter_pine_external_scanner_destroy(void *payload) {
|
|
404
|
-
Scanner *scanner = static_cast<Scanner *>(payload);
|
|
405
|
-
delete scanner;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
}
|
test/corpus/class_definitions.txt
CHANGED
|
@@ -4,30 +4,32 @@ Class definitions - Simple
|
|
|
4
4
|
|
|
5
5
|
package definitions
|
|
6
6
|
|
|
7
|
-
class AnimalStrong
|
|
7
|
+
class AnimalStrong(
|
|
8
|
-
count: String
|
|
8
|
+
val count: String,
|
|
9
|
-
userName: Int
|
|
9
|
+
val userName: Int,
|
|
10
|
-
currentAddress: Address
|
|
10
|
+
val currentAddress: Address
|
|
11
|
+
)
|
|
11
12
|
|
|
12
13
|
--------------------------------------------------------------------------------
|
|
13
14
|
|
|
14
15
|
(source_file
|
|
15
16
|
(package
|
|
16
17
|
(identifier))
|
|
18
|
+
(definitions
|
|
17
|
-
|
|
19
|
+
(class_definition
|
|
18
|
-
|
|
20
|
+
(definition_name)
|
|
19
|
-
|
|
21
|
+
(type_field
|
|
20
|
-
|
|
22
|
+
(variable_name)
|
|
21
|
-
|
|
23
|
+
(type
|
|
22
|
-
|
|
24
|
+
(definition_name)))
|
|
23
|
-
|
|
25
|
+
(type_field
|
|
24
|
-
|
|
26
|
+
(variable_name)
|
|
25
|
-
|
|
27
|
+
(type
|
|
26
|
-
|
|
28
|
+
(definition_name)))
|
|
27
|
-
|
|
29
|
+
(type_field
|
|
28
|
-
|
|
30
|
+
(variable_name)
|
|
29
|
-
|
|
31
|
+
(type
|
|
30
|
-
|
|
32
|
+
(definition_name))))))
|
|
31
33
|
|
|
32
34
|
================================================================================
|
|
33
35
|
Class definitions - Generic
|
|
@@ -35,28 +37,30 @@ Class definitions - Generic
|
|
|
35
37
|
|
|
36
38
|
package definitions
|
|
37
39
|
|
|
38
|
-
class Bat<S, T>
|
|
40
|
+
class Bat<S, T>(
|
|
39
|
-
a: S
|
|
41
|
+
val a: S,
|
|
40
|
-
b: T
|
|
42
|
+
val b: T
|
|
43
|
+
)
|
|
41
44
|
|
|
42
45
|
--------------------------------------------------------------------------------
|
|
43
46
|
|
|
44
47
|
(source_file
|
|
45
48
|
(package
|
|
46
49
|
(identifier))
|
|
50
|
+
(definitions
|
|
47
|
-
|
|
51
|
+
(class_definition
|
|
48
|
-
|
|
52
|
+
(definition_name)
|
|
49
|
-
|
|
53
|
+
(generic_list
|
|
50
|
-
|
|
54
|
+
(identifier)
|
|
51
|
-
|
|
55
|
+
(identifier))
|
|
52
|
-
|
|
56
|
+
(type_field
|
|
53
|
-
|
|
57
|
+
(variable_name)
|
|
54
|
-
|
|
58
|
+
(type
|
|
55
|
-
|
|
59
|
+
(definition_name)))
|
|
56
|
-
|
|
60
|
+
(type_field
|
|
57
|
-
|
|
61
|
+
(variable_name)
|
|
58
|
-
|
|
62
|
+
(type
|
|
59
|
-
|
|
63
|
+
(definition_name))))))
|
|
60
64
|
|
|
61
65
|
================================================================================
|
|
62
66
|
Class definitions - Traits
|
|
@@ -64,28 +68,32 @@ Class definitions - Traits
|
|
|
64
68
|
|
|
65
69
|
package definitions
|
|
66
70
|
|
|
71
|
+
@B @C
|
|
67
|
-
class AnimalSubSpecies
|
|
72
|
+
class AnimalSubSpecies (
|
|
68
|
-
a: String
|
|
73
|
+
val a: String,
|
|
69
|
-
b: Float
|
|
74
|
+
val b: Float
|
|
75
|
+
)
|
|
70
76
|
|
|
71
77
|
--------------------------------------------------------------------------------
|
|
72
78
|
|
|
73
79
|
(source_file
|
|
74
80
|
(package
|
|
75
81
|
(identifier))
|
|
82
|
+
(definitions
|
|
76
|
-
|
|
83
|
+
(class_definition
|
|
84
|
+
(trait_name
|
|
85
|
+
(definition_name))
|
|
86
|
+
(trait_name
|
|
87
|
+
(definition_name))
|
|
77
|
-
|
|
88
|
+
(definition_name)
|
|
78
|
-
(trait_list
|
|
79
|
-
(identifier)
|
|
80
|
-
(identifier))
|
|
81
|
-
|
|
89
|
+
(type_field
|
|
82
|
-
|
|
90
|
+
(variable_name)
|
|
83
|
-
|
|
91
|
+
(type
|
|
84
|
-
|
|
92
|
+
(definition_name)))
|
|
85
|
-
|
|
93
|
+
(type_field
|
|
86
|
-
|
|
94
|
+
(variable_name)
|
|
87
|
-
|
|
95
|
+
(type
|
|
88
|
-
|
|
96
|
+
(definition_name))))))
|
|
89
97
|
|
|
90
98
|
================================================================================
|
|
91
99
|
Class definitions - Genrics + Traits
|
|
@@ -93,28 +101,32 @@ Class definitions - Genrics + Traits
|
|
|
93
101
|
|
|
94
102
|
package definitions
|
|
95
103
|
|
|
104
|
+
@B @C
|
|
96
|
-
class A<S, T>(
|
|
105
|
+
class A<S, T>(
|
|
97
|
-
a: S
|
|
106
|
+
val a: S,
|
|
98
|
-
b: T
|
|
107
|
+
val b: T
|
|
108
|
+
)
|
|
99
109
|
|
|
100
110
|
--------------------------------------------------------------------------------
|
|
101
111
|
|
|
102
112
|
(source_file
|
|
103
113
|
(package
|
|
104
114
|
(identifier))
|
|
115
|
+
(definitions
|
|
105
|
-
|
|
116
|
+
(class_definition
|
|
117
|
+
(trait_name
|
|
118
|
+
(definition_name))
|
|
119
|
+
(trait_name
|
|
120
|
+
(definition_name))
|
|
106
|
-
|
|
121
|
+
(definition_name)
|
|
107
|
-
|
|
122
|
+
(generic_list
|
|
108
|
-
|
|
123
|
+
(identifier)
|
|
109
|
-
|
|
124
|
+
(identifier))
|
|
110
|
-
(trait_list
|
|
111
|
-
(identifier)
|
|
112
|
-
(identifier))
|
|
113
|
-
|
|
125
|
+
(type_field
|
|
114
|
-
|
|
126
|
+
(variable_name)
|
|
115
|
-
|
|
127
|
+
(type
|
|
116
|
-
|
|
128
|
+
(definition_name)))
|
|
117
|
-
|
|
129
|
+
(type_field
|
|
118
|
-
|
|
130
|
+
(variable_name)
|
|
119
|
-
|
|
131
|
+
(type
|
|
120
|
-
|
|
132
|
+
(definition_name))))))
|
test/corpus/enum_definitions.txt
CHANGED
|
@@ -4,29 +4,33 @@ Enum definitions - Int
|
|
|
4
4
|
|
|
5
5
|
package definitions
|
|
6
6
|
|
|
7
|
-
enum Colors(Int)
|
|
7
|
+
enum Colors(val rgb: Int) {
|
|
8
|
-
RED(0xFF0000)
|
|
8
|
+
RED(0xFF0000),
|
|
9
|
-
GREEN(0x00FF00)
|
|
9
|
+
GREEN(0x00FF00),
|
|
10
10
|
BLUE(0x0000FF)
|
|
11
|
+
}
|
|
11
12
|
|
|
12
13
|
--------------------------------------------------------------------------------
|
|
13
14
|
|
|
14
15
|
(source_file
|
|
15
16
|
(package
|
|
16
17
|
(identifier))
|
|
18
|
+
(definitions
|
|
17
|
-
|
|
19
|
+
(enum_definition
|
|
18
|
-
|
|
20
|
+
(definition_name)
|
|
19
|
-
|
|
21
|
+
(type_field
|
|
22
|
+
(variable_name)
|
|
23
|
+
(type
|
|
20
|
-
|
|
24
|
+
(definition_name)))
|
|
21
|
-
|
|
25
|
+
(enum_field
|
|
22
|
-
|
|
26
|
+
(enum_field_name)
|
|
23
|
-
|
|
27
|
+
(hex_literal))
|
|
24
|
-
|
|
28
|
+
(enum_field
|
|
25
|
-
|
|
29
|
+
(enum_field_name)
|
|
26
|
-
|
|
30
|
+
(hex_literal))
|
|
27
|
-
|
|
31
|
+
(enum_field
|
|
28
|
-
|
|
32
|
+
(enum_field_name)
|
|
29
|
-
|
|
33
|
+
(hex_literal)))))
|
|
30
34
|
|
|
31
35
|
================================================================================
|
|
32
36
|
Enum definitions - Float
|
|
@@ -34,33 +38,40 @@ Enum definitions - Float
|
|
|
34
38
|
|
|
35
39
|
package definitions
|
|
36
40
|
|
|
37
|
-
enum ColorsAlpha(Int, Float)
|
|
41
|
+
enum ColorsAlpha(val a: Int, val b: Float) {
|
|
38
|
-
RED(1, 0.1)
|
|
42
|
+
RED(1, 0.1),
|
|
39
|
-
GREEN(2, 0.2)
|
|
43
|
+
GREEN(2, 0.2),
|
|
40
44
|
BLUE(3, 0.3)
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
--------------------------------------------------------------------------------
|
|
43
48
|
|
|
44
49
|
(source_file
|
|
45
50
|
(package
|
|
46
51
|
(identifier))
|
|
52
|
+
(definitions
|
|
47
|
-
|
|
53
|
+
(enum_definition
|
|
48
|
-
|
|
54
|
+
(definition_name)
|
|
49
|
-
|
|
55
|
+
(type_field
|
|
50
|
-
|
|
56
|
+
(variable_name)
|
|
57
|
+
(type
|
|
51
|
-
|
|
58
|
+
(definition_name)))
|
|
59
|
+
(type_field
|
|
60
|
+
(variable_name)
|
|
61
|
+
(type
|
|
62
|
+
(definition_name)))
|
|
52
|
-
|
|
63
|
+
(enum_field
|
|
53
|
-
|
|
64
|
+
(enum_field_name)
|
|
54
|
-
|
|
65
|
+
(integer_literal)
|
|
55
|
-
|
|
66
|
+
(float_literal))
|
|
56
|
-
|
|
67
|
+
(enum_field
|
|
57
|
-
|
|
68
|
+
(enum_field_name)
|
|
58
|
-
|
|
69
|
+
(integer_literal)
|
|
59
|
-
|
|
70
|
+
(float_literal))
|
|
60
|
-
|
|
71
|
+
(enum_field
|
|
61
|
-
|
|
72
|
+
(enum_field_name)
|
|
62
|
-
|
|
73
|
+
(integer_literal)
|
|
63
|
-
|
|
74
|
+
(float_literal)))))
|
|
64
75
|
|
|
65
76
|
================================================================================
|
|
66
77
|
Enum definitions - String
|
|
@@ -68,30 +79,37 @@ Enum definitions - String
|
|
|
68
79
|
|
|
69
80
|
package definitions
|
|
70
81
|
|
|
71
|
-
enum ColorsAlpha(Int, String)
|
|
82
|
+
enum ColorsAlpha(val a: Int, val b: String) {
|
|
72
|
-
RED(1, "1")
|
|
83
|
+
RED(1, "1"),
|
|
73
|
-
GREEN(2, "2")
|
|
84
|
+
GREEN(2, "2"),
|
|
74
85
|
BLUE(3, "3")
|
|
86
|
+
}
|
|
75
87
|
|
|
76
88
|
--------------------------------------------------------------------------------
|
|
77
89
|
|
|
78
90
|
(source_file
|
|
79
91
|
(package
|
|
80
92
|
(identifier))
|
|
93
|
+
(definitions
|
|
81
|
-
|
|
94
|
+
(enum_definition
|
|
82
|
-
|
|
95
|
+
(definition_name)
|
|
83
|
-
|
|
96
|
+
(type_field
|
|
84
|
-
|
|
97
|
+
(variable_name)
|
|
98
|
+
(type
|
|
85
|
-
|
|
99
|
+
(definition_name)))
|
|
100
|
+
(type_field
|
|
101
|
+
(variable_name)
|
|
102
|
+
(type
|
|
103
|
+
(definition_name)))
|
|
86
|
-
|
|
104
|
+
(enum_field
|
|
87
|
-
|
|
105
|
+
(enum_field_name)
|
|
88
|
-
|
|
106
|
+
(integer_literal)
|
|
89
|
-
|
|
107
|
+
(line_string_literal))
|
|
90
|
-
|
|
108
|
+
(enum_field
|
|
91
|
-
|
|
109
|
+
(enum_field_name)
|
|
92
|
-
|
|
110
|
+
(integer_literal)
|
|
93
|
-
|
|
111
|
+
(line_string_literal))
|
|
94
|
-
|
|
112
|
+
(enum_field
|
|
95
|
-
|
|
113
|
+
(enum_field_name)
|
|
96
|
-
|
|
114
|
+
(integer_literal)
|
|
97
|
-
|
|
115
|
+
(line_string_literal)))))
|
test/corpus/functions.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
Functions - Simple
|
|
3
|
+
================================================================================
|
|
4
|
+
|
|
5
|
+
package definitions
|
|
6
|
+
|
|
7
|
+
fun main() => {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
--------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
(source_file
|
|
13
|
+
(package
|
|
14
|
+
(identifier))
|
|
15
|
+
(definitions
|
|
16
|
+
(fun_definition
|
|
17
|
+
(identifier))))
|
|
18
|
+
|
|
19
|
+
================================================================================
|
|
20
|
+
Functions - Extension
|
|
21
|
+
================================================================================
|
|
22
|
+
|
|
23
|
+
package definitions
|
|
24
|
+
|
|
25
|
+
fun User.main() => {
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
--------------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
(source_file
|
|
31
|
+
(package
|
|
32
|
+
(identifier))
|
|
33
|
+
(definitions
|
|
34
|
+
(fun_definition
|
|
35
|
+
(identifier)
|
|
36
|
+
(identifier))))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
================================================================================
|
|
40
|
+
Functions - Return
|
|
41
|
+
================================================================================
|
|
42
|
+
|
|
43
|
+
package definitions
|
|
44
|
+
|
|
45
|
+
fun add(a: Int, b: Int) => Int {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
--------------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
(source_file
|
|
51
|
+
(package
|
|
52
|
+
(identifier))
|
|
53
|
+
(definitions
|
|
54
|
+
(fun_definition
|
|
55
|
+
(identifier)
|
|
56
|
+
(param
|
|
57
|
+
(variable_name)
|
|
58
|
+
(type
|
|
59
|
+
(definition_name)))
|
|
60
|
+
(param
|
|
61
|
+
(variable_name)
|
|
62
|
+
(type
|
|
63
|
+
(definition_name)))
|
|
64
|
+
(type
|
|
65
|
+
(definition_name)))))
|
|
66
|
+
|
|
67
|
+
================================================================================
|
|
68
|
+
Functions - High Order 1
|
|
69
|
+
================================================================================
|
|
70
|
+
|
|
71
|
+
package definitions
|
|
72
|
+
|
|
73
|
+
fun add(a: Int, b: Int): () -> Unit
|
|
74
|
+
return {
|
|
75
|
+
println("A + B")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
--------------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
(source_file
|
|
81
|
+
(package
|
|
82
|
+
(identifier))
|
|
83
|
+
|
|
84
|
+
================================================================================
|
|
85
|
+
Functions - High Order 2
|
|
86
|
+
================================================================================
|
|
87
|
+
|
|
88
|
+
package definitions
|
|
89
|
+
|
|
90
|
+
fun add(a: Int, b: () -> Unit): () -> Unit =>
|
|
91
|
+
return {
|
|
92
|
+
b()
|
|
93
|
+
println("A + B")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
--------------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
(source_file
|
|
99
|
+
(package
|
|
100
|
+
(identifier))
|
test/corpus/traits.txt
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
Traits - Simple
|
|
3
|
+
================================================================================
|
|
4
|
+
|
|
5
|
+
package definitions
|
|
6
|
+
|
|
7
|
+
trait Animal(
|
|
8
|
+
val name: String,
|
|
9
|
+
fun legs() => Int
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
--------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
(source_file
|
|
15
|
+
(package
|
|
16
|
+
(identifier))
|
|
17
|
+
(definitions
|
|
18
|
+
(trait_definition
|
|
19
|
+
(definition_name)
|
|
20
|
+
(trait_field
|
|
21
|
+
(type_field
|
|
22
|
+
(variable_name)
|
|
23
|
+
(type
|
|
24
|
+
(definition_name))))
|
|
25
|
+
(trait_field
|
|
26
|
+
(fun_field
|
|
27
|
+
(identifier)
|
|
28
|
+
(type
|
|
29
|
+
(definition_name)))))))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
================================================================================
|
|
33
|
+
Traits - Generics
|
|
34
|
+
================================================================================
|
|
35
|
+
|
|
36
|
+
package definitions
|
|
37
|
+
|
|
38
|
+
trait Shape<T>(
|
|
39
|
+
val name: T,
|
|
40
|
+
fun area(size: Float) => T
|
|
41
|
+
)
|
|
42
|
+
--------------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
(source_file
|
|
45
|
+
(package
|
|
46
|
+
(identifier))
|
|
47
|
+
(definitions
|
|
48
|
+
(trait_definition
|
|
49
|
+
(definition_name)
|
|
50
|
+
(generic_list
|
|
51
|
+
(identifier))
|
|
52
|
+
(trait_field
|
|
53
|
+
(type_field
|
|
54
|
+
(variable_name)
|
|
55
|
+
(type
|
|
56
|
+
(definition_name))))
|
|
57
|
+
(trait_field
|
|
58
|
+
(fun_field
|
|
59
|
+
(identifier)
|
|
60
|
+
(param
|
|
61
|
+
(variable_name)
|
|
62
|
+
(type
|
|
63
|
+
(definition_name)))
|
|
64
|
+
(type
|
|
65
|
+
(definition_name)))))))
|