Change Match clauses from pairs to classes (#858)

Updates style of the Match class at the same time.
This commit is contained in:
Jon Meow
2021-09-29 13:36:54 -07:00
committed by GitHub
parent bf49f2efed
commit 25dce9fbcf
6 changed files with 57 additions and 43 deletions
+7 -7
View File
@@ -133,8 +133,8 @@
%type <BisonWrap<ChoiceDeclaration::Alternative>> alternative
%type <std::vector<ChoiceDeclaration::Alternative>> alternative_list
%type <std::vector<ChoiceDeclaration::Alternative>> alternative_list_contents
%type <std::pair<Nonnull<Pattern*>, Nonnull<Statement*>>> clause
%type <std::vector<std::pair<Nonnull<Pattern*>, Nonnull<Statement*>>>> clause_list
%type <BisonWrap<Match::Clause>> clause
%type <std::vector<Match::Clause>> clause_list
%token
// Most tokens have their spelling defined in lexer.lpp.
@@ -501,13 +501,13 @@ maybe_empty_tuple_pattern:
;
clause:
CASE pattern DOUBLE_ARROW statement
{ $$ = std::pair<Nonnull<Pattern*>, Nonnull<Statement*>>($2, $4); }
{ $$ = Match::Clause($2, $4); }
| DEFAULT DOUBLE_ARROW statement
{
auto vp = arena -> New<BindingPattern>(
context.SourceLoc(), std::nullopt,
arena->New<AutoPattern>(context.SourceLoc()));
$$ = std::pair<Nonnull<Pattern*>, Nonnull<Statement*>>(vp, $3);
$$ = Match::Clause(arena->New<BindingPattern>(
context.SourceLoc(), std::nullopt,
arena->New<AutoPattern>(context.SourceLoc())),
$3);
}
;
clause_list: