From 89f24fc5fd47d06f64e9a294524315ee4327d06d Mon Sep 17 00:00:00 2001 From: Sergio Alejandro Vargas Date: Tue, 1 Oct 2024 12:57:10 -0500 Subject: [PATCH] Remove unnecessary newlines - Remove unnecessary newlines from `_comprehension_clause` and `matrix_expression`. - Update definition of `_terminator`. Co-authored-by: Imran Khan --- grammar.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/grammar.js b/grammar.js index 6a14579..71dd4e6 100644 --- a/grammar.js +++ b/grammar.js @@ -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( @@ -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'), ']', )), @@ -1153,7 +1147,7 @@ module.exports = grammar({ _syntactic_operator: _ => token(choice('$', '.', '...', '->', '?')), - _terminator: _ => choice('\n', /;+/), + _terminator: _ => choice(/\r?\n/, /;+/), block_comment: $ => seq(/#=/, $._block_comment_rest),