-
Notifications
You must be signed in to change notification settings - Fork 3
Implement external scanner for raw_text #15
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
Conversation
src/tree-sitter-javascript/scanner.h
Outdated
// | ||
// To Update: | ||
// - delete everything under the comment block | ||
// - find and replace "tree_sitter_javascript" with "tree_sitter_javascript" |
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.
seems like something went wrong here 🙃 haha
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.
Sure did! Will update.
JSX_TEXT, | ||
}; | ||
|
||
void *tree_sitter_javascript_external_scanner_create() { return NULL; } |
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.
shouldn't these be tree_sitter_glimmer_javascript?
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.
maybe it doesn't matter?
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.
At the moment these aren’t in use, and duplicated version with glimmer_javascript
are in scanner.c
.
I see three options; leave them, call them, or remove them.
I thought it would be nice to have the ability to just copy paste scanner.c
from GitHub into scanner.h
. So maybe best to just call them from scanner.c
?
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.
They are now called from scanner.c
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.
yea, copy-paste ability is very nice
To simplify having a custom external scanner, I've moved JS scanner into `tree-sitter-javascript/scanner.h`. This will allow us to have custom scanner implementation and still allow us to easily update the upstream scanner.
It allows greater control and allows us to expose more of the template. External scanner seems to be the way if we want to expose more than just the `<template>` token. This obviously makes it more tedious to update the upstream TypeScript grammar. Especially the `GlimmerTokenType` which must continue the sequence of the parent's TokenType.
Some editor features requires the abillity to capture the brackets independent from the tag name. e.g. Zed captures `<` as brackets and highlight them different from the tag name. It uses it to highlight the opposite opening/closing pair when the cursor is on one of the brackets.
07f27d5
to
7688609
Compare
thank you!!! |
Same as ember-tooling/tree-sitter-glimmer-typescript#10, but moved the upstream parser into
src/tree-sitter-javascript/scanner.h
to make it easier to keep up with changes upstream. This partly matches what’s already in place fortree-sitter-glimmer-typescript
.