Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit f81ea67

Browse files
hugoplnobodywasishere
authored andcommitted
Correctly parse generics in methods, literals and procs.
1 parent 65c7f17 commit f81ea67

File tree

6 files changed

+13196
-12413
lines changed

6 files changed

+13196
-12413
lines changed

grammar.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ module.exports = grammar({
143143
),
144144
),
145145
),
146-
optional(field('returns', seq(':', $.constant))),
146+
optional(field('returns', seq(':', $.type_name))),
147147
optional(
148148
field(
149149
'forall',
150-
seq('forall', $.constant, repeat(seq(',', $.constant))),
150+
seq('forall', $.constant, repeat(seq(',', $.type_name))),
151151
),
152152
),
153153
),
@@ -271,7 +271,7 @@ module.exports = grammar({
271271
),
272272
),
273273
']',
274-
optional(seq('of', $.constant)),
274+
optional(seq('of', $.type_name)),
275275
),
276276

277277
hash: $ =>
@@ -286,19 +286,19 @@ module.exports = grammar({
286286
optional(
287287
seq(
288288
'of',
289-
field('key_type', $.constant),
289+
field('key_type', $.type_name),
290290
'=>',
291-
field('value_type', $.constant),
291+
field('value_type', $.type_name),
292292
),
293293
),
294294
),
295295
seq(
296296
'{',
297297
'}',
298298
'of',
299-
field('key_type', $.constant),
299+
field('key_type', $.type_name),
300300
'=>',
301-
field('value_type', $.constant),
301+
field('value_type', $.type_name),
302302
),
303303
),
304304

@@ -316,22 +316,22 @@ module.exports = grammar({
316316
')',
317317
),
318318
),
319-
optional(seq(':', field('return_type', $.constant))),
319+
optional(seq(':', field('return_type', $.type_name))),
320320
$.block,
321321
),
322322

323323
proc_param: $ =>
324324
seq(
325325
field('name', $.identifier), // support class/instance vars
326-
optional(seq(':', field('type', $.constant))),
326+
optional(seq(':', field('type', $.type_name))),
327327
),
328328

329329
method_param: $ =>
330330
seq(
331331
// repeat($.annotation),
332332
optional(field('external_name', $.identifier)),
333333
field('name', $.identifier), // support class/instance vars
334-
optional(seq(':', field('type', $.constant))),
334+
optional(seq(':', field('type', $.type_name))),
335335
optional(seq('=', field('default_value', $._expression))),
336336
),
337337

src/grammar.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 19 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)