summaryrefslogtreecommitdiff
path: root/src/minijava/typecheck/PrintError.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/minijava/typecheck/PrintError.java')
-rw-r--r--src/minijava/typecheck/PrintError.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/minijava/typecheck/PrintError.java b/src/minijava/typecheck/PrintError.java
new file mode 100644
index 0000000..a5a5157
--- /dev/null
+++ b/src/minijava/typecheck/PrintError.java
@@ -0,0 +1,24 @@
+/**
+ * 存放错误信息并统一打印
+ */
+package minijava.typecheck;
+
+import java.util.Vector;
+
+public class PrintError {
+ private static Vector<String> errors = new Vector<String>();
+
+ public static void print(int line, int column, String error_msg) {
+ String msg = "Line " + line + " Column " + column + ": " + error_msg;
+ errors.addElement(msg); // 存储错误信息
+ }
+
+ // 统一进行打印
+ public static void printAll() {
+ int sz = errors.size();
+ for (int i = 0; i < sz; i++) {
+ System.out.println(errors.elementAt(i));
+ }
+ }
+}
+