]> git.r.bdr.sh - rbdr/tree-sitter-api-notation/blobdiff - grammar.js
Test keyword to see how it affects syntax
[rbdr/tree-sitter-api-notation] / grammar.js
index e74c27b6a9cd718f5f73b087acc0ea31fc57669c..1aa01901425f40a8585726abd0f8d9e19a3d2818 100644 (file)
@@ -1,5 +1,5 @@
 module.exports = grammar({
 module.exports = grammar({
-  name: 'apinotation',
+  name: 'api_notation',
 
   rules: {
     source_file: $ => repeat(
 
   rules: {
     source_file: $ => repeat(
@@ -83,12 +83,20 @@ module.exports = grammar({
       )
     ),
     identifier: $ => prec.left(seq(
       )
     ),
     identifier: $ => prec.left(seq(
-      $._label,
+      choice(
+        $.optional_value,
+        $._label,
+      ),
       optional($.type_annotation),
       optional($.parameter_list),
       optional($.return_statement),
       optional($.throw_statement),
     )),
       optional($.type_annotation),
       optional($.parameter_list),
       optional($.return_statement),
       optional($.throw_statement),
     )),
+    optional_value: $ => seq(
+      '[',
+      $._label,
+      ']'
+    ),
     type_annotation: $ => seq(
       '<',
       $._entry_list,
     type_annotation: $ => seq(
       '<',
       $._entry_list,