From 9c1420ff18384316f9bd541831346365ccccfbd1 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Tue, 13 Sep 2022 12:46:29 -0300 Subject: [PATCH] support decorator - take2 --- grammar.js | 4 +++- test/corpus/decorators.txt | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/grammar.js b/grammar.js index 09586d0..92a8705 100644 --- a/grammar.js +++ b/grammar.js @@ -91,6 +91,7 @@ module.exports = grammar({ [$.parameter, $._pattern], [$.parameter, $._parenthesized_pattern], [$._switch_value_pattern, $._parenthesized_pattern], + [$.variant_declaration] ], rules: { @@ -290,7 +291,7 @@ module.exports = grammar({ )), variant_declaration: $ => prec.right(seq( - optional($.decorator), + repeat($.decorator), $.variant_identifier, optional($.variant_parameters), optional($.type_annotation), @@ -498,6 +499,7 @@ module.exports = grammar({ $._definition_signature ), '=>', + repeat($.decorator), field('body', $.expression), )), diff --git a/test/corpus/decorators.txt b/test/corpus/decorators.txt index 615c340..1aabe26 100644 --- a/test/corpus/decorators.txt +++ b/test/corpus/decorators.txt @@ -31,6 +31,8 @@ let foo = (@doesNotRaise String.make)(12, ' ') let foo = @doesNotRaise String.make(12, ' ') +let onResult = () => @doesNotRaise Belt.Array.getExn([], 0) + --- (source_file @@ -52,4 +54,16 @@ let foo = @doesNotRaise String.make(12, ' ') (value_identifier_path (module_identifier) (value_identifier)) (arguments (number) - (character))))) + (character)))) + + (let_binding + (value_identifier) + (function + (formal_parameters) + (decorator (decorator_identifier)) + (call_expression + (value_identifier_path (module_identifier) (module_identifier) (value_identifier)) + (arguments + (array) + (number)))))) +