diff --git a/executable_semantics/syntax.ypp b/executable_semantics/syntax.ypp index c7c3ecdf60ba..38ca71feffb6 100644 --- a/executable_semantics/syntax.ypp +++ b/executable_semantics/syntax.ypp @@ -289,14 +289,26 @@ member_list: { $$ = $2; $$->push_front($1); } ; alternative: - identifier tuple ';' + identifier tuple { $$ = new std::pair($1, $2); } +| identifier + { + $$ = new std::pair( + $1, Carbon::MakeTuple( + yylineno, + new std::vector>())); + } ; alternative_list: // Empty { $$ = new std::list>(); } -| alternative alternative_list - { $$ = $2; $$->push_front(*$1); } +| alternative + { + $$ = new std::list>(); + $$->push_front(*$1); + } +| alternative ',' alternative_list + { $$ = $3; $$->push_front(*$1); } ; declaration: function_definition diff --git a/executable_semantics/testdata/choice1.6c b/executable_semantics/testdata/choice1.6c index b031f59e639b..29c68baeec97 100644 --- a/executable_semantics/testdata/choice1.6c +++ b/executable_semantics/testdata/choice1.6c @@ -3,9 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception choice Ints { - None(); - One(Int); - Two(Int,Int); + None, + One(Int), + Two(Int,Int) } fn main() -> Int { @@ -13,7 +13,7 @@ fn main() -> Int { var auto: y = Ints.One(42); var auto: n = 0; match (y) { - case Ints.None() => + case Ints.None => n = n + 2; case Ints.One(auto: x) => n = x + 1 - 42; diff --git a/executable_semantics/testdata/choice1.golden b/executable_semantics/testdata/choice1.golden index 052a6d3ade66..94e198ca614b 100644 --- a/executable_semantics/testdata/choice1.golden +++ b/executable_semantics/testdata/choice1.golden @@ -9,7 +9,7 @@ var auto: x = Ints.None(); var auto: y = Ints.One(0 = 42); var auto: n = 0; match (y) { -case Ints.None() => +case Ints.None => n = (n + 2); case Ints.One(0 = auto: x) => n = ((x + 1) - 42);