home *** CD-ROM | disk | FTP | other *** search
/ Tutto per Internet / Internet.iso / soft95 / Java / espints / espinst.exe / classes / espresso / Report.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-02-28  |  2.4 KB  |  120 lines

  1. package espresso;
  2.  
  3. import java.io.IOException;
  4. import java.io.RandomAccessFile;
  5.  
  6. class Report implements Constants {
  7.    private static int lineNum = 0;
  8.    private static String errLine = null;
  9.    private static RandomAccessFile infile = null;
  10.    static int nwarnings = 0;
  11.    static int nerrors = 0;
  12.    static boolean silent = false;
  13.    public static String filename = "<input>";
  14.    static int noPos = -1;
  15.  
  16.    static void close() {
  17.       if (infile != null) {
  18.          try {
  19.             infile.close();
  20.             infile = null;
  21.          } catch (IOException var1) {
  22.          }
  23.       }
  24.  
  25.    }
  26.  
  27.    static void open(String var0) {
  28.       filename = var0;
  29.    }
  30.  
  31.    static void warning(int var0, String var1) {
  32.       if (!silent && nwarnings < 100) {
  33.          printError(var0, String.valueOf("warning: ").concat(String.valueOf(var1)));
  34.          ++nwarnings;
  35.       }
  36.  
  37.    }
  38.  
  39.    static void error(int var0, String var1) {
  40.       if (!silent && nerrors < 100) {
  41.          printError(var0, var1);
  42.          ++nerrors;
  43.       }
  44.  
  45.    }
  46.  
  47.    private static void printError(int var0, String var1) {
  48.       if (var0 == noPos) {
  49.          System.out.println(String.valueOf("error: ").concat(String.valueOf(var1)));
  50.       } else {
  51.          int var2 = var0 >>> 10;
  52.          int var3 = var0 - (var2 << 10);
  53.          System.out.print(String.valueOf(filename).concat(String.valueOf(":")));
  54.          System.out.print(var2);
  55.          System.out.print(": ");
  56.          System.out.println(var1);
  57.          printErrLine(var2, var3);
  58.          prompt();
  59.       }
  60.  
  61.    }
  62.  
  63.    private static void printErrLine(int var0, int var1) {
  64.       try {
  65.          if (infile == null) {
  66.             infile = new RandomAccessFile(filename, "r");
  67.             lineNum = 0;
  68.             errLine = "";
  69.          } else if (lineNum > var0) {
  70.             infile.seek(0L);
  71.             lineNum = 0;
  72.             errLine = "";
  73.          }
  74.  
  75.          if (infile != null) {
  76.             while(lineNum < var0 && errLine != null) {
  77.                errLine = infile.readLine();
  78.                ++lineNum;
  79.             }
  80.  
  81.             if (errLine != null) {
  82.                System.out.println(errLine);
  83.  
  84.                for(int var2 = 1; var2 < var1; ++var2) {
  85.                   System.out.write(32);
  86.                }
  87.  
  88.                System.out.println("^");
  89.             }
  90.          }
  91.       } catch (IOException var4) {
  92.       }
  93.  
  94.    }
  95.  
  96.    private static void prompt() {
  97.       if (Switches.promptOnError) {
  98.          System.out.println("R)esume, A)bort>");
  99.  
  100.          try {
  101.             while(true) {
  102.                switch (System.in.read()) {
  103.                   case 97:
  104.                   case 65:
  105.                      throw new CompilerError("user abort");
  106.                   case 114:
  107.                   case 82:
  108.                      return;
  109.                }
  110.             }
  111.          } catch (IOException var2) {
  112.             throw new CompilerError("input read error");
  113.          }
  114.       }
  115.    }
  116.  
  117.    public Report() {
  118.    }
  119. }
  120.