Expand description
Using SPL as a crate
SPL has a complete API for use in applications and libraries.
To start a file, use start_file
with the path, which is relatively straightforward, just like
start_file_in_runtime
, which is the same as start_file
but doesn’t create and set a
runtime.
To start code more customizably, you will have to create a stack and a runtime yourself, then
call add_std
to include the standard library.
Example:
use spl::*;
fn main() -> OError {
Runtime::new().set();
let mut stack = Stack::new();
add_std(&mut stack)?;
Words::new(vec![
Word::Const(Value::Str("Hello, World!".to_owned())),
Word::Call("println".to_owned(), /*pop result:*/ false, /*reference:*/ 0)
]).exec(&mut stack);
Ok(())
}
Re-exports
Modules
- This module creates a rust application that runs the desired SPL. At its current stage, this is just parsing and rewriting
@rust
functions from SPL into actual rust. The future plan is for this to effectively become a compiler.
Macros
Functions
- Include the standard library in a runtime-stack-pair, where the runtime has been .set().
- Creates a runtime, lexes and executes some SPL code from a file, returning the stack that was used for the operations, which should be empty in most cases.
- TO START A STANDALONE PIECE OF CODE, USE start_file!! Lexes and starts some SPL code from a file, returning the stack.