Macro sexpr

Source
sexpr!() { /* proc-macro */ }
Expand description

Parse a string of a single s-expression into a kamo::value::Value.

The syntax is defined by the Scheme standard R7RS for the read procedure. For the deviations from the standard see the documentation of the macros crate.

The macro takes an optional MutatorRef identifier. This is used to allocate values on the heap. If the expression does not contain any values that need to be allocated on the heap, then the Mutator identifier can be omitted.

The syntax is sexpr!(<mutator>, <expression>).

§Examples

use kamo::{mem::Mutator, sexpr, value::{print, Value}};
  
let m = Mutator::new_ref();
let value = sexpr!(m, "(1 2 3)");
  
assert_eq!(print(value).to_string(), "(1 2 3)");