public static void PrintErrMsg(bool printFlag, int index, LineObject lineObject, string token, int beginIndex, int endIndex, bool isTab) { if ((printFlag == true) && (index != -1)) { curErrMsg_ = GetMsg(index, lineObject, token, beginIndex, endIndex, isTab); Console.WriteLine(curErrMsg_); } }
private static string GetMsg(int index, LineObject lineObject, string token, int beginIndex, int endIndex, bool isTab) { string line = lineObject.GetLine(); int lineNum = lineObject.GetLineNum(); string msg = ""; if (ReferenceEquals(token, null)) { msg = "Syntax Error: at the beginning of line " + lineNum + LS + " Rule-" + (index + 1) + ": " + errMsg_[index] + LS + line + LS + GetErrorPositionString(beginIndex, endIndex, isTab); } else { msg = "Syntax Error: at token '" + token + "' on line " + lineNum + LS + " Rule-" + (index + 1) + ": " + errMsg_[index] + LS + line + LS + GetErrorPositionString(beginIndex, endIndex, isTab); } return(msg); }