gdamore / tree-sitter-d

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

Parsing of attributes treats the @-sign as a separate token #39

Closed nordlow closed 1 month ago

nordlow commented 1 month ago

Currently @property in

struct S { void foo() pure @property };

is currently parsed as two separate tokens

(function_declaration (member_function_attribute (at_attribute "@")))

and

(at_attribute (identifier))

when I believe it should be parsed as a single token

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

or

(function_declaration (member_function_attribute (identifier)))

.

nordlow commented 1 month ago

Ahh, I see now that this behaviour conforms with how decorators in Python's tree-sitter parser behaves like for instance for @decorator in

def decorator(func):
    def wrapper():
        print("Something is happening before the function is called.")
        func()
        print("Something is happening after the function is called.")
    return wrapper

@decorator
def say_whee():
    print("Whee!")

. Closing this for now.