-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat: Add a content field and element to raw string literals. #201
Conversation
This makes it possible to use language injection for this content.
src/scanner.c
Outdated
struct ScannerState { | ||
unsigned opening_hash_count; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A struct for one field is a bit overkill, let's just allocate a uint32_t instead (I'd rather not use unsigned)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about this? Personally I feel keeping it in a struct makes it explicitly clear that this is the only state we keep track of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright yeah, if we do need to add more fields later on for whatever reason it'd be easier. Can we declare it as a typedef, use uint32_t, and call it just Scanner though?
typedef struct {
uint32_t opening_hash_count;
} Scanner;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of anonymous structs, would f6caf4a work as a compromise?
If not I am okay with removing the name. It's mostly for the sake of things like lsp hover information.
@Natr1x what else needs to get done for this PR to move out of draft. This would be extremely useful for sql injections and would remove |
reworked it in #220 |
This makes it possible to use language injection for this content.
Which is useful since this is something that raw string literals are often used for.
A query like the following could for example be used to provide sql highlighting when using sqlx:
Note: I have not ran
tree-sitter-cli generate
in order to keep the commit smaller for review purposes.If you are interested in merging this but want me to change or add something (or run that code generation) then I am willing to do so.