-// CS1525: Unexpected symbol `public', expecting `:', `;', or `{'
+// CS1525: Unexpected symbol `public', expecting `:', `;', `{', or `=>'
// Line: 5
class TorrentEditor {
// Was added earlier in the case of body being eof for full ast
}
- method_body_expression_block
+ method_body
{
Method method = (Method) $1;
method.Block = (ToplevelBlock) $3;
}
;
-method_body_expression_block
- : method_body
- | expression_block
- ;
-
method_body
: block
+ | expression_block
| SEMICOLON { $$ = null; }
;
+destructor_body
+ : method_body
+ ;
+
+constructor_body
+ : block_prepared
+ | SEMICOLON { current_block = null; $$ = null; }
+ | ARROW
+ {
+ if (lang_version < LanguageVersion.V_7) {
+ FeatureIsNotAvailable (GetLocation ($1), "expression body constructor");
+ }
+
+ ++lexer.parsing_block;
+ }
+ expression SEMICOLON
+ {
+ lexer.parsing_block = 0;
+ current_block.AddStatement (new ContextualReturn ((Expression) $3));
+ var b = end_block (GetLocation ($4));
+ b.IsCompilerGenerated = true;
+ $$ = b;
+ current_block = null;
+ }
+ ;
+
expression_block
: ARROW
{
: opt_attributes opt_modifiers operator_declarator
{
}
- method_body_expression_block
+ method_body
{
OperatorDeclaration decl = (OperatorDeclaration) $3;
if (decl != null) {
}
;
-constructor_body
- : block_prepared
- | SEMICOLON { current_block = null; $$ = null; }
- ;
-
opt_constructor_initializer
: /* Empty */
| constructor_initializer
current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
}
- IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body
+ IDENTIFIER OPEN_PARENS CLOSE_PARENS destructor_body
{
var lt = (LocatedToken) $5;
if (lt.Value != current_container.MemberName.Name){
</method>
</type>
</test>
+ <test name="test-expression-bodied-04.cs">
+ <type name="VV">
+ <method name="Void Finalize()" attrs="196">
+ <size>19</size>
+ </method>
+ <method name="Void Test()" attrs="129">
+ <size>2</size>
+ </method>
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6273">
+ <size>13</size>
+ </method>
+ </type>
+ </test>
<test name="test-externalias-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">