# HG changeset patch # User ellis # Date 1684888982 14400 # Node ID 2bbf5ce735375c6bc61b80479ce339ef7fcde139 # Parent 1fedeaa5bfc5073a355a55b2da4492e77be7bf78 rs updates diff -r 1fedeaa5bfc5 -r 2bbf5ce73537 makefile --- a/makefile Fri May 19 22:38:49 2023 -0400 +++ b/makefile Tue May 23 20:43:02 2023 -0400 @@ -1,12 +1,10 @@ -M ?= release -L ?= sbcl -P ?= python3 - +M ?= release #mode +L ?= sbcl #lisp +P ?= python3 #python RS:Cargo.toml build.rs lib.rs obj fig CL:*.asd *.lisp -.PHONY:build clean:;rm -rf *.fasl;cargo clean -fmt:;cargo fmt +fmt:$(RS);cargo fmt build:$(RS) $(CL);cargo build --$(M);$L install.lisp ffi:build;cp target/$(M)/libdemo.dylib ffi;cd ffi;$(P) ffi/build.py docs:$(RS);cargo doc @@ -14,3 +12,4 @@ #pack:;scripts/pack.ros #check:;scripts/check.ros ci:clean fmt build ffi docs test; +.PHONY:build diff -r 1fedeaa5bfc5 -r 2bbf5ce73537 readme.org --- a/readme.org Fri May 19 22:38:49 2023 -0400 +++ b/readme.org Tue May 23 20:43:02 2023 -0400 @@ -1,11 +1,33 @@ #+TITTLE: cl-demo This is a demo software suite which showcases the power of Common Lisp and Rust. -* Make -* Run -* Play -* Config +* Guide +** Build +- *install dependencies* + - Rust =curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh= + - Common Lisp + - on Linux :: + - Ubuntu/Debian :: =sudo apt-get install sbcl= + - Arch BTW :: =sudo pacman -S sbcl= + - on MacOS :: =brew install sbcl= + - on Windows :: download from + and figure it out. + - Quiche + - RocksDB +- *make executables* \\ + Simply run =make build=. Read the ~makefile~ and change the options + as needed. +- M :: Mode (debug, release) +- L :: Lisp (sbcl, cmucl, ccl) +- P :: Python (python3, python2) +** Run +=./demo= +** Config +This demo features a novel configuration language inspired by +FORTH. You are free to use ~.fig~ files, but also have the option to +use a convention format (JSON,TOML,RON). +** Play +*** Weather * tasks -** TODO ros scripts ** TODO DSLs - consider tree-sitter parsing layout, use as a guide for developing a single syntax which expands to Rust or C. @@ -21,6 +43,7 @@ - rs-macros - rs-macroexpand - rs-macroexpand-1 + *** TODO c-macroexpand - c-gen-file h/c - c-defmacro diff -r 1fedeaa5bfc5 -r 2bbf5ce73537 rs.lisp --- a/rs.lisp Fri May 19 22:38:49 2023 -0400 +++ b/rs.lisp Tue May 23 20:43:02 2023 -0400 @@ -1,9 +1,22 @@ ;;; RUST DSL + +;; So basically, this was born out of personal frustration with how +;; cbindgen and Rust macros work (they don't). Rust macros in general +;; are something of a pain in my opinion, so I thought why not just +;; generate Rust code from Lisp instead? + (in-package :demo) (defvar *cargo-target* #p"/Users/ellis/dev/otom8/demo/target/") (defvar *rs-macros* nil) +;; TODO gensyms +(defmacro rs-defmacro (name args &body body) + "Define a macro which can be used within the body of a 'with-rs' form." + `(prog1 + (defmacro ,name ,@(mapcar #`(,a1) args) ,@body) + (push ',name *rs-macros*))) + (defun rs-mod-form (crate &optional mods pub) "Generate a basic mod form (CRATE . [MODS] [PUB])" `(,crate ,mods ,pub)) @@ -61,10 +74,5 @@ ;; (defun rs-macroexpand-1 (form &optional env)) ;; (defun rs-macroexpand (env &rest body) -;; "Cbindgen is quite the menace and really doesn't like our macros used -;; to generate C FFI bindings. To compensate for this, we use a tool -;; called cargo-expand by the most excellent dtolnay which expands Rust -;; macros. The expansions are assembled into an equivalent Rust source -;; file which cbindgen won't get stuck in an infinite compile loop on.") ;;; diff -r 1fedeaa5bfc5 -r 2bbf5ce73537 tk.lisp --- a/tk.lisp Fri May 19 22:38:49 2023 -0400 +++ b/tk.lisp Tue May 23 20:43:02 2023 -0400 @@ -23,6 +23,6 @@ ,(funcall (get-macro-character #\`) stream nil))) -(eval-when (:execute) +(eval-when (:load-toplevel) (set-dispatch-macro-character #\# #\` #'demo:sbq-reader))