public static String errorMsg(CharStream cs, long start, long finish, String msgPrefix) {
        cs.seek(0);
        int l = 1;
        int c = 1;
        String errstr = "";
        String errstr2 = "";
        int ch;
        for (int i = 0; i < start; i++) {
            if ((ch = cs.next()) != '\n' && ch!=-1) {
                c++;
                errstr += (char )ch;
                errstr2 += " ";
            } else {
                c = 1;
                errstr = "";
                errstr2 = "";
                l++;
            }
        }
        while ((ch = cs.next()) != '\n' && ch != -1 ) {
            errstr += (char) ch;
        }
        return msgPrefix+"At (" + l + "," + c + ").\n" + errstr + "\n" + errstr2 + "^";
    }