@raviqqe/stak 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,12 +39,32 @@ cargo install stak-interpret
|
|
|
39
39
|
|
|
40
40
|
### Running a Scheme script
|
|
41
41
|
|
|
42
|
+
First, prepare a Scheme script at `src/hello.scm`.
|
|
43
|
+
|
|
44
|
+
```scheme
|
|
45
|
+
(import (scheme base))
|
|
46
|
+
|
|
47
|
+
(write-string "Hello, world!\n")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then, add a build script at `build.rs` to build the Scheme source file into bytecodes.
|
|
51
|
+
|
|
52
|
+
```rust no_run
|
|
53
|
+
use stak_build::{build_r7rs, BuildError};
|
|
54
|
+
|
|
55
|
+
fn main() -> Result<(), BuildError> {
|
|
56
|
+
build_r7rs()
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Now, you can include the Scheme script into a program in Rust using [the `stak::include_bytecode` macro](https://docs.rs/stak/latest/stak).
|
|
61
|
+
|
|
42
62
|
```rust
|
|
43
63
|
use core::error::Error;
|
|
44
64
|
use stak::{
|
|
45
|
-
build::include_bytecode,
|
|
46
65
|
device::StdioDevice,
|
|
47
66
|
file::VoidFileSystem,
|
|
67
|
+
include_bytecode,
|
|
48
68
|
process_context::VoidProcessContext,
|
|
49
69
|
r7rs::{SmallError, SmallPrimitiveSet},
|
|
50
70
|
time::VoidClock,
|