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

No support for 'using enum'

Open DanielKriz opened this issue 3 years ago • 2 comments

As of C++20 it is possible to use using enum <name>;

The parser does not support it yet.

enum class Foo {
    bar,
};
int main()
{
    using enum Foo;
}

And TreeSitterPlayground shows:

enum_specifier [0, 0] - [2, 1]
  name: type_identifier [0, 11] - [0, 14]
  body: enumerator_list [0, 15] - [2, 1]
    enumerator [1, 4] - [1, 7]
      name: identifier [1, 4] - [1, 7]
function_definition [3, 0] - [6, 1]
  type: primitive_type [3, 0] - [3, 3]
  declarator: function_declarator [3, 4] - [3, 10]
    declarator: identifier [3, 4] - [3, 8]
    parameters: parameter_list [3, 8] - [3, 10]
  body: compound_statement [4, 0] - [6, 1]
    using_declaration [5, 4] - [5, 19]
      identifier [5, 10] - [5, 14]
      ERROR [5, 15] - [5, 18]
        identifier [5, 15] - [5, 18]

There is an error instead of enumerator identifier.

DanielKriz avatar Jul 29 '22 11:07 DanielKriz

I don't know how does the treesitter grammar work, but you would point me out. I would like to help resolve this.

DanielKriz avatar Jul 29 '22 11:07 DanielKriz

Not a maintainer but the documentation for writing tree-sitter grammar is here.

You only need to change grammar.js and test files (the .txt ones), everything else is generated by tree-sitter generate. To run that, you need tree-sitter cli. You probably want to alter this rule. Once that's done, add tests, run tree-sitter test and if everything is green you're done.

Meanwhile, if a maintainer does read this, perhaps these links can be included in README under Contributing?

alfaix avatar Jul 31 '22 16:07 alfaix

Fixed by 5ead1e26c6ab71919db0f1880c46a278a93bc5ea

jdrouhard avatar Dec 30 '22 13:12 jdrouhard