public static LsElse Read(string One, ref LswPython.PythonPositions PythonPosition) { LsElse Two = new LsElse(); Two.Tabindex = CountTabs(One); bool Continu = true; do { PythonPosition.Position++; try { string Four = PythonPosition.InLine[PythonPosition.Position]; if (CheckRepeate(Four, Two)) { LsBaseList list = (LsBaseList)(new PythonControler().In(new string[] { Four.Trim() })); Two.InerLines.Add(list.Bases[0]); } else { Continu = false; } } catch { Continu = false; } } while (Continu); PythonPosition.Position = PythonPosition.Position - 1; return(Two); }
public static string Write(object One, ref LswPython.PythonPositions PythonPosition) { string Return = "else:\r\n"; LsElse Two = (LsElse)One; foreach (var item in Two.InerLines) { Return += "\t" + new PythonControler().Out(new LsBaseList() { Bases = new List <lsBase>() { item } }); } return(Return); }
public static string Write(object One, ref LswPython.PythonPositions PythonPosition) { string Return = ""; LsBracket Two = (LsBracket)One; Return += Two.BracketTypesPears[Two.BracketType][0]; int Point = 0; while (Two.BaseProperties.Count + Two.StringProperties.Count > Point) { object ToAdd; LsName ToAdd2; if (Two.BaseProperties.TryGetValue(Point, out ToAdd)) { if (ToAdd.GetType() == typeof(string) || ToAdd.GetType() == typeof(char)) { Return += (ToAdd.ToString().Contains("\"")) ? "'" + ToAdd.ToString() + "'" : '"' + ToAdd.ToString() + @"""{string}"; } else if (ToAdd.GetType() == typeof(int)) { Return += ToAdd.ToString() + "{int}"; } else if (ToAdd.GetType() == typeof(bool)) { Return += ToAdd.ToString().ToLower() + "{bool}"; } else if (ToAdd.GetType() == typeof(LsBracket)) { Return += Write(ToAdd, ref PythonPosition) + "{bracket}"; } Return += Seperater(Two.BracketType) + " "; } else if (Two.StringProperties.TryGetValue(Point, out ToAdd2)) { Return += ToAdd2.Name + Seperater(Two.BracketType) + " "; } Point++; } Return = Return.TrimEnd(); Return = Return.Substring(0, Return.Length - 1); Return += ")"; return(Return); }
public static LsIf Read(string One, ref LswPython.PythonPositions PythonPosition) { LsIf Two = new LsIf(); Two.Tabindex = CountTabs(One); string Three = "(" + One.Trim().Substring(3, One.Length - 4).Trim() + ")"; Two.Bracket = (LsBracket) new PythonControler().PartInRef(Three, ref PythonPosition); bool Continu = true; do { PythonPosition.Position++; try { string Four = PythonPosition.InLine[PythonPosition.Position]; if (CheckRepeate(Four, Two)) { LsBaseList list = (LsBaseList)(new PythonControler().In(new string[] { Four.Trim() })); Two.InerLines.Add(list.Bases[0]); } else if (Four.Trim().ToLower().Substring(0, 4) != "elif" || Four.Trim().ToLower().Substring(0, 4) != "else") { Continu = false; Two.EndIf = false; } else { Continu = false; } } catch { Continu = false; } } while (Continu); PythonPosition.Position = PythonPosition.Position - 1; return(Two); }
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); }
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); }