private string TranslateArray(string s, LexObject lex, LexObject rlex) { TLArray tl = (TLArray)Arrays[lex.pointer]; TLArray tx = (TLArray)Arrays[rlex.pointer]; for (int i = 0; i < tl.content.Count; i++) { if (s == tl.content[i].ToString()) { return(tx.content[i].ToString()); } } return(null); }
private int getNumbers(ArrayList leftlex) { int x = 1; for (int i = 0; i < leftlex.Count; i++) { LexObject lex = (LexObject)leftlex[i]; if (!lex.isText) { TLArray ta = (TLArray)Arrays[lex.pointer]; x *= ta.content.Count; } } return(x); }
private int getFactor(ArrayList leftlex, int ind) { int factor = 1; for (int i = 0; i <= ind; i++) { LexObject lex = (LexObject)leftlex[i]; if (!lex.isText) { TLArray tl = (TLArray)Arrays[lex.pointer]; factor *= tl.content.Count; } } return(factor); }
private int FindArray(string tmp) { if (tmp == "del") { return(98761197); } else if (tmp == "null") { return(98761199); } for (int i = 0; i < Arrays.Count; i++) { TLArray t = (TLArray)Arrays[i]; if (t.name == tmp) { return(i); } } return(-1); }
private ArrayList GenerateLex(LexObject L, int x, int ind, ArrayList leftlex) { ArrayList al = new ArrayList(); if (L.isText) { for (int i = 0; i < x; i++) { al.Add(L.text); } return(al); } else { TLArray tl = (TLArray)Arrays[L.pointer]; int fx = getFactor(leftlex, ind); int factor = x / fx; int h = 0; int y = 0; while (al.Count < x) { al.Add(tl.content[y]); h++; if (h == factor) { h = 0; y++; if (y == tl.content.Count) { y = 0; } } } return(al); } return(null); }
private string ProcessArray(string currentline) { currentline = currentline.Substring(6); currentline = currentline.Trim(); ArrayList al = new ArrayList(); int state = 0; string tmp = ""; bool fin = false; bool foundu = false; foreach (char c in currentline.ToCharArray()) { switch (state) { case 0: if (c == '[') { state = 1; } else { return "Array Decleration Error"; } break; case 1: if (c == '\\') { state = 2; } else if (c == '.') { state = 3; } else if (c == ']') { if (tmp.Length > 1) { return "Error Array Item Contain More Than One Character"; } else if (tmp.Length == 0) { } else { al.Add(tmp); } state = 5; } else if (c == ',') { if (tmp.Length > 1) { return "Error Array Item Contain More Than One Character"; } else if (tmp.Length == 0) { } else { al.Add(tmp); } tmp = ""; } else if (c == ' ' || c == '\t') { } else if (c == '+') { if (tmp == "U") { state = 7; tmp = ""; } } else { tmp += c; } break; case 2: if (c == '\\' || c == '.' || c==']') { tmp += c; } else if (c == ',') { tmp += c; } else if (c == ' ' || c == '\t') { tmp += c; } else return "Invalid Escape Character - " + c; state = 1; break; case 3: if (c == '.') { state = 4; } else if (c == ',') { if (tmp.Length > 1) { return "Error Array Item Contain More Than One Character"; } else if (tmp.Length == 0) { } else { al.Add(tmp); } tmp = ""; } else { tmp += c; } break; case 4: char start = tmp[tmp.Length - 1]; char end = c; tmp = ""; for (int j = (int)start; j <= (int)end; j++) { al.Add(((char)j).ToString()); } state = 1; break; case 5: if (c == ' ' || c == '\t') { //do nothing } else if (c == '>') { state = 6; tmp = ""; } else { return "Error Array Name"; } break; case 6: if (c == ' ' || c == '\t') { if (tmp.Length > 0) { return "Error Array Name"; } } else if (c == '}') { fin = true; } else if (fin == false) { tmp += c; } else { return "Error Array Name"; } break; case 7: if (checkHex(c)) { tmp += c; } else if (c == ',' || c == ']') { if (tmp.Length == 4) { int i = Convert.ToInt32(tmp, 16); al.Add(((char)i).ToString()); tmp = ""; if (c == ',') state = 1; else state = 5; } else { return "Error Unicode point"; } } break; } } TLArray tla = new TLArray(); tla.name = tmp; tla.content = al; Arrays.Add(tla); return "OK"; }
private string ProcessArray(string currentline) { currentline = currentline.Substring(6); currentline = currentline.Trim(); ArrayList al = new ArrayList(); int state = 0; string tmp = ""; bool fin = false; bool foundu = false; foreach (char c in currentline.ToCharArray()) { switch (state) { case 0: if (c == '[') { state = 1; } else { return("Array Decleration Error"); } break; case 1: if (c == '\\') { state = 2; } else if (c == '.') { state = 3; } else if (c == ']') { if (tmp.Length > 1) { return("Error Array Item Contain More Than One Character"); } else if (tmp.Length == 0) { } else { al.Add(tmp); } state = 5; } else if (c == ',') { if (tmp.Length > 1) { return("Error Array Item Contain More Than One Character"); } else if (tmp.Length == 0) { } else { al.Add(tmp); } tmp = ""; } else if (c == ' ' || c == '\t') { } else if (c == '+') { if (tmp == "U") { state = 7; tmp = ""; } } else { tmp += c; } break; case 2: if (c == '\\' || c == '.' || c == ']') { tmp += c; } else if (c == ',') { tmp += c; } else if (c == ' ' || c == '\t') { tmp += c; } else { return("Invalid Escape Character - " + c); } state = 1; break; case 3: if (c == '.') { state = 4; } else if (c == ',') { if (tmp.Length > 1) { return("Error Array Item Contain More Than One Character"); } else if (tmp.Length == 0) { } else { al.Add(tmp); } tmp = ""; } else { tmp += c; } break; case 4: char start = tmp[tmp.Length - 1]; char end = c; tmp = ""; for (int j = (int)start; j <= (int)end; j++) { al.Add(((char)j).ToString()); } state = 1; break; case 5: if (c == ' ' || c == '\t') { //do nothing } else if (c == '>') { state = 6; tmp = ""; } else { return("Error Array Name"); } break; case 6: if (c == ' ' || c == '\t') { if (tmp.Length > 0) { return("Error Array Name"); } } else if (c == '}') { fin = true; } else if (fin == false) { tmp += c; } else { return("Error Array Name"); } break; case 7: if (checkHex(c)) { tmp += c; } else if (c == ',' || c == ']') { if (tmp.Length == 4) { int i = Convert.ToInt32(tmp, 16); al.Add(((char)i).ToString()); tmp = ""; if (c == ',') { state = 1; } else { state = 5; } } else { return("Error Unicode point"); } } break; } } TLArray tla = new TLArray(); tla.name = tmp; tla.content = al; Arrays.Add(tla); return("OK"); }
private void ProcessLex(ArrayList leftlex, LexObject midlex, ArrayList rightlex) { ArrayList LeftItems = new ArrayList(); int x = getNumbers(leftlex); if (!midlex.isText) { TLArray ta = (TLArray)Arrays[midlex.pointer]; x *= ta.content.Count; } for (int i = 0; i < leftlex.Count; i++) { LeftItems.Add(GenerateLex((LexObject)leftlex[i], x, i, leftlex)); } ArrayList MidItems = new ArrayList(); if (midlex.isText) { for (int i = 0; i < x; i++) { if (midlex.pointer == 98761197) { MidItems.Add("delete"); } else { MidItems.Add(midlex.text); } } } else { int h = 0; TLArray tl = (TLArray)Arrays[midlex.pointer]; while (MidItems.Count < x) { MidItems.Add(tl.content[h]); h++; if (h == tl.content.Count) { h = 0; } } } ArrayList RightItems = new ArrayList(); for (int i = 0; i < rightlex.Count; i++) { RightItems.Add(DereferenceLeft((LexObject)rightlex[i], x, LeftItems, leftlex, (LexObject)rightlex[i], MidItems, midlex)); } for (int i = 0; i < x; i++) { string left = ""; string right = ""; for (int j = 0; j < LeftItems.Count; j++) { left += ((ArrayList)LeftItems[j])[i].ToString(); } for (int j = 0; j < RightItems.Count; j++) { right += ((ArrayList)RightItems[j])[i].ToString(); } ENI.Add(left); Lines.Add(line.ToString()); ENM.Add(MidItems[i]); ENO.Add(right); } }