- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Tree-sitter grammar: support match expressions #5364
Conversation
623d80c
to
02bf119
Compare
Questions:
|
It's OK to capture these as Variable match patterns.
I'm not sure what that would look like. I don't believe similar languages have one we could use for inspiration (besides's F#'s record pattern but I don't think it perfectly applies). |
@@ -531,7 +613,64 @@ module.exports = grammar({ | |||
), | |||
|
|||
// | |||
// Match 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.
let's add a TODO to allow for one-line match
exprs (match myInt with | 1 -> ...
)
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.
Looking great! After adding that TODO and a test for | _ -> ...
, I think this is good to go.
tree-sitter-darklang/grammar.js
Outdated
@@ -184,6 +184,7 @@ module.exports = grammar({ | |||
alias($.mp_tuple, $.tuple), | |||
alias($.mp_enum, $.enum), | |||
alias($.variable_identifier, $.variable), | |||
alias(/_/, $.wildcard), |
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.
should we allow variable_identifier
to start with _
instead of handling it this way?
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.
Hmm, yeah I think so.
I've been thinking, and there's some value to (future) having a specific wildcard pattern: anything with _:
- may not be accessed
- should not be complained about, by the type-checker, for lack of usage (where we might otherwise warn "hey you captured this variable but didn't use it!")
b9ae44a
to
e7c7b17
Compare
Changelog:
#5321