|
|
@@ -130,6 +130,8 @@
|
|
|
%type <Nonnull<Expression*>> additive_operand
|
|
|
%type <Nonnull<Expression*>> additive_lhs
|
|
|
%type <Nonnull<Expression*>> additive_expression
|
|
|
+%type <Nonnull<Expression*>> as_operand
|
|
|
+%type <Nonnull<Expression*>> as_expression
|
|
|
%type <Nonnull<Expression*>> unimpl_expression
|
|
|
%type <Nonnull<Expression*>> value_expression
|
|
|
%type <Nonnull<Expression*>> comparison_operand
|
|
|
@@ -144,6 +146,7 @@
|
|
|
%type <Nonnull<WhereClause*>> where_clause
|
|
|
%type <std::vector<Nonnull<WhereClause*>>> where_clause_list
|
|
|
%type <Nonnull<Expression*>> where_expression
|
|
|
+%type <Nonnull<Expression*>> type_or_where_expression
|
|
|
%type <Nonnull<Expression*>> statement_expression
|
|
|
%type <Nonnull<Expression*>> if_expression
|
|
|
%type <Nonnull<Expression*>> expression
|
|
|
@@ -466,6 +469,18 @@ additive_expression:
|
|
|
std::vector<Nonnull<Expression*>>({$1, $3}));
|
|
|
}
|
|
|
;
|
|
|
+as_operand:
|
|
|
+ minus_expression
|
|
|
+| ref_deref_expression
|
|
|
+;
|
|
|
+as_expression:
|
|
|
+ as_operand AS as_operand
|
|
|
+ {
|
|
|
+ $$ = arena->New<PrimitiveOperatorExpression>(
|
|
|
+ context.source_loc(), Operator::As,
|
|
|
+ std::vector<Nonnull<Expression*>>{$1, $3});
|
|
|
+ }
|
|
|
+;
|
|
|
unimpl_expression:
|
|
|
// ref_deref_expression excluded due to precedence diamond.
|
|
|
ref_deref_expression UNIMPL_EXAMPLE ref_deref_expression
|
|
|
@@ -477,6 +492,7 @@ unimpl_expression:
|
|
|
value_expression:
|
|
|
// ref_deref_expression excluded due to precedence diamond.
|
|
|
additive_expression
|
|
|
+| as_expression
|
|
|
| combine_expression
|
|
|
| fn_type_expression
|
|
|
| unimpl_expression
|
|
|
@@ -560,6 +576,10 @@ where_expression:
|
|
|
$$ = arena->New<WhereExpression>(context.source_loc(), self, $3);
|
|
|
}
|
|
|
;
|
|
|
+type_or_where_expression:
|
|
|
+ type_expression
|
|
|
+| where_expression
|
|
|
+;
|
|
|
statement_expression:
|
|
|
ref_deref_expression
|
|
|
| predicate_expression
|
|
|
@@ -998,7 +1018,7 @@ declaration:
|
|
|
$$ = arena->New<InterfaceDeclaration>(context.source_loc(), $2, $3, self,
|
|
|
$5);
|
|
|
}
|
|
|
-| impl_kind IMPL impl_deduced_params impl_type AS expression LEFT_CURLY_BRACE impl_body RIGHT_CURLY_BRACE
|
|
|
+| impl_kind IMPL impl_deduced_params impl_type AS type_or_where_expression LEFT_CURLY_BRACE impl_body RIGHT_CURLY_BRACE
|
|
|
{
|
|
|
ErrorOr<ImplDeclaration*> impl = ImplDeclaration::Create(
|
|
|
arena, context.source_loc(), $1, $4, $6, $3, $8);
|
|
|
@@ -1021,7 +1041,7 @@ impl_kind:
|
|
|
impl_type:
|
|
|
// Self
|
|
|
{ $$ = arena->New<IdentifierExpression>(context.source_loc(), "Self"); }
|
|
|
-| expression
|
|
|
+| type_expression
|
|
|
;
|
|
|
declaration_list:
|
|
|
// Empty
|