cl-yaclyaml

https://github.com/mabragor/cl-yaclyaml.git

git clone 'https://github.com/mabragor/cl-yaclyaml.git'

(ql:quickload :cl-yaclyaml)
6

cl-yaclyaml

Yet Another Common Lisp YaML processor (so far, only loader, but not dumper)

Tries to adhere to YAML 1.2 specification (see www.yaml.org)

High-level interface is provided by exported YAML-LOAD function.

CL-USER> (ql:quickload 'cl-yaclyaml)
CL-USER> (ql:quickload 'cl-interpol)
CL-USER> (cl-interpol:enable-interpol-syntax)
CL-USER> (cl-yy:yaml-load #?"- foo\n- bar\n- baz\n")
((:DOCUMENT ("foo" "bar" "baz")))

If you are sure, that your stream contains only one YAML document, use can also use

CL-USER> (cl-yy:yaml-simple-load #?"- foo\n- bar\n- baz\n")
("foo" "bar" "baz")

Loader supports optional SCHEMA keyword parameter, which can now be :FAILSAFE :JSON and :CORE (default) and affects tag implication and resolution.

Technically, process of loading is done in three stages: parsing of raw-text, composing of representation graph and construction of native language structures.

Also, (mainly for loading of config files) there is YAML-LOAD-FILE function

CL-USER> (cl-yy::yaml-load-file "~/.my-config.yml" :size-limit 100 :on-size-exceed :warn)

where SIZE-LIMIT (default 1024) is the critical size of file in bytes, above which parsing will not be performed (so as not to be DDoS'ed).

ON-SIZE-EXCEED can be either :ERROR (default), or :WARN or NIL. In case of :ERROR YAML-LOAD-FILE-ERROR is signalled, in case of :WARN warning is printed and NIL is returned, as if config file was absent, and in case of NIL, NIL is silently returned with no warning whatsoever.

TODO: