@@ -32,9 +32,8 @@ Addison-Wesley, 1975"
3232 blancas.kern.core
3333 (:refer-clojure :exclude [cat])
3434 (:require [blancas.kern.i18n :refer :all ]
35- [clojure.string :refer [join]]
36- [clojure.java.io :refer [reader]]
37- [clojure.pprint :refer [pprint]]))
35+ [clojure.pprint :refer [pprint]]
36+ [clojure.string :refer [join]]))
3837
3938
4039(defmacro def-
@@ -100,18 +99,24 @@ Addison-Wesley, 1975"
10099(def- err-expect 2 ) ; ; Used to show a message of what's expected.
101100(def- err-message 3 ) ; ; Used for any kind of message from client code.
102101
102+ ; ; babashka doesn't support implementing Java interfaces on records, so we
103+ ; ; introduce a protocol for it
104+ #?(:bb
105+ (defprotocol IComparable
106+ (compareTo [this other])))
107+
103108; ; Keeps the position of the input:
104109; ; src - a string that identifies the source of input
105110; ; line - the line into the input stream.
106111; ; col - the column into the line.
107112(defrecord PPosition [src line col]
108113 ; ; removed for babashka, not sure if this will cause issues
109- #_ # _Comparable
110- (compareTo [this other]
111- (let [result (compare line (:line other))]
112- (if (zero? result)
113- (compare col (:col other))
114- result))))
114+ #? ( :bb IComparable :clj Comparable)
115+ (compareTo [_ other]
116+ (let [result (compare line (:line other))]
117+ (if (zero? result)
118+ (compare col (:col other))
119+ result))))
115120
116121; ; A PMessage consists of:
117122; ; type - One of the error types listed above.
@@ -223,7 +228,8 @@ Addison-Wesley, 1975"
223228 (cond (and (nil? e1) (nil? e2)) nil
224229 (nil? e1) e2
225230 (nil? e2) e1
226- :else (let [r (compare (:pos e1) (:pos e2))]
231+ :else (let [r (#?(:bb compareTo :clj compare)
232+ (:pos e1) (:pos e2))]
227233 (cond (zero? r) (update-in e1 [:msgs ] concat (:msgs e2))
228234 (pos? r) e1
229235 :else e2))))
0 commit comments