From c59b685f895df7cc90c366dc6d70ef6692df8168 Mon Sep 17 00:00:00 2001 From: Daniel Jay Haskin Date: Sat, 21 Oct 2023 11:34:55 -0600 Subject: [PATCH] Get the code to compile --- qlfile | 2 ++ qlfile.lock | 12 ++++++++++++ jfon.asd => skin.djha.jfon.asd | 8 ++++---- {jfon => src}/main.lisp | 32 ++++++++++++++++---------------- 4 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 qlfile create mode 100644 qlfile.lock rename jfon.asd => skin.djha.jfon.asd (80%) rename {jfon => src}/main.lisp (76%) diff --git a/qlfile b/qlfile new file mode 100644 index 0000000..f182427 --- /dev/null +++ b/qlfile @@ -0,0 +1,2 @@ +ql jzon +ql fset \ No newline at end of file diff --git a/qlfile.lock b/qlfile.lock new file mode 100644 index 0000000..075c212 --- /dev/null +++ b/qlfile.lock @@ -0,0 +1,12 @@ +("quicklisp" . + (:class qlot/source/dist:source-dist + :initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) + :version "2023-06-18")) +("jzon" . + (:class qlot/source/ql:source-ql + :initargs (:%version :latest) + :version "ql-2023-06-18")) +("fset" . + (:class qlot/source/ql:source-ql + :initargs (:%version :latest) + :version "ql-2023-06-18")) diff --git a/jfon.asd b/skin.djha.jfon.asd similarity index 80% rename from jfon.asd rename to skin.djha.jfon.asd index 70f08d5..5954786 100644 --- a/jfon.asd +++ b/skin.djha.jfon.asd @@ -8,15 +8,15 @@ #:trivial-features #:trivial-package-local-nicknames ) - :components ((:module "jfon" + :components ((:module "src" :components ( (:file "main") ))) :description "Port of com.inuoe.jzon to use FSet collections." - :in-order-to ((test-op (test-op "skin.djha.jfon/tests")))) + :in-order-to ((test-op (test-op #:skin.djha.jfon/tests)))) -(defsystem #:skin.djha.jfon/tests +(defsystem #:jfon/tests :version "0.1.0" :author "Daniel Jay Haskin" :license "MIT" @@ -30,4 +30,4 @@ :components ((:file "main")))) :description "Test system for jfon" - :perform (test-op (op c) (symbol-call :rove :run c))) + :perform (test-op (op c) (symbol-call :rove '#:run c))) diff --git a/jfon/main.lisp b/src/main.lisp similarity index 76% rename from jfon/main.lisp rename to src/main.lisp index 7aae3af..06233e4 100644 --- a/jfon/main.lisp +++ b/src/main.lisp @@ -1,6 +1,7 @@ (in-package #:cl-user) (defpackage - #:skin.djha.jfon (:use #:cl) + #:skin.djha.jfon + (:use #:cl) (:documentation " JZON for FSets @@ -9,34 +10,33 @@ (:export parse stringify) - (:import-from - #:fset) - (:package-local-nicknames (#:jzon #:com.inuoe.jzon))) + (:import-from #:fset) + (:local-nicknames (#:jzon #:com.inuoe.jzon))) (in-package #:skin.djha.jfon) ; Write a parser like jzon's `parse` except it outputs FSet maps and seqs. (defun parse-value (parser event value) - (declare (type jzon:parser parser)) (ecase event (:value value) (:begin-array (parse-array parser)) (:begin-object (parse-object parser)))) (defun parse-array (parser) - (declare (type jzon:parser parser)) (loop with result = (fset:empty-seq) - for event and value - do (setf (values event value) = (jzon:parse-next parser) + and event + and value + do (setf (values event value) (jzon:parse-next parser)) while (not (eq event :end-array)) do (fset:adjoinf result (parse-value parser event value)) finally - (return result)))) + (return result))) (defun parse-object (parser) - (declare (type jzon:parser parser)) + ;(declare (type jzon:parser parser)) (loop with result = (fset:empty-seq) - for event and value + and event + and value do (setf (values event value) (jzon:parse-next parser)) while (not (eq event :end-array)) do @@ -68,12 +68,12 @@ (jzon:write-value* thing)) (fset:seq (jzon:with-array* - (map nil #'recurse thing))) + (fset:do-seq (v thing) + (helper v)))) (fset:map (jzon:with-object* - (maphash (lambda (k v) - (jzon:write-key* k) - (helper v)) - thing)))))) + (fset:do-map (k v thing) + (jzon:write-key* k) + (helper v))))))) (jzon:with-writer* (:stream strm) (:pretty pretty) (helper thing)))) -- 2.45.2