%token ASYNC
%token AWAIT
%token INTERR_OPERATOR
+%token WHEN
+%token INTERPOLATED_STRING
+%token INTERPOLATED_STRING_END
/* C# keywords which are not really keywords */
%token GET
}
| opt_extern_alias_directives opt_using_directives attribute_sections
{
+ Attributes attrs = (Attributes) $3;
+ if (attrs != null) {
+ foreach (var a in attrs.Attrs) {
+ if (a.ExplicitTarget == "assembly" || a.ExplicitTarget == "module")
+ continue;
+
+ if (a.ExplicitTarget == null)
+ report.Error (-1671, a.Location, "Global attributes must have attribute target specified");
+ }
+ }
+
module.AddAttributes ((Attributes) $3, current_namespace);
}
| error
accessor_declarations
{
lexer.PropertyParsing = false;
-
+
if (doc_support)
- current_property.DocComment = ConsumeStoredComment ();
+ current_property.DocComment = ConsumeStoredComment ();
}
CLOSE_BRACE
{
if (type.Type != null && type.Type.Kind == MemberKind.Void)
report.Error (547, GetLocation ($3), "`{0}': property or indexer cannot have void type", property.GetSignatureForError ());
+ if (doc_support)
+ property.DocComment = ConsumeStoredComment ();
+
current_type.AddMember (property);
current_local_parameters = null;
lbag.AppendToMember (current_property, GetLocation ($1), GetLocation ($4));
end_block (GetLocation ($4));
current_local_parameters = null;
+
+ if (doc_support)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
;
}
} else {
if (current_type.Kind == MemberKind.Struct && current_local_parameters.IsEmpty) {
- if (lang_version < LanguageVersion.V_6)
- FeatureIsNotAvailable (GetLocation ($3), "struct parameterless instance constructor");
-
- if ((mods & Modifiers.PUBLIC) == 0) {
- report.Error (8075, c.Location, "`{0}': Structs parameterless instance constructor must be public", c.GetSignatureForError ());
- }
+ report.Error (568, c.Location, "Structs cannot contain explicit parameterless constructors");
}
}
| pointer_member_access
| anonymous_method_expression
| undocumented_expressions
+ | interpolated_string
;
type_name_expression
| FALSE { $$ = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation ($1)); }
;
+interpolated_string
+ : INTERPOLATED_STRING interpolations INTERPOLATED_STRING_END
+ {
+ $$ = new InterpolatedString ((StringLiteral) $1, (List<Expression>) $2, (StringLiteral) $3);
+ }
+ | INTERPOLATED_STRING_END
+ {
+ $$ = new InterpolatedString ((StringLiteral) $1, null, null);
+ }
+ ;
+
+interpolations
+ : interpolation
+ {
+ var list = new List<Expression> ();
+ list.Add ((InterpolatedStringInsert) $1);
+ $$ = list;
+ }
+ | interpolations INTERPOLATED_STRING interpolation
+ {
+ var list = (List<Expression>) $1;
+ list.Add ((StringLiteral) $2);
+ list.Add ((InterpolatedStringInsert) $3);
+ $$ = list;
+ }
+ ;
+
+interpolation
+ : expression
+ {
+ $$ = new InterpolatedStringInsert ((Expression) $1);
+ }
+ | expression COMMA expression
+ {
+ $$ = new InterpolatedStringInsert ((Expression) $1) {
+ Alignment = (Expression)$3
+ };
+ }
+ | expression COLON
+ {
+ lexer.parsing_interpolation_format = true;
+ }
+ LITERAL
+ {
+ lexer.parsing_interpolation_format = false;
+
+ $$ = new InterpolatedStringInsert ((Expression) $1) {
+ Format = (string)$4
+ };
+ }
+ | expression COMMA expression COLON
+ {
+ lexer.parsing_interpolation_format = true;
+ }
+ LITERAL
+ {
+ lexer.parsing_interpolation_format = false;
+
+ $$ = new InterpolatedStringInsert ((Expression) $1) {
+ Alignment = (Expression)$3,
+ Format = (string) $6
+ };
+ }
+ ;
+
//
// Here is the trick, tokenizer may think that parens is a special but
lbag.AddLocation ($$, GetLocation ($3));
}
- | OPEN_BRACKET_EXPR expression_list CLOSE_BRACKET ASSIGN initializer_value
+ | OPEN_BRACKET_EXPR argument_list CLOSE_BRACKET ASSIGN initializer_value
{
if (lang_version < LanguageVersion.V_6)
FeatureIsNotAvailable (GetLocation ($1), "dictionary initializer");
- $$ = new DictionaryElementInitializer ((List<Expression>)$2, (Expression) $5, GetLocation ($1));
+ $$ = new DictionaryElementInitializer ((Arguments)$2, (Expression) $5, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($3), GetLocation ($4));
}
| OPEN_BRACE CLOSE_BRACE
lbag.AddLocation (c, GetLocation ($2), GetLocation ($5));
$$ = c;
+ lexer.parsing_catch_when = true;
}
- opt_catch_filter block_prepared
+ opt_catch_filter_or_error
{
((Catch) $6).Filter = (CatchFilterExpression) $7;
$$ = $6;
$$ = new Catch (null, GetLocation ($1));
}
- | CATCH open_parens_any type opt_identifier CLOSE_PARENS error
+ ;
+
+opt_catch_filter_or_error
+ : opt_catch_filter block_prepared
{
+ $$ = $1;
+ }
+ | error
+ {
+ end_block (Location.Null);
Error_SyntaxError (yyToken);
-
- // Required otherwise missing block could not be detected because
- // start_block is run early
- var c = new Catch (null, GetLocation ($1));
- c.TypeExpression = (FullNamedExpression) $3;
-
- if ($4 != null) {
- var lt = (LocatedToken) $4;
- c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
- }
-
- lbag.AddLocation (c, GetLocation ($2), GetLocation ($5));
-
- $$ = c;
+ $$ = null;
}
;
opt_catch_filter
- : /* empty */
- | IF open_parens_any expression CLOSE_PARENS
+ : {
+ lexer.parsing_catch_when = false;
+ }
+ | WHEN
+ {
+ lexer.parsing_catch_when = false;
+ }
+ open_parens_any expression CLOSE_PARENS
{
if (lang_version <= LanguageVersion.V_5)
FeatureIsNotAvailable (GetLocation ($1), "exception filter");
- $$ = new CatchFilterExpression ((Expression) $3, GetLocation ($1));
- lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
+ $$ = new CatchFilterExpression ((Expression) $4, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3), GetLocation ($5));
}
;
return ";";
case Token.TILDE:
return "~";
-
+ case Token.WHEN:
+ return "when";
+ case Token.INTERPOLATED_STRING_END:
+ return "}";
+ case Token.INTERPOLATED_STRING:
+ return "${";
+
case Token.PLUS:
case Token.UMINUS:
case Token.MINUS: