aboutsummaryrefslogtreecommitdiff
path: root/crates/sloth_vm/src/sloth_std/stdio.rs
diff options
context:
space:
mode:
authornic-gaffney <gaffney_nic@protonmail.com>2023-04-27 17:19:54 -0500
committernic-gaffney <gaffney_nic@protonmail.com>2023-04-27 17:19:54 -0500
commitac8c9abab30d66ff208a623d0a6de8869373a554 (patch)
tree8d2d20d9a5312a1e2fad73d9a6ee7294b0c27dc2 /crates/sloth_vm/src/sloth_std/stdio.rs
parent757e804671ef3dcb2e0f1295e385780b5feae2ca (diff)
parentaf02ccd056754c60131d13d74b9fac0e23b2af31 (diff)
downloadsloth-ac8c9abab30d66ff208a623d0a6de8869373a554.tar.gz
Merge branch 'standard-library' of github.com-Nic:slothlang/sloth into standard-library
Diffstat (limited to 'crates/sloth_vm/src/sloth_std/stdio.rs')
-rw-r--r--crates/sloth_vm/src/sloth_std/stdio.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/sloth_vm/src/sloth_std/stdio.rs b/crates/sloth_vm/src/sloth_std/stdio.rs
index 75029bd..f56b604 100644
--- a/crates/sloth_vm/src/sloth_std/stdio.rs
+++ b/crates/sloth_vm/src/sloth_std/stdio.rs
@@ -28,6 +28,10 @@ pub const WRITE_FUNCTION: NativeFunction = NativeFunction {
function: write,
arity: 1,
returns_value: false,
+ doc: Some(
+ "NativeFunction write: \n\targs: string (str)\n\tdesc: Writes <string> to the \
+ terminal.\n\tExample: `write(\"I'm sleepy...\"); # Output: I'm sleepy...`",
+ ),
};
fn writeln(vm: &mut VM, args: &[Primitive]) -> NativeFunctionResult {
@@ -54,6 +58,11 @@ pub const WRITELN_FUNCTION: NativeFunction = NativeFunction {
function: writeln,
arity: 1,
returns_value: false,
+ doc: Some(
+ "NativeFunction writeln: \n\targs: string (str)\n\tdesc: Writes <string> to the terminal \
+ and starts a new line.\n\tExample: `writeln(\"I'm sleepy...\"); # Output: I'm \
+ sleepy...\n # This is a new line`",
+ ),
};
fn read(vm: &mut VM, _args: &[Primitive]) -> NativeFunctionResult {
@@ -74,4 +83,9 @@ pub const READ_FUNCTION: NativeFunction = NativeFunction {
function: read,
arity: 0,
returns_value: true,
+ doc: Some(
+ "NativeFunction read:\n\tdesc: Reads input from the terminal and returns what was \
+ read.\n\tExample: `var input = read(); # Hello World <execute code> input = 'Hello \
+ World'`",
+ ),
};