Clean up some stuff in scanner, try and fail to get quil working

This commit is contained in:
Scott Richmond 2023-05-02 18:55:56 -04:00
parent 1c2ab5182e
commit 0c2c646012
4 changed files with 23 additions and 12 deletions

2
justfile Normal file
View File

@ -0,0 +1,2 @@
repl: # start a repl
clj -X clojure.core.server/start-server :name repl :port 5555 :accept clojure.core.server/repl :server-daemon false

View File

@ -4,7 +4,8 @@
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.11.1"]
[babashka/fs "0.1.6"]]
[babashka/fs "0.1.6"]
[quil "4.0.0-SNAPSHOT"]]
:plugins [[lein-cljfmt "0.8.0"]]
:repl-options {:init-ns ludus.core}
:main ludus.core

View File

@ -1,7 +1,9 @@
(ns ludus.prelude
(:require
[ludus.data :as data]
[ludus.show :as show]))
[ludus.show :as show]
[ludus.draw :as d]
))
;; TODO: make eq, and, or special forms that short-circuit
;; Right now, they evaluate all their args
@ -81,7 +83,6 @@
(def sleep- {:name "sleep"
::data/type ::data/clj
:body (fn [ms] (Thread/sleep ms))})
(def conj- {:name "conj"
::data/type ::data/clj
:body conj})
@ -94,6 +95,10 @@
::data/type ::data/clj
:body get})
(def draw {:name "draw"
::data/type ::data/clj
:body d/draw})
(def prelude {"eq" eq
"add" add
"print" print-
@ -112,4 +117,5 @@
"assoc" assoc-
"conj" conj-
"get" get-
"draw" draw
})

View File

@ -20,7 +20,7 @@
"match" ::token/match ;; impl
"nil" ::token/nil ;; impl
"ns" ::token/ns ;; impl
"panic!" ::token/panic ;; impl
;; "panic!" ::token/panic ;; impl (should be a function)
"recur" ::token/recur ;; impl
"ref" ::token/ref ;; impl
"then" ::token/then ;; impl
@ -29,17 +29,17 @@
;; actor model/concurrency
"receive" ::token/receive
"self" ::token/self ;; maybe not necessary?
"send" ::token/send
;;"self" ::token/self ;; maybe not necessary?: self() is a function
;;"send" ::token/send ;; not necessary: send(pid, message) is a function
"spawn" ::token/spawn
"to" ::token/to
;;"to" ::token/to ;; not necessary if send is a function
;; type system
"data" ::token/data
;; "data" ::token/data ;; we are going to tear out datatypes for now: see if dynamism works for us
;; others
"repeat" ::token/repeat ;; syntax sugar over "loop"
"repeat" ::token/repeat ;; syntax sugar over "loop": still unclear what this syntax could be
"test" ::token/test
"when" ::token/when
"module" ::token/module
;; "module" ::token/module ;; not necessary if we don't have datatypes
})
(defn- new-scanner
@ -107,7 +107,7 @@
(defn- whitespace? [c]
(or (= c \space) (= c \tab)))
;; TODO: update terminators:
;; TODO: update token terminators:
;; remove: \|
;; add: \>
;; research others
@ -251,7 +251,7 @@
\- (cond
(= next \>) (add-token (advance scanner) ::token/rarrow)
(digit? next) (add-number char scanner)
:else (add-error scanner (str "Expected -> or negative number. Got " char next)))
:else (add-error scanner (str "Expected -> or negative number after `-`. Got `" char next "`")))
;; at current we're not using this
;; <-
@ -331,3 +331,5 @@
:errors (::errors scanner)})
(recur (-> scanner (scan-token) (next-token))))))
(scan "2 :three true nil")