Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-yaml Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:10:24 2022 GMT+0.
Next: Systems, Previous: The cl-yaml Reference Manual, Up: The cl-yaml Reference Manual [Contents][Index]
A YAML parser and emitter built on top of libyaml. Uses the cl-libyaml library.
The yaml
package exports three functions:
(parse string-or-pathname)
: Parses a string or a pathname into Lisp values.(emit value stream)
: Emit a Lisp value into a stream.(emit-to-string value)
: Emit a Lisp value into a string.CL-USER> (yaml:parse "[1, 2, 3]")
(1 2 3)
CL-USER> (yaml:parse "{ a: 1, b: 2 }")
{"a" => 1, "b" => 2}
CL-USER> (yaml:parse "- Mercury
- Venus
- Earth
- Mars")
("Mercury" "Venus" "Earth" "Mars")
CL-USER> (yaml:parse "foo
---
bar" :multi-document-p t)
(:DOCUMENTS "foo" "bar")
CL-USER> (yaml:emit-to-string (list 1 2 3))
"[1, 2, 3]"
CL-USER> (yaml:emit-to-string
(alexandria:alist-hash-table '(("a" . 1)
("b" . 2))))
"{ b: 2, a: 1 }"
CL-USER> (yaml:emit (list t 123 3.14) *standard-output*)
[true, 123, 3.14]
cl-yaml uses YAML's Core Schema to map YAML values to Lisp types an vice versa. A table showing the correspondence of values and types is shown below:
| YAML type | Lisp type |
| ---------- | ----------------- |
| Null | nil
|
| Boolean | t
and nil
|
| Integer | Integer |
| Float | Double float |
| String | String |
| List | List |
| Map | Hash table |
| Document | (:document ...)
|
Common Lisp doesn't natively support the IEEE special floating point values: NaN (Not a number), positive infinity and negative infinity are unrepresentable in portable Common Lisp. Since YAML allows documents to include these values, we have to figure out what to do with them. cl-yaml supports multiple float strategies.
The default strategy is :keyword
, which uses keywords to represent these
values. The strategy can be customized by setting the value of
yaml.float:*float-strategy*
to one of the following keywords:
:error
: The simplest approach, simply signal the condition
yaml.error:unsupported-float-value
whenever a NaN or infinity value is
encountered.
:keyword
: Use keywords to represent the different values, i.e.: :NaN
for
NaN, :+Inf
for positive infinity and :-Inf
for negative infinity.
:best-effort
: Use implementation-specific values whenever possible, fall
back on :keyword
in unsupported implementations. On SBCL and Allegro Common
Lisp, NaN and infinity can be represented.
Copyright (c) 2013-2015 Fernando Borretti
Licensed under the MIT License.
Next: Modules, Previous: Introduction, Up: The cl-yaml Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
A YAML parser and emitter.
Fernando Borretti <eudoxiahp@gmail.com>
Fernando Borretti <eudoxiahp@gmail.com>
(GIT git@github.com:eudoxia0/cl-yaml.git)
MIT
# cl-yaml
[](https://travis-ci.org/eudoxia0/cl-yaml)
[](https://coveralls.io/r/eudoxia0/cl-yaml?branch=master)
[](http://quickdocs.org/cl-yaml/)
A YAML parser and emitter built on top of [libyaml][libyaml]. Uses the
[cl-libyaml][cl-libyaml] library.
# Usage
The ‘yaml‘ package exports three functions:
* ‘(parse string-or-pathname)‘: Parses a string or a pathname into Lisp values.
* ‘(emit value stream)‘: Emit a Lisp value into a stream.
* ‘(emit-to-string value)‘: Emit a Lisp value into a string.
## Parsing
“‘lisp
CL-USER> (yaml:parse "[1, 2, 3]")
(1 2 3)
CL-USER> (yaml:parse "{ a: 1, b: 2 }")
{"a" => 1, "b" => 2}
CL-USER> (yaml:parse "- Mercury
- Venus
- Earth
- Mars")
("Mercury" "Venus" "Earth" "Mars")
CL-USER> (yaml:parse "foo
—
bar" :multi-document-p t)
(:DOCUMENTS "foo" "bar")
“‘
## Emitting
“‘lisp
CL-USER> (yaml:emit-to-string (list 1 2 3))
"[1, 2, 3]"
CL-USER> (yaml:emit-to-string
(alexandria:alist-hash-table ’(("a" . 1)
("b" . 2))))
"{ b: 2, a: 1 }"
CL-USER> (yaml:emit (list t 123 3.14) *standard-output*)
[true, 123, 3.14]
“‘
# Documentation
## Type Mapping
cl-yaml uses YAML’s [Core Schema][core-schema] to map YAML values to Lisp types
an vice versa. A table showing the correspondence of values and types is shown
below:
| YAML type | Lisp type |
| ———- | —————– |
| Null | ‘nil‘ |
| Boolean | ‘t‘ and ‘nil‘ |
| Integer | Integer |
| Float | Double float |
| String | String |
| List | List |
| Map | Hash table |
| Document | ‘(:document ...)‘ |
## IEEE Floating Point Support
Common Lisp doesn’t natively support the IEEE special floating point values: NaN
(Not a number), positive infinity and negative infinity are unrepresentable in
portable Common Lisp. Since YAML allows documents to include these values, we
have to figure out what to do with them. cl-yaml supports multiple float
strategies.
The default strategy is ‘:keyword‘, which uses keywords to represent these
values. The strategy can be customized by setting the value of
‘yaml.float:*float-strategy*‘ to one of the following keywords:
1. ‘:error‘: The simplest approach, simply signal the condition
‘yaml.error:unsupported-float-value‘ whenever a NaN or infinity value is
encountered.
2. ‘:keyword‘: Use keywords to represent the different values, i.e.: ‘:NaN‘ for
NaN, ‘:+Inf‘ for positive infinity and ‘:-Inf‘ for negative infinity.
3. ‘:best-effort‘: Use implementation-specific values whenever possible, fall
back on ‘:keyword‘ in unsupported implementations. On SBCL and Allegro Common
Lisp, NaN and infinity can be represented.
[core-schema]: http://www.yaml.org/spec/1.2/spec.html#id2804923
[libyaml]: http://pyyaml.org/wiki/LibYAML
[cl-libyaml]: https://github.com/eudoxia0/cl-libyaml
# License
Copyright (c) 2013-2015 Fernando Borretti
Licensed under the MIT License.
0.1
src (module).
Next: Files, Previous: Systems, Up: The cl-yaml Reference Manual [Contents][Index]
Modules are listed depth-first from the system components tree.
cl-yaml (system).
Next: Packages, Previous: Modules, Up: The cl-yaml Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: cl-yaml/src/error.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
cl-yaml (system).
Next: cl-yaml/src/float.lisp, Previous: cl-yaml/cl-yaml.asd, Up: Lisp [Contents][Index]
src (module).
Next: cl-yaml/src/scalar.lisp, Previous: cl-yaml/src/error.lisp, Up: Lisp [Contents][Index]
error.lisp (file).
src (module).
*sbcl-nan-value* (special variable).
Next: cl-yaml/src/parser.lisp, Previous: cl-yaml/src/float.lisp, Up: Lisp [Contents][Index]
float.lisp (file).
src (module).
parse-scalar (function).
Next: cl-yaml/src/emitter.lisp, Previous: cl-yaml/src/scalar.lisp, Up: Lisp [Contents][Index]
scalar.lisp (file).
src (module).
Next: cl-yaml/src/yaml.lisp, Previous: cl-yaml/src/parser.lisp, Up: Lisp [Contents][Index]
parser.lisp (file).
src (module).
Previous: cl-yaml/src/emitter.lisp, Up: Lisp [Contents][Index]
emitter.lisp (file).
src (module).
Next: Definitions, Previous: Files, Up: The cl-yaml Reference Manual [Contents][Index]
Packages are listed by definition order.
Next: yaml.error, Previous: Packages, Up: Packages [Contents][Index]
The main YAML interface.
yaml
common-lisp.
Next: yaml.emitter, Previous: cl-yaml, Up: Packages [Contents][Index]
YAML errors.
common-lisp.
Next: yaml.float, Previous: yaml.error, Up: Packages [Contents][Index]
The YAML emitter.
common-lisp.
Next: yaml.parser, Previous: yaml.emitter, Up: Packages [Contents][Index]
Handle IEEE floating point values.
common-lisp.
*sbcl-nan-value* (special variable).
Next: yaml.scalar, Previous: yaml.float, Up: Packages [Contents][Index]
The YAML parser.
common-lisp.
Previous: yaml.parser, Up: Packages [Contents][Index]
Parser for scalar values.
common-lisp.
parse-scalar (function).
Next: Indexes, Previous: Packages, Up: The cl-yaml Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Macros, Previous: Public Interface, Up: Public Interface [Contents][Index]
Next: Ordinary functions, Previous: Special variables, Up: Public Interface [Contents][Index]
Next: Generic functions, Previous: Macros, Up: Public Interface [Contents][Index]
Emit a value to a stream.
Emit a value to string.
Parse a YAML scalar string into a Lisp scalar value.
Next: Conditions, Previous: Ordinary functions, Up: Public Interface [Contents][Index]
Emit YAML representation of obj
Write the YAML corresponding to value to a stream.
Encode a hash table.
Encode a vector.
Encode a list.
Encode a string.
Encode a float.
Encode an integer.
Encode false.
Encode true.
line.
Parse a YAML string or a pathname to a YAML file into Lisp data.
Convert a scalar object into its printed representation
Previous: Generic functions, Up: Public Interface [Contents][Index]
An error when parsing a YAML file.
This condition is signalled when the parser receives an IEEE
floating point special value it cannot parse. This is only signalled when the
floating point strategy is :error.
The base class of all YAML conditions.
condition.
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Ordinary functions, Previous: Internals, Up: Internals [Contents][Index]
The falsehood constant. Nil by default.
The NULL constant. Nil by default.
Previous: Special variables, Up: Internals [Contents][Index]
Parse a YAML string, returning a list of tokens.
Previous: Definitions, Up: The cl-yaml Reference Manual [Contents][Index]
Jump to: | C D E F G L M N P R S W |
---|
Jump to: | C D E F G L M N P R S W |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | *
+
C L M S |
---|
Jump to: | *
+
C L M S |
---|
Jump to: | C E F M P S U Y |
---|
Jump to: | C E F M P S U Y |
---|