transcribe 점점점
This commit is contained in:
1 parent
beb9bc3a4c
commit
3f825c2750
1 file changed
+4
-18
@@ -107,18 +107,7 @@
|
||||
(scm/datum->syntax-recursive datum))
|
||||
(update-vals scm/syntax->datum)))
|
||||
|
||||
(defn strip-ellipsis [x depth]
|
||||
(match x
|
||||
[:ellipsis xs]
|
||||
(if (< 0 depth)
|
||||
[:ellipsis (map #(strip-ellipsis % (dec depth)) xs)]
|
||||
(throw (IllegalArgumentException. "점점점은 나쁘다.")))
|
||||
:else (if (zero? depth)
|
||||
x
|
||||
(throw (IllegalArgumentException.
|
||||
"depth는 영 아니지만 인수에 점점점이 남지 않는다.")))))
|
||||
|
||||
(defn- transcribe-rec [template unification depth]
|
||||
(defn transcribe [template unification]
|
||||
(match (scm/syntax-e template)
|
||||
(_ :guard ellipsis?)
|
||||
(throw (IllegalArgumentException. "점점점은 여기 있으면 안 되다."))
|
||||
@@ -129,22 +118,19 @@
|
||||
x-val x-val)
|
||||
|
||||
([x (_ :guard ellipsis?) & xs] :seq)
|
||||
(match (transcribe-rec x unification depth)
|
||||
(match (transcribe x unification)
|
||||
[:ellipsis x*] (scm/datum->syntax x* template)
|
||||
:else (throw (IllegalArgumentException. "점점점은 나쁘다ㅠㅠ")))
|
||||
|
||||
([x & xs] :seq)
|
||||
(let [xs* (transcribe-rec depth (scm/datum->syntax xs template) unification)]
|
||||
(let [xs* (transcribe (scm/datum->syntax xs template) unification)]
|
||||
(scm/datum->syntax
|
||||
(cons (transcribe-rec depth x unification) (scm/syntax-e xs*))
|
||||
(cons (transcribe x unification) (scm/syntax-e xs*))
|
||||
template))
|
||||
|
||||
([] :seq)
|
||||
template))
|
||||
|
||||
(defn transcribe [template unification]
|
||||
(transcribe-rec template unification 0))
|
||||
|
||||
(defn transcribe*
|
||||
([template unification]
|
||||
(-> template
|
||||
|
||||
Reference in new issue
Block a user