mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user