Author: Omar Valdez [80359343+ValdezFOmar@users.noreply.github.com]
Committer: GitHub [noreply@github.com] Sun, 30 Jun 2024 13:04:00 +0000
Hash: f2a374304dfe9967eeda35eeb281ae0b460640f0
Timestamp: Sun, 30 Jun 2024 13:04:00 +0000 (3 months ago)

+25 -1 +/-2 browse
Support comments (#15)
Support comments (#15)

1diff --git a/grammar.js b/grammar.js
2index 9954788..117fe8e 100644
3--- a/grammar.js
4+++ b/grammar.js
5 @@ -25,7 +25,8 @@ module.exports = grammar({
6 $.location,
7 $.addition,
8 $.deletion,
9- $.context
10+ $.context,
11+ $.comment
12 ),
13
14 block: ($) =>
15 @@ -102,6 +103,7 @@ module.exports = grammar({
16 ),
17
18 context: ($) => token(prec(-1, ANYTHING)),
19+ comment: ($) => iseq("#", optional(ANYTHING)),
20
21 linerange: ($) => /[-\+]\d+(,\d+)?/,
22 filename: ($) => repeat1(/\S+/),
23 diff --git a/test/corpus/text.txt b/test/corpus/text.txt
24index cde0efc..2128db0 100644
25--- a/test/corpus/text.txt
26+++ b/test/corpus/text.txt
27 @@ -303,3 +303,25 @@ new mode 100755
28 (mode))
29 (file_change
30 (mode))))
31+
32+ ================================================================================
33+ Comments
34+ ================================================================================
35+ # Some comment
36+ # This is not a comment
37+ # But this is
38+ context
39+ # Empty comment
40+ #
41+ more contex
42+
43+ --------------------------------------------------------------------------------
44+
45+ (source
46+ (comment)
47+ (context)
48+ (comment)
49+ (context)
50+ (comment)
51+ (comment)
52+ (context))