Skip to content

Commit

Permalink
fix: parse whole line of comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jgollenz committed Dec 9, 2022
1 parent f057eec commit 2a4e148
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = grammar({

line_comment: $ => token(seq(
'#',
/.*/,
)),

// How lines can end
Expand Down
4 changes: 4 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
{
"type": "STRING",
"value": "#"
},
{
"type": "PATTERN",
"value": ".*"
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4847,6 +4847,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
END_STATE();
case 94:
ACCEPT_TOKEN(sym_line_comment);
if (lookahead != 0 &&
lookahead != '\n') ADVANCE(94);
END_STATE();
case 95:
ACCEPT_TOKEN(anon_sym_PIPE);
Expand Down
10 changes: 10 additions & 0 deletions test/corpus/line_comment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
==================
line comment
==================

# comment

---

(source_file
(line_comment))

0 comments on commit 2a4e148

Please sign in to comment.