Exemplo n.º 1
0
        public static void Summarize()
        {
            if (mergeErrors)
            {
                mergedList.WriteLine();
                ErrorRec cur = first;
                Buffer.Pos = 0;
                int    lnr = 1;
                string s   = GetLine();
                while (!eof)
                {
                    mergedList.WriteLine("{0,4} {1}", lnr, s);
                    while (cur != null && cur.line == lnr)
                    {
                        Display(s, cur); cur = cur.next;
                    }
                    lnr++; s = GetLine();
                }
                if (cur != null)
                {
                    mergedList.WriteLine("{0,4}", lnr);
                    while (cur != null)
                    {
                        Display(s, cur); cur = cur.next;
                    }
                }
                mergedList.WriteLine();
                mergedList.WriteLine(count + " errors detected");
                if (warns > 0)
                {
                    mergedList.WriteLine(warns + " warnings detected");
                }
                mergedList.Close();
            }
            switch (count)
            {
            case 0: Console.WriteLine("Parsed correctly"); break;

            case 1: Console.WriteLine("1 error detected"); break;

            default: Console.WriteLine(count + " errors detected"); break;
            }
            if (warns > 0)
            {
                Console.WriteLine(warns + " warnings detected");
            }
            if ((count > 0 || warns > 0) && mergeErrors)
            {
                Console.WriteLine("see " + listName);
            }
        }
Exemplo n.º 2
0
 static void Display(string s, ErrorRec e)
 {
     mergedList.Write("**** ");
     for (int c = 1; c < e.col; c++)
     {
         if (s[c - 1] == '\t')
         {
             mergedList.Write("\t");
         }
         else
         {
             mergedList.Write(" ");
         }
     }
     mergedList.WriteLine("^ " + e.str);
 }
Exemplo n.º 3
0
 public static void StoreError(int line, int col, string s)
 {
     if (mergeErrors)
     {
         ErrorRec latest = new ErrorRec(line, col, s);
         if (first == null)
         {
             first = latest;
         }
         else
         {
             last.next = latest;
         }
         last = latest;
     }
     else
     {
         Console.WriteLine(errMsgFormat, fileName, line, col, s);
     }
 }
Exemplo n.º 4
0
 public ErrorRec(int l, int c, string s)
 {
     line = l; col = c; str = s; next = null;
 }