예제 #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);
		}