X-Git-Url: https://git.r.bdr.sh/rbdr/tree-sitter-api-notation/blobdiff_plain/dc87cd894bad9ad0202dcd4a89e7d0af47c53fc9..5b3c29fedf2c2cc4e9da582d4cdb0a6bafbfe55d:/grammar.js?ds=sidebyside diff --git a/grammar.js b/grammar.js index e74c27b..1aa0190 100644 --- a/grammar.js +++ b/grammar.js @@ -1,5 +1,5 @@ module.exports = grammar({ - name: 'apinotation', + name: 'api_notation', rules: { source_file: $ => repeat( @@ -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,