fix broken link in readme
refactor file parsing, tests
refactor txtar parser to use record-based state management
txtar enables you to work with a simple text archive format compatible with Go's txtar. It concatenates files together and allows for a top-level comment.
Math implementation
-- math.h --
#ifndef MATH_H
#define MATH_H
int add(int a, int b);
#endif
-- math.c --
#include "math.h"
int add(int a, int b) {
return a + b;
}
This format is easy for humans to read and write by hand and is perfect for test data.
# Install the library.
$ make install
# Add the library directory to your CHEZSCHEMELIBDIRS.
$ export CHEZSCHEMELIBDIRS="$HOME/.local/lib/chez-scheme:$CHEZSCHEMELIBDIRS"
If you want to remove the library from your system, simply run make uninstall
.
This library requires:
;; For using it.
(srfi s13 strings)
;; For running the tests only.
(srfi s64 testing)
You can obtain these libraries and many more via Thunderchez:
$ git clone https://github.com/ovenpasta/thunderchez
# Add the library directory to your CHEZSCHEMELIBDIRS.
$ export CHEZSCHEMELIBDIRS=/path/to/thunderchez
All the exports of this library are documented with type expectations. I encourage you to scan the implementation.
A few common example usecases are presented below for convenience:
To use this library, simply import txtar
:
(import (txtar))
(txtar-read-files "Test files" '("test1.txt" "test2.txt"))
(let* ([files
(list
(make-txtar-file "math.h" "#ifndef MATH_H\n#define MATH_H\n\nint add(int a, int b);\n\n#endif")
(make-txtar-file "math.c" "#include \"math.h\"\n\nint add(int a, int b) {\n return a + b;\n}"))]
[archive (make-txtar-archive "Math implementation" files)]
[output-port (open-output-file "math.txtar")])
(txtar-write archive output-port)
(close-output-port output-port))
(let ([file (txtar-file-ref archive "file-in-the-archive.txt")])
(if file
(display "the file existed")
(display "the file did not exist")))
Copyright (C) 2025 Evan Tann, ParaVoce LLC
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.