stsewd / tree-sitter-comment

Tree-sitter grammar for comment tags like TODO, FIXME(user).
https://stsewd.dev/tree-sitter-comment/
MIT License
134 stars 9 forks source link

Tips for downgrading this to an older version of tree-sitter #3

Closed jonboiser closed 1 year ago

jonboiser commented 3 years ago

Hi! I'm interested in forking this library and rebuilding it for use in an Atom grammar. I tried doing this with the library as is, but because it the language version is 13

https://github.com/stsewd/tree-sitter-comment/blob/674c5cbb948b596c3ed664b510dde76e1f21aee3/src/parser.c#L8

it is incompatible with the current versions of Atom (and Atom might not catch up any time soon).

I'm completely ignorant about tree-sitter parser side of things. Do you think it's a simple matter of just regenerating the C code with an older version of tree-sitter-cli, but with the same grammar you have here?

stsewd commented 3 years ago

Do you think it's a simple matter of just regenerating the C code with an older version of tree-sitter-cli, but with the same grammar you have here?

Yeah, you can re-generate the grammar, it should just work. You just need to download the ts cli version that you want and call tree-sitter-cli generate, you can also use this commit https://github.com/stsewd/tree-sitter-comment/tree/6b0dbd56284023617c3ea755624e55d0254f813a (that's using 0.17.3). There aren't any differences in the grammar from that commit vs master, so you can use it without problems.

jonboiser commented 3 years ago

Thanks! Installing from '6b0dbd5' was a quick fix.

I was wondering if you might know how to work around what seems to be a common limitation with other language grammars: that comments are parsed as single block, which makes language injection of this grammar hard/impossible.

For example, I'm trying to use the tree-sitter-vue parser for an Atom vue grammar. But it treats the entire comment block as a comment. I think that I cannot just parse the entire node using tree-sitter-comment. I need to identify a child node of comment that can be passed in to your parser. So if the AST of the comment were something like

(comment (comment_block),

I think I could have passed comment_block into your parser.

Screen Shot 2021-03-20 at 8 36 13 PM
stsewd commented 3 years ago

you mean having <!-- being a different node and the comment just TODO? then you can pass the whole thing without problems <!-- TODO: something --> that would be parsed as ("text" tag (name) ":" "text") or (tag (name))

stsewd commented 1 year ago

Let me know if there is anything actionable from my side.