Beispiel #1
0
        /// <summary>
        /// Visits the syntax node.
        /// </summary>
        /// <param name="node">Node</param>
        /// <param name="iterate">Iterate</param>
        internal void Visit(PPayloadSendExpressionNode node)
        {
            if (base.TokenStream.Peek().Type == TokenType.LeftParenthesis)
            {
                new PayloadTupleVisitor(base.TokenStream).Visit(node);

                base.TokenStream.Index++;
                base.TokenStream.SkipWhiteSpaceAndCommentTokens();
            }
            else
            {
                node.StmtTokens.Add(base.TokenStream.Peek());

                base.TokenStream.Index++;
                base.TokenStream.SkipWhiteSpaceAndCommentTokens();

                if (base.TokenStream.Peek().Type == TokenType.LeftSquareBracket)
                {
                    new PayloadCollectionVisitor(base.TokenStream).Visit(node);

                    base.TokenStream.Index++;
                    base.TokenStream.SkipWhiteSpaceAndCommentTokens();
                }
            }
        }
        /// <summary>
        /// Visits the syntax node.
        /// </summary>
        /// <param name="node">Node</param>
        internal void Visit(PPayloadSendExpressionNode node)
        {
            node.StmtTokens.Add(base.TokenStream.Peek());

            base.TokenStream.Index++;
            base.TokenStream.SkipWhiteSpaceAndCommentTokens();

            bool expectsComma = false;
            while (!base.TokenStream.Done &&
                base.TokenStream.Peek().Type != TokenType.RightParenthesis)
            {
                if ((!expectsComma &&
                    base.TokenStream.Peek().Type != TokenType.This &&
                    base.TokenStream.Peek().Type != TokenType.Identifier &&
                    base.TokenStream.Peek().Type != TokenType.True &&
                    base.TokenStream.Peek().Type != TokenType.False &&
                    base.TokenStream.Peek().Type != TokenType.Null &&
                    base.TokenStream.Peek().Type != TokenType.LeftParenthesis) ||
                    (expectsComma && base.TokenStream.Peek().Type != TokenType.Comma))
                {
                    break;
                }

                if (base.TokenStream.Peek().Type == TokenType.This ||
                    base.TokenStream.Peek().Type == TokenType.Identifier ||
                    base.TokenStream.Peek().Type == TokenType.True ||
                    base.TokenStream.Peek().Type == TokenType.False ||
                    base.TokenStream.Peek().Type == TokenType.Null ||
                    base.TokenStream.Peek().Type == TokenType.LeftParenthesis)
                {
                    new PayloadVisitor(base.TokenStream).Visit(node);
                    expectsComma = true;
                }
                else if (base.TokenStream.Peek().Type == TokenType.Comma)
                {
                    node.StmtTokens.Add(base.TokenStream.Peek());

                    base.TokenStream.Index++;
                    base.TokenStream.SkipWhiteSpaceAndCommentTokens();
                    expectsComma = false;
                }
            }

            if (base.TokenStream.Done ||
                base.TokenStream.Peek().Type != TokenType.RightParenthesis)
            {
                throw new ParsingException("Expected \")\".",
                    new List<TokenType>
                {
                    TokenType.RightParenthesis
                });
            }

            node.StmtTokens.Add(base.TokenStream.Peek());
        }