Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): handle cases where brackets are not children of container #37

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

AckslD
Copy link
Owner

@AckslD AckslD commented Feb 19, 2024

closes #36

The issue with languages such as r is that the opening and closing brackets are not node-children of the container node. For example in r:

f(a, b)

has the tree:

(call) ; [1:1 - 7]
 function: (identifier) ; [1:1 - 1]
 "(" ; [1:2 - 2]
 arguments: (arguments) ; [1:3 - 6]
  (identifier) ; [1:3 - 3]
  "," ; [1:4 - 4]
  (identifier) ; [1:6 - 6]
 ")" ; [1:7 - 7]
"\n" ; [1:8 - 2:0]

whereas eg python (and all other languages I've seen) have something like:

def f(a, b):
    pass

with

(function_definition) ; [1:1 - 2:8]
 "def" ; [1:1 - 3]
 name: (identifier) ; [1:5 - 5]
 parameters: (parameters) ; [1:6 - 11]
  "(" ; [1:6 - 6]
  (identifier) ; [1:7 - 7]
  "," ; [1:8 - 8]
  (identifier) ; [1:10 - 10]
  ")" ; [1:11 - 11]
 ":" ; [1:12 - 12]
 body: (block) ; [2:5 - 8]
  (pass_statement) ; [2:5 - 8]
   "pass" ; [2:5 - 8]

ie the opening and closing brackets are part of parameters whereas in r it is part of function.

@AckslD AckslD merged commit 96196f9 into main Feb 19, 2024
2 checks passed
@AckslD AckslD deleted the fix-r branch February 19, 2024 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initial spaces after parenthesis
1 participant