Esempio n. 1
0
        private SeparatedSyntaxList<ParameterSyntax> ParseSeparatedParameters()
        {
            var parameters = ImmutableArray.CreateBuilder<SeparatedSyntaxNode<ParameterSyntax>>();

            var parseNext = true;
            while (parseNext = Current != TokenKind.CloseParenthesis && Current != TokenKind.EoF)
            {
                var parameter = ParseParameterSyntax();

                parseNext = Current == TokenKind.Comma;

                var comma = Current == TokenKind.Comma ? MatchToken(TokenKind.Comma) : null;

                if (parseNext && Current == TokenKind.CloseParenthesis)
                    diagnostics.Syntax.UnexpectedToken(comma, "Unexpected comma");

                var separatedParameter = new SeparatedSyntaxNode<ParameterSyntax>(parameter, comma);
                parameters.Add(separatedParameter);
            }

            return new SeparatedSyntaxList<ParameterSyntax>(parameters.ToImmutable());
        }
Esempio n. 2
0
        private SeparatedSyntaxList<Expression> ParseArguments()
        {
            var expressions = ImmutableArray.CreateBuilder<SeparatedSyntaxNode<Expression>>();

            var parseNext = true;
            while (parseNext && Current != TokenKind.CloseParenthesis && Current != TokenKind.EoF)
            {
                var expression = ParseExpression();

                parseNext = Current == TokenKind.Comma;

                var comma = Current == TokenKind.Comma ? MatchToken(TokenKind.Comma) : null;

                if (parseNext && Current == TokenKind.CloseParenthesis)
                    diagnostics.Syntax.UnexpectedToken(comma, "Unexpected comma");

                var separatedExpression = new SeparatedSyntaxNode<Expression>(expression, comma);
                expressions.Add(separatedExpression);
            }

            return new SeparatedSyntaxList<Expression>(expressions.ToImmutable());
        }