Beispiel #1
0
 public override bool Walk(ComprehensionFor node) {
     if (node.Left != null) {
         node.Left.Walk(Define);
     }            
     if (node.List != null) {
         node.List.Walk(this);
     }
     return false;
 }
 public override bool Walk(ComprehensionFor node) {
     if (!IsActualExpression(node.Left) || HasCaret(node.Left)) {
         CanComplete = false;
         CommitByDefault = false;
     } else if (IsActualExpression(node.List)) {
         CanComplete = true;
         CommitByDefault = true;
         node.List.Walk(this);
     }
     return false;
 }
Beispiel #3
0
        // list_for: 'for' target_list 'in' old_expression_list [list_iter]
        private ComprehensionFor ParseListCompFor() {
            Eat(TokenKind.KeywordFor);
            string startWhiteSpace = _tokenWhiteSpace;
            var start = GetStart();
            bool trailingComma;
            List<string> listWhiteSpace;
            List<Expression> l = ParseExpressionList(out trailingComma, out listWhiteSpace);

            // expr list is something like:
            //  ()
            //  a
            //  a,b
            //  a,b,c
            // we either want just () or a or we want (a,b) and (a,b,c)
            // so we can do tupleExpr.EmitSet() or loneExpr.EmitSet()

            Expression lhs = MakeTupleOrExpr(l, listWhiteSpace, trailingComma, true);
            bool ateIn = Eat(TokenKind.KeywordIn);
            string inWhiteSpace;
            Expression list;

            if (ateIn) {
                inWhiteSpace = _tokenWhiteSpace;
                if (_langVersion.Is3x()) {
                    list = ParseOrTest();
                } else {
                    list = ParseOldExpressionListAsExpr();
                }
            } else {
                inWhiteSpace = null;
                list = Error("");
            }

            ComprehensionFor ret = new ComprehensionFor(lhs, list);
            if (_verbatim) {
                AddPreceedingWhiteSpace(ret, startWhiteSpace);
                if (inWhiteSpace != null) {
                    AddSecondPreceedingWhiteSpace(ret, inWhiteSpace);
                }
                if (!ateIn) {
                    AddErrorIsIncompleteNode(ret);
                }
            }

            ret.SetLoc(start, GetEnd());
            return ret;
        }
 public override bool Walk(ComprehensionFor node) {
     AddParameter(node.Left);
     return base.Walk(node);
 }
Beispiel #5
0
 // ListComprehensionFor
 public override bool Walk(ComprehensionFor node) {
     node.Left.Walk(_define);
     return true;
 }
Beispiel #6
0
 public override bool Walk(ComprehensionFor node) {
     return UpdateLineInfo(node, true);
 }
Beispiel #7
0
 public override void PostWalk(ComprehensionFor node) { PostWalkWorker(node); }
Beispiel #8
0
 // ComprehensionFor
 public override bool Walk(ComprehensionFor node) { return ShouldWalkWorker(node); }
Beispiel #9
0
 // ListComprehensionFor
 public override bool Walk(ComprehensionFor node)
 {
     node.Left.Walk(_define);
     return(true);
 }