/// <summary>
        /// Gets a query continuation clause.
        /// </summary>
        /// <param name="parentReference">The parent code unit.</param>
        /// <param name="unsafeCode">Indicates whether the code being parsed resides 
        /// in an unsafe code block.</param>
        /// <returns>Returns the query continuation clause.</returns>
        private QueryContinuationClause GetQueryContinuationClause(Reference<ICodePart> parentReference, bool unsafeCode)
        {
            Param.AssertNotNull(parentReference, "parentReference");
            Param.Ignore(unsafeCode);

            // Get and add the 'into' symbol.
            Symbol symbol = this.GetNextSymbol(SymbolType.Other, parentReference);
            Debug.Assert(symbol.Text == "into", "Expected an into keyword");

            var clauseReference = new Reference<ICodePart>();

            Node<CsToken> firstTokenNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Into, SymbolType.Other, clauseReference));

            // Get the identifier.
            Variable rangeVariable = this.GetVariable(clauseReference, unsafeCode, true, true);
            if (rangeVariable == null)
            {
                throw this.CreateSyntaxException();
            }

            // Get the continuation clauses.
            List<QueryClause> clauses = new List<QueryClause>();

            // The variables defined by the clauses under this continuation clause.
            List<Variable> variables = new List<Variable>();

            // Extract the clauses.
            CsTokenList continuationClauseTokens = this.GetQueryExpressionClauses(clauseReference, unsafeCode, clauses, variables);
            if (clauses.Count == 0 || continuationClauseTokens.First == null)
            {
                throw this.CreateSyntaxException();
            }

            // Create and return the clause.
            QueryContinuationClause continuationClause = new QueryContinuationClause(
                new CsTokenList(this.tokens, firstTokenNode, continuationClauseTokens.Last),
                rangeVariable,
                clauses.ToArray());

            clauseReference.Target = continuationClause;
            continuationClause.Variables.AddRange(variables);

            return continuationClause;
        }
Beispiel #2
0
 private QueryContinuationClause GetQueryContinuationClause(bool unsafeCode)
 {
     this.GetNextSymbol(SymbolType.Other);
     Microsoft.StyleCop.Node<CsToken> firstItemNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Into, SymbolType.Other));
     Variable variable = this.GetVariable(unsafeCode, true, true);
     if (variable == null)
     {
         throw this.CreateSyntaxException();
     }
     List<QueryClause> clauses = new List<QueryClause>();
     List<Variable> variables = new List<Variable>();
     CsTokenList list3 = this.GetQueryExpressionClauses(unsafeCode, clauses, variables);
     if ((clauses.Count == 0) || (list3.First == null))
     {
         throw this.CreateSyntaxException();
     }
     QueryContinuationClause clause = new QueryContinuationClause(new CsTokenList(this.tokens, firstItemNode, list3.Last), variable, clauses.ToArray());
     clause.Variables.AddRange(variables);
     return clause;
 }