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§
- dyn_fns
- lexer
- mutex
- oxidizer
- 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. - runtime
- sasm
- std_fns
- stdlib
- stream
Macros§
- require_
array - require_
array_ on_ stack - require_
byte_ array_ on_ stack - require_
int_ on_ stack - require_
mut - require_
mut_ array - require_
mut_ array_ on_ stack - require_
mut_ on_ stack - require_
on_ stack - type_
err
Functions§
- add_std
- Include the standard library in a runtime-stack-pair, where the runtime has been .set().
- start_
file - 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.
- start_
file_ in_ runtime - TO START A STANDALONE PIECE OF CODE, USE start_file!! Lexes and starts some SPL code from a file, returning the stack.