示例#1
0
            internal Print(PrintStatement stmt)
                : this() {
                if (stmt.Destination != null)
                    _dest = Convert(stmt.Destination);

                _values = PythonOps.MakeEmptyList(stmt.Expressions.Count);
                foreach (Compiler.Ast.Expression expr in stmt.Expressions)
                    _values.Add(Convert(expr));

                _nl = !stmt.TrailingComma;
            }
示例#2
0
        //print_stmt: 'print' ( [ expression (',' expression)* [','] ] | '>>' expression [ (',' expression)+ [','] ] )
        private PrintStatement ParsePrintStmt() {
            Eat(TokenKind.KeywordPrint);
            var start = GetStart();
            Expression dest = null;
            PrintStatement ret;

            bool needNonEmptyTestList = false;
            if (MaybeEat(TokenKind.RightShift)) {
                dest = ParseExpression();
                if (MaybeEat(TokenKind.Comma)) {
                    needNonEmptyTestList = true;
                } else {
                    ret = new PrintStatement(dest, new Expression[0], false);
                    ret.SetLoc(_globalParent, start, GetEnd());
                    return ret;
                }
            }

            bool trailingComma;
            List<Expression> l = ParseExpressionList(out trailingComma);
            if (needNonEmptyTestList && l.Count == 0) {
                ReportSyntaxError(_lookahead);
            }
            Expression[] exprs = l.ToArray();
            ret = new PrintStatement(dest, exprs, trailingComma);
            ret.SetLoc(_globalParent, start, GetEnd());
            return ret;
        }
示例#3
0
        public override void PostWalk(PrintStatement node)
        {
            List<string> statements = new List<string>();
            for (int i = 0; i < node.Expressions.Count; i++)
            {
                statements.Add(Content());
            }
            statements.Reverse();

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

            CommonPostWalk(node);
        }
示例#4
0
 public override bool Walk(PrintStatement node)
 {
     node.Parent = _currentScope;
     return base.Walk(node);
 }
 // PrintStatement
 public bool Walk(PrintStatement node)
 {
     return Process(node);
 }
示例#6
0
 public override bool Walk(PrintStatement node)
 {
     CommonWalk(node);
     return true;
 }
示例#7
0
 // PrintStatement
 public override bool Walk(PrintStatement node)
 {
     node.Parent = _currentScope;
     return(base.Walk(node));
 }
 public void PostWalk(PrintStatement node)
 {
     PostProcess(node);
 }
 public override bool Walk(PrintStatement node)
 {
     Emit(node); return false;
 }
 public virtual void PostWalk(PrintStatement node)
 {
 }
 // PrintStatement
 public virtual bool Walk(PrintStatement node)
 {
     return true;
 }
示例#12
0
 public void Visit(PyAst.PrintStatement node) => throw CreateNotImplementedEx();
示例#13
0
		public override bool Walk(PrintStatement node)
		{
			writer.WriteLine("PrintStatement");
			return base.Walk(node);
		}