public virtual Expression VisitComprehension(Comprehension comprehension) { if (comprehension == null) return null; comprehension.BindingsAndFilters = this.VisitExpressionList(comprehension.BindingsAndFilters); comprehension.Elements = this.VisitExpressionList(comprehension.Elements); return comprehension; }
public override Expression VisitComprehension(Comprehension Comprehension) { if (Comprehension == null) return null; return base.VisitComprehension((Comprehension)Comprehension.Clone()); }
public Quantifier(NodeType t, Comprehension comprehension) : base(NodeType.Quantifier) { this.QuantifierType = t; this.Comprehension = comprehension; }
private Comprehension ParseComprehension(TokenSet followers, SourceContext sctx){ bool isDisplay = true; ExpressionList bindingAndFilterList = new ExpressionList(); ExpressionList elementList = new ExpressionList(); Expression e = null; if (this.currentToken != Token.RightBrace){ e = this.ParseIteratorOrExpression(followers|Token.RightBrace|Token.Semicolon|Token.Comma); if (e == null){ this.HandleError(sctx, Error.SyntaxError,"iterator or expression"); return null; }else{ bindingAndFilterList.Add(e); } isDisplay = !(e is ComprehensionBinding); while (this.currentToken == Token.Comma){ this.GetNextToken(); e = this.ParseIteratorOrExpression(followers|Token.RightBrace|Token.Semicolon|Token.Comma); if (e == null){ this.HandleError(sctx, Error.SyntaxError,"iterator or expression"); return null; } else { bindingAndFilterList.Add(e); } if (isDisplay) isDisplay = !(e is ComprehensionBinding); } if (!isDisplay) { if (this.currentToken != Token.Semicolon) { this.SkipTo(followers, Error.InvalidExprTerm, this.scanner.GetTokenSource()); } else { this.GetNextToken(); Expression temp = this.ParseExpression(followers | Token.RightBrace | Token.Semicolon); if (temp != null) elementList.Add(temp); if (this.currentToken == Token.Semicolon) { this.GetNextToken(); this.Skip(Token.Default); temp = this.ParseExpression(followers | Token.RightBrace); if (temp != null) elementList.Add(temp); } } } } sctx.EndPos = this.scanner.endPos; this.Skip(Token.RightBrace); if (isDisplay){ // display, what we thought were bindings/filters are actually all elements elementList = bindingAndFilterList; bindingAndFilterList = null; } Comprehension comp = new Comprehension(); if (bindingAndFilterList != null && bindingAndFilterList.Count > 0) comp.BindingsAndFilters = bindingAndFilterList; comp.Elements = elementList; this.sawReturnOrYield = true; comp.SourceContext = sctx; comp.SourceContext.EndPos = this.scanner.CurrentSourceContext.StartPos; this.SkipTo(followers); return comp; }
public EventingVisitor(Action<Comprehension> visitComprehension) { VisitedComprehension += visitComprehension; } public event Action<Comprehension> VisitedComprehension; public override Expression VisitComprehension(Comprehension comprehension) { if (VisitedComprehension != null) VisitedComprehension(comprehension); return base.VisitComprehension(comprehension); }