dark icon indicating copy to clipboard operation
dark copied to clipboard

Tree-sitter grammar: support match expressions

Open OceanOak opened this issue 1 year ago • 1 comments
trafficstars

Changelog:

Tree-sitter-darklang
- Update the grammar to support match expressions

#5321

OceanOak avatar May 02 '24 14:05 OceanOak

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?

OceanOak avatar May 03 '24 14:05 OceanOak

  • 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.

StachuDotNet avatar May 06 '24 15:05 StachuDotNet