I use tree-sitter to write the parser for comment input. this is the code I write for single line comment parsing:
seq(
"//",
optional(seq($.comment_prefix, optional(/[ ]*/))),
/[^\n]*/
),
For the input string "@ TODO", it recognizes the comment_prefix and output as expected:
(source_file [0, 0] - [2, 0]
(comment [0, 0] - [0, 8]
(comment_prefix [0, 2] - [0, 8])))
However, for input string become "@ TODO this is a comment", it outputs:
(source_file [0, 0] - [2, 0]
(comment [0, 0] - [0, 26]))
Why is the comment prefix no longer recognized if @TODO is followed by a string?
note: comment_prefix includes a range of annotations such as "@TODO", etc.