]> git.r.bdr.sh - rbdr/tree-sitter-api-notation/blobdiff - grammar.js
Add optionals
[rbdr/tree-sitter-api-notation] / grammar.js
index e74c27b6a9cd718f5f73b087acc0ea31fc57669c..db1219dab138467c5861408015009e6a81f216e9 100644 (file)
@@ -83,12 +83,20 @@ module.exports = grammar({
       )
     ),
     identifier: $ => prec.left(seq(
-      $._label,
+      choice(
+        $.optional_value,
+        $._label,
+      ),
       optional($.type_annotation),
       optional($.parameter_list),
       optional($.return_statement),
       optional($.throw_statement),
     )),
+    optional_value: $ => seq(
+      '[',
+      $._label,
+      ']'
+    ),
     type_annotation: $ => seq(
       '<',
       $._entry_list,