+pattern_type_expr
+ : variable_type
+ ;
+
+pattern_expr
+ : literal
+ | PLUS prefixed_unary_expression
+ {
+ $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $2, GetLocation ($1));
+ }
+ | MINUS prefixed_unary_expression
+ {
+ $$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $2, GetLocation ($1));
+ }
+ | sizeof_expression
+ | default_value_expression
+ | OPEN_PARENS_CAST type CLOSE_PARENS prefixed_unary_expression
+ {
+ $$ = new Cast ((FullNamedExpression) $2, (Expression) $4, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3));
+ }
+ | STAR
+ {
+ $$ = new WildcardPattern (GetLocation ($1));
+ }
+ | pattern_expr_invocation
+ | pattern_property
+ ;
+
+pattern_expr_invocation
+ : type_name_expression OPEN_PARENS opt_pattern_list CLOSE_PARENS
+ {
+ $$ = new RecursivePattern ((ATypeNameExpression) $1, (Arguments) $3, GetLocation ($2));
+ }
+ ;
+
+pattern_property
+ : type_name_expression OPEN_BRACE pattern_property_list CLOSE_BRACE
+ {
+ $$ = new PropertyPattern ((ATypeNameExpression) $1, (List<PropertyPatternMember>) $3, GetLocation ($2));
+ }
+ ;
+
+pattern_property_list
+ : pattern_property_entry
+ {
+ var list = new List<PropertyPatternMember> ();
+ list.Add ((PropertyPatternMember) $1);
+ $$ = list;
+ }
+ | pattern_property_list COMMA pattern_property_entry
+ {
+ var list = (List<PropertyPatternMember>) $1;
+ list.Add ((PropertyPatternMember) $3);
+ $$ = list;
+ }
+ ;
+
+pattern_property_entry
+ : identifier_inside_body IS pattern
+ {
+ var lt = (LocatedToken) $1;
+ $$ = new PropertyPatternMember (lt.Value, (Expression) $3, lt.Location);
+ }
+ ;
+
+pattern
+ : pattern_expr
+ | pattern_type_expr opt_identifier
+ {
+ if ($2 != null) {
+ var lt = (LocatedToken) $2;
+ var variable = new LocalVariable (current_block, lt.Value, lt.Location);
+ current_block.AddLocalName (variable);
+ }
+ }
+ ;
+
+opt_pattern_list
+ : /* empty */
+ {
+ $$ = new Arguments (0);
+ }
+ | pattern_list
+ ;
+
+pattern_list
+ : pattern_argument
+ {
+ Arguments args = new Arguments (4);
+ args.Add ((Argument) $1);
+ $$ = args;
+ }
+ | pattern_list COMMA pattern_argument
+ {
+ Arguments args = (Arguments) $1;
+ if (args [args.Count - 1] is NamedArgument && !($3 is NamedArgument))
+ Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]);
+
+ args.Add ((Argument) $3);
+ $$ = args;
+ }
+ ;
+
+pattern_argument
+ : pattern
+ {
+ $$ = new Argument ((Expression) $1);
+ }
+ | IDENTIFIER COLON pattern
+ {
+ var lt = (LocatedToken) $1;
+ $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $3);
+ }
+ ;
+