-
Notifications
You must be signed in to change notification settings - Fork 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
Support new curly brace syntax #43
base: main
Are you sure you want to change the base?
Support new curly brace syntax #43
Conversation
Thanks for doing this! I'll have time tomorrow to test these changes locally. |
grammar.js
Outdated
seq( | ||
choice("{"), | ||
prec.left( | ||
seq( | ||
choice( | ||
$.partial_expression_value, | ||
$.ending_expression_value, | ||
$.expression_value | ||
), | ||
choice("}") | ||
) | ||
) | ||
) |
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.
Partial/end expression is not allowed in {...}
, it should always be a single expression. We can do this:
seq( | |
choice("{"), | |
prec.left( | |
seq( | |
choice( | |
$.partial_expression_value, | |
$.ending_expression_value, | |
$.expression_value | |
), | |
choice("}") | |
) | |
) | |
) | |
alias($.expression, "expression") |
Aliasing as string makes the node anonymous, so it appears as directive
.
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.
Actually, I would consider parsing {...}
as expression
node, regardless if it's <div attr={...}>
or <div>{...}</div>
. So it would be this:
_node: ($) =>
- choice($.doctype, $.tag, $.component, $.text, $.comment, $.directive),
+ choice($.doctype, $.tag, $.component, $.text, $.comment, $.directive, $.expression),
@connorlay wdyt?
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.
@jonatanklosko That makes sense to me!
parse curly braces directive only with single expressions Co-authored-by: Jonatan Kłosko <[email protected]>
Is tree-sitter able to respect |
25edee6
to
f8bb3dd
Compare
I think it may be possible, but I'm pretty sure it's not worth the complexity. The way I would try to implement it, would be to have a separate grammar node for |
Closes #42
This is me just jumping into the codebase but i wanted have a stab at it. Hope this helps and i'm happy to get feedback if anything needs changing!