dark
dark copied to clipboard
Tree-sitter grammar: support match expressions
Changelog:
Tree-sitter-darklang
- Update the grammar to support match expressions
#5321
Questions:
- What should we do about wildcard eg.
Error _ -> ...or| _ -> ...we can add support for it in the grammar, but I am not sure how it will be captured in writtenTypes. Could you please provide some insights on this? - why don't we have MPDict?
- What should we do about wildcard eg.
Error _ -> ...or| _ -> ...we can add support for it in the grammar, but I am not sure how it will be captured in writtenTypes. Could you please provide some insights on this?
It's OK to capture these as Variable match patterns.
Maybe someday we'll have a separate Wildcard MatchPattern, though -- I've thought that for a while - I'm not sure, then, what _this would be captured as (wildcard or variable?).
- why don't we have MPDict?
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). I suppose the answer here is that our other match patterns are used to deconstruct structures and extract values out of them, safely, but the fields of a dict are unstable, so unsafe to deconstruct them Also, our other patterns can be checked at parse-time, whereas a dict one (if we could imagine how it looks) probably couldn't.