コード例 #1
0
ファイル: Parser.cs プロジェクト: techarch/ironruby
        // list_for: 'for' target_list 'in' old_expression_list [list_iter]
        private ListComprehensionFor ParseListCompFor() {
            Eat(TokenKind.KeywordFor);
            SourceLocation start = GetStart();
            bool trailingComma;
            List<Expression> l = ParseTargetList(out trailingComma);

            // 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, trailingComma);
            Eat(TokenKind.KeywordIn);

            Expression list = null;
            list = ParseOldExpressionListAsExpr();

            ListComprehensionFor ret = new ListComprehensionFor(lhs, list);

            ret.SetLoc(start, GetEnd());
            return ret;
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: FabioNascimento/DICommander
        // list_for: 'for' exprlist 'in' testlist_safe [list_iter]
        private ListComprehensionFor ParseListCompFor()
        {
            Eat(TokenKind.KeywordFor);
            Location start = GetStart();
            List<Expression> l = ParseExprList();

            // 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, false);
            Eat(TokenKind.KeywordIn);

            Expression list = null;
            if (Options.Python25 == true) {
                list = ParseTestListAsSafeExpr();
            } else {
                list = ParseTestListAsExpr(false);
            }

            ListComprehensionFor ret = new ListComprehensionFor(lhs, list);

            ret.SetLoc(GetExternal(), start, GetEnd());
            return ret;
        }