-
Notifications
You must be signed in to change notification settings - Fork 4
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
bug: Unable to parse some of the modern syntaxes #4
Comments
With the caveat that I'm not very familiar with tree sitter grammars (yet): I would start by looking at tree-sitter-scss/src/grammar.json Line 1254 in 9ab738d
"declaration": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "variable"
},
{
"type": "SYMBOL",
"name": "_concatenated_identifier"
}
]
},
"named": true,
"value": "property_name"
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_value"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "important"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
}, |
@bajrangCoder As I also mention over at bajrangCoder/zed-scss#2 (comment), the following is not valid SCSS: body {
@mixin body_long_14;
color: red;
} Per Sass documentation: @mixin and @include, it is correct to use body {
@include body_long_14;
color: red;
} This said, from what I can tell, the current tree-sitter grammar here does not support the latter (correct) example. |
I'm apologised for my confusion |
As for variable Interpolation, it's already implemented here Line 224 in 9ab738d
|
@bajrangCoder Speaking of the nested @include, without having dug in very much, I suspect the key problem is that the Update as of 2024-05-06 9:21 am EDT: ah, now that I've read a bit more, I see now that Line 78 in 9ab738d
// Declarations
declaration: $ => seq(
alias(
choice($.identifier, $.variable, $._concatenated_identifier),
$.property_name,
),
':',
$._value,
repeat(seq(optional(','), $._value)),
optional($.important),
';',
), ... and I'm not seeing any inclusion of I would bet (high confidence) that it will make sense and be practical to extract a new rule that parses one "property: value" pair. Call it Then @bajrangCoder Does this make sense to you? |
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)No response
Describe the bug
The current version of Tree-sitter-scss does not fully parse certain syntaxes in SCSS, such as variable interpolation
Examples:
color: #{$color};
These syntaxes are not parsed correctly by Tree-sitter, leading to potential parsing errors and inconsistencies in syntax highlighting.
Steps To Reproduce/Bad Parse Tree
Just try to parse the above examples
Expected Behavior/Parse Tree
It should parse those syntaxes without any errors
Repro
No response
The text was updated successfully, but these errors were encountered: