plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
3152e7c
— Peter John
2023-04-20T10:33:04+05:30
make fns work
Generated files not shown: src/parser.c
- binding.gyp +3 -2
- grammar.js +136 -254
- package.json +12 -8
- src/grammar.json +1179 -150
- src/node-types.json +671 -27
- src/scanner.c +29 -0
- test/corpus/functions.txt +10 -157
binding.gyp
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"targets": [
|
|
3
3
|
{
|
|
4
|
-
"target_name": "
|
|
4
|
+
"target_name": "tree_sitter_palm_binding",
|
|
5
5
|
"include_dirs": [
|
|
6
6
|
"<!(node -e \"require('nan')\")",
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
9
9
|
"sources": [
|
|
10
10
|
"bindings/node/binding.cc",
|
|
11
|
-
"src/parser.c"
|
|
11
|
+
"src/parser.c",
|
|
12
|
+
"src/scanner.c"
|
|
12
13
|
],
|
|
13
14
|
"cflags_c": [
|
|
14
15
|
"-std=c99",
|
grammar.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const DEC_DIGITS = token(sep1(/[0-9]+/, /_+/));
|
|
2
2
|
const HEX_DIGITS = token(sep1(/[0-9a-fA-F]+/, /_+/));
|
|
3
3
|
const BIN_DIGITS = token(sep1(/[01]/, /_+/));
|
|
4
|
+
const NEWLINE = /\r?\n/;
|
|
4
5
|
|
|
5
6
|
module.exports = grammar({
|
|
6
7
|
name: 'palm',
|
|
@@ -8,6 +9,11 @@ module.exports = grammar({
|
|
|
8
9
|
// $.comment,
|
|
9
10
|
// /\s+/ // Whitespace
|
|
10
11
|
// ],
|
|
12
|
+
externals: ($) => [$.quoted_content],
|
|
13
|
+
conflicts: $ => [
|
|
14
|
+
[$.proc],
|
|
15
|
+
[$.record],
|
|
16
|
+
],
|
|
11
17
|
rules: {
|
|
12
18
|
source_file: $ => seq(
|
|
13
19
|
$.module,
|
|
@@ -15,7 +21,7 @@ module.exports = grammar({
|
|
|
15
21
|
repeat(choice(
|
|
16
22
|
$.record,
|
|
17
23
|
$.type,
|
|
18
|
-
|
|
24
|
+
$.proc,
|
|
19
25
|
)),
|
|
20
26
|
),
|
|
21
27
|
|
|
@@ -44,6 +50,9 @@ module.exports = grammar({
|
|
|
44
50
|
)
|
|
45
51
|
),
|
|
46
52
|
|
|
53
|
+
/* Constant statements */
|
|
54
|
+
// _constant_type_annotation: ($) => seq(":", field("type", $._constant_type)),
|
|
55
|
+
|
|
47
56
|
/* Declarations */
|
|
48
57
|
|
|
49
58
|
record: $ => seq(
|
|
@@ -61,21 +70,102 @@ module.exports = grammar({
|
|
|
61
70
|
field('types', pipeSep1($.type_name)),
|
|
62
71
|
),
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
proc: $ => seq(
|
|
74
|
+
// 'proc',
|
|
65
|
-
|
|
75
|
+
field('name', $.identifier),
|
|
66
|
-
|
|
76
|
+
field('params', seq('(', optional(commaSep1($.type_field)), ')')),
|
|
67
|
-
|
|
77
|
+
optional(
|
|
68
|
-
|
|
78
|
+
seq(
|
|
69
|
-
|
|
79
|
+
'->',
|
|
70
|
-
|
|
80
|
+
field('return_type', optional($.return_type)),
|
|
71
|
-
// ),
|
|
72
|
-
|
|
81
|
+
),
|
|
73
|
-
|
|
82
|
+
),
|
|
74
|
-
// // field('body', $._block)
|
|
75
|
-
|
|
83
|
+
'=',
|
|
84
|
+
field('body', $._statement_seq),
|
|
85
|
+
),
|
|
76
86
|
|
|
77
87
|
/* Shared AST nodes */
|
|
88
|
+
|
|
78
|
-
|
|
89
|
+
// param: $ => seq(
|
|
90
|
+
// field('name', $.variable_name),
|
|
91
|
+
// ':',
|
|
92
|
+
// field('type', $.type)
|
|
93
|
+
// ),
|
|
94
|
+
|
|
95
|
+
/* Expressions */
|
|
96
|
+
|
|
97
|
+
_statement_seq: ($) => repeat1($._statement),
|
|
98
|
+
_statement: ($) => choice($._expression, $.let),
|
|
99
|
+
_expression: ($) => choice($._expression_unit, $.binary_expression),
|
|
100
|
+
binary_expression: ($) =>
|
|
101
|
+
choice(
|
|
102
|
+
binaryExpr(prec.left, 1, "||", $._expression),
|
|
103
|
+
binaryExpr(prec.left, 2, "&&", $._expression),
|
|
104
|
+
binaryExpr(prec.left, 3, "==", $._expression),
|
|
105
|
+
binaryExpr(prec.left, 3, "!=", $._expression),
|
|
106
|
+
binaryExpr(prec.left, 4, "<", $._expression),
|
|
107
|
+
binaryExpr(prec.left, 4, "<=", $._expression),
|
|
108
|
+
binaryExpr(prec.left, 4, ">", $._expression),
|
|
109
|
+
binaryExpr(prec.left, 4, ">=", $._expression),
|
|
110
|
+
binaryExpr(prec.left, 5, "|>", $._expression),
|
|
111
|
+
binaryExpr(prec.left, 6, "+", $._expression),
|
|
112
|
+
binaryExpr(prec.left, 6, "-", $._expression),
|
|
113
|
+
binaryExpr(prec.left, 7, "*", $._expression),
|
|
114
|
+
binaryExpr(prec.left, 7, "/", $._expression),
|
|
115
|
+
binaryExpr(prec.left, 7, "%", $._expression),
|
|
116
|
+
binaryExpr(prec.left, 7, "<>", $._expression)
|
|
117
|
+
),
|
|
118
|
+
_expression_unit: ($) =>
|
|
119
|
+
choice(
|
|
120
|
+
$.string,
|
|
121
|
+
$.integer,
|
|
122
|
+
$.float,
|
|
123
|
+
$.record,
|
|
124
|
+
$.identifier,
|
|
125
|
+
$.todo,
|
|
126
|
+
$.panic,
|
|
127
|
+
// $.anonymous_function,
|
|
128
|
+
$.expression_group,
|
|
129
|
+
// $.case,
|
|
130
|
+
$.negation,
|
|
131
|
+
// $.record_update,
|
|
132
|
+
// $.field_access,
|
|
133
|
+
// $.function_call
|
|
134
|
+
),
|
|
135
|
+
expression_group: ($) => seq("{", $._statement_seq, "}"),
|
|
136
|
+
negation: ($) => seq("!", $._expression_unit),
|
|
137
|
+
let: ($) => seq("let", $._assignment),
|
|
138
|
+
_assignment: ($) =>
|
|
139
|
+
seq(
|
|
140
|
+
field("pattern", $._pattern),
|
|
141
|
+
optional($._type_annotation),
|
|
142
|
+
"=",
|
|
143
|
+
field("value", $._expression)
|
|
144
|
+
),
|
|
145
|
+
_pattern: ($) =>
|
|
146
|
+
seq(
|
|
147
|
+
$._pattern_expression,
|
|
148
|
+
optional(field("assign", seq("as", $.identifier)))
|
|
149
|
+
),
|
|
150
|
+
_pattern_expression: ($) =>
|
|
151
|
+
choice(
|
|
152
|
+
$.identifier,
|
|
153
|
+
// $.discard,
|
|
154
|
+
// $.record_pattern,
|
|
155
|
+
// $.string,
|
|
156
|
+
$.integer,
|
|
157
|
+
$.float,
|
|
158
|
+
alias($._pattern_binary_expression, $.binary_expression)
|
|
159
|
+
),
|
|
160
|
+
_pattern_binary_expression: ($) =>
|
|
161
|
+
binaryExpr(prec.left, 1, "<>", $._pattern_expression),
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
todo: ($) =>
|
|
165
|
+
seq("todo", optional(seq("(", field("message", $.string), ")"))),
|
|
166
|
+
panic: (_$) => seq("panic"),
|
|
167
|
+
|
|
168
|
+
/* Types */
|
|
79
169
|
return_type: $ => seq(
|
|
80
170
|
field('name', $.type_identifier),
|
|
81
171
|
field("generics", optional(seq(
|
|
@@ -103,255 +193,38 @@ module.exports = grammar({
|
|
|
103
193
|
':',
|
|
104
194
|
field('type', $.identifier)
|
|
105
195
|
),
|
|
106
|
-
|
|
196
|
+
|
|
107
|
-
type_identifier: ($) => $._upname,
|
|
108
197
|
generic_list: $ => seq(
|
|
109
198
|
'(',
|
|
110
199
|
commaSep1($.identifier),
|
|
111
200
|
')'
|
|
112
201
|
),
|
|
113
202
|
|
|
203
|
+
/* Literals */
|
|
204
|
+
float: ($) => /-?[0-9_]+\.[0-9_]*(e-?[0-9_]+)?/,
|
|
205
|
+
integer: ($) =>
|
|
206
|
+
seq(optional("-"), choice($._hex, $._decimal, $._octal, $._binary)),
|
|
207
|
+
string: ($) =>
|
|
208
|
+
seq(
|
|
209
|
+
'"',
|
|
210
|
+
repeat(choice($.escape_sequence, $.quoted_content)),
|
|
211
|
+
token.immediate('"')
|
|
212
|
+
),
|
|
213
|
+
_hex: ($) => /0[xX][0-9a-fA-F_]+/,
|
|
214
|
+
_decimal: ($) => /[0-9][0-9_]*/,
|
|
215
|
+
_octal: ($) => /0[oO][0-7_]+/,
|
|
216
|
+
_binary: ($) => /0[bB][0-1_]+/,
|
|
217
|
+
_interpolation: $ => choice(
|
|
218
|
+
seq("{", $.identifier, "}")
|
|
219
|
+
),
|
|
220
|
+
escape_sequence: ($) => token.immediate(/\\[efnrt\"\\]/),
|
|
221
|
+
// identifier: ($) => $._name,
|
|
222
|
+
identifier: $ => /[a-zA-Z_][a-zA-Z_0-9]*/,
|
|
223
|
+
type_identifier: ($) => $._upname,
|
|
224
|
+
_type_annotation: ($) => seq(":", field("type", $.identifier)),
|
|
114
225
|
_discard_name: ($) => /_[_0-9a-z]*/,
|
|
115
226
|
_name: ($) => /[_a-z][_0-9a-z]*/,
|
|
116
227
|
_upname: ($) => /[A-Z][0-9a-zA-Z]*/,
|
|
117
|
-
|
|
118
|
-
// param: $ => seq(
|
|
119
|
-
// field('name', $.variable_name),
|
|
120
|
-
// ':',
|
|
121
|
-
// field('type', $.type)
|
|
122
|
-
// ),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// fun_field: $ => seq(
|
|
127
|
-
// 'fun',
|
|
128
|
-
// field('name', $.identifier),
|
|
129
|
-
// field('params', seq('(', optional(commaSep1($.param)), ')')),
|
|
130
|
-
// '=>',
|
|
131
|
-
// field('returns', optional(commaSep1($.type))),
|
|
132
|
-
// ),
|
|
133
|
-
|
|
134
|
-
// trait_field: $ => choice(
|
|
135
|
-
// $.type_field,
|
|
136
|
-
// $.fun_field,
|
|
137
|
-
// ),
|
|
138
|
-
|
|
139
|
-
// enum_field: $ => seq($.enum_field_name, '(', commaSep1($._primary_expression), ')'),
|
|
140
|
-
|
|
141
|
-
// // Expressions
|
|
142
|
-
|
|
143
|
-
// _block: $ => prec(PREC.BLOCK, seq(
|
|
144
|
-
// "{",
|
|
145
|
-
// // optional($.statements),
|
|
146
|
-
// "}"
|
|
147
|
-
// )),
|
|
148
|
-
|
|
149
|
-
// // assignment: $ => choice(
|
|
150
|
-
// // prec.left(PREC.ASSIGNMENT, seq($.directly_assignable_expression, $._assignment_and_operator, $._expression)),
|
|
151
|
-
// // prec.left(PREC.ASSIGNMENT, seq($.directly_assignable_expression, "=", $._expression)),
|
|
152
|
-
// // // TODO
|
|
153
|
-
// // ),
|
|
154
|
-
|
|
155
|
-
// // // ==========
|
|
156
|
-
// // // Expressions
|
|
157
|
-
// // // ==========
|
|
158
|
-
|
|
159
|
-
// // _expression: $ => choice(
|
|
160
|
-
// // $._unary_expression,
|
|
161
|
-
// // $._binary_expression,
|
|
162
|
-
// // $._primary_expression
|
|
163
|
-
// // ),
|
|
164
|
-
|
|
165
|
-
// // // Unary expressions
|
|
166
|
-
|
|
167
|
-
// // _unary_expression: $ => choice(
|
|
168
|
-
// // $.postfix_expression,
|
|
169
|
-
// // $.call_expression,
|
|
170
|
-
// // $.indexing_expression,
|
|
171
|
-
// // $.navigation_expression,
|
|
172
|
-
// // $.prefix_expression,
|
|
173
|
-
// // $.as_expression,
|
|
174
|
-
// // $.spread_expression
|
|
175
|
-
// // ),
|
|
176
|
-
|
|
177
|
-
// // postfix_expression: $ => prec.left(PREC.POSTFIX, seq($._expression, $._postfix_unary_operator)),
|
|
178
|
-
|
|
179
|
-
// // call_expression: $ => prec.left(PREC.POSTFIX, seq($._expression, $.call_suffix)),
|
|
180
|
-
|
|
181
|
-
// // indexing_expression: $ => prec.left(PREC.POSTFIX, seq($._expression, $.indexing_suffix)),
|
|
182
|
-
|
|
183
|
-
// // navigation_expression: $ => prec.left(PREC.POSTFIX, seq($._expression, $.navigation_suffix)),
|
|
184
|
-
|
|
185
|
-
// // prefix_expression: $ => prec.right(seq(choice($.annotation, $.label, $._prefix_unary_operator), $._expression)),
|
|
186
|
-
|
|
187
|
-
// // as_expression: $ => prec.left(PREC.AS, seq($._expression, $._as_operator, $._type)),
|
|
188
|
-
|
|
189
|
-
// // spread_expression: $ => prec.left(PREC.SPREAD, seq("*", $._expression)),
|
|
190
|
-
|
|
191
|
-
// // _binary_expression: $ => choice(
|
|
192
|
-
// // $.multiplicative_expression,
|
|
193
|
-
// // $.additive_expression,
|
|
194
|
-
// // $.range_expression,
|
|
195
|
-
// // $.infix_expression,
|
|
196
|
-
// // $.elvis_expression,
|
|
197
|
-
// // $.check_expression,
|
|
198
|
-
// // $.comparison_expression,
|
|
199
|
-
// // $.equality_expression,
|
|
200
|
-
// // $.comparison_expression,
|
|
201
|
-
// // $.equality_expression,
|
|
202
|
-
// // $.conjunction_expression,
|
|
203
|
-
// // $.disjunction_expression
|
|
204
|
-
// // ),
|
|
205
|
-
|
|
206
|
-
// // multiplicative_expression: $ => prec.left(PREC.MULTIPLICATIVE, seq($._expression, $._multiplicative_operator, $._expression)),
|
|
207
|
-
|
|
208
|
-
// // additive_expression: $ => prec.left(PREC.ADDITIVE, seq($._expression, $._additive_operator, $._expression)),
|
|
209
|
-
|
|
210
|
-
// // range_expression: $ => prec.left(PREC.RANGE, seq($._expression, "..", $._expression)),
|
|
211
|
-
|
|
212
|
-
// // infix_expression: $ => prec.left(PREC.INFIX, seq($._expression, $.simple_identifier, $._expression)),
|
|
213
|
-
|
|
214
|
-
// // elvis_expression: $ => prec.left(PREC.ELVIS, seq($._expression, "?:", $._expression)),
|
|
215
|
-
|
|
216
|
-
// // check_expression: $ => prec.left(PREC.CHECK, seq($._expression, choice(
|
|
217
|
-
// // seq($._in_operator, $._expression),
|
|
218
|
-
// // seq($._is_operator, $._type)))),
|
|
219
|
-
|
|
220
|
-
// // comparison_expression: $ => prec.left(PREC.COMPARISON, seq($._expression, $._comparison_operator, $._expression)),
|
|
221
|
-
|
|
222
|
-
// // equality_expression: $ => prec.left(PREC.EQUALITY, seq($._expression, $._equality_operator, $._expression)),
|
|
223
|
-
|
|
224
|
-
// // conjunction_expression: $ => prec.left(PREC.CONJUNCTION, seq($._expression, "&&", $._expression)),
|
|
225
|
-
|
|
226
|
-
// // disjunction_expression: $ => prec.left(PREC.DISJUNCTION, seq($._expression, "||", $._expression)),
|
|
227
|
-
|
|
228
|
-
// // // Suffixes
|
|
229
|
-
|
|
230
|
-
// // indexing_suffix: $ => seq("[", sep1($._expression, ","), "]"),
|
|
231
|
-
|
|
232
|
-
// // navigation_suffix: $ => seq(
|
|
233
|
-
// // $._member_access_operator,
|
|
234
|
-
// // choice(
|
|
235
|
-
// // $.simple_identifier,
|
|
236
|
-
// // $.parenthesized_expression,
|
|
237
|
-
// // "class"
|
|
238
|
-
// // )
|
|
239
|
-
// // ),
|
|
240
|
-
|
|
241
|
-
// // call_suffix: $ => prec.left(seq(
|
|
242
|
-
// // // this introduces ambiguities with 'less than' for comparisons
|
|
243
|
-
// // optional($.type_arguments),
|
|
244
|
-
// // choice(
|
|
245
|
-
// // seq(optional($.value_arguments), $.annotated_lambda),
|
|
246
|
-
// // $.value_arguments
|
|
247
|
-
// // )
|
|
248
|
-
// // )),
|
|
249
|
-
|
|
250
|
-
// // variable_declaration: $ => prec.left(PREC.VAR_DECL, seq(
|
|
251
|
-
// // // repeat($.annotation), TODO
|
|
252
|
-
// // $.simple_identifier,
|
|
253
|
-
// // optional(seq(":", $._type))
|
|
254
|
-
// // )),
|
|
255
|
-
|
|
256
|
-
// // function_type: $ => seq(
|
|
257
|
-
// // optional(seq($._simple_user_type, ".")), // TODO: Support "real" types
|
|
258
|
-
// // $.function_type_parameters,
|
|
259
|
-
// // "->",
|
|
260
|
-
// // $._type
|
|
261
|
-
// // ),
|
|
262
|
-
|
|
263
|
-
// // function_type_parameters: $ => prec.left(1, seq(
|
|
264
|
-
// // "(",
|
|
265
|
-
// // optional(sep1(choice($.parameter, $._type), ",")),
|
|
266
|
-
// // ")"
|
|
267
|
-
// // )),
|
|
268
|
-
|
|
269
|
-
// // parenthesized_type: $ => seq("(", $._type, ")"),
|
|
270
|
-
|
|
271
|
-
// _primary_expression: $ => choice(
|
|
272
|
-
// $._literal_constant,
|
|
273
|
-
// $._string_literal,
|
|
274
|
-
// ),
|
|
275
|
-
|
|
276
|
-
url: $ => sep1(/[a-zA-Z_][a-zA-Z_0-9]*/, '/'),
|
|
277
|
-
// module: $ => $.identifier,
|
|
278
|
-
identifier: $ => /[a-zA-Z_][a-zA-Z_0-9]*/,
|
|
279
|
-
// definition_name: $ => /[A-Z](([a-z]+[A-Z]?)*)/, // Pascal Case - no digits allowed
|
|
280
|
-
// variable_name: $ => /[a-z][a-z]*(([A-Z][a-z]+)*[A-Z]?|([a-z]+[A-Z])*|[A-Z])/, // Lower Camel Case - no digits allowed
|
|
281
|
-
// enum_field_name: $ => /[A-Z_][A-Z_0-9]*/,
|
|
282
|
-
|
|
283
|
-
// // Literals
|
|
284
|
-
// boolean_literal: $ => choice("true", "false"),
|
|
285
|
-
// integer_literal: $ => token(seq(optional(/[1-9]/), DEC_DIGITS)),
|
|
286
|
-
// hex_literal: $ => token(seq("0", /[xX]/, HEX_DIGITS)),
|
|
287
|
-
// bin_literal: $ => token(seq("0", /[bB]/, BIN_DIGITS)),
|
|
288
|
-
// float_literal: $ => token(choice(
|
|
289
|
-
// seq(
|
|
290
|
-
// seq(optional(DEC_DIGITS), ".", DEC_DIGITS),
|
|
291
|
-
// optional(/[fF]/)
|
|
292
|
-
// ),
|
|
293
|
-
// seq(DEC_DIGITS, /[fF]/)
|
|
294
|
-
// )),
|
|
295
|
-
// character_literal: $ => seq(
|
|
296
|
-
// "'",
|
|
297
|
-
// choice($.character_escape_seq, /[^\n\r'\\]/),
|
|
298
|
-
// "'"
|
|
299
|
-
// ),
|
|
300
|
-
// character_escape_seq: $ => choice(
|
|
301
|
-
// $._uni_character_literal,
|
|
302
|
-
// $._escaped_identifier
|
|
303
|
-
// ),
|
|
304
|
-
// _uni_character_literal: $ => seq(
|
|
305
|
-
// "\\u",
|
|
306
|
-
// /[0-9a-fA-F]{4}/
|
|
307
|
-
// ),
|
|
308
|
-
// _escaped_identifier: $ => /\\[tbrn'"\\$]/,
|
|
309
|
-
|
|
310
|
-
// _string_literal: $ => choice(
|
|
311
|
-
// $.line_string_literal,
|
|
312
|
-
// $.multi_line_string_literal
|
|
313
|
-
// ),
|
|
314
|
-
|
|
315
|
-
// line_string_literal: $ => seq('"', repeat(choice($._line_string_content, $._interpolation)), '"'),
|
|
316
|
-
|
|
317
|
-
// multi_line_string_literal: $ => seq(
|
|
318
|
-
// '`',
|
|
319
|
-
// repeat(choice(
|
|
320
|
-
// $._multi_line_string_content,
|
|
321
|
-
// $._interpolation
|
|
322
|
-
// )),
|
|
323
|
-
// '`'
|
|
324
|
-
// ),
|
|
325
|
-
|
|
326
|
-
// _line_string_content: $ => choice(
|
|
327
|
-
// $._line_str_text,
|
|
328
|
-
// $.character_escape_seq
|
|
329
|
-
// ),
|
|
330
|
-
|
|
331
|
-
// _multi_line_string_content: $ => choice($._multi_line_str_text, '"'),
|
|
332
|
-
|
|
333
|
-
// _line_str_text: $ => /[^\\"$]+/,
|
|
334
|
-
|
|
335
|
-
// _multi_line_str_text: $ => /[^"$]+/,
|
|
336
|
-
|
|
337
|
-
// _interpolation: $ => choice(
|
|
338
|
-
// // seq("${", alias($._expression, $.interpolated_expression), "}"),
|
|
339
|
-
// seq("$", alias($.identifier, $.interpolated_identifier))
|
|
340
|
-
// ),
|
|
341
|
-
|
|
342
|
-
// _literal_constant: $ => choice(
|
|
343
|
-
// $.boolean_literal,
|
|
344
|
-
// $.integer_literal,
|
|
345
|
-
// $.hex_literal,
|
|
346
|
-
// $.bin_literal,
|
|
347
|
-
// $.character_literal,
|
|
348
|
-
// $.float_literal,
|
|
349
|
-
// "null",
|
|
350
|
-
// ),
|
|
351
|
-
|
|
352
|
-
// comment: $ => token(prec(PREC.COMMENT, choice(
|
|
353
|
-
// seq("#", /.*/),
|
|
354
|
-
// ))),
|
|
355
228
|
}
|
|
356
229
|
});
|
|
357
230
|
|
|
@@ -369,4 +242,13 @@ function sep1(rule, separator) {
|
|
|
369
242
|
|
|
370
243
|
function series_of(rule, separator) {
|
|
371
244
|
return seq(rule, repeat(seq(separator, rule)), optional(separator));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// A binary expression with a left-hand side, infix operator, and then right-hand-side
|
|
248
|
+
// https://github.com/elixir-lang/tree-sitter-elixir/blob/de20391afe5cb03ef1e8a8e43167e7b58cc52869/grammar.js#L850-L859
|
|
249
|
+
function binaryExpr(assoc, precedence, operator, expr) {
|
|
250
|
+
return assoc(
|
|
251
|
+
precedence,
|
|
252
|
+
seq(field("left", expr), field("operator", operator), field("right", expr))
|
|
253
|
+
);
|
|
372
254
|
}
|
package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-palm",
|
|
3
3
|
"version": "0.1.0",
|
|
4
|
+
"description": "A tree-sitter grammar for the Palm programming language",
|
|
4
5
|
"main": "bindings/node",
|
|
5
|
-
"description": "Tree-Sitter grammar for pine",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "tree-sitter test",
|
|
8
8
|
"install": "node-gyp rebuild",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"author": "pyrossh",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"keywords": [
|
|
17
|
+
"palm",
|
|
17
18
|
"tree-sitter",
|
|
18
|
-
"pine",
|
|
19
|
-
"grammar",
|
|
20
19
|
"parser",
|
|
21
|
-
"lexer"
|
|
20
|
+
"lexer",
|
|
21
|
+
"grammar"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"nan": "^2.17.0"
|
|
@@ -26,13 +26,17 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tree-sitter-cli": "^0.20.7"
|
|
28
28
|
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
29
|
-
|
|
31
|
+
"url": "git+ssh://git@github.com/pyrossh/tree-sitter-palm.git"
|
|
32
|
+
},
|
|
30
33
|
"tree-sitter": [
|
|
31
34
|
{
|
|
32
|
-
"scope": "source.
|
|
35
|
+
"scope": "source.palm",
|
|
33
36
|
"file-types": [
|
|
34
|
-
"
|
|
37
|
+
"palm"
|
|
35
|
-
]
|
|
38
|
+
],
|
|
39
|
+
"injection-regex": "^palm$"
|
|
36
40
|
}
|
|
37
41
|
]
|
|
38
42
|
}
|
src/grammar.json
CHANGED
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
{
|
|
28
28
|
"type": "SYMBOL",
|
|
29
29
|
"name": "type"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "SYMBOL",
|
|
33
|
+
"name": "proc"
|
|
30
34
|
}
|
|
31
35
|
]
|
|
32
36
|
}
|
|
@@ -391,7 +395,7 @@
|
|
|
391
395
|
}
|
|
392
396
|
]
|
|
393
397
|
},
|
|
394
|
-
"
|
|
398
|
+
"proc": {
|
|
395
399
|
"type": "SEQ",
|
|
396
400
|
"members": [
|
|
397
401
|
{
|
|
@@ -399,28 +403,28 @@
|
|
|
399
403
|
"name": "name",
|
|
400
404
|
"content": {
|
|
401
405
|
"type": "SYMBOL",
|
|
402
|
-
"name": "
|
|
406
|
+
"name": "identifier"
|
|
403
407
|
}
|
|
404
408
|
},
|
|
405
409
|
{
|
|
406
410
|
"type": "FIELD",
|
|
407
|
-
"name": "
|
|
411
|
+
"name": "params",
|
|
408
412
|
"content": {
|
|
409
|
-
"type": "
|
|
413
|
+
"type": "SEQ",
|
|
410
414
|
"members": [
|
|
411
415
|
{
|
|
412
|
-
"type": "
|
|
416
|
+
"type": "STRING",
|
|
417
|
+
"value": "("
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"type": "CHOICE",
|
|
413
421
|
"members": [
|
|
414
|
-
{
|
|
415
|
-
"type": "STRING",
|
|
416
|
-
"value": "("
|
|
417
|
-
},
|
|
418
422
|
{
|
|
419
423
|
"type": "SEQ",
|
|
420
424
|
"members": [
|
|
421
425
|
{
|
|
422
426
|
"type": "SYMBOL",
|
|
423
|
-
"name": "
|
|
427
|
+
"name": "type_field"
|
|
424
428
|
},
|
|
425
429
|
{
|
|
426
430
|
"type": "REPEAT",
|
|
@@ -433,7 +437,7 @@
|
|
|
433
437
|
},
|
|
434
438
|
{
|
|
435
439
|
"type": "SYMBOL",
|
|
436
|
-
"name": "
|
|
440
|
+
"name": "type_field"
|
|
437
441
|
}
|
|
438
442
|
]
|
|
439
443
|
}
|
|
@@ -441,29 +445,16 @@
|
|
|
441
445
|
]
|
|
442
446
|
},
|
|
443
447
|
{
|
|
444
|
-
"type": "
|
|
448
|
+
"type": "BLANK"
|
|
445
|
-
"value": ")"
|
|
446
449
|
}
|
|
447
450
|
]
|
|
448
451
|
},
|
|
449
452
|
{
|
|
450
|
-
"type": "
|
|
453
|
+
"type": "STRING",
|
|
454
|
+
"value": ")"
|
|
451
455
|
}
|
|
452
456
|
]
|
|
453
457
|
}
|
|
454
|
-
}
|
|
455
|
-
]
|
|
456
|
-
},
|
|
457
|
-
"type_name": {
|
|
458
|
-
"type": "SEQ",
|
|
459
|
-
"members": [
|
|
460
|
-
{
|
|
461
|
-
"type": "FIELD",
|
|
462
|
-
"name": "name",
|
|
463
|
-
"content": {
|
|
464
|
-
"type": "SYMBOL",
|
|
465
|
-
"name": "type_identifier"
|
|
466
|
-
}
|
|
467
458
|
},
|
|
468
459
|
{
|
|
469
460
|
"type": "CHOICE",
|
|
@@ -473,45 +464,23 @@
|
|
|
473
464
|
"members": [
|
|
474
465
|
{
|
|
475
466
|
"type": "STRING",
|
|
476
|
-
"value": "
|
|
467
|
+
"value": "->"
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
"type": "CHOICE",
|
|
480
|
-
"members": [
|
|
481
|
-
{
|
|
482
|
-
"type": "SYMBOL",
|
|
483
|
-
"name": "identifier"
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
"type": "SEQ",
|
|
487
|
-
"members": [
|
|
488
|
-
{
|
|
489
|
-
"type": "SYMBOL",
|
|
490
|
-
"name": "type_field"
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
"type": "REPEAT",
|
|
494
|
-
"content": {
|
|
495
|
-
"type": "SEQ",
|
|
496
|
-
"members": [
|
|
497
|
-
{
|
|
498
|
-
"type": "STRING",
|
|
499
|
-
"value": ","
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
"type": "SYMBOL",
|
|
503
|
-
"name": "type_field"
|
|
504
|
-
}
|
|
505
|
-
]
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
]
|
|
509
|
-
}
|
|
510
|
-
]
|
|
511
468
|
},
|
|
512
469
|
{
|
|
470
|
+
"type": "FIELD",
|
|
471
|
+
"name": "return_type",
|
|
472
|
+
"content": {
|
|
513
|
-
|
|
473
|
+
"type": "CHOICE",
|
|
474
|
+
"members": [
|
|
475
|
+
{
|
|
476
|
+
"type": "SYMBOL",
|
|
477
|
+
"name": "return_type"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
514
|
-
|
|
480
|
+
"type": "BLANK"
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
515
484
|
}
|
|
516
485
|
]
|
|
517
486
|
},
|
|
@@ -519,127 +488,1187 @@
|
|
|
519
488
|
"type": "BLANK"
|
|
520
489
|
}
|
|
521
490
|
]
|
|
522
|
-
}
|
|
523
|
-
]
|
|
524
|
-
},
|
|
525
|
-
"type_field": {
|
|
526
|
-
"type": "SEQ",
|
|
527
|
-
"members": [
|
|
528
|
-
{
|
|
529
|
-
"type": "FIELD",
|
|
530
|
-
"name": "name",
|
|
531
|
-
"content": {
|
|
532
|
-
"type": "SYMBOL",
|
|
533
|
-
"name": "identifier"
|
|
534
|
-
}
|
|
535
491
|
},
|
|
536
492
|
{
|
|
537
493
|
"type": "STRING",
|
|
538
|
-
"value": "
|
|
494
|
+
"value": "="
|
|
539
495
|
},
|
|
540
496
|
{
|
|
541
497
|
"type": "FIELD",
|
|
542
|
-
"name": "
|
|
498
|
+
"name": "body",
|
|
543
499
|
"content": {
|
|
544
500
|
"type": "SYMBOL",
|
|
545
|
-
"name": "
|
|
501
|
+
"name": "_statement_seq"
|
|
546
502
|
}
|
|
547
503
|
}
|
|
548
504
|
]
|
|
549
505
|
},
|
|
550
|
-
"
|
|
506
|
+
"_statement_seq": {
|
|
551
|
-
"type": "
|
|
507
|
+
"type": "REPEAT1",
|
|
552
|
-
"value": "[a-zA-Z_][a-zA-Z_0-9]*"
|
|
553
|
-
},
|
|
554
|
-
|
|
508
|
+
"content": {
|
|
555
|
-
|
|
509
|
+
"type": "SYMBOL",
|
|
556
|
-
|
|
510
|
+
"name": "_statement"
|
|
511
|
+
}
|
|
557
512
|
},
|
|
558
|
-
"
|
|
513
|
+
"_statement": {
|
|
559
|
-
"type": "
|
|
514
|
+
"type": "CHOICE",
|
|
560
515
|
"members": [
|
|
561
516
|
{
|
|
562
|
-
"type": "
|
|
517
|
+
"type": "SYMBOL",
|
|
563
|
-
"
|
|
518
|
+
"name": "_expression"
|
|
564
519
|
},
|
|
565
520
|
{
|
|
566
|
-
"type": "
|
|
521
|
+
"type": "SYMBOL",
|
|
522
|
+
"name": "let"
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
},
|
|
526
|
+
"_expression": {
|
|
527
|
+
"type": "CHOICE",
|
|
567
|
-
|
|
528
|
+
"members": [
|
|
568
|
-
|
|
529
|
+
{
|
|
569
|
-
|
|
530
|
+
"type": "SYMBOL",
|
|
570
|
-
|
|
531
|
+
"name": "_expression_unit"
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
"type": "REPEAT",
|
|
574
|
-
"content": {
|
|
575
|
-
"type": "SEQ",
|
|
576
|
-
"members": [
|
|
577
|
-
{
|
|
578
|
-
"type": "STRING",
|
|
579
|
-
"value": ","
|
|
580
|
-
},
|
|
581
|
-
{
|
|
582
|
-
"type": "SYMBOL",
|
|
583
|
-
"name": "identifier"
|
|
584
|
-
}
|
|
585
|
-
]
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
]
|
|
589
532
|
},
|
|
590
533
|
{
|
|
591
|
-
"type": "
|
|
534
|
+
"type": "SYMBOL",
|
|
592
|
-
"
|
|
535
|
+
"name": "binary_expression"
|
|
593
536
|
}
|
|
594
537
|
]
|
|
595
538
|
},
|
|
596
|
-
"
|
|
539
|
+
"binary_expression": {
|
|
597
|
-
"type": "PATTERN",
|
|
598
|
-
"value": "_[_0-9a-z]*"
|
|
599
|
-
},
|
|
600
|
-
"_name": {
|
|
601
|
-
"type": "PATTERN",
|
|
602
|
-
"value": "[_a-z][_0-9a-z]*"
|
|
603
|
-
},
|
|
604
|
-
"_upname": {
|
|
605
|
-
"type": "PATTERN",
|
|
606
|
-
"value": "[A-Z][0-9a-zA-Z]*"
|
|
607
|
-
},
|
|
608
|
-
"url": {
|
|
609
|
-
"type": "
|
|
540
|
+
"type": "CHOICE",
|
|
610
541
|
"members": [
|
|
611
542
|
{
|
|
543
|
+
"type": "PREC_LEFT",
|
|
544
|
+
"value": 1,
|
|
545
|
+
"content": {
|
|
546
|
+
"type": "SEQ",
|
|
547
|
+
"members": [
|
|
548
|
+
{
|
|
549
|
+
"type": "FIELD",
|
|
550
|
+
"name": "left",
|
|
551
|
+
"content": {
|
|
552
|
+
"type": "SYMBOL",
|
|
553
|
+
"name": "_expression"
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
"type": "FIELD",
|
|
558
|
+
"name": "operator",
|
|
559
|
+
"content": {
|
|
612
|
-
|
|
560
|
+
"type": "STRING",
|
|
561
|
+
"value": "||"
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"type": "FIELD",
|
|
566
|
+
"name": "right",
|
|
567
|
+
"content": {
|
|
568
|
+
"type": "SYMBOL",
|
|
613
|
-
|
|
569
|
+
"name": "_expression"
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
]
|
|
573
|
+
}
|
|
614
574
|
},
|
|
615
575
|
{
|
|
616
|
-
"type": "
|
|
576
|
+
"type": "PREC_LEFT",
|
|
577
|
+
"value": 2,
|
|
617
578
|
"content": {
|
|
618
579
|
"type": "SEQ",
|
|
619
580
|
"members": [
|
|
620
581
|
{
|
|
582
|
+
"type": "FIELD",
|
|
583
|
+
"name": "left",
|
|
584
|
+
"content": {
|
|
585
|
+
"type": "SYMBOL",
|
|
586
|
+
"name": "_expression"
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"type": "FIELD",
|
|
591
|
+
"name": "operator",
|
|
592
|
+
"content": {
|
|
621
|
-
|
|
593
|
+
"type": "STRING",
|
|
622
|
-
|
|
594
|
+
"value": "&&"
|
|
595
|
+
}
|
|
623
596
|
},
|
|
624
597
|
{
|
|
625
|
-
"type": "
|
|
598
|
+
"type": "FIELD",
|
|
599
|
+
"name": "right",
|
|
600
|
+
"content": {
|
|
601
|
+
"type": "SYMBOL",
|
|
626
|
-
|
|
602
|
+
"name": "_expression"
|
|
603
|
+
}
|
|
627
604
|
}
|
|
628
605
|
]
|
|
629
606
|
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"type": "PREC_LEFT",
|
|
610
|
+
"value": 3,
|
|
611
|
+
"content": {
|
|
612
|
+
"type": "SEQ",
|
|
613
|
+
"members": [
|
|
614
|
+
{
|
|
615
|
+
"type": "FIELD",
|
|
616
|
+
"name": "left",
|
|
617
|
+
"content": {
|
|
618
|
+
"type": "SYMBOL",
|
|
619
|
+
"name": "_expression"
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"type": "FIELD",
|
|
624
|
+
"name": "operator",
|
|
625
|
+
"content": {
|
|
626
|
+
"type": "STRING",
|
|
627
|
+
"value": "=="
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
"type": "FIELD",
|
|
632
|
+
"name": "right",
|
|
633
|
+
"content": {
|
|
634
|
+
"type": "SYMBOL",
|
|
635
|
+
"name": "_expression"
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"type": "PREC_LEFT",
|
|
643
|
+
"value": 3,
|
|
644
|
+
"content": {
|
|
645
|
+
"type": "SEQ",
|
|
646
|
+
"members": [
|
|
647
|
+
{
|
|
648
|
+
"type": "FIELD",
|
|
649
|
+
"name": "left",
|
|
650
|
+
"content": {
|
|
651
|
+
"type": "SYMBOL",
|
|
652
|
+
"name": "_expression"
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
"type": "FIELD",
|
|
657
|
+
"name": "operator",
|
|
658
|
+
"content": {
|
|
659
|
+
"type": "STRING",
|
|
660
|
+
"value": "!="
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"type": "FIELD",
|
|
665
|
+
"name": "right",
|
|
666
|
+
"content": {
|
|
667
|
+
"type": "SYMBOL",
|
|
668
|
+
"name": "_expression"
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"type": "PREC_LEFT",
|
|
676
|
+
"value": 4,
|
|
677
|
+
"content": {
|
|
678
|
+
"type": "SEQ",
|
|
679
|
+
"members": [
|
|
680
|
+
{
|
|
681
|
+
"type": "FIELD",
|
|
682
|
+
"name": "left",
|
|
683
|
+
"content": {
|
|
684
|
+
"type": "SYMBOL",
|
|
685
|
+
"name": "_expression"
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"type": "FIELD",
|
|
690
|
+
"name": "operator",
|
|
691
|
+
"content": {
|
|
692
|
+
"type": "STRING",
|
|
693
|
+
"value": "<"
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"type": "FIELD",
|
|
698
|
+
"name": "right",
|
|
699
|
+
"content": {
|
|
700
|
+
"type": "SYMBOL",
|
|
701
|
+
"name": "_expression"
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
]
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
"type": "PREC_LEFT",
|
|
709
|
+
"value": 4,
|
|
710
|
+
"content": {
|
|
711
|
+
"type": "SEQ",
|
|
712
|
+
"members": [
|
|
713
|
+
{
|
|
714
|
+
"type": "FIELD",
|
|
715
|
+
"name": "left",
|
|
716
|
+
"content": {
|
|
717
|
+
"type": "SYMBOL",
|
|
718
|
+
"name": "_expression"
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
"type": "FIELD",
|
|
723
|
+
"name": "operator",
|
|
724
|
+
"content": {
|
|
725
|
+
"type": "STRING",
|
|
726
|
+
"value": "<="
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"type": "FIELD",
|
|
731
|
+
"name": "right",
|
|
732
|
+
"content": {
|
|
733
|
+
"type": "SYMBOL",
|
|
734
|
+
"name": "_expression"
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
]
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
"type": "PREC_LEFT",
|
|
742
|
+
"value": 4,
|
|
743
|
+
"content": {
|
|
744
|
+
"type": "SEQ",
|
|
745
|
+
"members": [
|
|
746
|
+
{
|
|
747
|
+
"type": "FIELD",
|
|
748
|
+
"name": "left",
|
|
749
|
+
"content": {
|
|
750
|
+
"type": "SYMBOL",
|
|
751
|
+
"name": "_expression"
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
"type": "FIELD",
|
|
756
|
+
"name": "operator",
|
|
757
|
+
"content": {
|
|
758
|
+
"type": "STRING",
|
|
759
|
+
"value": ">"
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"type": "FIELD",
|
|
764
|
+
"name": "right",
|
|
765
|
+
"content": {
|
|
766
|
+
"type": "SYMBOL",
|
|
767
|
+
"name": "_expression"
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"type": "PREC_LEFT",
|
|
775
|
+
"value": 4,
|
|
776
|
+
"content": {
|
|
777
|
+
"type": "SEQ",
|
|
778
|
+
"members": [
|
|
779
|
+
{
|
|
780
|
+
"type": "FIELD",
|
|
781
|
+
"name": "left",
|
|
782
|
+
"content": {
|
|
783
|
+
"type": "SYMBOL",
|
|
784
|
+
"name": "_expression"
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"type": "FIELD",
|
|
789
|
+
"name": "operator",
|
|
790
|
+
"content": {
|
|
791
|
+
"type": "STRING",
|
|
792
|
+
"value": ">="
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
"type": "FIELD",
|
|
797
|
+
"name": "right",
|
|
798
|
+
"content": {
|
|
799
|
+
"type": "SYMBOL",
|
|
800
|
+
"name": "_expression"
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"type": "PREC_LEFT",
|
|
808
|
+
"value": 5,
|
|
809
|
+
"content": {
|
|
810
|
+
"type": "SEQ",
|
|
811
|
+
"members": [
|
|
812
|
+
{
|
|
813
|
+
"type": "FIELD",
|
|
814
|
+
"name": "left",
|
|
815
|
+
"content": {
|
|
816
|
+
"type": "SYMBOL",
|
|
817
|
+
"name": "_expression"
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"type": "FIELD",
|
|
822
|
+
"name": "operator",
|
|
823
|
+
"content": {
|
|
824
|
+
"type": "STRING",
|
|
825
|
+
"value": "|>"
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
"type": "FIELD",
|
|
830
|
+
"name": "right",
|
|
831
|
+
"content": {
|
|
832
|
+
"type": "SYMBOL",
|
|
833
|
+
"name": "_expression"
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
]
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
"type": "PREC_LEFT",
|
|
841
|
+
"value": 6,
|
|
842
|
+
"content": {
|
|
843
|
+
"type": "SEQ",
|
|
844
|
+
"members": [
|
|
845
|
+
{
|
|
846
|
+
"type": "FIELD",
|
|
847
|
+
"name": "left",
|
|
848
|
+
"content": {
|
|
849
|
+
"type": "SYMBOL",
|
|
850
|
+
"name": "_expression"
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"type": "FIELD",
|
|
855
|
+
"name": "operator",
|
|
856
|
+
"content": {
|
|
857
|
+
"type": "STRING",
|
|
858
|
+
"value": "+"
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
"type": "FIELD",
|
|
863
|
+
"name": "right",
|
|
864
|
+
"content": {
|
|
865
|
+
"type": "SYMBOL",
|
|
866
|
+
"name": "_expression"
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
]
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"type": "PREC_LEFT",
|
|
874
|
+
"value": 6,
|
|
875
|
+
"content": {
|
|
876
|
+
"type": "SEQ",
|
|
877
|
+
"members": [
|
|
878
|
+
{
|
|
879
|
+
"type": "FIELD",
|
|
880
|
+
"name": "left",
|
|
881
|
+
"content": {
|
|
882
|
+
"type": "SYMBOL",
|
|
883
|
+
"name": "_expression"
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"type": "FIELD",
|
|
888
|
+
"name": "operator",
|
|
889
|
+
"content": {
|
|
890
|
+
"type": "STRING",
|
|
891
|
+
"value": "-"
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
"type": "FIELD",
|
|
896
|
+
"name": "right",
|
|
897
|
+
"content": {
|
|
898
|
+
"type": "SYMBOL",
|
|
899
|
+
"name": "_expression"
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
]
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"type": "PREC_LEFT",
|
|
907
|
+
"value": 7,
|
|
908
|
+
"content": {
|
|
909
|
+
"type": "SEQ",
|
|
910
|
+
"members": [
|
|
911
|
+
{
|
|
912
|
+
"type": "FIELD",
|
|
913
|
+
"name": "left",
|
|
914
|
+
"content": {
|
|
915
|
+
"type": "SYMBOL",
|
|
916
|
+
"name": "_expression"
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"type": "FIELD",
|
|
921
|
+
"name": "operator",
|
|
922
|
+
"content": {
|
|
923
|
+
"type": "STRING",
|
|
924
|
+
"value": "*"
|
|
925
|
+
}
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
"type": "FIELD",
|
|
929
|
+
"name": "right",
|
|
930
|
+
"content": {
|
|
931
|
+
"type": "SYMBOL",
|
|
932
|
+
"name": "_expression"
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
]
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"type": "PREC_LEFT",
|
|
940
|
+
"value": 7,
|
|
941
|
+
"content": {
|
|
942
|
+
"type": "SEQ",
|
|
943
|
+
"members": [
|
|
944
|
+
{
|
|
945
|
+
"type": "FIELD",
|
|
946
|
+
"name": "left",
|
|
947
|
+
"content": {
|
|
948
|
+
"type": "SYMBOL",
|
|
949
|
+
"name": "_expression"
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
"type": "FIELD",
|
|
954
|
+
"name": "operator",
|
|
955
|
+
"content": {
|
|
956
|
+
"type": "STRING",
|
|
957
|
+
"value": "/"
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"type": "FIELD",
|
|
962
|
+
"name": "right",
|
|
963
|
+
"content": {
|
|
964
|
+
"type": "SYMBOL",
|
|
965
|
+
"name": "_expression"
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
]
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"type": "PREC_LEFT",
|
|
973
|
+
"value": 7,
|
|
974
|
+
"content": {
|
|
975
|
+
"type": "SEQ",
|
|
976
|
+
"members": [
|
|
977
|
+
{
|
|
978
|
+
"type": "FIELD",
|
|
979
|
+
"name": "left",
|
|
980
|
+
"content": {
|
|
981
|
+
"type": "SYMBOL",
|
|
982
|
+
"name": "_expression"
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"type": "FIELD",
|
|
987
|
+
"name": "operator",
|
|
988
|
+
"content": {
|
|
989
|
+
"type": "STRING",
|
|
990
|
+
"value": "%"
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
"type": "FIELD",
|
|
995
|
+
"name": "right",
|
|
996
|
+
"content": {
|
|
997
|
+
"type": "SYMBOL",
|
|
998
|
+
"name": "_expression"
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
"type": "PREC_LEFT",
|
|
1006
|
+
"value": 7,
|
|
1007
|
+
"content": {
|
|
1008
|
+
"type": "SEQ",
|
|
1009
|
+
"members": [
|
|
1010
|
+
{
|
|
1011
|
+
"type": "FIELD",
|
|
1012
|
+
"name": "left",
|
|
1013
|
+
"content": {
|
|
1014
|
+
"type": "SYMBOL",
|
|
1015
|
+
"name": "_expression"
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
"type": "FIELD",
|
|
1020
|
+
"name": "operator",
|
|
1021
|
+
"content": {
|
|
1022
|
+
"type": "STRING",
|
|
1023
|
+
"value": "<>"
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
"type": "FIELD",
|
|
1028
|
+
"name": "right",
|
|
1029
|
+
"content": {
|
|
1030
|
+
"type": "SYMBOL",
|
|
1031
|
+
"name": "_expression"
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
]
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
]
|
|
1038
|
+
},
|
|
1039
|
+
"_expression_unit": {
|
|
1040
|
+
"type": "CHOICE",
|
|
1041
|
+
"members": [
|
|
1042
|
+
{
|
|
1043
|
+
"type": "SYMBOL",
|
|
1044
|
+
"name": "string"
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
"type": "SYMBOL",
|
|
1048
|
+
"name": "integer"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"type": "SYMBOL",
|
|
1052
|
+
"name": "float"
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
"type": "SYMBOL",
|
|
1056
|
+
"name": "record"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
"type": "SYMBOL",
|
|
1060
|
+
"name": "identifier"
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"type": "SYMBOL",
|
|
1064
|
+
"name": "todo"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"type": "SYMBOL",
|
|
1068
|
+
"name": "panic"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"type": "SYMBOL",
|
|
1072
|
+
"name": "expression_group"
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
"type": "SYMBOL",
|
|
1076
|
+
"name": "negation"
|
|
1077
|
+
}
|
|
1078
|
+
]
|
|
1079
|
+
},
|
|
1080
|
+
"expression_group": {
|
|
1081
|
+
"type": "SEQ",
|
|
1082
|
+
"members": [
|
|
1083
|
+
{
|
|
1084
|
+
"type": "STRING",
|
|
1085
|
+
"value": "{"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
"type": "SYMBOL",
|
|
1089
|
+
"name": "_statement_seq"
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
"type": "STRING",
|
|
1093
|
+
"value": "}"
|
|
1094
|
+
}
|
|
1095
|
+
]
|
|
1096
|
+
},
|
|
1097
|
+
"negation": {
|
|
1098
|
+
"type": "SEQ",
|
|
1099
|
+
"members": [
|
|
1100
|
+
{
|
|
1101
|
+
"type": "STRING",
|
|
1102
|
+
"value": "!"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
"type": "SYMBOL",
|
|
1106
|
+
"name": "_expression_unit"
|
|
1107
|
+
}
|
|
1108
|
+
]
|
|
1109
|
+
},
|
|
1110
|
+
"let": {
|
|
1111
|
+
"type": "SEQ",
|
|
1112
|
+
"members": [
|
|
1113
|
+
{
|
|
1114
|
+
"type": "STRING",
|
|
1115
|
+
"value": "let"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
"type": "SYMBOL",
|
|
1119
|
+
"name": "_assignment"
|
|
1120
|
+
}
|
|
1121
|
+
]
|
|
1122
|
+
},
|
|
1123
|
+
"_assignment": {
|
|
1124
|
+
"type": "SEQ",
|
|
1125
|
+
"members": [
|
|
1126
|
+
{
|
|
1127
|
+
"type": "FIELD",
|
|
1128
|
+
"name": "pattern",
|
|
1129
|
+
"content": {
|
|
1130
|
+
"type": "SYMBOL",
|
|
1131
|
+
"name": "_pattern"
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
"type": "CHOICE",
|
|
1136
|
+
"members": [
|
|
1137
|
+
{
|
|
1138
|
+
"type": "SYMBOL",
|
|
1139
|
+
"name": "_type_annotation"
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
"type": "BLANK"
|
|
1143
|
+
}
|
|
1144
|
+
]
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"type": "STRING",
|
|
1148
|
+
"value": "="
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
"type": "FIELD",
|
|
1152
|
+
"name": "value",
|
|
1153
|
+
"content": {
|
|
1154
|
+
"type": "SYMBOL",
|
|
1155
|
+
"name": "_expression"
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
]
|
|
1159
|
+
},
|
|
1160
|
+
"_pattern": {
|
|
1161
|
+
"type": "SEQ",
|
|
1162
|
+
"members": [
|
|
1163
|
+
{
|
|
1164
|
+
"type": "SYMBOL",
|
|
1165
|
+
"name": "_pattern_expression"
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
"type": "CHOICE",
|
|
1169
|
+
"members": [
|
|
1170
|
+
{
|
|
1171
|
+
"type": "FIELD",
|
|
1172
|
+
"name": "assign",
|
|
1173
|
+
"content": {
|
|
1174
|
+
"type": "SEQ",
|
|
1175
|
+
"members": [
|
|
1176
|
+
{
|
|
1177
|
+
"type": "STRING",
|
|
1178
|
+
"value": "as"
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
"type": "SYMBOL",
|
|
1182
|
+
"name": "identifier"
|
|
1183
|
+
}
|
|
1184
|
+
]
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
"type": "BLANK"
|
|
1189
|
+
}
|
|
1190
|
+
]
|
|
1191
|
+
}
|
|
1192
|
+
]
|
|
1193
|
+
},
|
|
1194
|
+
"_pattern_expression": {
|
|
1195
|
+
"type": "CHOICE",
|
|
1196
|
+
"members": [
|
|
1197
|
+
{
|
|
1198
|
+
"type": "SYMBOL",
|
|
1199
|
+
"name": "identifier"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"type": "SYMBOL",
|
|
1203
|
+
"name": "integer"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
"type": "SYMBOL",
|
|
1207
|
+
"name": "float"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"type": "ALIAS",
|
|
1211
|
+
"content": {
|
|
1212
|
+
"type": "SYMBOL",
|
|
1213
|
+
"name": "_pattern_binary_expression"
|
|
1214
|
+
},
|
|
1215
|
+
"named": true,
|
|
1216
|
+
"value": "binary_expression"
|
|
1217
|
+
}
|
|
1218
|
+
]
|
|
1219
|
+
},
|
|
1220
|
+
"_pattern_binary_expression": {
|
|
1221
|
+
"type": "PREC_LEFT",
|
|
1222
|
+
"value": 1,
|
|
1223
|
+
"content": {
|
|
1224
|
+
"type": "SEQ",
|
|
1225
|
+
"members": [
|
|
1226
|
+
{
|
|
1227
|
+
"type": "FIELD",
|
|
1228
|
+
"name": "left",
|
|
1229
|
+
"content": {
|
|
1230
|
+
"type": "SYMBOL",
|
|
1231
|
+
"name": "_pattern_expression"
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
"type": "FIELD",
|
|
1236
|
+
"name": "operator",
|
|
1237
|
+
"content": {
|
|
1238
|
+
"type": "STRING",
|
|
1239
|
+
"value": "<>"
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
"type": "FIELD",
|
|
1244
|
+
"name": "right",
|
|
1245
|
+
"content": {
|
|
1246
|
+
"type": "SYMBOL",
|
|
1247
|
+
"name": "_pattern_expression"
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
]
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
"todo": {
|
|
1254
|
+
"type": "SEQ",
|
|
1255
|
+
"members": [
|
|
1256
|
+
{
|
|
1257
|
+
"type": "STRING",
|
|
1258
|
+
"value": "todo"
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
"type": "CHOICE",
|
|
1262
|
+
"members": [
|
|
1263
|
+
{
|
|
1264
|
+
"type": "SEQ",
|
|
1265
|
+
"members": [
|
|
1266
|
+
{
|
|
1267
|
+
"type": "STRING",
|
|
1268
|
+
"value": "("
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
"type": "FIELD",
|
|
1272
|
+
"name": "message",
|
|
1273
|
+
"content": {
|
|
1274
|
+
"type": "SYMBOL",
|
|
1275
|
+
"name": "string"
|
|
1276
|
+
}
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"type": "STRING",
|
|
1280
|
+
"value": ")"
|
|
1281
|
+
}
|
|
1282
|
+
]
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
"type": "BLANK"
|
|
1286
|
+
}
|
|
1287
|
+
]
|
|
1288
|
+
}
|
|
1289
|
+
]
|
|
1290
|
+
},
|
|
1291
|
+
"panic": {
|
|
1292
|
+
"type": "SEQ",
|
|
1293
|
+
"members": [
|
|
1294
|
+
{
|
|
1295
|
+
"type": "STRING",
|
|
1296
|
+
"value": "panic"
|
|
1297
|
+
}
|
|
1298
|
+
]
|
|
1299
|
+
},
|
|
1300
|
+
"return_type": {
|
|
1301
|
+
"type": "SEQ",
|
|
1302
|
+
"members": [
|
|
1303
|
+
{
|
|
1304
|
+
"type": "FIELD",
|
|
1305
|
+
"name": "name",
|
|
1306
|
+
"content": {
|
|
1307
|
+
"type": "SYMBOL",
|
|
1308
|
+
"name": "type_identifier"
|
|
1309
|
+
}
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
"type": "FIELD",
|
|
1313
|
+
"name": "generics",
|
|
1314
|
+
"content": {
|
|
1315
|
+
"type": "CHOICE",
|
|
1316
|
+
"members": [
|
|
1317
|
+
{
|
|
1318
|
+
"type": "SEQ",
|
|
1319
|
+
"members": [
|
|
1320
|
+
{
|
|
1321
|
+
"type": "STRING",
|
|
1322
|
+
"value": "("
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
"type": "SEQ",
|
|
1326
|
+
"members": [
|
|
1327
|
+
{
|
|
1328
|
+
"type": "SYMBOL",
|
|
1329
|
+
"name": "identifier"
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
"type": "REPEAT",
|
|
1333
|
+
"content": {
|
|
1334
|
+
"type": "SEQ",
|
|
1335
|
+
"members": [
|
|
1336
|
+
{
|
|
1337
|
+
"type": "STRING",
|
|
1338
|
+
"value": ","
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
"type": "SYMBOL",
|
|
1342
|
+
"name": "identifier"
|
|
1343
|
+
}
|
|
1344
|
+
]
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
]
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
"type": "STRING",
|
|
1351
|
+
"value": ")"
|
|
1352
|
+
}
|
|
1353
|
+
]
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
"type": "BLANK"
|
|
1357
|
+
}
|
|
1358
|
+
]
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
]
|
|
1362
|
+
},
|
|
1363
|
+
"type_name": {
|
|
1364
|
+
"type": "SEQ",
|
|
1365
|
+
"members": [
|
|
1366
|
+
{
|
|
1367
|
+
"type": "FIELD",
|
|
1368
|
+
"name": "name",
|
|
1369
|
+
"content": {
|
|
1370
|
+
"type": "SYMBOL",
|
|
1371
|
+
"name": "type_identifier"
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
"type": "CHOICE",
|
|
1376
|
+
"members": [
|
|
1377
|
+
{
|
|
1378
|
+
"type": "SEQ",
|
|
1379
|
+
"members": [
|
|
1380
|
+
{
|
|
1381
|
+
"type": "STRING",
|
|
1382
|
+
"value": "("
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
"type": "CHOICE",
|
|
1386
|
+
"members": [
|
|
1387
|
+
{
|
|
1388
|
+
"type": "SYMBOL",
|
|
1389
|
+
"name": "identifier"
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
"type": "SEQ",
|
|
1393
|
+
"members": [
|
|
1394
|
+
{
|
|
1395
|
+
"type": "SYMBOL",
|
|
1396
|
+
"name": "type_field"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"type": "REPEAT",
|
|
1400
|
+
"content": {
|
|
1401
|
+
"type": "SEQ",
|
|
1402
|
+
"members": [
|
|
1403
|
+
{
|
|
1404
|
+
"type": "STRING",
|
|
1405
|
+
"value": ","
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
"type": "SYMBOL",
|
|
1409
|
+
"name": "type_field"
|
|
1410
|
+
}
|
|
1411
|
+
]
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
]
|
|
1415
|
+
}
|
|
1416
|
+
]
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
"type": "STRING",
|
|
1420
|
+
"value": ")"
|
|
1421
|
+
}
|
|
1422
|
+
]
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
"type": "BLANK"
|
|
1426
|
+
}
|
|
1427
|
+
]
|
|
1428
|
+
}
|
|
1429
|
+
]
|
|
1430
|
+
},
|
|
1431
|
+
"type_field": {
|
|
1432
|
+
"type": "SEQ",
|
|
1433
|
+
"members": [
|
|
1434
|
+
{
|
|
1435
|
+
"type": "FIELD",
|
|
1436
|
+
"name": "name",
|
|
1437
|
+
"content": {
|
|
1438
|
+
"type": "SYMBOL",
|
|
1439
|
+
"name": "identifier"
|
|
1440
|
+
}
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
"type": "STRING",
|
|
1444
|
+
"value": ":"
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
"type": "FIELD",
|
|
1448
|
+
"name": "type",
|
|
1449
|
+
"content": {
|
|
1450
|
+
"type": "SYMBOL",
|
|
1451
|
+
"name": "identifier"
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
]
|
|
1455
|
+
},
|
|
1456
|
+
"generic_list": {
|
|
1457
|
+
"type": "SEQ",
|
|
1458
|
+
"members": [
|
|
1459
|
+
{
|
|
1460
|
+
"type": "STRING",
|
|
1461
|
+
"value": "("
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
"type": "SEQ",
|
|
1465
|
+
"members": [
|
|
1466
|
+
{
|
|
1467
|
+
"type": "SYMBOL",
|
|
1468
|
+
"name": "identifier"
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
"type": "REPEAT",
|
|
1472
|
+
"content": {
|
|
1473
|
+
"type": "SEQ",
|
|
1474
|
+
"members": [
|
|
1475
|
+
{
|
|
1476
|
+
"type": "STRING",
|
|
1477
|
+
"value": ","
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
"type": "SYMBOL",
|
|
1481
|
+
"name": "identifier"
|
|
1482
|
+
}
|
|
1483
|
+
]
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
]
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
"type": "STRING",
|
|
1490
|
+
"value": ")"
|
|
1491
|
+
}
|
|
1492
|
+
]
|
|
1493
|
+
},
|
|
1494
|
+
"float": {
|
|
1495
|
+
"type": "PATTERN",
|
|
1496
|
+
"value": "-?[0-9_]+\\.[0-9_]*(e-?[0-9_]+)?"
|
|
1497
|
+
},
|
|
1498
|
+
"integer": {
|
|
1499
|
+
"type": "SEQ",
|
|
1500
|
+
"members": [
|
|
1501
|
+
{
|
|
1502
|
+
"type": "CHOICE",
|
|
1503
|
+
"members": [
|
|
1504
|
+
{
|
|
1505
|
+
"type": "STRING",
|
|
1506
|
+
"value": "-"
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
"type": "BLANK"
|
|
1510
|
+
}
|
|
1511
|
+
]
|
|
1512
|
+
},
|
|
1513
|
+
{
|
|
1514
|
+
"type": "CHOICE",
|
|
1515
|
+
"members": [
|
|
1516
|
+
{
|
|
1517
|
+
"type": "SYMBOL",
|
|
1518
|
+
"name": "_hex"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
"type": "SYMBOL",
|
|
1522
|
+
"name": "_decimal"
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
"type": "SYMBOL",
|
|
1526
|
+
"name": "_octal"
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
"type": "SYMBOL",
|
|
1530
|
+
"name": "_binary"
|
|
1531
|
+
}
|
|
1532
|
+
]
|
|
1533
|
+
}
|
|
1534
|
+
]
|
|
1535
|
+
},
|
|
1536
|
+
"string": {
|
|
1537
|
+
"type": "SEQ",
|
|
1538
|
+
"members": [
|
|
1539
|
+
{
|
|
1540
|
+
"type": "STRING",
|
|
1541
|
+
"value": "\""
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
"type": "REPEAT",
|
|
1545
|
+
"content": {
|
|
1546
|
+
"type": "CHOICE",
|
|
1547
|
+
"members": [
|
|
1548
|
+
{
|
|
1549
|
+
"type": "SYMBOL",
|
|
1550
|
+
"name": "escape_sequence"
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
"type": "SYMBOL",
|
|
1554
|
+
"name": "quoted_content"
|
|
1555
|
+
}
|
|
1556
|
+
]
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
"type": "IMMEDIATE_TOKEN",
|
|
1561
|
+
"content": {
|
|
1562
|
+
"type": "STRING",
|
|
1563
|
+
"value": "\""
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
]
|
|
1567
|
+
},
|
|
1568
|
+
"_hex": {
|
|
1569
|
+
"type": "PATTERN",
|
|
1570
|
+
"value": "0[xX][0-9a-fA-F_]+"
|
|
1571
|
+
},
|
|
1572
|
+
"_decimal": {
|
|
1573
|
+
"type": "PATTERN",
|
|
1574
|
+
"value": "[0-9][0-9_]*"
|
|
1575
|
+
},
|
|
1576
|
+
"_octal": {
|
|
1577
|
+
"type": "PATTERN",
|
|
1578
|
+
"value": "0[oO][0-7_]+"
|
|
1579
|
+
},
|
|
1580
|
+
"_binary": {
|
|
1581
|
+
"type": "PATTERN",
|
|
1582
|
+
"value": "0[bB][0-1_]+"
|
|
1583
|
+
},
|
|
1584
|
+
"_interpolation": {
|
|
1585
|
+
"type": "CHOICE",
|
|
1586
|
+
"members": [
|
|
1587
|
+
{
|
|
1588
|
+
"type": "SEQ",
|
|
1589
|
+
"members": [
|
|
1590
|
+
{
|
|
1591
|
+
"type": "STRING",
|
|
1592
|
+
"value": "{"
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
"type": "SYMBOL",
|
|
1596
|
+
"name": "identifier"
|
|
1597
|
+
},
|
|
1598
|
+
{
|
|
1599
|
+
"type": "STRING",
|
|
1600
|
+
"value": "}"
|
|
1601
|
+
}
|
|
1602
|
+
]
|
|
1603
|
+
}
|
|
1604
|
+
]
|
|
1605
|
+
},
|
|
1606
|
+
"escape_sequence": {
|
|
1607
|
+
"type": "IMMEDIATE_TOKEN",
|
|
1608
|
+
"content": {
|
|
1609
|
+
"type": "PATTERN",
|
|
1610
|
+
"value": "\\\\[efnrt\\\"\\\\]"
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
"identifier": {
|
|
1614
|
+
"type": "PATTERN",
|
|
1615
|
+
"value": "[a-zA-Z_][a-zA-Z_0-9]*"
|
|
1616
|
+
},
|
|
1617
|
+
"type_identifier": {
|
|
1618
|
+
"type": "SYMBOL",
|
|
1619
|
+
"name": "_upname"
|
|
1620
|
+
},
|
|
1621
|
+
"_type_annotation": {
|
|
1622
|
+
"type": "SEQ",
|
|
1623
|
+
"members": [
|
|
1624
|
+
{
|
|
1625
|
+
"type": "STRING",
|
|
1626
|
+
"value": ":"
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
"type": "FIELD",
|
|
1630
|
+
"name": "type",
|
|
1631
|
+
"content": {
|
|
1632
|
+
"type": "SYMBOL",
|
|
1633
|
+
"name": "identifier"
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
]
|
|
1637
|
+
},
|
|
1638
|
+
"_discard_name": {
|
|
1639
|
+
"type": "PATTERN",
|
|
1640
|
+
"value": "_[_0-9a-z]*"
|
|
1641
|
+
},
|
|
1642
|
+
"_name": {
|
|
1643
|
+
"type": "PATTERN",
|
|
1644
|
+
"value": "[_a-z][_0-9a-z]*"
|
|
1645
|
+
},
|
|
1646
|
+
"_upname": {
|
|
1647
|
+
"type": "PATTERN",
|
|
1648
|
+
"value": "[A-Z][0-9a-zA-Z]*"
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
"extras": [
|
|
1652
|
+
{
|
|
1653
|
+
"type": "PATTERN",
|
|
1654
|
+
"value": "\\s"
|
|
1655
|
+
}
|
|
1656
|
+
],
|
|
1657
|
+
"conflicts": [
|
|
1658
|
+
[
|
|
1659
|
+
"proc"
|
|
1660
|
+
],
|
|
1661
|
+
[
|
|
1662
|
+
"record"
|
|
1663
|
+
]
|
|
1664
|
+
],
|
|
1665
|
+
"precedences": [],
|
|
1666
|
+
"externals": [
|
|
1667
|
+
{
|
|
1668
|
+
"type": "SYMBOL",
|
|
1669
|
+
"name": "quoted_content"
|
|
1670
|
+
}
|
|
1671
|
+
],
|
|
643
1672
|
"inline": [],
|
|
644
1673
|
"supertypes": []
|
|
645
1674
|
}
|
src/node-types.json
CHANGED
|
@@ -1,81 +1,552 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"type": "binary_expression",
|
|
4
|
+
"named": true,
|
|
5
|
+
"fields": {
|
|
6
|
+
"left": {
|
|
7
|
+
"multiple": false,
|
|
8
|
+
"required": true,
|
|
9
|
+
"types": [
|
|
10
|
+
{
|
|
11
|
+
"type": "binary_expression",
|
|
12
|
+
"named": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "expression_group",
|
|
16
|
+
"named": true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "float",
|
|
20
|
+
"named": true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "identifier",
|
|
24
|
+
"named": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "integer",
|
|
28
|
+
"named": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "negation",
|
|
32
|
+
"named": true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "panic",
|
|
36
|
+
"named": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "record",
|
|
40
|
+
"named": true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "string",
|
|
44
|
+
"named": true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"type": "todo",
|
|
48
|
+
"named": true
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"operator": {
|
|
53
|
+
"multiple": false,
|
|
54
|
+
"required": true,
|
|
55
|
+
"types": [
|
|
56
|
+
{
|
|
57
|
+
"type": "!=",
|
|
58
|
+
"named": false
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"type": "%",
|
|
62
|
+
"named": false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "&&",
|
|
66
|
+
"named": false
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "*",
|
|
70
|
+
"named": false
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"type": "+",
|
|
74
|
+
"named": false
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"type": "-",
|
|
78
|
+
"named": false
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"type": "/",
|
|
82
|
+
"named": false
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"type": "<",
|
|
86
|
+
"named": false
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"type": "<=",
|
|
90
|
+
"named": false
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "<>",
|
|
94
|
+
"named": false
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"type": "==",
|
|
98
|
+
"named": false
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"type": ">",
|
|
102
|
+
"named": false
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"type": ">=",
|
|
106
|
+
"named": false
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "|>",
|
|
110
|
+
"named": false
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "||",
|
|
114
|
+
"named": false
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"right": {
|
|
119
|
+
"multiple": false,
|
|
120
|
+
"required": true,
|
|
121
|
+
"types": [
|
|
122
|
+
{
|
|
123
|
+
"type": "binary_expression",
|
|
124
|
+
"named": true
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "expression_group",
|
|
128
|
+
"named": true
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "float",
|
|
132
|
+
"named": true
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"type": "identifier",
|
|
136
|
+
"named": true
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "integer",
|
|
140
|
+
"named": true
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"type": "negation",
|
|
144
|
+
"named": true
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"type": "panic",
|
|
148
|
+
"named": true
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "record",
|
|
152
|
+
"named": true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "string",
|
|
156
|
+
"named": true
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"type": "todo",
|
|
160
|
+
"named": true
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "expression_group",
|
|
168
|
+
"named": true,
|
|
169
|
+
"fields": {},
|
|
170
|
+
"children": {
|
|
171
|
+
"multiple": true,
|
|
172
|
+
"required": false,
|
|
173
|
+
"types": [
|
|
174
|
+
{
|
|
175
|
+
"type": "binary_expression",
|
|
176
|
+
"named": true
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"type": "expression_group",
|
|
180
|
+
"named": true
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"type": "float",
|
|
184
|
+
"named": true
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"type": "identifier",
|
|
188
|
+
"named": true
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"type": "integer",
|
|
192
|
+
"named": true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"type": "let",
|
|
196
|
+
"named": true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"type": "negation",
|
|
200
|
+
"named": true
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "panic",
|
|
204
|
+
"named": true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"type": "record",
|
|
208
|
+
"named": true
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"type": "string",
|
|
212
|
+
"named": true
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"type": "todo",
|
|
216
|
+
"named": true
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
},
|
|
2
221
|
{
|
|
3
222
|
"type": "generic_list",
|
|
4
223
|
"named": true,
|
|
5
224
|
"fields": {},
|
|
6
225
|
"children": {
|
|
7
|
-
"multiple": true,
|
|
226
|
+
"multiple": true,
|
|
227
|
+
"required": true,
|
|
228
|
+
"types": [
|
|
229
|
+
{
|
|
230
|
+
"type": "identifier",
|
|
231
|
+
"named": true
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"type": "import",
|
|
238
|
+
"named": true,
|
|
239
|
+
"fields": {
|
|
240
|
+
"alias": {
|
|
241
|
+
"multiple": false,
|
|
242
|
+
"required": false,
|
|
243
|
+
"types": [
|
|
244
|
+
{
|
|
245
|
+
"type": "identifier",
|
|
246
|
+
"named": true
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
"imports": {
|
|
251
|
+
"multiple": false,
|
|
252
|
+
"required": false,
|
|
253
|
+
"types": [
|
|
254
|
+
{
|
|
255
|
+
"type": "unqualified_imports",
|
|
256
|
+
"named": true
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
"module": {
|
|
261
|
+
"multiple": false,
|
|
262
|
+
"required": true,
|
|
263
|
+
"types": [
|
|
264
|
+
{
|
|
265
|
+
"type": "module_name",
|
|
266
|
+
"named": true
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"type": "integer",
|
|
274
|
+
"named": true,
|
|
275
|
+
"fields": {}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"type": "let",
|
|
279
|
+
"named": true,
|
|
280
|
+
"fields": {
|
|
281
|
+
"assign": {
|
|
282
|
+
"multiple": true,
|
|
283
|
+
"required": false,
|
|
284
|
+
"types": [
|
|
285
|
+
{
|
|
286
|
+
"type": "as",
|
|
287
|
+
"named": false
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"type": "identifier",
|
|
291
|
+
"named": true
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
"pattern": {
|
|
296
|
+
"multiple": true,
|
|
297
|
+
"required": true,
|
|
298
|
+
"types": [
|
|
299
|
+
{
|
|
300
|
+
"type": "as",
|
|
301
|
+
"named": false
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"type": "binary_expression",
|
|
305
|
+
"named": true
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"type": "float",
|
|
309
|
+
"named": true
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"type": "identifier",
|
|
313
|
+
"named": true
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"type": "integer",
|
|
317
|
+
"named": true
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
"type": {
|
|
322
|
+
"multiple": false,
|
|
323
|
+
"required": false,
|
|
324
|
+
"types": [
|
|
325
|
+
{
|
|
326
|
+
"type": "identifier",
|
|
327
|
+
"named": true
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
"value": {
|
|
332
|
+
"multiple": false,
|
|
333
|
+
"required": true,
|
|
334
|
+
"types": [
|
|
335
|
+
{
|
|
336
|
+
"type": "binary_expression",
|
|
337
|
+
"named": true
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"type": "expression_group",
|
|
341
|
+
"named": true
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"type": "float",
|
|
345
|
+
"named": true
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "identifier",
|
|
349
|
+
"named": true
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"type": "integer",
|
|
353
|
+
"named": true
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"type": "negation",
|
|
357
|
+
"named": true
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"type": "panic",
|
|
361
|
+
"named": true
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"type": "record",
|
|
365
|
+
"named": true
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"type": "string",
|
|
369
|
+
"named": true
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"type": "todo",
|
|
373
|
+
"named": true
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"type": "module",
|
|
381
|
+
"named": true,
|
|
382
|
+
"fields": {
|
|
383
|
+
"module": {
|
|
384
|
+
"multiple": false,
|
|
385
|
+
"required": true,
|
|
386
|
+
"types": [
|
|
387
|
+
{
|
|
388
|
+
"type": "module_name",
|
|
389
|
+
"named": true
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"type": "module_name",
|
|
397
|
+
"named": true,
|
|
398
|
+
"fields": {}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"type": "negation",
|
|
402
|
+
"named": true,
|
|
403
|
+
"fields": {},
|
|
404
|
+
"children": {
|
|
405
|
+
"multiple": false,
|
|
8
406
|
"required": true,
|
|
9
407
|
"types": [
|
|
408
|
+
{
|
|
409
|
+
"type": "expression_group",
|
|
410
|
+
"named": true
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"type": "float",
|
|
414
|
+
"named": true
|
|
415
|
+
},
|
|
10
416
|
{
|
|
11
417
|
"type": "identifier",
|
|
12
418
|
"named": true
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"type": "integer",
|
|
422
|
+
"named": true
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"type": "negation",
|
|
426
|
+
"named": true
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"type": "panic",
|
|
430
|
+
"named": true
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"type": "record",
|
|
434
|
+
"named": true
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"type": "string",
|
|
438
|
+
"named": true
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"type": "todo",
|
|
442
|
+
"named": true
|
|
13
443
|
}
|
|
14
444
|
]
|
|
15
445
|
}
|
|
16
446
|
},
|
|
17
447
|
{
|
|
18
|
-
"type": "
|
|
448
|
+
"type": "panic",
|
|
19
449
|
"named": true,
|
|
20
450
|
"fields": {}
|
|
21
451
|
},
|
|
22
452
|
{
|
|
23
|
-
"type": "
|
|
453
|
+
"type": "proc",
|
|
24
454
|
"named": true,
|
|
25
455
|
"fields": {
|
|
26
|
-
"
|
|
456
|
+
"body": {
|
|
27
|
-
"multiple":
|
|
457
|
+
"multiple": true,
|
|
28
|
-
"required":
|
|
458
|
+
"required": true,
|
|
29
459
|
"types": [
|
|
460
|
+
{
|
|
461
|
+
"type": "binary_expression",
|
|
462
|
+
"named": true
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"type": "expression_group",
|
|
466
|
+
"named": true
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"type": "float",
|
|
470
|
+
"named": true
|
|
471
|
+
},
|
|
30
472
|
{
|
|
31
473
|
"type": "identifier",
|
|
32
474
|
"named": true
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"type": "integer",
|
|
478
|
+
"named": true
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
"type": "let",
|
|
482
|
+
"named": true
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"type": "negation",
|
|
486
|
+
"named": true
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"type": "panic",
|
|
490
|
+
"named": true
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"type": "record",
|
|
494
|
+
"named": true
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
"type": "string",
|
|
498
|
+
"named": true
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
"type": "todo",
|
|
502
|
+
"named": true
|
|
33
503
|
}
|
|
34
504
|
]
|
|
35
505
|
},
|
|
36
|
-
"
|
|
506
|
+
"name": {
|
|
37
507
|
"multiple": false,
|
|
38
|
-
"required":
|
|
508
|
+
"required": true,
|
|
39
509
|
"types": [
|
|
40
510
|
{
|
|
41
|
-
"type": "
|
|
511
|
+
"type": "identifier",
|
|
42
512
|
"named": true
|
|
43
513
|
}
|
|
44
514
|
]
|
|
45
515
|
},
|
|
46
|
-
"
|
|
516
|
+
"params": {
|
|
47
|
-
"multiple":
|
|
517
|
+
"multiple": true,
|
|
48
518
|
"required": true,
|
|
49
519
|
"types": [
|
|
50
520
|
{
|
|
521
|
+
"type": "(",
|
|
522
|
+
"named": false
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"type": ")",
|
|
526
|
+
"named": false
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"type": ",",
|
|
530
|
+
"named": false
|
|
531
|
+
},
|
|
532
|
+
{
|
|
51
|
-
"type": "
|
|
533
|
+
"type": "type_field",
|
|
52
534
|
"named": true
|
|
53
535
|
}
|
|
54
536
|
]
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
537
|
+
},
|
|
58
|
-
{
|
|
59
|
-
"type": "module",
|
|
60
|
-
"named": true,
|
|
61
|
-
"fields": {
|
|
62
|
-
"
|
|
538
|
+
"return_type": {
|
|
63
539
|
"multiple": false,
|
|
64
|
-
"required":
|
|
540
|
+
"required": false,
|
|
65
541
|
"types": [
|
|
66
542
|
{
|
|
67
|
-
"type": "
|
|
543
|
+
"type": "return_type",
|
|
68
544
|
"named": true
|
|
69
545
|
}
|
|
70
546
|
]
|
|
71
547
|
}
|
|
72
548
|
}
|
|
73
549
|
},
|
|
74
|
-
{
|
|
75
|
-
"type": "module_name",
|
|
76
|
-
"named": true,
|
|
77
|
-
"fields": {}
|
|
78
|
-
},
|
|
79
550
|
{
|
|
80
551
|
"type": "record",
|
|
81
552
|
"named": true,
|
|
@@ -112,6 +583,44 @@
|
|
|
112
583
|
}
|
|
113
584
|
}
|
|
114
585
|
},
|
|
586
|
+
{
|
|
587
|
+
"type": "return_type",
|
|
588
|
+
"named": true,
|
|
589
|
+
"fields": {
|
|
590
|
+
"generics": {
|
|
591
|
+
"multiple": true,
|
|
592
|
+
"required": false,
|
|
593
|
+
"types": [
|
|
594
|
+
{
|
|
595
|
+
"type": "(",
|
|
596
|
+
"named": false
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"type": ")",
|
|
600
|
+
"named": false
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
"type": ",",
|
|
604
|
+
"named": false
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
"type": "identifier",
|
|
608
|
+
"named": true
|
|
609
|
+
}
|
|
610
|
+
]
|
|
611
|
+
},
|
|
612
|
+
"name": {
|
|
613
|
+
"multiple": false,
|
|
614
|
+
"required": true,
|
|
615
|
+
"types": [
|
|
616
|
+
{
|
|
617
|
+
"type": "type_identifier",
|
|
618
|
+
"named": true
|
|
619
|
+
}
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
},
|
|
115
624
|
{
|
|
116
625
|
"type": "source_file",
|
|
117
626
|
"named": true,
|
|
@@ -128,6 +637,10 @@
|
|
|
128
637
|
"type": "module",
|
|
129
638
|
"named": true
|
|
130
639
|
},
|
|
640
|
+
{
|
|
641
|
+
"type": "proc",
|
|
642
|
+
"named": true
|
|
643
|
+
},
|
|
131
644
|
{
|
|
132
645
|
"type": "record",
|
|
133
646
|
"named": true
|
|
@@ -139,6 +652,41 @@
|
|
|
139
652
|
]
|
|
140
653
|
}
|
|
141
654
|
},
|
|
655
|
+
{
|
|
656
|
+
"type": "string",
|
|
657
|
+
"named": true,
|
|
658
|
+
"fields": {},
|
|
659
|
+
"children": {
|
|
660
|
+
"multiple": true,
|
|
661
|
+
"required": false,
|
|
662
|
+
"types": [
|
|
663
|
+
{
|
|
664
|
+
"type": "escape_sequence",
|
|
665
|
+
"named": true
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"type": "quoted_content",
|
|
669
|
+
"named": true
|
|
670
|
+
}
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"type": "todo",
|
|
676
|
+
"named": true,
|
|
677
|
+
"fields": {
|
|
678
|
+
"message": {
|
|
679
|
+
"multiple": false,
|
|
680
|
+
"required": false,
|
|
681
|
+
"types": [
|
|
682
|
+
{
|
|
683
|
+
"type": "string",
|
|
684
|
+
"named": true
|
|
685
|
+
}
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
},
|
|
142
690
|
{
|
|
143
691
|
"type": "type",
|
|
144
692
|
"named": true,
|
|
@@ -289,6 +837,26 @@
|
|
|
289
837
|
]
|
|
290
838
|
}
|
|
291
839
|
},
|
|
840
|
+
{
|
|
841
|
+
"type": "!",
|
|
842
|
+
"named": false
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"type": "!=",
|
|
846
|
+
"named": false
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
"type": "\"",
|
|
850
|
+
"named": false
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
"type": "%",
|
|
854
|
+
"named": false
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
"type": "&&",
|
|
858
|
+
"named": false
|
|
859
|
+
},
|
|
292
860
|
{
|
|
293
861
|
"type": "(",
|
|
294
862
|
"named": false
|
|
@@ -297,10 +865,26 @@
|
|
|
297
865
|
"type": ")",
|
|
298
866
|
"named": false
|
|
299
867
|
},
|
|
868
|
+
{
|
|
869
|
+
"type": "*",
|
|
870
|
+
"named": false
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"type": "+",
|
|
874
|
+
"named": false
|
|
875
|
+
},
|
|
300
876
|
{
|
|
301
877
|
"type": ",",
|
|
302
878
|
"named": false
|
|
303
879
|
},
|
|
880
|
+
{
|
|
881
|
+
"type": "-",
|
|
882
|
+
"named": false
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
"type": "->",
|
|
886
|
+
"named": false
|
|
887
|
+
},
|
|
304
888
|
{
|
|
305
889
|
"type": ".",
|
|
306
890
|
"named": false
|
|
@@ -313,26 +897,78 @@
|
|
|
313
897
|
"type": ":",
|
|
314
898
|
"named": false
|
|
315
899
|
},
|
|
900
|
+
{
|
|
901
|
+
"type": "<",
|
|
902
|
+
"named": false
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"type": "<=",
|
|
906
|
+
"named": false
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"type": "<>",
|
|
910
|
+
"named": false
|
|
911
|
+
},
|
|
316
912
|
{
|
|
317
913
|
"type": "=",
|
|
318
914
|
"named": false
|
|
319
915
|
},
|
|
916
|
+
{
|
|
917
|
+
"type": "==",
|
|
918
|
+
"named": false
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"type": ">",
|
|
922
|
+
"named": false
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"type": ">=",
|
|
926
|
+
"named": false
|
|
927
|
+
},
|
|
320
928
|
{
|
|
321
929
|
"type": "as",
|
|
322
930
|
"named": false
|
|
323
931
|
},
|
|
932
|
+
{
|
|
933
|
+
"type": "escape_sequence",
|
|
934
|
+
"named": true
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
"type": "float",
|
|
938
|
+
"named": true
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"type": "identifier",
|
|
942
|
+
"named": true
|
|
943
|
+
},
|
|
324
944
|
{
|
|
325
945
|
"type": "import",
|
|
326
946
|
"named": false
|
|
327
947
|
},
|
|
948
|
+
{
|
|
949
|
+
"type": "let",
|
|
950
|
+
"named": false
|
|
951
|
+
},
|
|
328
952
|
{
|
|
329
953
|
"type": "module",
|
|
330
954
|
"named": false
|
|
331
955
|
},
|
|
956
|
+
{
|
|
957
|
+
"type": "panic",
|
|
958
|
+
"named": false
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"type": "quoted_content",
|
|
962
|
+
"named": true
|
|
963
|
+
},
|
|
332
964
|
{
|
|
333
965
|
"type": "record",
|
|
334
966
|
"named": false
|
|
335
967
|
},
|
|
968
|
+
{
|
|
969
|
+
"type": "todo",
|
|
970
|
+
"named": false
|
|
971
|
+
},
|
|
336
972
|
{
|
|
337
973
|
"type": "type",
|
|
338
974
|
"named": false
|
|
@@ -345,6 +981,14 @@
|
|
|
345
981
|
"type": "|",
|
|
346
982
|
"named": false
|
|
347
983
|
},
|
|
984
|
+
{
|
|
985
|
+
"type": "|>",
|
|
986
|
+
"named": false
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
"type": "||",
|
|
990
|
+
"named": false
|
|
991
|
+
},
|
|
348
992
|
{
|
|
349
993
|
"type": "}",
|
|
350
994
|
"named": false
|
src/scanner.c
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include <tree_sitter/parser.h>
|
|
2
|
+
|
|
3
|
+
enum TokenType {
|
|
4
|
+
QUOTED_CONTENT
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
void * tree_sitter_palm_external_scanner_create() {return NULL;}
|
|
8
|
+
void tree_sitter_palm_external_scanner_destroy(void * payload) {}
|
|
9
|
+
unsigned tree_sitter_palm_external_scanner_serialize(void * payload, char * buffer) {return 0;}
|
|
10
|
+
void tree_sitter_palm_external_scanner_deserialize(void * payload, const char * buffer, unsigned length) {}
|
|
11
|
+
|
|
12
|
+
bool tree_sitter_palm_external_scanner_scan(void * payload, TSLexer *lexer, const bool * valid_symbols) {
|
|
13
|
+
if (valid_symbols[QUOTED_CONTENT]) {
|
|
14
|
+
bool has_content = false;
|
|
15
|
+
|
|
16
|
+
while (true) {
|
|
17
|
+
if (lexer->lookahead == '\"' || lexer->lookahead == '\\') {
|
|
18
|
+
break;
|
|
19
|
+
} else if (lexer->lookahead == 0) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
has_content = true;
|
|
23
|
+
lexer->advance(lexer, false);
|
|
24
|
+
}
|
|
25
|
+
lexer->result_symbol = QUOTED_CONTENT;
|
|
26
|
+
return has_content;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
test/corpus/functions.txt
CHANGED
|
@@ -1,167 +1,20 @@
|
|
|
1
1
|
================================================================================
|
|
2
|
-
|
|
2
|
+
Function - Simple
|
|
3
3
|
================================================================================
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
module palm
|
|
6
6
|
|
|
7
7
|
main() =
|
|
8
|
-
|
|
8
|
+
let a = "123"
|
|
9
9
|
|
|
10
10
|
--------------------------------------------------------------------------------
|
|
11
11
|
|
|
12
12
|
(source_file
|
|
13
|
-
(
|
|
13
|
+
(module
|
|
14
|
-
(identifier))
|
|
15
|
-
(definitions
|
|
16
|
-
(fun_definition
|
|
17
|
-
(identifier))))
|
|
18
|
-
|
|
19
|
-
================================================================================
|
|
20
|
-
Functions - Extension
|
|
21
|
-
================================================================================
|
|
22
|
-
|
|
23
|
-
package definitions
|
|
24
|
-
|
|
25
|
-
fun User.fullName() => {
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
--------------------------------------------------------------------------------
|
|
29
|
-
|
|
30
|
-
(
|
|
14
|
+
(module_name))
|
|
31
|
-
(
|
|
15
|
+
(proc
|
|
32
|
-
(identifier))
|
|
33
|
-
(definitions
|
|
34
|
-
(fun_definition
|
|
35
|
-
|
|
16
|
+
(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
|
-
|
|
17
|
+
(let
|
|
59
|
-
(definition_name)))
|
|
60
|
-
(param
|
|
61
|
-
(variable_name)
|
|
62
|
-
(type
|
|
63
|
-
(definition_name)))
|
|
64
|
-
(type
|
|
65
|
-
(definition_name)))))
|
|
66
|
-
|
|
67
|
-
================================================================================
|
|
68
|
-
Functions - Generics
|
|
69
|
-
================================================================================
|
|
70
|
-
|
|
71
|
-
package definitions
|
|
72
|
-
|
|
73
|
-
fun add<S, T>(a: S, b: T) => S {
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
--------------------------------------------------------------------------------
|
|
77
|
-
|
|
78
|
-
(source_file
|
|
79
|
-
(package
|
|
80
|
-
(identifier))
|
|
81
|
-
(definitions
|
|
82
|
-
(fun_definition
|
|
83
18
|
(identifier)
|
|
84
|
-
(generic_list
|
|
85
|
-
(identifier)
|
|
86
|
-
(identifier))
|
|
87
|
-
(
|
|
19
|
+
(string
|
|
88
|
-
(variable_name)
|
|
89
|
-
(type
|
|
90
|
-
(definition_name)))
|
|
91
|
-
(param
|
|
92
|
-
(variable_name)
|
|
93
|
-
(type
|
|
94
|
-
(definition_name)))
|
|
95
|
-
(type
|
|
96
|
-
(
|
|
20
|
+
(quoted_content)))))
|
|
97
|
-
|
|
98
|
-
================================================================================
|
|
99
|
-
Functions - Decorators
|
|
100
|
-
================================================================================
|
|
101
|
-
|
|
102
|
-
package definitions
|
|
103
|
-
|
|
104
|
-
@cache(1000)
|
|
105
|
-
@get()
|
|
106
|
-
fun add(a: Int, b: Int) => Int {
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
--------------------------------------------------------------------------------
|
|
110
|
-
|
|
111
|
-
(source_file
|
|
112
|
-
(package
|
|
113
|
-
(identifier))
|
|
114
|
-
(definitions
|
|
115
|
-
(fun_definition
|
|
116
|
-
(decorator_name
|
|
117
|
-
(identifier)
|
|
118
|
-
(integer_literal))
|
|
119
|
-
(decorator_name
|
|
120
|
-
(identifier))
|
|
121
|
-
(identifier)
|
|
122
|
-
(param
|
|
123
|
-
(variable_name)
|
|
124
|
-
(type
|
|
125
|
-
(definition_name)))
|
|
126
|
-
(param
|
|
127
|
-
(variable_name)
|
|
128
|
-
(type
|
|
129
|
-
(definition_name)))
|
|
130
|
-
(type
|
|
131
|
-
(definition_name)))))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
================================================================================
|
|
135
|
-
Functions - High Order 1
|
|
136
|
-
================================================================================
|
|
137
|
-
|
|
138
|
-
package definitions
|
|
139
|
-
|
|
140
|
-
fun add(a: Int, b: Int): () -> Unit
|
|
141
|
-
return {
|
|
142
|
-
println("A + B")
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
--------------------------------------------------------------------------------
|
|
146
|
-
|
|
147
|
-
(source_file
|
|
148
|
-
(package
|
|
149
|
-
(identifier))
|
|
150
|
-
|
|
151
|
-
================================================================================
|
|
152
|
-
Functions - High Order 2
|
|
153
|
-
================================================================================
|
|
154
|
-
|
|
155
|
-
package definitions
|
|
156
|
-
|
|
157
|
-
fun add(a: Int, b: () -> Unit): () -> Unit =>
|
|
158
|
-
return {
|
|
159
|
-
b()
|
|
160
|
-
println("A + B")
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
--------------------------------------------------------------------------------
|
|
164
|
-
|
|
165
|
-
(source_file
|
|
166
|
-
(package
|
|
167
|
-
(identifier))
|