chore: tidying

pull/643/head
Amaan Qureshi 2024-01-31 09:52:52 +07:00
parent d63fbd4be8
commit d59b29d600
1 changed files with 12 additions and 12 deletions

@ -1,5 +1,7 @@
const JavaScript = require('tree-sitter-javascript/grammar');
module.exports = function defineGrammar(dialect) { module.exports = function defineGrammar(dialect) {
return grammar(require('tree-sitter-javascript/grammar'), { return grammar(JavaScript, {
name: dialect, name: dialect,
externals: ($, previous) => previous.concat([ externals: ($, previous) => previous.concat([
@ -257,14 +259,14 @@ module.exports = function defineGrammar(dialect) {
'/>' '/>'
)), )),
export_specifier: ($, previous) => seq( export_specifier: (_, previous) => seq(
optional(choice('type', 'typeof')), optional(choice('type', 'typeof')),
previous previous
), ),
_import_identifier: $ => choice($.identifier, alias('type', $.identifier)), _import_identifier: $ => choice($.identifier, alias('type', $.identifier)),
import_specifier: ($, previous) => seq( import_specifier: $ => seq(
optional(choice('type', 'typeof')), optional(choice('type', 'typeof')),
choice( choice(
field('name', $._import_identifier), field('name', $._import_identifier),
@ -275,7 +277,7 @@ module.exports = function defineGrammar(dialect) {
), ),
)), )),
import_clause: ($, previous) => choice( import_clause: $ => choice(
$.namespace_import, $.namespace_import,
$.named_imports, $.named_imports,
seq( seq(
@ -352,7 +354,7 @@ module.exports = function defineGrammar(dialect) {
$._call_signature $._call_signature
), ),
parenthesized_expression: ($, previous) => seq( parenthesized_expression: $ => seq(
'(', '(',
choice( choice(
seq($.expression, field('type', optional($.type_annotation))), seq($.expression, field('type', optional($.type_annotation))),
@ -400,7 +402,7 @@ module.exports = function defineGrammar(dialect) {
$.public_field_definition $.public_field_definition
), ),
choice($._semicolon, ',') choice($._semicolon, ',')
) ),
)), )),
'}' '}'
), ),
@ -601,7 +603,7 @@ module.exports = function defineGrammar(dialect) {
$._semicolon $._semicolon
), ),
accessibility_modifier: $ => choice( accessibility_modifier: _ => choice(
'public', 'public',
'private', 'private',
'protected' 'protected'
@ -883,15 +885,13 @@ module.exports = function defineGrammar(dialect) {
field('argument', $.number) field('argument', $.number)
)), )),
existential_type: $ => '*', existential_type: _ => '*',
flow_maybe_type: $ => prec.right(seq('?', $._primary_type)), flow_maybe_type: $ => prec.right(seq('?', $._primary_type)),
parenthesized_type: $ => seq( parenthesized_type: $ => seq('(', $._type, ')'),
'(', $._type, ')'
),
predefined_type: $ => choice( predefined_type: _ => choice(
'any', 'any',
'number', 'number',
'boolean', 'boolean',