Exemplo n.º 1
0
        private Statement ParseReturnStatement()
        {
            var returnKeyword = MatchToken(TokenKind.ReturnKeyword);

            // Cheat
            var keywordLine = source.LineIndexOf(returnKeyword.Location.Span.Start);
            var currentLine = source.LineIndexOf(PeekToken(0).Location.Span.Start);
            var isEoF = Current == TokenKind.EoF;
            var isCloseBrace = Current == TokenKind.CloseBrace;
            var sameLine = keywordLine == currentLine;

            var expression = sameLine && !isEoF && !isCloseBrace ? ParseExpression() : null;

            return new ReturnStatement(syntaxTree, returnKeyword, expression);
        }