tree-sitter-comment icon indicating copy to clipboard operation
tree-sitter-comment copied to clipboard

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

Open jonboiser opened this issue 4 years ago • 3 comments

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?

jonboiser avatar Mar 19 '21 17:03 jonboiser

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.

stsewd avatar Mar 20 '21 01:03 stsewd

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

jonboiser avatar Mar 21 '21 03:03 jonboiser

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 avatar Mar 21 '21 22:03 stsewd

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

stsewd avatar Feb 11 '23 15:02 stsewd