Skip to content

Commit

Permalink
[tree_sitter] minimal cleanup, add optional ; support between state…
Browse files Browse the repository at this point in the history
…ments in {} blocks (#88)
  • Loading branch information
Lycs-D authored Apr 10, 2024
1 parent 42798b5 commit 9ba1aa8
Show file tree
Hide file tree
Showing 4 changed files with 249,322 additions and 235,624 deletions.
20 changes: 2 additions & 18 deletions tree_sitter_v/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,6 @@ module.exports = grammar({

array_type: ($) => prec.right(PREC.primary, seq('[', ']', field('element', $.plain_type))),

variadic_type: ($) => seq('...', $.plain_type),

pointer_type: ($) => prec(PREC.match_arm_type, seq('&', $.plain_type)),

// In languages like Go, pointers use an asterisk, not an ampersand,
Expand All @@ -1036,18 +1034,6 @@ module.exports = grammar({

// ==================== STATEMENTS ====================

_statement_list: ($) =>
choice(
seq(
$._statement,
repeat(seq(terminator, $._statement)),
optional(
seq(terminator, optional(alias($.empty_labeled_statement, $.labeled_statement))),
),
),
alias($.empty_labeled_statement, $.labeled_statement),
),

_statement: ($) =>
choice(
$.simple_statement,
Expand Down Expand Up @@ -1111,7 +1097,7 @@ module.exports = grammar({
field('right', $.expression_list),
),

block: ($) => seq('{', optional($._statement_list), '}'),
block: ($) => seq('{', repeat(seq($._statement, optional(semi))), '}'),

defer_statement: ($) => seq('defer', $.block),

Expand All @@ -1128,9 +1114,7 @@ module.exports = grammar({

label_definition: ($) => seq($.identifier, ':'),

labeled_statement: ($) => seq($.label_definition, $._statement),

empty_labeled_statement: ($) => prec.left($.label_definition),
labeled_statement: ($) => prec.right(seq($.label_definition, optional($._statement))),

compile_time_for_statement: ($) => seq('$for', $.range_clause, field('body', $.block)),

Expand Down
202 changes: 64 additions & 138 deletions tree_sitter_v/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ba1aa8

Please sign in to comment.