tree-sitter / tree-sitter-ruby

Ruby grammar for tree-sitter
MIT License
182 stars 58 forks source link

Add named rules for the various call operators #211

Closed aibaars closed 2 years ago

aibaars commented 2 years ago

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

Checklist:

maxbrunsfeld commented 2 years ago

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 commented 2 years ago

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.