public override void Analysis() { UnityEngine.Debug.LogError("LSharpScript Analysis"); string lineValue = ""; if (lineList == null) { return; } if (lineList.Count == 0) { if (dataList.Count > 0) { dataList.RemoveAt(0); } if (dataList.Count > 0) { List <string>[] arr = dataList[0]; lineList = arr[1]; copyList = arr[2]; Analysis(); } return; } while (lineList.Count > 0 && lineValue.Length == 0) { lineValue = lineList[0].Trim(); lineList.RemoveAt(0); } if (string.IsNullOrEmpty(lineValue.Trim())) { Analysis(); return; } lineValue = LSharpVarlable.GetVarlable(lineValue); Debug.Log("lineValue = " + lineValue); if (lineValue.IndexOf("if", StringComparison.Ordinal) >= 0) { LSharpIf.GetIf(lineValue); return; } else if (lineValue.IndexOf("function", StringComparison.Ordinal) >= 0) { LSharpFunction.AddFunction(lineValue); return; } string[] sarr = lineValue.Split('.'); string key = sarr[0]; Debug.Log("key = " + key + ", " + subClasses.ContainsKey(key)); if (subClasses.ContainsKey(key)) { object subClass = subClasses[key]; CallAnalysis(subClass, lineValue); } else { Analysis(); } }
public static void GetIf(string lineValue) { int start = lineValue.IndexOf("(", System.StringComparison.Ordinal); int end = lineValue.IndexOf(")", System.StringComparison.Ordinal); string str = lineValue.Substring(start + 1, end - start - 1); string[] ifArr = str.Split(new string[] { "&&" }, System.StringSplitOptions.RemoveEmptyEntries); bool ifvalue = LSharpIf.CheckCondition(ifArr); bool ifvalueend = false; int sCount = 0; int eCount = 0; List <string> childArray = new List <string>(); while (LSharpScript.Instance.LineListCount > 0) { sCount = 0; string child = LSharpScript.Instance.ShiftLine(); if (child.IndexOf("elseif", System.StringComparison.Ordinal) >= 0) { if (ifvalue) { ifvalueend = true; continue; } start = child.IndexOf("(", System.StringComparison.Ordinal); end = child.IndexOf(")", System.StringComparison.Ordinal); str = child.Substring(start + 1, end - start - 1); str = LSharpVarlable.GetVarlable(str); ifArr = str.Split(new string[] { "&&" }, System.StringSplitOptions.RemoveEmptyEntries); ifvalue = LSharpIf.CheckCondition(ifArr); continue; } else if (child.IndexOf("else", System.StringComparison.Ordinal) >= 0) { if (ifvalue) { ifvalueend = true; continue; } ifvalue = true; continue; } else if (child.IndexOf("endif", System.StringComparison.Ordinal) >= 0) { break; } else if (child.IndexOf("if", System.StringComparison.Ordinal) >= 0) { if (ifvalue && !ifvalueend) { childArray.Add(child); } sCount = 1; eCount = 0; while (sCount > eCount) { string subChild = LSharpScript.Instance.ShiftLine(); if (subChild.IndexOf("if", System.StringComparison.Ordinal) >= 0 && subChild.IndexOf("else", System.StringComparison.Ordinal) < 0 && subChild.IndexOf("end", System.StringComparison.Ordinal) < 0) { sCount++; } else if (subChild.IndexOf("endif", System.StringComparison.Ordinal) >= 0) { eCount++; } if (ifvalue && !ifvalueend) { childArray.Add(subChild); } } } if (sCount == 0) { if (ifvalue && !ifvalueend) { childArray.Add(child); } } } for (var i = childArray.Count - 1; i >= 0; i--) { LSharpScript.Instance.UnshiftLine(childArray[i]); } LSharpScript.Instance.Analysis(); }