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

C++20 modules support

Open Tomcat-42 opened this issue 1 year ago • 1 comments

As discussed in #173, this PR implements the C++20 modules grammar after the last contributor time restraints. It Closes #174.

Parser states

before:

#define STATE_COUNT 9798
#define LARGE_STATE_COUNT 2603

after:

#define STATE_COUNT 10516
#define LARGE_STATE_COUNT 2971

Implementation

The most complex rules in the grammar are:

export declaration 	(2)
export { declaration-seq (optional) } (3) 	

Declarations, in turn, can be any one of those discussed in https://en.cppreference.com/w/cpp/language/declarations. Said that, due to the inerent complexity of c++20 modules, I think that the state count can't go much lower than that. I'm open to suggestions tho.

Tomcat-42 avatar May 18 '24 12:05 Tomcat-42

@amaanq could you please take a look?

Tomcat-42 avatar May 18 '24 12:05 Tomcat-42

Support for parsing C++20 modules related syntax is something we'll be interested in using soon -- is there anything we can do to help get this merged? (maybe a question for @amaanq, since they seem to be the current POC for handling incoming PRs)

nightlark avatar Dec 18 '24 23:12 nightlark

@jdrouhard is this PR something you can help out with, or point me to what I can do to help get C++20 modules support added?

Probably late spring/early summer if this still seems to be stalled with no guidance on how it can be helped along, I might need to look into what it would take to create a tree-sitter-cpp20modules fork that I can include as a dependency in other projects until the main repository gets support for c++ 20 modules.

nightlark avatar Feb 06 '25 00:02 nightlark

@jdrouhard is this PR something you can help out with, or point me to what I can do to help get C++20 modules support added?

Probably late spring/early summer if this still seems to be stalled with no guidance on how it can be helped along, I might need to look into what it would take to create a tree-sitter-cpp20modules fork that I can include as a dependency in other projects until the main repository gets support for c++ 20 modules.

I don't know why this is stalled; this repo seems to have been unmaintained for some time.

I've actually been using this PR locally in Neovim for a while and have had zero issues.

Tomcat-42 avatar Feb 06 '25 01:02 Tomcat-42

I made some changes:

  • Reduce the state count and parser size growth
  • Improved the exportable item stuff a bit
  • Removed the seemingly unrelated "constants" highlight
  • Rewrote the commits to be by you instead of "Your Name"

I hadn't gotten around to looking at this because I knew it needed a little tweaking--thanks for the reminder to look at it.

jdrouhard avatar Feb 06 '25 15:02 jdrouhard

Nice @jdrouhard , thanks for your time

Tomcat-42 avatar Feb 06 '25 16:02 Tomcat-42

Thanks @jdrouhard and @Tomcat-42 for getting this feature added 😄

nightlark avatar Feb 06 '25 18:02 nightlark