mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:01:04 +01:00
Change Match clauses from pairs to classes (#858)
Updates style of the Match class at the same time.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user