X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fcs-parser.jay;h=153a6bc7bdba4d8cc56dca48f8c9396ed3e00df3;hb=51b93b6c23229e18f9e99db621ea3d733cee9f9d;hp=91e6a23b1406f17bcc0ff188c1161ba949f1a98d;hpb=ed9fb93c62f03eb9ffde370edffafa8779e69ec1;p=mono.git diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 91e6a23b140..153a6bc7bdb 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -219,7 +219,7 @@ namespace Mono.CSharp %token STRUCT %token SWITCH %token THIS -%token THROW +%token THROW %token TRUE %token TRY %token TYPEOF @@ -261,6 +261,7 @@ namespace Mono.CSharp %token WHEN %token INTERPOLATED_STRING %token INTERPOLATED_STRING_END +%token THROW_EXPR /* C# keywords which are not really keywords */ %token GET @@ -4310,6 +4311,13 @@ unary_expression $$ = new Await ((Expression) $2, GetLocation ($1)); } + | THROW_EXPR prefixed_unary_expression + { + if (lang_version < LanguageVersion.V_7) + FeatureIsNotAvailable (lexer.Location, "throw expression"); + + $$ = new ThrowExpression ((Expression) $2, GetLocation ($1)); + } | BANG error { Error_SyntaxError (yyToken); @@ -6366,11 +6374,16 @@ return_statement ; throw_statement - : THROW opt_expression SEMICOLON + : THROW expression SEMICOLON { $$ = new Throw ((Expression) $2, GetLocation ($1)); lbag.AddStatement ($$, GetLocation ($3)); } + | THROW SEMICOLON + { + $$ = new Throw (null, GetLocation ($1)); + lbag.AddStatement ($$, GetLocation ($2)); + } | THROW expression error { Error_SyntaxError (yyToken); @@ -8081,6 +8094,7 @@ static string GetTokenName (int token) case Token.THIS: return "this"; case Token.THROW: + case Token.THROW_EXPR: return "throw"; case Token.TRUE: return "true";