private int caseFunction(Gramatica alfa) { string[] split = alfa.prod.Split('.'); if (split[1].Length > 0) { if (Program.neterminale.Contains(split[1].Substring(0, 1))) { return(1); } if (Program.terminale.Contains(split[1].Substring(0, 1))) { return(2); } return(3); } else { return(3); } }
public void constructMatrix() { int k = 0; do { _I = _C[k]; do { Gramatica alfa = _I[0]; _I.RemoveAt(0); string[] splitAlfa = alfa.prod.Split('.'); switch (caseFunction(alfa)) { case 1: tabel[k + splitAlfa[1].Substring(0, 1)] = findFunctie(k, splitAlfa[1].Substring(0, 1)); break; case 2: tabel[k + splitAlfa[1].Substring(0, 1)] = "d" + findFunctie(k, splitAlfa[1].Substring(0, 1)); break; case 3: if (splitAlfa[0] == Program.simbolInitial) { addAccept(k, splitAlfa[0]); } else { addReducere(k, splitAlfa[0].Substring(splitAlfa[0].Length - 1), findPord(alfa.neterminal, splitAlfa[0])); } break; } } while (_I.Count > 0); k++; } while (k < _C.Count); }
static public void readFile() { try { // Open the text file using a stream reader. using (var sr = new StreamReader("C:\\Users\\DxGod\\source\\repos\\ConsoleApp2\\input.txt")) { string line; sirIntrare = sr.ReadLine(); neterminale = sr.ReadLine(); terminale = sr.ReadLine(); simbolInitial = sr.ReadLine(); int indexLine = 0; while ((indexLine < neterminale.Length) && (line = sr.ReadLine()) != null) { gramatica[indexLine++] = new Gramatica(line); } Split(sr.ReadLine(), linie); Split(sr.ReadLine(), coloana); int l = 0, c = 0; while ((line = sr.ReadLine()) != null) { string[] words = line.Split(' '); c = 0; foreach (var word in words) { tabel.Add(linie[l] + coloana[c++], word); } l++; } } } catch (IOException e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } }