1
0
Fork
You've already forked scheme.rs
0
Static Scheme API wrapper for Rust.
  • Rust 100%
higuy apzhyn 8a11af91bd readme
2026年06月28日 20:40:35 +02:00
src pair isnt copy cuz i never derive it 2026年06月28日 20:33:00 +02:00
tests tests folder 2026年06月28日 20:38:10 +02:00
vendor Add vendor/scheme.c 2026年06月17日 13:25:10 +02:00
.gitignore stuff 2026年06月28日 20:31:49 +02:00
build.rs stuffs 2026年06月28日 20:31:28 +02:00
Cargo.toml rename cuz scheme-rs is already took 2026年06月28日 20:38:49 +02:00
LICENSE wtfpl 2026年06月28日 20:36:48 +02:00
README.md readme 2026年06月28日 20:40:35 +02:00

scheme-rs

FFI bindings to a minimal C s-expression parser. No interpreter, no eval, no macros - just lexing and parsing into a tree you can walk. Built for config/DSL use cases (service definitions, port metadata), not for running Scheme.

Usage

usescheme::{parse,parse_all};letsrc=r#"(service (name "nginx") (deps "network") (backoff 1 2 4 8))"#;letexpr=parse(src).unwrap();println!("{:?}",expr);fortop_levelinparse_all(src){foritemintop_level.items(){// walk pairs
}}

Types

pubenum Expr{Sym(String),Str(String),Num(i64),Float(f64),Bool(bool),Pair(Box<Expr>,Box<Expr>),Nil,}

Cons-cell pairs, not vectors - .items() walks a proper list into a Vec<&Expr> for convenience. Improper lists ((a b . c)) will silently drop the tail; don't feed it those.

as_sym, as_str, as_num, as_float, as_bool give you Option<_> accessors instead of matching by hand every time.

Supported syntax

  • Symbols: foo, on-failure
  • Strings: "daemon off;" (basic escape handling)
  • Integers: 1, -4
  • Floats: 1.5
  • Booleans: #t, #f
  • Lists: (a b c), nested freely
  • Comments: ; line comment

No quoting, no vectors, no chars, no bignums. If you need more than this, you want a real Scheme implementation, not this.

Build

Vendors and compiles a small C parser (vendor/scheme.c) via cc at build time. No system dependency on a Scheme runtime, no dynamic linking.

License

WTFPL.