1 package polyglot.util; 2 3 4 public class ErrorInfo 5 { 6 public static final int WARNING = 0; 7 public static final int INTERNAL_ERROR = 1; 8 public static final int IO_ERROR = 2; 9 public static final int LEXICAL_ERROR = 3; 10 public static final int SYNTAX_ERROR = 4; 11 public static final int SEMANTIC_ERROR = 5; 12 public static final int POST_COMPILER_ERROR= 6; 13 14 protected int kind; 15 protected String message; 16 protected Position position; 17 18 public ErrorInfo(int kind, String message, Position position) 19 { 20 this.kind = kind; 21 this.message = message; 22 this.position = position; 23 } 24 25 public int getErrorKind() 26 { 27 return kind; 28 } 29 30 public String getMessage() 31 { 32 return message; 33 } 34 35 public Position getPosition() 36 { 37 return position; 38 } 39 40 public String getErrorString() 41 { 42 return getErrorString( kind); 43 } 44 45 public static String getErrorString( int kind) 46 { 47 switch( kind) { 48 case WARNING: 49 return "Warning"; 50 case INTERNAL_ERROR: 51 return "Internal Error"; 52 case IO_ERROR: 53 return "I/O Error"; 54 case LEXICAL_ERROR: 55 return "Lexical Error"; 56 case SYNTAX_ERROR: 57 return "Syntax Error"; 58 case SEMANTIC_ERROR: 59 return "Semantic Error"; 60 case POST_COMPILER_ERROR: 61 return "Post-compiler Error"; 62 default: 63 return "(Unknown)"; 64 } 65 } 66 } 67 68 | Popular Tags |