Inheritance: IronPython.Compiler.Ast.SequenceExpression
Esempio n. 1
0
 public override bool Walk(ListExpression node)
 {
     return(true);
 }
Esempio n. 2
0
            internal List(ListExpression list, expr_context ctx)
                : this() {
                _elts = PythonOps.MakeEmptyList(list.Items.Count);
                foreach (Compiler.Ast.Expression expr in list.Items)
                    _elts.Add(Convert(expr, ctx));

                _ctx = ctx;
            }
Esempio n. 3
0
        // listmaker: expression ( list_for | (',' expression)* [','] )
        private Expression FinishListValue() {
            var oStart = GetStart();
            var oEnd = GetEnd();
            int grouping = _tokenizer.GroupingLevel;

            Expression ret;
            if (MaybeEat(TokenKind.RightBracket)) {
                ret = new ListExpression();
            } else {
                bool prevAllow = _allowIncomplete;
                try {
                    _allowIncomplete = true;
                    Expression t0 = ParseExpression();
                    if (MaybeEat(TokenKind.Comma)) {
                        List<Expression> l = ParseTestList();
                        Eat(TokenKind.RightBracket);
                        l.Insert(0, t0);
                        ret = new ListExpression(l.ToArray());
                    } else if (PeekToken(Tokens.KeywordForToken)) {
                        ret = FinishListComp(t0);
                    } else {
                        Eat(TokenKind.RightBracket);
                        ret = new ListExpression(t0);
                    }
                } finally {
                    _allowIncomplete = prevAllow;
                }
            }

            var cStart = GetStart();
            var cEnd = GetEnd();

            if (_sink != null) {
                _sink.MatchPair(
                    new SourceSpan(_tokenizer.IndexToLocation(oStart), _tokenizer.IndexToLocation(oEnd)), 
                    new SourceSpan(_tokenizer.IndexToLocation(cStart), _tokenizer.IndexToLocation(cEnd)), 
                    grouping
                );
            }

            ret.SetLoc(_globalParent, oStart, cEnd);
            return ret;
        }
Esempio n. 4
0
 public override bool Walk(ListExpression node)
 {
     node.Parent = _currentScope;
     return base.Walk(node);
 }
Esempio n. 5
0
 public override bool Walk(ListExpression node)
 {
     return true;
 }
Esempio n. 6
0
        public override void PostWalk(ListExpression node)
        {
            List<string> items = new List<string>();
            for (int i = 0; i < node.Items.Count; i++)
            {
                items.Add(Content());
            }
            items.Reverse();

            Content("[{0}]", String.Join(", ", items));

            CommonPostWalk(node, true);
        }
Esempio n. 7
0
 // ListExpression
 public override bool Walk(ListExpression node)
 {
     node.Parent = _currentScope;
     return(base.Walk(node));
 }
 // ListExpression
 public bool Walk(ListExpression node)
 {
     return Process(node);
 }
Esempio n. 9
0
 public override bool Walk(ListExpression node)
 {
     CommonWalk(node);
     return true;
 }
Esempio n. 10
0
 public override bool Walk(ListExpression node) => WalkItems(node.Items);
 public void PostWalk(ListExpression node)
 {
     PostProcess(node);
 }
Esempio n. 12
0
 public static string Format(ListExpression node)
 {
     return("[" + node.Items.Format() + "]");
 }
 public virtual void PostWalk(ListExpression node)
 {
 }
 // ListExpression
 public virtual bool Walk(ListExpression node)
 {
     return true;
 }
Esempio n. 15
0
        //        /*
        //        listmaker: test ( list_for | (',' test)* [','] )
        //        */
        private Expression FinishListValue()
        {
            Location oStart = GetStart();
            Location oEnd = GetEnd();
            int grouping = tokenizer.GroupingLevel;

            Expression ret;
            if (MaybeEat(TokenKind.RightBracket)) {
                ret = new ListExpression();
            } else {
                Expression t0 = ParseTest();
                if (MaybeEat(TokenKind.Comma)) {
                    List<Expression> l = ParseTestList();
                    Eat(TokenKind.RightBracket);
                    l.Insert(0, t0);
                    ret = new ListExpression(l.ToArray());
                } else if (PeekToken(Tokens.KeywordForToken)) {
                    ret = FinishListComp(t0);
                } else {
                    Eat(TokenKind.RightBracket);
                    ret = new ListExpression(t0);
                }
            }

            Location cStart = GetStart();
            Location cEnd = GetEnd();

            context.Sink.MatchPair(new CodeSpan(oStart, oEnd), new CodeSpan(cStart, cEnd), grouping);

            ret.SetLoc(GetExternal(), oStart, cEnd);
            return ret;
        }
Esempio n. 16
0
 public string Visit(PyAst.ListExpression node) => $"[{ VisitExpressionsList(node.Items)}]";