Skip to content

Commit

Permalink
Remove unnecessary newlines
Browse files Browse the repository at this point in the history
- Remove unnecessary newlines from `_comprehension_clause` and
  `matrix_expression`.
- Update definition of `_terminator`.

Co-authored-by: Imran Khan <[email protected]>
  • Loading branch information
savq and natrys committed Oct 29, 2024
1 parent e06643f commit 89f24fc
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,10 @@ module.exports = grammar({

_comprehension_clause: $ => seq(
$.for_clause,
optional('\n'),
sep(optional('\n'), choice(
repeat(choice(
$.for_clause,
$.if_clause,
)),
optional('\n'),
),

if_clause: $ => seq(
Expand All @@ -562,13 +560,9 @@ module.exports = grammar({

matrix_expression: $ => prec(PREC.array, seq(
'[',
choice(
// Must allow newlines even if there's already a semicolon.
seq($.matrix_row, $._terminator, optional('\n')),
sep1(seq($._terminator, optional('\n')), $.matrix_row),
),
$.matrix_row,
repeat(seq($._terminator, $.matrix_row)),
optional($._terminator),
optional('\n'),
']',
)),

Expand Down Expand Up @@ -1153,7 +1147,7 @@ module.exports = grammar({
_syntactic_operator: _ => token(choice('$', '.', '...', '->', '?')),


_terminator: _ => choice('\n', /;+/),
_terminator: _ => choice(/\r?\n/, /;+/),

block_comment: $ => seq(/#=/, $._block_comment_rest),

Expand Down

0 comments on commit 89f24fc

Please sign in to comment.