private ArgumentSyntax ParseArgumentExpression(bool isIndexer)
        {
            NameColonSyntax nameColon = null;

            if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.ColonToken)
            {
                var name  = this.ParseIdentifierName();
                var colon = this.EatToken(SyntaxKind.ColonToken);
                nameColon = _syntaxFactory.NameColon(name, colon);
                nameColon = CheckFeatureAvailability(nameColon, MessageID.IDS_FeatureNamedArgument);
            }

            SyntaxToken refOrOutKeyword = null;


            ExpressionSyntax expression;

            if (isIndexer && (this.CurrentToken.Kind == SyntaxKind.CommaToken || this.CurrentToken.Kind == SyntaxKind.CloseBracketToken))
            {
                expression = this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_ValueExpected);
            }
            else if (this.CurrentToken.Kind == SyntaxKind.CommaToken)
            {
                expression = this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_MissingArgument);
            }
            else
            {
                expression = this.ParseSubExpression(0, contextRequiresVariable: refOrOutKeyword != null);
            }

            return(_syntaxFactory.Argument(nameColon, expression));
        }
        private SubpatternSyntax ParseSubpatternElement()
        {
            NameColonSyntax nameColon = null;

            if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.ColonToken)
            {
                var name  = this.ParseIdentifierName();
                var colon = this.EatToken(SyntaxKind.ColonToken);
                nameColon = _syntaxFactory.NameColon(name, colon);
            }

            var pattern = ParsePattern(Precedence.Conditional);

            return(this._syntaxFactory.Subpattern(nameColon, pattern));
        }
        private AnnotationArgumentSyntax ParseAnnotationArgument(ref bool shouldHaveName)
        {
            // Need to parse both "real" named arguments and _annotation-style named arguments.
            // We track _annotation-style named arguments only with fShouldHaveName.

            NameEqualsSyntax nameEquals = null;
            NameColonSyntax  nameColon  = null;

            if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken)
            {
                SyntaxKind nextTokenKind = this.PeekToken(1).Kind;
                switch (nextTokenKind)
                {
                case SyntaxKind.EqualsToken:
                {
                    var name   = this.ParseIdentifierToken();
                    var equals = this.EatToken(SyntaxKind.EqualsToken);
                    nameEquals     = _syntaxFactory.NameEquals(_syntaxFactory.IdentifierName(name), equals);
                    shouldHaveName = true;
                }

                break;

                case SyntaxKind.ColonToken:
                {
                    var name       = this.ParseIdentifierName();
                    var colonToken = this.EatToken(SyntaxKind.ColonToken);
                    nameColon = _syntaxFactory.NameColon(name, colonToken);
                    nameColon = CheckFeatureAvailability(nameColon, MessageID.IDS_FeatureNamedArgument);
                }

                break;
                }
            }

            var expr = this.ParseExpression();

            // Not named -- give an error if it's supposed to be
            if (shouldHaveName && nameEquals == null)
            {
                expr = this.AddError(expr, ErrorCode.ERR_NamedArgumentExpected);
            }

            return(_syntaxFactory.AnnotationArgument(nameEquals, nameColon, expr));
        }