Skip to content

Commit 6bdc5ca

Browse files
committed
Make bb compatible
1 parent 3ef65e5 commit 6bdc5ca

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.clj-kondo/config.edn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:cljc {:features #{:clj}}}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ codox
77
\#*
88
.project
99
.classpath
10+
.clj-kondo/.cache

src/main/clojure/blancas/kern/core.clj renamed to src/main/clojure/blancas/kern/core.cljc

+17-10
Original file line numberDiff line numberDiff line change
@@ -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,17 +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]
108-
Comparable
109-
(compareTo [this other]
110-
(let [result (compare line (:line other))]
111-
(if (zero? result)
112-
(compare col (:col other))
113-
result))))
113+
;; removed for babashka, not sure if this will cause issues
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))))
114120

115121
;; A PMessage consists of:
116122
;; type - One of the error types listed above.
@@ -222,7 +228,8 @@ Addison-Wesley, 1975"
222228
(cond (and (nil? e1) (nil? e2)) nil
223229
(nil? e1) e2
224230
(nil? e2) e1
225-
:else (let [r (compare (:pos e1) (:pos e2))]
231+
:else (let [r (#?(:bb compareTo :clj compare)
232+
(:pos e1) (:pos e2))]
226233
(cond (zero? r) (update-in e1 [:msgs] concat (:msgs e2))
227234
(pos? r) e1
228235
:else e2))))

0 commit comments

Comments
 (0)