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

`open` used in function declaration is parsed as keyword `open` (which is used in module declaration)

Open dezhen-k opened this issue 3 years ago • 0 comments

Problem description

open used in function declaration is parsed as keyword open (which is used in module declaration)

An example program:

class A{
    void open() {
        
    }
}

Expected parse tree output (optional)

Actual parse tree output (optional)

I transform it to a Python object.

{'type': 'program',
 'children': [{'type': 'class_declaration',
   'children': [{'type': 'class', 'children': [], 'text': 'class'},
    {'type': 'identifier', 'children': [], 'text': 'A'},
    {'type': 'class_body',
     'children': [{'type': '{', 'children': [], 'text': '{'},
      {'type': 'method_declaration',
       'children': [{'type': 'void_type', 'children': [], 'text': 'void'},
        {'type': 'open', 'children': [], 'text': 'open'},
        {'type': 'formal_parameters',
         'children': [{'type': '(', 'children': [], 'text': '('},
          {'type': ')', 'children': [], 'text': ')'}]},
        {'type': 'block',
         'children': [{'type': '{', 'children': [], 'text': '{'},
          {'type': '}', 'children': [], 'text': '}'}]}]},
      {'type': '}', 'children': [], 'text': '}'}]}]}]}

dezhen-k avatar Aug 08 '22 09:08 dezhen-k