Update executable semantics for choice to match final state of p0157 (#304)

* Make parentheses optional for alternatives with no arguments.

* Use `,` instead of `;` as separator for alternatives, and make the trailing separator optional.
This commit is contained in:
Geoff Romer
2021-02-26 13:12:09 -08:00
committed by GitHub
parent 29a59944fa
commit 853360345e
3 changed files with 20 additions and 8 deletions
+15 -3
View File
@@ -289,14 +289,26 @@ member_list:
{ $$ = $2; $$->push_front($1); }
;
alternative:
identifier tuple ';'
identifier tuple
{ $$ = new std::pair<std::string, Carbon::Expression*>($1, $2); }
| identifier
{
$$ = new std::pair<std::string, Carbon::Expression*>(
$1, Carbon::MakeTuple(
yylineno,
new std::vector<std::pair<std::string, Carbon::Expression*>>()));
}
;
alternative_list:
// Empty
{ $$ = new std::list<std::pair<std::string, Carbon::Expression*>>(); }
| alternative alternative_list
{ $$ = $2; $$->push_front(*$1); }
| alternative
{
$$ = new std::list<std::pair<std::string, Carbon::Expression*>>();
$$->push_front(*$1);
}
| alternative ',' alternative_list
{ $$ = $3; $$->push_front(*$1); }
;
declaration:
function_definition