Exemplo n.º 1
0
        // Private Methods 

        private static string Collect(PySourceCodeEmiter emiter, PyEmitStyle style, IPyStatement[] collection)
        {
            var list   = new List <string>();
            var xStyle = PyEmitStyle.xClone(style);

            xStyle.AsIncrementor = true;
            foreach (var item in collection)
            {
                var writer = new PySourceCodeWriter();
                writer.Clear();
                item.Emit(emiter, writer, xStyle);
                list.Add(writer.GetCode().Trim());
            }

            return(string.Join(", ", list));
        }
Exemplo n.º 2
0
        public string GetPyCode(PyEmitStyle style)
        {
            /*
             * echo preg_replace_callback('~-([a-z])~', function ($match) {
             * return strtoupper($match[1]);
             * }, 'hello-world');
             * // outputs helloWorld
             */
            var s = PyEmitStyle.xClone(style);

            s.AsIncrementor = true;
            var e   = new PySourceCodeEmiter();
            var wde = new PySourceCodeWriter();

            wde.Clear();
            MethodDefinition.Emit(e, wde, s);
            var code = wde.GetCode().Trim();

            return(code);
        }