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

Add additional namestyle configuration for const variables #160

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

AndreaWalchshoferSCCH
Copy link
Contributor

This PR adds a name style configuration option for variables marked with the attribute <const>, as described in #158

How it's designed:

  • Configuration item const_variable_name_style
  • "Special variables" like ImportModuleName and ModuleName are not affected
  • Local variables with the attribute <const> are affected
  • The default configuration is set that SnakeCase and UpperSnakeCase are allowed, so it should not affect existing code bases using the default name style configuration. If preferred, we could also set it to Ignore as the default, but as the name styles themselves are still quite recent, I wouldn't assume it would annoy people.

@CppCXY
Copy link
Owner

CppCXY commented Feb 4, 2024

Good job, it seems that you need a more user-friendly syntax tree and node API, just like what I did with C#, in this case, writing such diagnostics would only need to be like:

auto nodes = tree.Children<NameExpr>().Where([](auto it) -> { return it.Declaration(tree).Is<LocalName>();  });
// make diagnostic

of course I didn't design such an API for this project, for this project, I didn't initially intend to implement complex diagnostic algorithms, including format checking, which was just written casually. therefore, although the AST has the shadow of the red-green tree, it is not strongly typed, which leads to a very unfriendly API.

I might take the time to write a C++ parser that can parse all LuaCats and emmyluadoc, if I have the time. Many people should need it to write tools.

@CppCXY CppCXY merged commit c9bbaa4 into CppCXY:master Feb 5, 2024
4 of 9 checks passed
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.

2 participants