public string Start(List <TokensClass> tokens) { //Boolean isDone = false; string tokenstream = ""; string result; int line = 1; int linejump = 0; foreach (var t in tokens) { if (t.getLines() != line) { linejump = t.getLines() - line; line = t.getLines(); for (int i = 0; i < linejump; i++) { tokenstream += "\n"; } } tokenstream += t.getTokens() + " "; } tokenstream = tokenstream.TrimEnd(); Parser p; p = CreateParser(tokenstream); try { Node parse = p.Parse(); Fail("parsing succeeded"); result = "Syntax Analyzer Succeeded..."; } catch (ParserCreationException e) { Fail(e.Message); result = e.Message; } catch (ParserLogException e) { List <int> codes = p.GetAllProductionCode(); PredictSets ps = new PredictSets(); string message = "Expected: "; errors.setColumn(e.GetError(0).Column); errors.setLines(e.GetError(0).Line); int ctr = GetSyntaxTable(codes); //isDone = true; if (codes.Count - 1 >= ctr) { int code = codes[ctr]; message += ps.GetPredictSet(code); } else { int code = codes[ctr - 1]; message += ps.GetPredictSet(code); } //if (p.GetLastProductionState() == "NULL") //{ // int code = p.GetLastProductionCode(); // message += ps.GetPredictSet(code); //} //else //{ // foreach (var item in e.GetError(0).Details) // { // message += item + ", "; // } //} if (message == "Expected: ") { string errormessage = e.GetError(0).ErrorMessage; if (errormessage.Contains("unexpected token")) { errormessage = ""; foreach (var item in e.GetError(0).Details) { errormessage += item + ", "; } } if (errormessage == "unexpected end of file") { errormessage = "\".\""; } message += errormessage; } //if (message == "Expected: @, (, &&, ||, >=, <=, <, >, ==, !=, )") //{ // message = "Expected: "; // foreach (var item in e.GetError(0).Details) // { // message += item + ", "; // } //} message += "."; errors.setErrorMessage(message); errors.setType(e.GetError(0).Type.ToString()); result = e.Message; } recursiveprod = p.GetRecursiveProduction(); GetSyntaxTable(p.GetAllProductionCode()); return(result); }