Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish between line and block comments #174

Open
nacl opened this issue Nov 9, 2023 · 1 comment
Open

Distinguish between line and block comments #174

nacl opened this issue Nov 9, 2023 · 1 comment

Comments

@nacl
Copy link

nacl commented Nov 9, 2023

The current grammar does not distinguish between line comment and block comments. Supporting this would make it more convenient for editors to see in what type of comment they are in, and then make formatting decisions without examining the code themselves.

FWIW, the Java grammar (which has the same comment syntax as C and C++), does this already. Something similar could easily be done here (there's already a skeleton for it). See also tree-sitter/tree-sitter-java#92

@savetheclocktower
Copy link

There is a strong convention across lots of parsers to use one comment node for all kinds of comments. Use cases that need to distinguish between comment types can use queries and #match? predicates.

You're right thattree-sitter-java does things differently, but it's the exception, and I'm honestly pretty surprised that that change got landed. (A later proposal to distinguish JavaDoc comments was closed under the “use queries instead” rationale.)

I think it's worth having a philosophical discussion about. I'd be just as happy to have different line_comment and block_comment types for all languages, but I'd much rather have a uniform pattern across all parsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants