7 releases (2 stable)
Uses new Rust 2024
| 1.0.1 | Oct 3, 2025 |
|---|---|
| 0.2.3 | Oct 3, 2025 |
| 0.2.2 | Sep 23, 2025 |
| 0.2.1 | Dec 23, 2024 |
| 0.1.0 | Jul 23, 2023 |
#1266 in Command line utilities
384 downloads per month
145KB
1K
SLoC
sexpfmt
S-expressions are easy for machines to write, but generating formatted S-expressions can be painful.
sexpfmt formats an input stream in a consistent way such that the output is both line-diffable and human-readable.
The formatting style used by sexpfmt is highly regular, unlike what many Lispers and Schemers prefer. Each indentation increments spaces by a fixed number of spaces (by default, 2).
(object
(object
(name "croissant")
(quantity 2))
(object
(name "latte")
(quantity 1)
(size "tall")))
The S-expression data format used is highly simplified compared to LISP's.
There is no support for quote, quasiquote, unquote, or dot pair-builders.
The character literal #\ (for space) is not supported either. Use #\space instead.
There is also no support for #1234 = ... expressions to construct graphs.
Setup and Installation
-
To build and install this tool, you will need
Cargoand a Rust toolchain. -
Navigate to the root of this repository with a shell, then run:
cargo install --path . -
To run tests, you will also need
bashandPython3
Example Usage
$ cat my-file.sexp | sexpfmt > my-formatted-file.sexp
$ ./build/my-sexp-generator-program arg1 arg2 | sexpfmt >> formatted-logfile.sexp
For examples of sexpfmt's behavior, see the test directory.
TODO
- allow command line options to specify...
- whether to print help and exit (e.g.
-hor--help) - whether to normalize bookend tokens
- the margin width and indent width.
- file input, directly map file using OS API to handle very large files.
- whether to print help and exit (e.g.
- preserve comments when parsing.
- consider whether to support more features like quote, quasiquote, unquote, pair building, etc.
- explicit support for labels, e.g.
(menu :version "0.1.2" :items (list ...))
- explicit support for labels, e.g.
- better documentation
- C API, binaries for easier integration into expect-testing in other languages.
Dependencies
~1–1.7MB
~35K SLoC