// this method gets the indices of OMG, GTFO, and OIC statements private switch_index[] getIndexSwitch(int i, Boolean isOMGGTFO, Boolean isOIC, Boolean isOMGWTF) { List<switch_index> indices = new List<switch_index>(); if (isOIC) { for (i = i; i < lexemes.Length; i++) { switch_index s = new switch_index(); if (lexemes[i].CompareTo("OIC") == 0) { s.index = i; s.gtfo_index = -1; indices.Add(s); break; } } if (indices == null || !indices.Any()) indices.Clear(); } else if (isOMGWTF) { for (i = i; i < lexemes.Length; i++) { switch_index s = new switch_index(); if (lexemes[i].CompareTo("OMGWTF") == 0) { s.index = i; s.gtfo_index = -1; indices.Add(s); break; } } if (indices == null || !indices.Any()) indices.Clear(); } else if (isOMGGTFO) { for (i = i; i < lexemes.Length; i++) { switch_index s = new switch_index(); if (lexemes[i].CompareTo("OMG") == 0) { s.index = i; for (int k = i + 1; k < lexemes.Length; k++) { if (lexemes[k].CompareTo("GTFO") == 0) { s.gtfo_index = k; i = k; break; } else if (lexemes[k].CompareTo("OMG") == 0 || lexemes[k].CompareTo("OIC") == 0) { s.gtfo_index = -1; i = k - 1; break; } } indices.Add(s); } else if (lexemes[i].CompareTo("OIC") == 0) break; } if (indices == null || !indices.Any()) indices.Clear(); } return indices.ToArray(); }
// this method performs the interpreation of switch statements private Boolean isSwitchStatement(String switch_control_statement, switch_index[] omggtfo_indices, int omgwtf_index) { Boolean has_been_matched = false; int i; for (i = 0; i < omggtfo_indices.Length; i++) { if (has_been_matched) { for (int k = ((omggtfo_indices[i].index) + 2); k < lexemes.Length; k++) { if (lexemes[k].CompareTo("OMG") == 0 || lexemes[k].CompareTo("GTFO") == 0 || lexemes[k].CompareTo("OMGWTF") == 0 || lexemes[k].CompareTo("OIC") == 0) break; else k = interpretSubexpressionLexemes(k); if (k == -1) return true; } if (omggtfo_indices[i].gtfo_index != -1) break; } else { if (switch_control_statement.CompareTo(lexemes[(omggtfo_indices[i].index) + 1]) == 0) { has_been_matched = true; for (int k = ((omggtfo_indices[i].index) + 2); k < lexemes.Length; k++) { if (lexemes[k].CompareTo("OMG") == 0 || lexemes[k].CompareTo("GTFO") == 0 || lexemes[k].CompareTo("OMGWTF") == 0 || lexemes[k].CompareTo("OIC") == 0) break; else k = interpretSubexpressionLexemes(k); if (k == -1) return true; } if (omggtfo_indices[i].gtfo_index != -1) break; } else continue; } } if(omgwtf_index != -1 && i == omggtfo_indices.Length && has_been_matched) { if (omggtfo_indices[--i].gtfo_index == -1) { for (int k = omgwtf_index + 1; k < lexemes.Length; k++) { if (lexemes[k].CompareTo("OIC") == 0) break; else { k = interpretSubexpressionLexemes(k); if (k == -1) return true; } } } } else if(omgwtf_index != -1 && !has_been_matched) { for (int k = omgwtf_index + 1; k < lexemes.Length; k++) { if (lexemes[k].CompareTo("OIC") == 0) break; else { k = interpretSubexpressionLexemes(k); if (k == -1) return true; } } } return false; }