Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chee/kdlcl
KDL reader/printer for common lisp
https://github.com/chee/kdlcl
common-lisp kdl
Last synced: about 1 month ago
JSON representation
KDL reader/printer for common lisp
- Host: GitHub
- URL: https://github.com/chee/kdlcl
- Owner: chee
- License: mit-0
- Created: 2023-03-15T02:10:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-15T23:57:55.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T04:45:41.416Z (9 months ago)
- Topics: common-lisp, kdl
- Language: Common Lisp
- Homepage:
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.org
- License: LICENSE
Awesome Lists containing this project
README
* kdlcl
[[https://kdl.dev/][KDL]] reader/writer for Common Lisp.
** Interface
*** Reading a document#+begin_src lisp
(in-package :kdl-user)
(read-document stream) ; dispatches to `from-stream'
(read-document string) ; dispatches to `from-string'
(read-document filespec) ; dispatches to `from-file'
#+end_src*** Working with the document
These getters all have =setf= forms too.
#+begin_src lisp
(in-package :kdl-user);; Get the value from a value cons cell
(value value);; Get the type from a value cons cell
(value-type value);; Get the name of a property
(property-name property);; Get the value from a property
(property-value property);; Get the value-type from a property
(property-type property);; Get the name of a node
(node-name node);; Get the properties from a node
(node-properties node);; Get the children from a node
(node-children node);; get the second child
(node-child node 1);; Get the type of a node
(node-type node)
#+end_src*** Writing the document
#+begin_src lisp
(in-package :kdl-user)
(to-stream kdl-document)
(to-string kdl-document)
(to-file kdl-document)
#+end_src** Quirks
This implementation of KDL is spec-compliant, but the test-cases differ from the
[[https://github.com/kdl-org/kdl/tree/main/tests/test_cases][official test-cases]] is a few ways:*** Properties
Like [[https://github.com/kdl-org/kdl-rs][kdl-rs]], multiple properties with the same name are allowed and all
duplicated *will be preserved*.*** Really large numbers
Very big floats max out at =*most-positive-double-float*=.
For example:
- Input :: =chubby-number 1e1000=
- Output :: =chubby-number 1.7976931348623157e308=*** Exponent representation
- Exponents use lowercase e
- official tests :: ~1.1E-100~
- :kdl/t :: ~1.1e-100~
- Positive exponents have no plus
- official tests :: ~1.1E+100~
- :kdl/t :: ~1.1e100~
- Non-integer numbers always have a decimal point:
- official tests :: ~1E+100~
- :kdl/t :: ~1.0e100~
**** Lisp implementation differencesThe tests for the exponent formats are based on the output from SBCL. The
library works on at least GNU CLISP and ECL, but the floating point number
output is in a different format. For instance, ECL prints the floats in this
cute fashion: ~1.e10~.I haven't been able to test on any other implementations yet because I can't get
them running on my computer :o(** [[file:LICENSE][License]]
[[https://spdx.org/licenses/MIT-0.html][MIT-0]]