From f2a374304dfe9967eeda35eeb281ae0b460640f0 Mon Sep 17 00:00:00 2001 From: Omar Valdez <80359343+ValdezFOmar@users.noreply.github.com> Date: Sun, 30 Jun 2024 06:04:00 -0700 Subject: [PATCH] Support comments (#15) --- grammar.js | 4 +++- test/corpus/text.txt | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/grammar.js b/grammar.js index 9954788..117fe8e 100644 --- a/grammar.js +++ b/grammar.js @@ -25,7 +25,8 @@ module.exports = grammar({ $.location, $.addition, $.deletion, - $.context + $.context, + $.comment ), block: ($) => @@ -102,6 +103,7 @@ module.exports = grammar({ ), context: ($) => token(prec(-1, ANYTHING)), + comment: ($) => iseq("#", optional(ANYTHING)), linerange: ($) => /[-\+]\d+(,\d+)?/, filename: ($) => repeat1(/\S+/), diff --git a/test/corpus/text.txt b/test/corpus/text.txt index cde0efc..2128db0 100644 --- a/test/corpus/text.txt +++ b/test/corpus/text.txt @@ -303,3 +303,25 @@ new mode 100755 (mode)) (file_change (mode)))) + +================================================================================ +Comments +================================================================================ +# Some comment + # This is not a comment +# But this is + context +# Empty comment +# + more contex + +-------------------------------------------------------------------------------- + +(source + (comment) + (context) + (comment) + (context) + (comment) + (comment) + (context))