gdamore / tree-sitter-d

D Grammar for Tree Sitter
MIT License
41 stars 7 forks source link

(Member) function attributes should be placed under `function_declaration` #38

Closed nordlow closed 1 month ago

nordlow commented 3 months ago

Currently property in

void foo() pure @property;

is put in

(at_attribute (identifier))

when it should be

(function_declaration (member_function_attribute (at_attribute (identifier))))

to conform with pure being put in

(function_declaration (member_function_attribute (pure)))

.

gdamore commented 1 month ago

I'm not sure the grammar is completely clear here. I'll have a look -- but its possible that the grammar is ambiguous in this case (there are other cases where you need semantic information that isn't available in the syntax tree. This might be one of them.)

gdamore commented 1 month ago

I tested this, and it seems right already:

(source_file
  (function_declaration
    (type
      (void))
    (identifier)
    (parameters)
    (member_function_attribute
      (pure))
    (member_function_attribute
      (at_attribute
        (identifier)))
    (function_body)))
gdamore commented 1 month ago

I've added a test case for the above. I'm closing this because I don't see a bug right now.