Exemplo n.º 1
0
        private void Write(PrintStatementNode stmt, bool notlambda = true)
        {
            Fill();
            _code.Append("print");
            //todo print destination

            var addParenthesis = (stmt.Children.Any() && !(stmt.Children.First() is ParenthesisExpressionNode));

            if (addParenthesis)
            {
                _code.Append("(");
            }
            for (var i = 0; i < stmt.Children.Count; i++)
            {
                Write(stmt.Children[i]);
                if (i < stmt.Children.Count - 1)
                {
                    _code.Append(", ");
                }
            }
            if (addParenthesis)
            {
                _code.Append(")");
            }
        }
Exemplo n.º 2
0
        void PrintStatement(ref StatementNode node)
        {
            var psn = new PrintStatementNode(); node = psn;

            Expect(13);
            while (StartOf(5))
            {
                PrintList(psn.items);
            }
        }
Exemplo n.º 3
0
        private static PythonNode Wrap(PrintStatement stmt, PythonNode parent)
        {
            var result = new PrintStatementNode(stmt)
            {
                Parent = parent
            };

            if (stmt.Destination != null)
            {
                result.AddChild(Wrap(stmt.Destination, result));
            }
            stmt.Expressions.ForEach(e => result.AddChild(Wrap(e, result)));
            return(result);
        }