Example #1
0
        /// <summary>
        /// Initializes the contents of the statement.
        /// </summary>
        private void Initialize()
        {
            OpenParenthesisToken openParen = this.FindFirstChild <OpenParenthesisToken>();

            if (openParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.condition.Value = openParen.FindNextSiblingExpression();
            if (this.condition.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            CloseParenthesisToken closeParen = this.condition.Value.FindNextSibling <CloseParenthesisToken>();

            if (closeParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.body.Value = closeParen.FindNextSiblingStatement();
            if (this.body.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes the contents of the statement.
        /// </summary>
        private void Initialize()
        {
            OpenParenthesisToken openParen = this.FindFirstChild <OpenParenthesisToken>();

            if (openParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.initializers.Value = this.FindInitializers(openParen);
            if (this.initializers.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            SemicolonToken semicolon = openParen.FindNextSibling <SemicolonToken>();

            if (semicolon == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.condition.Value = this.FindCondition(semicolon);

            semicolon = semicolon.FindNextSibling <SemicolonToken>();
            if (semicolon == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.iterators.Value = this.FindIterators(semicolon);
            if (this.iterators.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            CloseParenthesisToken closeParen = semicolon.FindNextSibling <CloseParenthesisToken>();

            if (closeParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.body.Value = closeParen.FindNextSiblingStatement();
            if (this.body.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }
        }
Example #3
0
        /// <summary>
        /// Initializes the contents of the statement.
        /// </summary>
        private void Initialize()
        {
            OpenParenthesisToken openParen = this.FindFirstChild <OpenParenthesisToken>();

            if (openParen == null)
            {
                this.condition.Value = null;
                this.body.Value      = this.FindFirstChildStatement();
            }
            else
            {
                this.condition.Value = openParen.FindNextSiblingExpression();
                if (this.condition.Value == null)
                {
                    throw new SyntaxException(this.Document, this.LineNumber);
                }

                CloseParenthesisToken closeParen = this.condition.Value.FindNextSibling <CloseParenthesisToken>();
                if (closeParen == null)
                {
                    throw new SyntaxException(this.Document, this.LineNumber);
                }

                this.body.Value = closeParen.FindNextSiblingStatement();
            }

            if (this.body.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            // Look for another attached else statement.
            this.elseStatement.Value = null;

            for (CodeUnit c = this.FindNextSibling(); c != null; c = c.FindNext())
            {
                if (c.Is(StatementType.Else))
                {
                    this.elseStatement.Value = (ElseStatement)c;
                }
                else if (!c.Is(CodeUnitType.LexicalElement) || c.Is(LexicalElementType.Token))
                {
                    break;
                }
            }
        }
Example #4
0
        /// <summary>
        /// Initializes the contents of the statement.
        /// </summary>
        private void Initialize()
        {
            OpenParenthesisToken openParen = this.FindFirstChild <OpenParenthesisToken>();

            if (openParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.iterationVariable.Value = openParen.FindNextSibling <VariableDeclarationExpression>();
            if (this.iterationVariable.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            InToken @in = openParen.FindNextSibling <InToken>();

            if (@in == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.collection.Value = @in.FindNextSiblingExpression();
            if (this.collection.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            CloseParenthesisToken closeParen = this.collection.Value.FindNextSibling <CloseParenthesisToken>();

            if (closeParen == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }

            this.body.Value = closeParen.FindNextSiblingStatement();
            if (this.body.Value == null)
            {
                throw new SyntaxException(this.Document, this.LineNumber);
            }
        }