-
-
Notifications
You must be signed in to change notification settings - Fork 16
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 Int/Float operators in guard expressions #92
Support Int/Float operators in guard expressions #92
Conversation
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.
Yooo that was fast! Thank you
@gleam-lang/tree-sitter-team this look good to you?
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.
Just one thing about precedence, otherwise this looks good 👍
grammar.js
Outdated
binaryExpr(prec.left, 5, "*", $._case_clause_guard_expression), | ||
binaryExpr(prec.left, 5, "*.", $._case_clause_guard_expression), | ||
binaryExpr(prec.left, 5, "/", $._case_clause_guard_expression), | ||
binaryExpr(prec.left, 5, "/.", $._case_clause_guard_expression) |
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.
binaryExpr(prec.left, 5, "*", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 5, "*.", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 5, "/", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 5, "/.", $._case_clause_guard_expression) | |
binaryExpr(prec.left, 6, "*", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 6, "*.", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 6, "/", $._case_clause_guard_expression), | |
binaryExpr(prec.left, 6, "/.", $._case_clause_guard_expression) |
I believe we want these higher than the +
/-
/etc. ones so that the expressions associate properly. For example if you add a branch to one of the case
s in the test file
case value {
n if n + 1 * 2 > 5 -> False
}
without the change it would be (n + 1) * 2
but it should associate as n + (1 * 2)
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.
🤦🏻♂️ whoops, thanks
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.
Thanks!
Closes #90