Esempio n. 1
0
        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_);
            }
        }
Esempio n. 2
0
        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);
        }