Skip to content

Commit de1d7b0

Browse files
authored
Merge pull request #131 from aspeddro/decorator-take2
support decorator - take 2
2 parents f1b1e34 + 9c1420f commit de1d7b0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

grammar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module.exports = grammar({
9191
[$.parameter, $._pattern],
9292
[$.parameter, $._parenthesized_pattern],
9393
[$._switch_value_pattern, $._parenthesized_pattern],
94+
[$.variant_declaration]
9495
],
9596

9697
rules: {
@@ -290,7 +291,7 @@ module.exports = grammar({
290291
)),
291292

292293
variant_declaration: $ => prec.right(seq(
293-
optional($.decorator),
294+
repeat($.decorator),
294295
$.variant_identifier,
295296
optional($.variant_parameters),
296297
optional($.type_annotation),
@@ -498,6 +499,7 @@ module.exports = grammar({
498499
$._definition_signature
499500
),
500501
'=>',
502+
repeat($.decorator),
501503
field('body', $.expression),
502504
)),
503505

test/corpus/decorators.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ let foo = (@doesNotRaise String.make)(12, ' ')
3131

3232
let foo = @doesNotRaise String.make(12, ' ')
3333

34+
let onResult = () => @doesNotRaise Belt.Array.getExn([], 0)
35+
3436
---
3537

3638
(source_file
@@ -52,4 +54,16 @@ let foo = @doesNotRaise String.make(12, ' ')
5254
(value_identifier_path (module_identifier) (value_identifier))
5355
(arguments
5456
(number)
55-
(character)))))
57+
(character))))
58+
59+
(let_binding
60+
(value_identifier)
61+
(function
62+
(formal_parameters)
63+
(decorator (decorator_identifier))
64+
(call_expression
65+
(value_identifier_path (module_identifier) (module_identifier) (value_identifier))
66+
(arguments
67+
(array)
68+
(number))))))
69+

0 commit comments

Comments
 (0)