From 0c2c64601200692952f26d6bd0d2bab775113792 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Tue, 2 May 2023 18:55:56 -0400 Subject: [PATCH] Clean up some stuff in scanner, try and fail to get quil working --- justfile | 2 ++ project.clj | 3 ++- src/ludus/prelude.clj | 10 ++++++++-- src/ludus/scanner.clj | 20 +++++++++++--------- 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 justfile diff --git a/justfile b/justfile new file mode 100644 index 0000000..db14e23 --- /dev/null +++ b/justfile @@ -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 \ No newline at end of file diff --git a/project.clj b/project.clj index d0c36f5..b040fc4 100644 --- a/project.clj +++ b/project.clj @@ -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 diff --git a/src/ludus/prelude.clj b/src/ludus/prelude.clj index 41ec6f9..3e03e31 100644 --- a/src/ludus/prelude.clj +++ b/src/ludus/prelude.clj @@ -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 }) \ No newline at end of file diff --git a/src/ludus/scanner.clj b/src/ludus/scanner.clj index 9c948d4..7884bf7 100644 --- a/src/ludus/scanner.clj +++ b/src/ludus/scanner.clj @@ -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") +