This commit is contained in:
msyds committed 2026-09-23 11:18:12 -06:00
1 parent babfed1bb7
commit 5359bc1c0a
2 files changed
+33 -32

No files matched your search

+3 -18
View File
@@ -14,7 +14,7 @@
`(~f ~@(mapcat #(list (keyword %) %)
syms))))
(s/def ::scope symbol?)
(s/def ::scope scm/scope?)
(s/def ::binding
#(match %
@@ -74,10 +74,6 @@
:ss (s/coll-of ::context))
:ret (s/coll-of ::context :kind set?))
(s/fdef new-scope
:args (s/cat :prefix (s/? string?))
:ret ::scope)
;;; prim specs
@@ -107,16 +103,6 @@
(defn new-scope
([] (gensym "scope__"))
([prefix] (gensym (str "scope__" prefix))))
#_
(defn bind-lexical [sym denot store-atom]
(let [bind [:lexical sym (gensym)]]
(swap! store-atom #(assoc % [sym scopes] bind))
{bind denot}))
#_
(s/fdef binding-form
:args (s/cat :binds (s/coll-of (s/tuple symbol? ::denotation))
@@ -125,9 +111,8 @@
(defn binding-form [ident env store-atom binds f]
(let [scopes (conj (scm/syntax-context ident)
(new-scope))
ident* (scm/->Syntax (scm/syntax-e ident)
scopes)
(scm/new-scope))
ident* (scm/->Syntax (scm/syntax-e ident) scopes)
additions (for [[sym denot] binds]
[sym
[:lexical sym (gensym)]
+30 -14
View File
@@ -1,11 +1,13 @@
(ns scm
(:require [instaparse.core :as insta]
[clojure.java.io :as io]
[clojure.core.match :refer [match]]
[clojure.string :as str]
[clojure.spec.alpha :as s])
(:import clojure.lang.ILookup)
(:refer-clojure :exclude [read]))
(:refer-clojure :exclude [read])
(:require
[clojure.core.match :refer [match]]
[clojure.java.io :as io]
[clojure.pprint]
[instaparse.core :as insta]
[clojure.spec.alpha :as s])
(:import
(clojure.lang ILookup)))
;;; syntax objects
@@ -80,12 +82,6 @@
[x]
(and (syntax? x) (-> x syntax-e symbol?)))
(defn constant? [x]
(or (and (syntax? x) (-> x syntax-e constant?))
(number? x)
(string? x)
(boolean? x)))
;;; improper list
@@ -196,7 +192,27 @@
(read text (merge {:syntax? true} opts)))
;;; specs
;;; scopes
(defn scope? [x]
(symbol? x))
(s/fdef new-scope
:args (s/cat :prefix (s/? string?))
:ret scope?)
(defn new-scope
([] (gensym "scope__"))
([prefix] (gensym (str "scope__" prefix))))
;;; general scheme stuff
(defn constant? [x]
(or (and (syntax? x) (-> x syntax-e constant?))
(number? x)
(string? x)
(boolean? x)))
(defn datum? [x]
(or (number? x)