public class SYSTEM { /* Каркас для фреймов процедур */ public static abstract class FRAME { public FRAME up; } /* Длинна строки LEN(s$) */ public static int LEN(byte[] x) { int i = 0; while(x[i] != 0) { i += 1; } return i; } public static String STRING(byte[] x) { return new String(x, 0, LEN(x)); } public static void COPY(byte[] x, byte[] v) { int ix = LEN(x); int iv = v.length - 1; int i = 0; int len = (ix < iv) ? (ix) : (iv); while(i < len) { v[i] = x[i]; i += 1; } v[i] = 0; } public static int STRCMP(byte[] a, byte[] b) { int i = 0; while(a[i] != 0 && a[i] == b[i]) { i += 1; } return a[i] - b[i]; } public static void HALT(long n) { System.exit((int) n); } public static void ASSERT(boolean x) { assert x; } public static void ASSERT(boolean x, long n) { assert x : n; } public static void TRAP(long n) { if(n == -1) { throw new RuntimeException("CASE TRAP"); } else if(n == -2) { throw new RuntimeException("WITH TRAP"); } else if(n == -3) { throw new RuntimeException("NOT IMPLEMENTED"); } else { throw new RuntimeException("TRAP CODE " + n); } } }