1 22 23 package org.javacc.parser; 24 25 public class JavaCCErrors { 26 27 private static int parse_error_count = 0, semantic_error_count = 0, warning_count = 0; 28 29 private static void printLocationInfo(Object node) { 30 if (node instanceof NormalProduction) { 31 NormalProduction n = (NormalProduction)node; 32 System.err.print("Line " + n.line + ", Column " + n.column + ": "); 33 } else if (node instanceof TokenProduction) { 34 TokenProduction n = (TokenProduction)node; 35 System.err.print("Line " + n.line + ", Column " + n.column + ": "); 36 } else if (node instanceof Expansion) { 37 Expansion n = (Expansion)node; 38 System.err.print("Line " + n.line + ", Column " + n.column + ": "); 39 } else if (node instanceof CharacterRange) { 40 CharacterRange n = (CharacterRange)node; 41 System.err.print("Line " + n.line + ", Column " + n.column + ": "); 42 } else if (node instanceof SingleCharacter) { 43 SingleCharacter n = (SingleCharacter)node; 44 System.err.print("Line " + n.line + ", Column " + n.column + ": "); 45 } else if (node instanceof Token) { 46 Token t = (Token)node; 47 System.err.print("Line " + t.beginLine + ", Column " + t.beginColumn + ": "); 48 } 49 } 50 51 public static void parse_error(Object node, String mess) { 52 System.err.print("Error: "); 53 printLocationInfo(node); 54 System.err.println(mess); 55 parse_error_count++; 56 } 57 58 public static void parse_error(String mess) { 59 System.err.print("Error: "); 60 System.err.println(mess); 61 parse_error_count++; 62 } 63 64 public static int get_parse_error_count() { 65 return parse_error_count; 66 } 67 68 public static void semantic_error(Object node, String mess) { 69 System.err.print("Error: "); 70 printLocationInfo(node); 71 System.err.println(mess); 72 semantic_error_count++; 73 } 74 75 public static void semantic_error(String mess) { 76 System.err.print("Error: "); 77 System.err.println(mess); 78 semantic_error_count++; 79 } 80 81 public static int get_semantic_error_count() { 82 return semantic_error_count; 83 } 84 85 public static void warning(Object node, String mess) { 86 System.err.print("Warning: "); 87 printLocationInfo(node); 88 System.err.println(mess); 89 warning_count++; 90 } 91 92 public static void warning(String mess) { 93 System.err.print("Warning: "); 94 System.err.println(mess); 95 warning_count++; 96 } 97 98 public static int get_warning_count() { 99 return warning_count; 100 } 101 102 public static int get_error_count() { 103 return parse_error_count + semantic_error_count; 104 } 105 106 public static void reInit() 107 { 108 parse_error_count = 0; 109 semantic_error_count = 0; 110 warning_count = 0; 111 } 112 113 } 114 | Popular Tags |