Exemplo n.º 1
0
        public static string Write(object One, ref LswPython.PythonPositions PythonPosition)
        {
            string Return = "if ";
            LsIf   Two    = (LsIf)One;

            Return += new PythonControler().Out(new LsBaseList()
            {
                Bases = new List <lsBase>()
                {
                    Two.Bracket
                }
            }).TrimEnd(")\r\n".ToCharArray()).TrimStart('(') + ":\r\n";
            foreach (var item in Two.InerLines)
            {
                Return += "\t" + new PythonControler().Out(new LsBaseList()
                {
                    Bases = new List <lsBase>()
                    {
                        item
                    }
                }) + "\r\n";
            }
            return(Return);
        }
Exemplo n.º 2
0
        public static LsBracket Read(string One, ref LswPython.PythonPositions PythonPosition)
        {
            LsBracket Two   = new LsBracket();
            string    Three = One[0].ToString();

            switch (Three)
            {
            case "<":
                Three = Three + "|>";
                break;

            case "(":
                Three = Three + "|)";
                break;

            case "[":
                Three = Three + "|]";
                break;

            case "{":
                Three = Three + "|}";
                break;

            default:
                Three = "(|)";
                break;
            }
            if (Two.BracketTypesPears.ContainsValue(Three))
            {
                Two.BracketType = Dic.KeyByValue(Three); // //
            }
            else
            {
                Two.BracketType = LsBracket.BracketTypes.Round;
            }
            //do
            //{
            string[] Parts;
            Parts = One.Trim().Substring(1, One.Length - 2).Split(Seperater(Two.BracketType).ToCharArray());
            foreach (var item in Parts)
            {
                string itemT = item.Trim();
                var    Four  = new PythonControler().PartInRef(itemT, ref PythonPosition);
                if (Four is string && (itemT[0] != '"' && itemT[0] != "'"[0]))
                {
                    Two.AddString(new LsName()
                    {
                        Name = Four.ToString()
                    });
                }
                else
                {
                    Two.AddBase(Four);
                }
            }
            PythonPosition.Position++;
            try
            { One = PythonPosition.InLine[PythonPosition.Position]; }
            catch { }
            //} while(CheckRepeate(One, Two));
            PythonPosition.Position = PythonPosition.Position - 1;
            return(Two);
        }