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

C++20 modules support #266

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Tomcat-42
Copy link

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
Copy link
Author

@amaanq could you please take a look?

'export',
choice($._exportable_item, seq('{', repeat($._exportable_item), '}'))
),
import_declaration: $ => seq(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it reduce productions to remove the optional('export') and instead add this to the list of exportable items? The standard enforces that a module import declaration shall not be contained in a declaration-seq of an export-declaration: https://eel.is/c%2B%2Bdraft/module#interface-1. This could simplify the productions here since it's more of a semantic error.

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

Successfully merging this pull request may close these issues.

[feature request] Parse C++20 modules
2 participants