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 named rules for the various call operators #211

Merged
merged 1 commit into from
Apr 23, 2022

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Apr 22, 2022

Having named operators helps the CodeQL dbscheme generator to produce better output.

Checklist:

  • All tests pass in CI.
  • There are sufficient tests for the new fix/feature.
  • Grammar rules have not been renamed unless absolutely necessary.
  • The conflicts section hasn't grown too much.
  • The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).

@maxbrunsfeld
Copy link
Contributor

Can the CodeQL generator be adjusted to use the field name (operator) that is associated with the operator? Making the operator a named node doesn't fit the general pattern of using anonymous nodes for simple strings that represent punctuation/operator tokens, which is in use in a lot of other places.

@aibaars aibaars force-pushed the call-operator branch 2 times, most recently from dd1f354 to 0fdbd41 Compare April 22, 2022 16:56
@aibaars
Copy link
Contributor Author

aibaars commented Apr 22, 2022

Can the CodeQL generator be adjusted to use the field name (operator) that is associated with the operator? Making the operator a named node doesn't fit the general pattern of using anonymous nodes for simple strings that represent punctuation/operator tokens, which is in use in a lot of other places.

Ok, fair point. We're introducing names for other tokens already such as nil, self, false, but you're right there are none for operators.

Would it be OK to introduce an anonymous rule _call_operator that gets re-used in the various places? That gives a slightly nicer node-types.json. The node-types.json is the input to our generator, and the more concise it is the better code we can generate.

Copy link
Contributor

@maxbrunsfeld maxbrunsfeld left a comment

Choose a reason for hiding this comment

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

Yeah, I'm on board with this. Thanks for adjusting!

@aibaars aibaars merged commit 1a3936a into tree-sitter:master Apr 23, 2022
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