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

Class Specifier Does Not Include Semicolon

Open berchn opened this issue 3 years ago • 0 comments

The following is the code I'm using:

class Dummy {​​​​​​​​​​
public:
  int foo();
  int bar(int val);
}​​​​​​​​​​​;

class DummyTwo;
translation_unit [0, 0] - [7, 0]
  class_specifier [0, 0] - [4, 1]
    name: type_identifier [0, 6] - [0, 11]
    body: field_declaration_list [0, 12] - [4, 1]
      access_specifier [1, 0] - [1, 7]
      field_declaration [2, 2] - [2, 12]
        type: primitive_type [2, 2] - [2, 5]
        declarator: function_declarator [2, 6] - [2, 11]
          declarator: field_identifier [2, 6] - [2, 9]
          parameters: parameter_list [2, 9] - [2, 11]
      field_declaration [3, 2] - [3, 19]
        type: primitive_type [3, 2] - [3, 5]
        declarator: function_declarator [3, 6] - [3, 18]
          declarator: field_identifier [3, 6] - [3, 9]
          parameters: parameter_list [3, 9] - [3, 18]
            parameter_declaration [3, 10] - [3, 17]
              type: primitive_type [3, 10] - [3, 13]
              declarator: identifier [3, 14] - [3, 17]
  class_specifier [6, 0] - [6, 14]
    name: type_identifier [6, 6] - [6, 14]

Notice that neither class specifier includes the semicolon. The semicolon is instead a sibling of the class_specifier subtree. This is due to the usage of empty_declaration in _top_level_item.

berchn avatar Jan 31 '22 19:01 berchn