|
|
@@ -104,6 +104,7 @@ void yy::parser::error(
|
|
|
%type <const Carbon::Expression*> return_type
|
|
|
%type <const Carbon::Expression*> paren_expression
|
|
|
%type <const Carbon::Expression*> tuple
|
|
|
+%type <std::optional<std::string>> binding_lhs
|
|
|
%type <Carbon::Member*> variable_declaration
|
|
|
%type <Carbon::Member*> member
|
|
|
%type <std::list<Carbon::Member*>> member_list
|
|
|
@@ -146,6 +147,7 @@ void yy::parser::error(
|
|
|
%token DBLARROW "=>"
|
|
|
%token DEFAULT
|
|
|
%token AUTO
|
|
|
+%token UNDERSCORE
|
|
|
%token
|
|
|
EQUAL "="
|
|
|
MINUS "-"
|
|
|
@@ -199,6 +201,10 @@ pattern:
|
|
|
expression
|
|
|
{ $$ = $1; }
|
|
|
;
|
|
|
+binding_lhs:
|
|
|
+ identifier { $$ = $1; }
|
|
|
+| UNDERSCORE { $$ = std::nullopt; }
|
|
|
+;
|
|
|
expression:
|
|
|
identifier
|
|
|
{ $$ = Carbon::Expression::MakeIdentifierExpression(yylineno, $1); }
|
|
|
@@ -206,7 +212,7 @@ expression:
|
|
|
{ $$ = Carbon::Expression::MakeFieldAccessExpression(yylineno, $1, $2); }
|
|
|
| expression "[" expression "]"
|
|
|
{ $$ = Carbon::Expression::MakeIndexExpression(yylineno, $1, $3); }
|
|
|
-| identifier ":" expression
|
|
|
+| binding_lhs ":" expression
|
|
|
{
|
|
|
$$ = Carbon::Expression::MakeBindingExpression(yylineno, $1, $3);
|
|
|
}
|