Queries on anonymous nodes in tree-sitter-ruby
#2109
Unanswered
savetheclocktower
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on modernizing the Ruby tree-sitter grammar in Pulsar (the Atom fork), and I've run into some weird behavior that I'd like to get clarification on.
I noticed that
tree-sitter-ruby
will parse all sorts of strings as though they have identical delimiters. For instance:I'm nearly certain this is a bug, but I thought I'd ask here first. I've always assumed that anonymous nodes are purposefully meant to capture the exact literal text used.
My goal is to be able to scope the variously delimited strings differently —
string.quoted.single
,string.quoted.double
, et cetera, but I can't figure out any way for the query file to treat these three strings differently.Which brings me to my second question: in the general case, is there a good way to match anonymous nodes based on their position? I noticed that anchors only operate on named nodes. I'm doing something like this right now…
…and I think it'll always do the right thing because
string_content
wraps around the string contents and saves me from having to care about the internal structure, but I don't think I'll always be that lucky, so I'd like to be able to target delimiters without caring about the stuff in the middle.The docs make me think that this ought to work, but it doesn't:
Beta Was this translation helpful? Give feedback.
All reactions