plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
12ed161
— Peter John
2022-11-07T23:07:50+05:30
add enums
Generated files not shown: src/parser.c
- grammar.js +113 -11
- src/grammar.json +737 -91
- src/node-types.json +286 -40
- test/corpus/class_definitions.txt +13 -9
- test/corpus/enum_definitions.txt +97 -0
- test/corpus/import_statements.txt +6 -4
grammar.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const DEC_DIGITS = token(sep1(/[0-9]+/, /_+/));
|
|
2
|
+
const HEX_DIGITS = token(sep1(/[0-9a-fA-F]+/, /_+/));
|
|
3
|
+
const BIN_DIGITS = token(sep1(/[01]/, /_+/));
|
|
4
|
+
|
|
1
5
|
module.exports = grammar({
|
|
2
6
|
name: 'pine',
|
|
3
7
|
externals: $ => [
|
|
@@ -22,16 +26,18 @@ module.exports = grammar({
|
|
|
22
26
|
'}',
|
|
23
27
|
],
|
|
24
28
|
rules: {
|
|
25
|
-
module: $ => repeat($._definitions),
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
source_file: $ => seq(
|
|
30
|
+
seq("package", $.package),
|
|
28
|
-
$.import_statement,
|
|
31
|
+
repeat($.import_statement),
|
|
29
|
-
$.class_definition,
|
|
32
|
+
repeat($.class_definition),
|
|
33
|
+
repeat($.enum_definition),
|
|
30
34
|
),
|
|
31
35
|
|
|
32
|
-
import_statement: $ => seq(
|
|
36
|
+
import_statement: $ => seq('import', $.url),
|
|
37
|
+
|
|
38
|
+
definitions: $ => choice(
|
|
33
|
-
|
|
39
|
+
$.class_definition,
|
|
34
|
-
|
|
40
|
+
$.enum_definition,
|
|
35
41
|
),
|
|
36
42
|
|
|
37
43
|
class_definition: $ => seq(
|
|
@@ -41,11 +47,28 @@ module.exports = grammar({
|
|
|
41
47
|
field('traits', optional($.trait_list)),
|
|
42
48
|
':',
|
|
43
49
|
field('fields', seq($._indent, seq(
|
|
44
|
-
repeat($.
|
|
50
|
+
repeat($.class_field),
|
|
45
51
|
$._dedent
|
|
46
52
|
))),
|
|
47
53
|
),
|
|
48
54
|
|
|
55
|
+
enum_definition: $ => seq(
|
|
56
|
+
'enum',
|
|
57
|
+
field('name', $.identifier),
|
|
58
|
+
field('types', $.type_list),
|
|
59
|
+
':',
|
|
60
|
+
field('fields', seq($._indent, seq(
|
|
61
|
+
repeat($.enum_field),
|
|
62
|
+
$._dedent
|
|
63
|
+
))),
|
|
64
|
+
),
|
|
65
|
+
|
|
66
|
+
type_list: $ => seq(
|
|
67
|
+
'(',
|
|
68
|
+
commaSep1($.identifier),
|
|
69
|
+
')'
|
|
70
|
+
),
|
|
71
|
+
|
|
49
72
|
trait_list: $ => seq(
|
|
50
73
|
'(',
|
|
51
74
|
commaSep1($.identifier),
|
|
@@ -58,13 +81,92 @@ module.exports = grammar({
|
|
|
58
81
|
'>'
|
|
59
82
|
),
|
|
60
83
|
|
|
61
|
-
|
|
84
|
+
class_field: $ => seq(
|
|
62
85
|
field('key', $.identifier),
|
|
63
86
|
':',
|
|
64
87
|
field('value', $.identifier)
|
|
65
88
|
),
|
|
66
89
|
|
|
90
|
+
enum_field: $ => seq($.enum_identifier, '(', commaSep1($._primary_expression), ')'),
|
|
91
|
+
|
|
92
|
+
_primary_expression: $ => choice(
|
|
93
|
+
$._literal_constant,
|
|
94
|
+
$._string_literal,
|
|
95
|
+
),
|
|
96
|
+
|
|
97
|
+
url: $ => sep1(/[a-zA-Z_][a-zA-Z_0-9]*/, '/'),
|
|
98
|
+
package: $ => $.identifier,
|
|
67
|
-
identifier: $ => /[
|
|
99
|
+
identifier: $ => /[a-zA-Z_][a-zA-Z_0-9]*/,
|
|
100
|
+
enum_identifier: $ => /[A-Z_][A-Z_0-9]*/,
|
|
101
|
+
|
|
102
|
+
// Literals
|
|
103
|
+
boolean_literal: $ => choice("true", "false"),
|
|
104
|
+
integer_literal: $ => token(seq(optional(/[1-9]/), DEC_DIGITS)),
|
|
105
|
+
hex_literal: $ => token(seq("0", /[xX]/, HEX_DIGITS)),
|
|
106
|
+
bin_literal: $ => token(seq("0", /[bB]/, BIN_DIGITS)),
|
|
107
|
+
float_literal: $ => token(choice(
|
|
108
|
+
seq(
|
|
109
|
+
seq(optional(DEC_DIGITS), ".", DEC_DIGITS),
|
|
110
|
+
optional(/[fF]/)
|
|
111
|
+
),
|
|
112
|
+
seq(DEC_DIGITS, /[fF]/)
|
|
113
|
+
)),
|
|
114
|
+
character_literal: $ => seq(
|
|
115
|
+
"'",
|
|
116
|
+
choice($.character_escape_seq, /[^\n\r'\\]/),
|
|
117
|
+
"'"
|
|
118
|
+
),
|
|
119
|
+
character_escape_seq: $ => choice(
|
|
120
|
+
$._uni_character_literal,
|
|
121
|
+
$._escaped_identifier
|
|
122
|
+
),
|
|
123
|
+
_uni_character_literal: $ => seq(
|
|
124
|
+
"\\u",
|
|
125
|
+
/[0-9a-fA-F]{4}/
|
|
126
|
+
),
|
|
127
|
+
_escaped_identifier: $ => /\\[tbrn'"\\$]/,
|
|
128
|
+
|
|
129
|
+
_string_literal: $ => choice(
|
|
130
|
+
$.line_string_literal,
|
|
131
|
+
$.multi_line_string_literal
|
|
132
|
+
),
|
|
133
|
+
|
|
134
|
+
line_string_literal: $ => seq('"', repeat(choice($._line_string_content, $._interpolation)), '"'),
|
|
135
|
+
|
|
136
|
+
multi_line_string_literal: $ => seq(
|
|
137
|
+
'`',
|
|
138
|
+
repeat(choice(
|
|
139
|
+
$._multi_line_string_content,
|
|
140
|
+
$._interpolation
|
|
141
|
+
)),
|
|
142
|
+
'`'
|
|
143
|
+
),
|
|
144
|
+
|
|
145
|
+
_line_string_content: $ => choice(
|
|
146
|
+
$._line_str_text,
|
|
147
|
+
$.character_escape_seq
|
|
148
|
+
),
|
|
149
|
+
|
|
150
|
+
_multi_line_string_content: $ => choice($._multi_line_str_text, '"'),
|
|
151
|
+
|
|
152
|
+
_line_str_text: $ => /[^\\"$]+/,
|
|
153
|
+
|
|
154
|
+
_multi_line_str_text: $ => /[^"$]+/,
|
|
155
|
+
|
|
156
|
+
_interpolation: $ => choice(
|
|
157
|
+
// seq("${", alias($._expression, $.interpolated_expression), "}"),
|
|
158
|
+
seq("$", alias($.identifier, $.interpolated_identifier))
|
|
159
|
+
),
|
|
160
|
+
|
|
161
|
+
_literal_constant: $ => choice(
|
|
162
|
+
$.boolean_literal,
|
|
163
|
+
$.integer_literal,
|
|
164
|
+
$.hex_literal,
|
|
165
|
+
$.bin_literal,
|
|
166
|
+
$.character_literal,
|
|
167
|
+
$.float_literal,
|
|
168
|
+
"null",
|
|
169
|
+
),
|
|
68
170
|
}
|
|
69
171
|
});
|
|
70
172
|
|
src/grammar.json
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pine",
|
|
3
3
|
"rules": {
|
|
4
|
-
"
|
|
4
|
+
"source_file": {
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "SEQ",
|
|
6
|
-
"content": {
|
|
7
|
-
"type": "SYMBOL",
|
|
8
|
-
"name": "_definitions"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"_definitions": {
|
|
12
|
-
"type": "CHOICE",
|
|
13
6
|
"members": [
|
|
14
7
|
{
|
|
8
|
+
"type": "SEQ",
|
|
9
|
+
"members": [
|
|
10
|
+
{
|
|
11
|
+
"type": "STRING",
|
|
12
|
+
"value": "package"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
-
|
|
15
|
+
"type": "SYMBOL",
|
|
16
|
-
|
|
16
|
+
"name": "package"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
17
19
|
},
|
|
18
20
|
{
|
|
21
|
+
"type": "REPEAT",
|
|
22
|
+
"content": {
|
|
19
|
-
|
|
23
|
+
"type": "SYMBOL",
|
|
24
|
+
"name": "import_statement"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "REPEAT",
|
|
29
|
+
"content": {
|
|
30
|
+
"type": "SYMBOL",
|
|
20
|
-
|
|
31
|
+
"name": "class_definition"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "REPEAT",
|
|
36
|
+
"content": {
|
|
37
|
+
"type": "SYMBOL",
|
|
38
|
+
"name": "enum_definition"
|
|
39
|
+
}
|
|
21
40
|
}
|
|
22
41
|
]
|
|
23
42
|
},
|
|
@@ -29,79 +48,21 @@
|
|
|
29
48
|
"value": "import"
|
|
30
49
|
},
|
|
31
50
|
{
|
|
32
|
-
"type": "
|
|
51
|
+
"type": "SYMBOL",
|
|
52
|
+
"name": "url"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"definitions": {
|
|
57
|
+
"type": "CHOICE",
|
|
33
|
-
|
|
58
|
+
"members": [
|
|
34
|
-
|
|
59
|
+
{
|
|
35
|
-
"type": "FIELD",
|
|
36
|
-
"name": "name",
|
|
37
|
-
"content": {
|
|
38
|
-
|
|
60
|
+
"type": "SYMBOL",
|
|
39
|
-
|
|
61
|
+
"name": "class_definition"
|
|
62
|
+
},
|
|
40
|
-
|
|
63
|
+
{
|
|
41
|
-
|
|
64
|
+
"type": "SYMBOL",
|
|
42
|
-
|
|
65
|
+
"name": "enum_definition"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"type": "REPEAT",
|
|
46
|
-
"content": {
|
|
47
|
-
"type": "SEQ",
|
|
48
|
-
"members": [
|
|
49
|
-
{
|
|
50
|
-
"type": "STRING",
|
|
51
|
-
"value": "/"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"type": "SYMBOL",
|
|
55
|
-
"name": "identifier"
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"type": "REPEAT",
|
|
65
|
-
"content": {
|
|
66
|
-
"type": "SEQ",
|
|
67
|
-
"members": [
|
|
68
|
-
{
|
|
69
|
-
"type": "STRING",
|
|
70
|
-
"value": ","
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"type": "FIELD",
|
|
74
|
-
"name": "name",
|
|
75
|
-
"content": {
|
|
76
|
-
"type": "SEQ",
|
|
77
|
-
"members": [
|
|
78
|
-
{
|
|
79
|
-
"type": "SYMBOL",
|
|
80
|
-
"name": "identifier"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"type": "REPEAT",
|
|
84
|
-
"content": {
|
|
85
|
-
"type": "SEQ",
|
|
86
|
-
"members": [
|
|
87
|
-
{
|
|
88
|
-
"type": "STRING",
|
|
89
|
-
"value": "/"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "SYMBOL",
|
|
93
|
-
"name": "identifier"
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
66
|
}
|
|
106
67
|
]
|
|
107
68
|
},
|
|
@@ -173,7 +134,65 @@
|
|
|
173
134
|
"type": "REPEAT",
|
|
174
135
|
"content": {
|
|
175
136
|
"type": "SYMBOL",
|
|
137
|
+
"name": "class_field"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "SYMBOL",
|
|
142
|
+
"name": "_dedent"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"enum_definition": {
|
|
152
|
+
"type": "SEQ",
|
|
153
|
+
"members": [
|
|
154
|
+
{
|
|
155
|
+
"type": "STRING",
|
|
156
|
+
"value": "enum"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"type": "FIELD",
|
|
160
|
+
"name": "name",
|
|
161
|
+
"content": {
|
|
162
|
+
"type": "SYMBOL",
|
|
163
|
+
"name": "identifier"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "FIELD",
|
|
168
|
+
"name": "types",
|
|
169
|
+
"content": {
|
|
170
|
+
"type": "SYMBOL",
|
|
176
|
-
|
|
171
|
+
"name": "type_list"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"type": "STRING",
|
|
176
|
+
"value": ":"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"type": "FIELD",
|
|
180
|
+
"name": "fields",
|
|
181
|
+
"content": {
|
|
182
|
+
"type": "SEQ",
|
|
183
|
+
"members": [
|
|
184
|
+
{
|
|
185
|
+
"type": "SYMBOL",
|
|
186
|
+
"name": "_indent"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "SEQ",
|
|
190
|
+
"members": [
|
|
191
|
+
{
|
|
192
|
+
"type": "REPEAT",
|
|
193
|
+
"content": {
|
|
194
|
+
"type": "SYMBOL",
|
|
195
|
+
"name": "enum_field"
|
|
177
196
|
}
|
|
178
197
|
},
|
|
179
198
|
{
|
|
@@ -187,6 +206,44 @@
|
|
|
187
206
|
}
|
|
188
207
|
]
|
|
189
208
|
},
|
|
209
|
+
"type_list": {
|
|
210
|
+
"type": "SEQ",
|
|
211
|
+
"members": [
|
|
212
|
+
{
|
|
213
|
+
"type": "STRING",
|
|
214
|
+
"value": "("
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "SEQ",
|
|
218
|
+
"members": [
|
|
219
|
+
{
|
|
220
|
+
"type": "SYMBOL",
|
|
221
|
+
"name": "identifier"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"type": "REPEAT",
|
|
225
|
+
"content": {
|
|
226
|
+
"type": "SEQ",
|
|
227
|
+
"members": [
|
|
228
|
+
{
|
|
229
|
+
"type": "STRING",
|
|
230
|
+
"value": ","
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"type": "SYMBOL",
|
|
234
|
+
"name": "identifier"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"type": "STRING",
|
|
243
|
+
"value": ")"
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
},
|
|
190
247
|
"trait_list": {
|
|
191
248
|
"type": "SEQ",
|
|
192
249
|
"members": [
|
|
@@ -263,7 +320,7 @@
|
|
|
263
320
|
}
|
|
264
321
|
]
|
|
265
322
|
},
|
|
266
|
-
"
|
|
323
|
+
"class_field": {
|
|
267
324
|
"type": "SEQ",
|
|
268
325
|
"members": [
|
|
269
326
|
{
|
|
@@ -288,9 +345,598 @@
|
|
|
288
345
|
}
|
|
289
346
|
]
|
|
290
347
|
},
|
|
348
|
+
"enum_field": {
|
|
349
|
+
"type": "SEQ",
|
|
350
|
+
"members": [
|
|
351
|
+
{
|
|
352
|
+
"type": "SYMBOL",
|
|
353
|
+
"name": "enum_identifier"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"type": "STRING",
|
|
357
|
+
"value": "("
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"type": "SEQ",
|
|
361
|
+
"members": [
|
|
362
|
+
{
|
|
363
|
+
"type": "SYMBOL",
|
|
364
|
+
"name": "_primary_expression"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"type": "REPEAT",
|
|
368
|
+
"content": {
|
|
369
|
+
"type": "SEQ",
|
|
370
|
+
"members": [
|
|
371
|
+
{
|
|
372
|
+
"type": "STRING",
|
|
373
|
+
"value": ","
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"type": "SYMBOL",
|
|
377
|
+
"name": "_primary_expression"
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"type": "STRING",
|
|
386
|
+
"value": ")"
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
"_primary_expression": {
|
|
391
|
+
"type": "CHOICE",
|
|
392
|
+
"members": [
|
|
393
|
+
{
|
|
394
|
+
"type": "SYMBOL",
|
|
395
|
+
"name": "_literal_constant"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"type": "SYMBOL",
|
|
399
|
+
"name": "_string_literal"
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
"url": {
|
|
404
|
+
"type": "SEQ",
|
|
405
|
+
"members": [
|
|
406
|
+
{
|
|
407
|
+
"type": "PATTERN",
|
|
408
|
+
"value": "[a-zA-Z_][a-zA-Z_0-9]*"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"type": "REPEAT",
|
|
412
|
+
"content": {
|
|
413
|
+
"type": "SEQ",
|
|
414
|
+
"members": [
|
|
415
|
+
{
|
|
416
|
+
"type": "STRING",
|
|
417
|
+
"value": "/"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"type": "PATTERN",
|
|
421
|
+
"value": "[a-zA-Z_][a-zA-Z_0-9]*"
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
},
|
|
428
|
+
"package": {
|
|
429
|
+
"type": "SYMBOL",
|
|
430
|
+
"name": "identifier"
|
|
431
|
+
},
|
|
291
|
-
"identifier": {
|
|
432
|
+
"identifier": {
|
|
292
|
-
"type": "PATTERN",
|
|
433
|
+
"type": "PATTERN",
|
|
434
|
+
"value": "[a-zA-Z_][a-zA-Z_0-9]*"
|
|
435
|
+
},
|
|
436
|
+
"enum_identifier": {
|
|
437
|
+
"type": "PATTERN",
|
|
438
|
+
"value": "[A-Z_][A-Z_0-9]*"
|
|
439
|
+
},
|
|
440
|
+
"boolean_literal": {
|
|
441
|
+
"type": "CHOICE",
|
|
442
|
+
"members": [
|
|
443
|
+
{
|
|
444
|
+
"type": "STRING",
|
|
445
|
+
"value": "true"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"type": "STRING",
|
|
449
|
+
"value": "false"
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
},
|
|
453
|
+
"integer_literal": {
|
|
454
|
+
"type": "TOKEN",
|
|
455
|
+
"content": {
|
|
456
|
+
"type": "SEQ",
|
|
457
|
+
"members": [
|
|
458
|
+
{
|
|
459
|
+
"type": "CHOICE",
|
|
460
|
+
"members": [
|
|
461
|
+
{
|
|
462
|
+
"type": "PATTERN",
|
|
463
|
+
"value": "[1-9]"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"type": "BLANK"
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"type": "TOKEN",
|
|
472
|
+
"content": {
|
|
473
|
+
"type": "SEQ",
|
|
474
|
+
"members": [
|
|
475
|
+
{
|
|
476
|
+
"type": "PATTERN",
|
|
477
|
+
"value": "[0-9]+"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"type": "REPEAT",
|
|
481
|
+
"content": {
|
|
482
|
+
"type": "SEQ",
|
|
483
|
+
"members": [
|
|
484
|
+
{
|
|
485
|
+
"type": "PATTERN",
|
|
486
|
+
"value": "_+"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"type": "PATTERN",
|
|
490
|
+
"value": "[0-9]+"
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
"hex_literal": {
|
|
502
|
+
"type": "TOKEN",
|
|
503
|
+
"content": {
|
|
504
|
+
"type": "SEQ",
|
|
505
|
+
"members": [
|
|
506
|
+
{
|
|
507
|
+
"type": "STRING",
|
|
508
|
+
"value": "0"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"type": "PATTERN",
|
|
512
|
+
"value": "[xX]"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"type": "TOKEN",
|
|
516
|
+
"content": {
|
|
517
|
+
"type": "SEQ",
|
|
518
|
+
"members": [
|
|
519
|
+
{
|
|
520
|
+
"type": "PATTERN",
|
|
521
|
+
"value": "[0-9a-fA-F]+"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"type": "REPEAT",
|
|
525
|
+
"content": {
|
|
526
|
+
"type": "SEQ",
|
|
527
|
+
"members": [
|
|
528
|
+
{
|
|
529
|
+
"type": "PATTERN",
|
|
530
|
+
"value": "_+"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"type": "PATTERN",
|
|
534
|
+
"value": "[0-9a-fA-F]+"
|
|
535
|
+
}
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
"bin_literal": {
|
|
546
|
+
"type": "TOKEN",
|
|
547
|
+
"content": {
|
|
548
|
+
"type": "SEQ",
|
|
549
|
+
"members": [
|
|
550
|
+
{
|
|
551
|
+
"type": "STRING",
|
|
552
|
+
"value": "0"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"type": "PATTERN",
|
|
556
|
+
"value": "[bB]"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"type": "TOKEN",
|
|
560
|
+
"content": {
|
|
561
|
+
"type": "SEQ",
|
|
562
|
+
"members": [
|
|
563
|
+
{
|
|
564
|
+
"type": "PATTERN",
|
|
565
|
+
"value": "[01]"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"type": "REPEAT",
|
|
569
|
+
"content": {
|
|
570
|
+
"type": "SEQ",
|
|
571
|
+
"members": [
|
|
572
|
+
{
|
|
573
|
+
"type": "PATTERN",
|
|
574
|
+
"value": "_+"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"type": "PATTERN",
|
|
578
|
+
"value": "[01]"
|
|
579
|
+
}
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
"float_literal": {
|
|
590
|
+
"type": "TOKEN",
|
|
591
|
+
"content": {
|
|
592
|
+
"type": "CHOICE",
|
|
593
|
+
"members": [
|
|
594
|
+
{
|
|
595
|
+
"type": "SEQ",
|
|
596
|
+
"members": [
|
|
597
|
+
{
|
|
598
|
+
"type": "SEQ",
|
|
599
|
+
"members": [
|
|
600
|
+
{
|
|
601
|
+
"type": "CHOICE",
|
|
602
|
+
"members": [
|
|
603
|
+
{
|
|
604
|
+
"type": "TOKEN",
|
|
605
|
+
"content": {
|
|
606
|
+
"type": "SEQ",
|
|
607
|
+
"members": [
|
|
608
|
+
{
|
|
609
|
+
"type": "PATTERN",
|
|
610
|
+
"value": "[0-9]+"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
"type": "REPEAT",
|
|
614
|
+
"content": {
|
|
615
|
+
"type": "SEQ",
|
|
616
|
+
"members": [
|
|
617
|
+
{
|
|
618
|
+
"type": "PATTERN",
|
|
619
|
+
"value": "_+"
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"type": "PATTERN",
|
|
623
|
+
"value": "[0-9]+"
|
|
624
|
+
}
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
]
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"type": "BLANK"
|
|
633
|
+
}
|
|
634
|
+
]
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"type": "STRING",
|
|
638
|
+
"value": "."
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"type": "TOKEN",
|
|
642
|
+
"content": {
|
|
643
|
+
"type": "SEQ",
|
|
644
|
+
"members": [
|
|
645
|
+
{
|
|
646
|
+
"type": "PATTERN",
|
|
647
|
+
"value": "[0-9]+"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"type": "REPEAT",
|
|
651
|
+
"content": {
|
|
652
|
+
"type": "SEQ",
|
|
653
|
+
"members": [
|
|
654
|
+
{
|
|
655
|
+
"type": "PATTERN",
|
|
656
|
+
"value": "_+"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"type": "PATTERN",
|
|
660
|
+
"value": "[0-9]+"
|
|
661
|
+
}
|
|
662
|
+
]
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
]
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"type": "CHOICE",
|
|
672
|
+
"members": [
|
|
673
|
+
{
|
|
674
|
+
"type": "PATTERN",
|
|
675
|
+
"value": "[fF]"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"type": "BLANK"
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
]
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
"type": "SEQ",
|
|
686
|
+
"members": [
|
|
687
|
+
{
|
|
688
|
+
"type": "TOKEN",
|
|
689
|
+
"content": {
|
|
690
|
+
"type": "SEQ",
|
|
691
|
+
"members": [
|
|
692
|
+
{
|
|
693
|
+
"type": "PATTERN",
|
|
694
|
+
"value": "[0-9]+"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"type": "REPEAT",
|
|
698
|
+
"content": {
|
|
699
|
+
"type": "SEQ",
|
|
700
|
+
"members": [
|
|
701
|
+
{
|
|
702
|
+
"type": "PATTERN",
|
|
703
|
+
"value": "_+"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
"type": "PATTERN",
|
|
707
|
+
"value": "[0-9]+"
|
|
708
|
+
}
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
]
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"type": "PATTERN",
|
|
717
|
+
"value": "[fF]"
|
|
718
|
+
}
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
]
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
"character_literal": {
|
|
725
|
+
"type": "SEQ",
|
|
726
|
+
"members": [
|
|
727
|
+
{
|
|
728
|
+
"type": "STRING",
|
|
729
|
+
"value": "'"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"type": "CHOICE",
|
|
733
|
+
"members": [
|
|
734
|
+
{
|
|
735
|
+
"type": "SYMBOL",
|
|
736
|
+
"name": "character_escape_seq"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
"type": "PATTERN",
|
|
740
|
+
"value": "[^\\n\\r'\\\\]"
|
|
741
|
+
}
|
|
742
|
+
]
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"type": "STRING",
|
|
746
|
+
"value": "'"
|
|
747
|
+
}
|
|
748
|
+
]
|
|
749
|
+
},
|
|
750
|
+
"character_escape_seq": {
|
|
751
|
+
"type": "CHOICE",
|
|
752
|
+
"members": [
|
|
753
|
+
{
|
|
754
|
+
"type": "SYMBOL",
|
|
755
|
+
"name": "_uni_character_literal"
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"type": "SYMBOL",
|
|
759
|
+
"name": "_escaped_identifier"
|
|
760
|
+
}
|
|
761
|
+
]
|
|
762
|
+
},
|
|
763
|
+
"_uni_character_literal": {
|
|
764
|
+
"type": "SEQ",
|
|
765
|
+
"members": [
|
|
766
|
+
{
|
|
767
|
+
"type": "STRING",
|
|
768
|
+
"value": "\\u"
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
"type": "PATTERN",
|
|
772
|
+
"value": "[0-9a-fA-F]{4}"
|
|
773
|
+
}
|
|
774
|
+
]
|
|
775
|
+
},
|
|
776
|
+
"_escaped_identifier": {
|
|
777
|
+
"type": "PATTERN",
|
|
293
|
-
"value": "
|
|
778
|
+
"value": "\\\\[tbrn'\"\\\\$]"
|
|
779
|
+
},
|
|
780
|
+
"_string_literal": {
|
|
781
|
+
"type": "CHOICE",
|
|
782
|
+
"members": [
|
|
783
|
+
{
|
|
784
|
+
"type": "SYMBOL",
|
|
785
|
+
"name": "line_string_literal"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"type": "SYMBOL",
|
|
789
|
+
"name": "multi_line_string_literal"
|
|
790
|
+
}
|
|
791
|
+
]
|
|
792
|
+
},
|
|
793
|
+
"line_string_literal": {
|
|
794
|
+
"type": "SEQ",
|
|
795
|
+
"members": [
|
|
796
|
+
{
|
|
797
|
+
"type": "STRING",
|
|
798
|
+
"value": "\""
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
"type": "REPEAT",
|
|
802
|
+
"content": {
|
|
803
|
+
"type": "CHOICE",
|
|
804
|
+
"members": [
|
|
805
|
+
{
|
|
806
|
+
"type": "SYMBOL",
|
|
807
|
+
"name": "_line_string_content"
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
"type": "SYMBOL",
|
|
811
|
+
"name": "_interpolation"
|
|
812
|
+
}
|
|
813
|
+
]
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"type": "STRING",
|
|
818
|
+
"value": "\""
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
},
|
|
822
|
+
"multi_line_string_literal": {
|
|
823
|
+
"type": "SEQ",
|
|
824
|
+
"members": [
|
|
825
|
+
{
|
|
826
|
+
"type": "STRING",
|
|
827
|
+
"value": "`"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"type": "REPEAT",
|
|
831
|
+
"content": {
|
|
832
|
+
"type": "CHOICE",
|
|
833
|
+
"members": [
|
|
834
|
+
{
|
|
835
|
+
"type": "SYMBOL",
|
|
836
|
+
"name": "_multi_line_string_content"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"type": "SYMBOL",
|
|
840
|
+
"name": "_interpolation"
|
|
841
|
+
}
|
|
842
|
+
]
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"type": "STRING",
|
|
847
|
+
"value": "`"
|
|
848
|
+
}
|
|
849
|
+
]
|
|
850
|
+
},
|
|
851
|
+
"_line_string_content": {
|
|
852
|
+
"type": "CHOICE",
|
|
853
|
+
"members": [
|
|
854
|
+
{
|
|
855
|
+
"type": "SYMBOL",
|
|
856
|
+
"name": "_line_str_text"
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
"type": "SYMBOL",
|
|
860
|
+
"name": "character_escape_seq"
|
|
861
|
+
}
|
|
862
|
+
]
|
|
863
|
+
},
|
|
864
|
+
"_multi_line_string_content": {
|
|
865
|
+
"type": "CHOICE",
|
|
866
|
+
"members": [
|
|
867
|
+
{
|
|
868
|
+
"type": "SYMBOL",
|
|
869
|
+
"name": "_multi_line_str_text"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"type": "STRING",
|
|
873
|
+
"value": "\""
|
|
874
|
+
}
|
|
875
|
+
]
|
|
876
|
+
},
|
|
877
|
+
"_line_str_text": {
|
|
878
|
+
"type": "PATTERN",
|
|
879
|
+
"value": "[^\\\\\"$]+"
|
|
880
|
+
},
|
|
881
|
+
"_multi_line_str_text": {
|
|
882
|
+
"type": "PATTERN",
|
|
883
|
+
"value": "[^\"$]+"
|
|
884
|
+
},
|
|
885
|
+
"_interpolation": {
|
|
886
|
+
"type": "CHOICE",
|
|
887
|
+
"members": [
|
|
888
|
+
{
|
|
889
|
+
"type": "SEQ",
|
|
890
|
+
"members": [
|
|
891
|
+
{
|
|
892
|
+
"type": "STRING",
|
|
893
|
+
"value": "$"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"type": "ALIAS",
|
|
897
|
+
"content": {
|
|
898
|
+
"type": "SYMBOL",
|
|
899
|
+
"name": "identifier"
|
|
900
|
+
},
|
|
901
|
+
"named": true,
|
|
902
|
+
"value": "interpolated_identifier"
|
|
903
|
+
}
|
|
904
|
+
]
|
|
905
|
+
}
|
|
906
|
+
]
|
|
907
|
+
},
|
|
908
|
+
"_literal_constant": {
|
|
909
|
+
"type": "CHOICE",
|
|
910
|
+
"members": [
|
|
911
|
+
{
|
|
912
|
+
"type": "SYMBOL",
|
|
913
|
+
"name": "boolean_literal"
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
"type": "SYMBOL",
|
|
917
|
+
"name": "integer_literal"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"type": "SYMBOL",
|
|
921
|
+
"name": "hex_literal"
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
"type": "SYMBOL",
|
|
925
|
+
"name": "bin_literal"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
"type": "SYMBOL",
|
|
929
|
+
"name": "character_literal"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"type": "SYMBOL",
|
|
933
|
+
"name": "float_literal"
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"type": "STRING",
|
|
937
|
+
"value": "null"
|
|
938
|
+
}
|
|
939
|
+
]
|
|
294
940
|
}
|
|
295
941
|
},
|
|
296
942
|
"extras": [
|
src/node-types.json
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"type": "boolean_literal",
|
|
4
|
+
"named": true,
|
|
5
|
+
"fields": {}
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "character_escape_seq",
|
|
9
|
+
"named": true,
|
|
10
|
+
"fields": {}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "character_literal",
|
|
14
|
+
"named": true,
|
|
15
|
+
"fields": {},
|
|
16
|
+
"children": {
|
|
17
|
+
"multiple": false,
|
|
18
|
+
"required": false,
|
|
19
|
+
"types": [
|
|
20
|
+
{
|
|
21
|
+
"type": "character_escape_seq",
|
|
22
|
+
"named": true
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
2
27
|
{
|
|
3
28
|
"type": "class_definition",
|
|
4
29
|
"named": true,
|
|
@@ -8,7 +33,7 @@
|
|
|
8
33
|
"required": true,
|
|
9
34
|
"types": [
|
|
10
35
|
{
|
|
11
|
-
"type": "
|
|
36
|
+
"type": "class_field",
|
|
12
37
|
"named": true
|
|
13
38
|
}
|
|
14
39
|
]
|
|
@@ -45,6 +70,115 @@
|
|
|
45
70
|
}
|
|
46
71
|
}
|
|
47
72
|
},
|
|
73
|
+
{
|
|
74
|
+
"type": "class_field",
|
|
75
|
+
"named": true,
|
|
76
|
+
"fields": {
|
|
77
|
+
"key": {
|
|
78
|
+
"multiple": false,
|
|
79
|
+
"required": true,
|
|
80
|
+
"types": [
|
|
81
|
+
{
|
|
82
|
+
"type": "identifier",
|
|
83
|
+
"named": true
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"value": {
|
|
88
|
+
"multiple": false,
|
|
89
|
+
"required": true,
|
|
90
|
+
"types": [
|
|
91
|
+
{
|
|
92
|
+
"type": "identifier",
|
|
93
|
+
"named": true
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"type": "enum_definition",
|
|
101
|
+
"named": true,
|
|
102
|
+
"fields": {
|
|
103
|
+
"fields": {
|
|
104
|
+
"multiple": true,
|
|
105
|
+
"required": true,
|
|
106
|
+
"types": [
|
|
107
|
+
{
|
|
108
|
+
"type": "enum_field",
|
|
109
|
+
"named": true
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"name": {
|
|
114
|
+
"multiple": false,
|
|
115
|
+
"required": true,
|
|
116
|
+
"types": [
|
|
117
|
+
{
|
|
118
|
+
"type": "identifier",
|
|
119
|
+
"named": true
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"types": {
|
|
124
|
+
"multiple": false,
|
|
125
|
+
"required": true,
|
|
126
|
+
"types": [
|
|
127
|
+
{
|
|
128
|
+
"type": "type_list",
|
|
129
|
+
"named": true
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"type": "enum_field",
|
|
137
|
+
"named": true,
|
|
138
|
+
"fields": {},
|
|
139
|
+
"children": {
|
|
140
|
+
"multiple": true,
|
|
141
|
+
"required": true,
|
|
142
|
+
"types": [
|
|
143
|
+
{
|
|
144
|
+
"type": "bin_literal",
|
|
145
|
+
"named": true
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "boolean_literal",
|
|
149
|
+
"named": true
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "character_literal",
|
|
153
|
+
"named": true
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "enum_identifier",
|
|
157
|
+
"named": true
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"type": "float_literal",
|
|
161
|
+
"named": true
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"type": "hex_literal",
|
|
165
|
+
"named": true
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "integer_literal",
|
|
169
|
+
"named": true
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"type": "line_string_literal",
|
|
173
|
+
"named": true
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"type": "multi_line_string_literal",
|
|
177
|
+
"named": true
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
},
|
|
48
182
|
{
|
|
49
183
|
"type": "generic_list",
|
|
50
184
|
"named": true,
|
|
@@ -60,41 +194,103 @@
|
|
|
60
194
|
]
|
|
61
195
|
}
|
|
62
196
|
},
|
|
197
|
+
{
|
|
198
|
+
"type": "identifier",
|
|
199
|
+
"named": true,
|
|
200
|
+
"fields": {}
|
|
201
|
+
},
|
|
63
202
|
{
|
|
64
203
|
"type": "import_statement",
|
|
65
204
|
"named": true,
|
|
66
|
-
"fields": {
|
|
205
|
+
"fields": {},
|
|
67
|
-
|
|
206
|
+
"children": {
|
|
68
|
-
|
|
207
|
+
"multiple": false,
|
|
69
|
-
|
|
208
|
+
"required": true,
|
|
70
|
-
|
|
209
|
+
"types": [
|
|
71
|
-
|
|
210
|
+
{
|
|
72
|
-
|
|
211
|
+
"type": "url",
|
|
73
|
-
"named": false
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"type": "identifier",
|
|
77
|
-
|
|
212
|
+
"named": true
|
|
78
|
-
|
|
213
|
+
}
|
|
79
|
-
|
|
214
|
+
]
|
|
80
|
-
}
|
|
81
215
|
}
|
|
82
216
|
},
|
|
83
217
|
{
|
|
218
|
+
"type": "interpolated_identifier",
|
|
219
|
+
"named": true,
|
|
220
|
+
"fields": {}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
84
|
-
"type": "
|
|
223
|
+
"type": "line_string_literal",
|
|
85
224
|
"named": true,
|
|
86
225
|
"fields": {},
|
|
87
226
|
"children": {
|
|
88
227
|
"multiple": true,
|
|
89
228
|
"required": false,
|
|
229
|
+
"types": [
|
|
230
|
+
{
|
|
231
|
+
"type": "character_escape_seq",
|
|
232
|
+
"named": true
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"type": "interpolated_identifier",
|
|
236
|
+
"named": true
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"type": "multi_line_string_literal",
|
|
243
|
+
"named": true,
|
|
244
|
+
"fields": {},
|
|
245
|
+
"children": {
|
|
246
|
+
"multiple": true,
|
|
247
|
+
"required": false,
|
|
248
|
+
"types": [
|
|
249
|
+
{
|
|
250
|
+
"type": "interpolated_identifier",
|
|
251
|
+
"named": true
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"type": "package",
|
|
258
|
+
"named": true,
|
|
259
|
+
"fields": {},
|
|
260
|
+
"children": {
|
|
261
|
+
"multiple": false,
|
|
262
|
+
"required": true,
|
|
263
|
+
"types": [
|
|
264
|
+
{
|
|
265
|
+
"type": "identifier",
|
|
266
|
+
"named": true
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"type": "source_file",
|
|
273
|
+
"named": true,
|
|
274
|
+
"fields": {},
|
|
275
|
+
"children": {
|
|
276
|
+
"multiple": true,
|
|
277
|
+
"required": true,
|
|
90
278
|
"types": [
|
|
91
279
|
{
|
|
92
280
|
"type": "class_definition",
|
|
93
281
|
"named": true
|
|
94
282
|
},
|
|
283
|
+
{
|
|
284
|
+
"type": "enum_definition",
|
|
285
|
+
"named": true
|
|
286
|
+
},
|
|
95
287
|
{
|
|
96
288
|
"type": "import_statement",
|
|
97
289
|
"named": true
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"type": "package",
|
|
293
|
+
"named": true
|
|
98
294
|
}
|
|
99
295
|
]
|
|
100
296
|
}
|
|
@@ -115,31 +311,37 @@
|
|
|
115
311
|
}
|
|
116
312
|
},
|
|
117
313
|
{
|
|
118
|
-
"type": "
|
|
314
|
+
"type": "type_list",
|
|
119
315
|
"named": true,
|
|
120
|
-
"fields": {
|
|
316
|
+
"fields": {},
|
|
121
|
-
|
|
317
|
+
"children": {
|
|
122
|
-
|
|
318
|
+
"multiple": true,
|
|
123
|
-
|
|
319
|
+
"required": true,
|
|
124
|
-
|
|
320
|
+
"types": [
|
|
125
|
-
|
|
321
|
+
{
|
|
126
|
-
|
|
322
|
+
"type": "identifier",
|
|
127
|
-
|
|
323
|
+
"named": true
|
|
128
|
-
|
|
324
|
+
}
|
|
129
|
-
|
|
325
|
+
]
|
|
130
|
-
},
|
|
131
|
-
"value": {
|
|
132
|
-
"multiple": false,
|
|
133
|
-
"required": true,
|
|
134
|
-
"types": [
|
|
135
|
-
{
|
|
136
|
-
"type": "identifier",
|
|
137
|
-
"named": true
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
326
|
}
|
|
142
327
|
},
|
|
328
|
+
{
|
|
329
|
+
"type": "url",
|
|
330
|
+
"named": true,
|
|
331
|
+
"fields": {}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"type": "\"",
|
|
335
|
+
"named": false
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"type": "$",
|
|
339
|
+
"named": false
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"type": "'",
|
|
343
|
+
"named": false
|
|
344
|
+
},
|
|
143
345
|
{
|
|
144
346
|
"type": "(",
|
|
145
347
|
"named": false
|
|
@@ -168,16 +370,60 @@
|
|
|
168
370
|
"type": ">",
|
|
169
371
|
"named": false
|
|
170
372
|
},
|
|
373
|
+
{
|
|
374
|
+
"type": "\\u",
|
|
375
|
+
"named": false
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"type": "`",
|
|
379
|
+
"named": false
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"type": "bin_literal",
|
|
383
|
+
"named": true
|
|
384
|
+
},
|
|
171
385
|
{
|
|
172
386
|
"type": "class",
|
|
173
387
|
"named": false
|
|
174
388
|
},
|
|
175
389
|
{
|
|
390
|
+
"type": "enum",
|
|
391
|
+
"named": false
|
|
392
|
+
},
|
|
393
|
+
{
|
|
176
|
-
"type": "
|
|
394
|
+
"type": "enum_identifier",
|
|
395
|
+
"named": true
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"type": "false",
|
|
399
|
+
"named": false
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"type": "float_literal",
|
|
403
|
+
"named": true
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"type": "hex_literal",
|
|
177
407
|
"named": true
|
|
178
408
|
},
|
|
179
409
|
{
|
|
180
410
|
"type": "import",
|
|
181
411
|
"named": false
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"type": "integer_literal",
|
|
415
|
+
"named": true
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"type": "null",
|
|
419
|
+
"named": false
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"type": "package",
|
|
423
|
+
"named": false
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"type": "true",
|
|
427
|
+
"named": false
|
|
182
428
|
}
|
|
183
429
|
]
|
test/corpus/class_definitions.txt
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Class definitions
|
|
3
3
|
================================================================================
|
|
4
4
|
|
|
5
|
+
package definitions
|
|
6
|
+
|
|
5
7
|
class A:
|
|
6
8
|
a: String
|
|
7
9
|
b: Int
|
|
@@ -20,13 +22,15 @@ class A<S, T>(B, C):
|
|
|
20
22
|
|
|
21
23
|
--------------------------------------------------------------------------------
|
|
22
24
|
|
|
25
|
+
(source_file
|
|
23
|
-
(
|
|
26
|
+
(package
|
|
27
|
+
(identifier))
|
|
24
28
|
(class_definition
|
|
25
29
|
(identifier)
|
|
26
|
-
(
|
|
30
|
+
(class_field
|
|
27
31
|
(identifier)
|
|
28
32
|
(identifier))
|
|
29
|
-
(
|
|
33
|
+
(class_field
|
|
30
34
|
(identifier)
|
|
31
35
|
(identifier)))
|
|
32
36
|
(class_definition
|
|
@@ -34,10 +38,10 @@ class A<S, T>(B, C):
|
|
|
34
38
|
(generic_list
|
|
35
39
|
(identifier)
|
|
36
40
|
(identifier))
|
|
37
|
-
(
|
|
41
|
+
(class_field
|
|
38
42
|
(identifier)
|
|
39
43
|
(identifier))
|
|
40
|
-
(
|
|
44
|
+
(class_field
|
|
41
45
|
(identifier)
|
|
42
46
|
(identifier)))
|
|
43
47
|
(class_definition
|
|
@@ -45,10 +49,10 @@ class A<S, T>(B, C):
|
|
|
45
49
|
(trait_list
|
|
46
50
|
(identifier)
|
|
47
51
|
(identifier))
|
|
48
|
-
(
|
|
52
|
+
(class_field
|
|
49
53
|
(identifier)
|
|
50
54
|
(identifier))
|
|
51
|
-
(
|
|
55
|
+
(class_field
|
|
52
56
|
(identifier)
|
|
53
57
|
(identifier)))
|
|
54
58
|
(class_definition
|
|
@@ -59,9 +63,9 @@ class A<S, T>(B, C):
|
|
|
59
63
|
(trait_list
|
|
60
64
|
(identifier)
|
|
61
65
|
(identifier))
|
|
62
|
-
(
|
|
66
|
+
(class_field
|
|
63
67
|
(identifier)
|
|
64
68
|
(identifier))
|
|
65
|
-
(
|
|
69
|
+
(class_field
|
|
66
70
|
(identifier)
|
|
67
71
|
(identifier))))
|
test/corpus/enum_definitions.txt
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
Enum definitions - Int
|
|
3
|
+
================================================================================
|
|
4
|
+
|
|
5
|
+
package definitions
|
|
6
|
+
|
|
7
|
+
enum Colors(Int):
|
|
8
|
+
RED(0xFF0000)
|
|
9
|
+
GREEN(0x00FF00)
|
|
10
|
+
BLUE(0x0000FF)
|
|
11
|
+
|
|
12
|
+
--------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
(source_file
|
|
15
|
+
(package
|
|
16
|
+
(identifier))
|
|
17
|
+
(enum_definition
|
|
18
|
+
(identifier)
|
|
19
|
+
(type_list
|
|
20
|
+
(identifier))
|
|
21
|
+
(enum_field
|
|
22
|
+
(enum_identifier)
|
|
23
|
+
(hex_literal))
|
|
24
|
+
(enum_field
|
|
25
|
+
(enum_identifier)
|
|
26
|
+
(hex_literal))
|
|
27
|
+
(enum_field
|
|
28
|
+
(enum_identifier)
|
|
29
|
+
(hex_literal))))
|
|
30
|
+
|
|
31
|
+
================================================================================
|
|
32
|
+
Enum definitions - Float
|
|
33
|
+
================================================================================
|
|
34
|
+
|
|
35
|
+
package definitions
|
|
36
|
+
|
|
37
|
+
enum ColorsAlpha(Int, Float):
|
|
38
|
+
RED(1, 0.1)
|
|
39
|
+
GREEN(2, 0.2)
|
|
40
|
+
BLUE(3, 0.3)
|
|
41
|
+
|
|
42
|
+
--------------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
(source_file
|
|
45
|
+
(package
|
|
46
|
+
(identifier))
|
|
47
|
+
(enum_definition
|
|
48
|
+
(identifier)
|
|
49
|
+
(type_list
|
|
50
|
+
(identifier)
|
|
51
|
+
(identifier))
|
|
52
|
+
(enum_field
|
|
53
|
+
(enum_identifier)
|
|
54
|
+
(integer_literal)
|
|
55
|
+
(float_literal))
|
|
56
|
+
(enum_field
|
|
57
|
+
(enum_identifier)
|
|
58
|
+
(integer_literal)
|
|
59
|
+
(float_literal))
|
|
60
|
+
(enum_field
|
|
61
|
+
(enum_identifier)
|
|
62
|
+
(integer_literal)
|
|
63
|
+
(float_literal))))
|
|
64
|
+
|
|
65
|
+
================================================================================
|
|
66
|
+
Enum definitions - String
|
|
67
|
+
================================================================================
|
|
68
|
+
|
|
69
|
+
package definitions
|
|
70
|
+
|
|
71
|
+
enum ColorsAlpha(Int, String):
|
|
72
|
+
RED(1, "1")
|
|
73
|
+
GREEN(2, "2")
|
|
74
|
+
BLUE(3, "3")
|
|
75
|
+
|
|
76
|
+
--------------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
(source_file
|
|
79
|
+
(package
|
|
80
|
+
(identifier))
|
|
81
|
+
(enum_definition
|
|
82
|
+
(identifier)
|
|
83
|
+
(type_list
|
|
84
|
+
(identifier)
|
|
85
|
+
(identifier))
|
|
86
|
+
(enum_field
|
|
87
|
+
(enum_identifier)
|
|
88
|
+
(integer_literal)
|
|
89
|
+
(line_string_literal))
|
|
90
|
+
(enum_field
|
|
91
|
+
(enum_identifier)
|
|
92
|
+
(integer_literal)
|
|
93
|
+
(line_string_literal))
|
|
94
|
+
(enum_field
|
|
95
|
+
(enum_identifier)
|
|
96
|
+
(integer_literal)
|
|
97
|
+
(line_string_literal))))
|
test/corpus/import_statements.txt
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Import statements
|
|
3
3
|
================================================================================
|
|
4
4
|
|
|
5
|
+
package imports
|
|
6
|
+
|
|
5
7
|
import github/pyros2097/std
|
|
6
8
|
|
|
7
9
|
--------------------------------------------------------------------------------
|
|
8
10
|
|
|
11
|
+
(source_file
|
|
9
|
-
(
|
|
12
|
+
(package
|
|
13
|
+
(identifier))
|
|
10
14
|
(import_statement
|
|
11
|
-
(identifier)
|
|
12
|
-
(identifier)
|
|
13
|
-
(
|
|
15
|
+
(url)))
|