From 8a6d8b144f45c509602a598f962d872a98226997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 21 Jan 2021 21:56:29 +0100 Subject: call external functions without parameters --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d5cb465..7909eb9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; use tihdy::run_file; +use tihdy::vm::Value; struct Args { file: Option, @@ -10,7 +11,7 @@ struct Args { fn main() { let args = parse_args(); let file = args.file.unwrap_or_else(|| Path::new("tests/simple.tdy").to_owned()); - if let Err(errs) = run_file(&file, args.print) { + if let Err(errs) = run_file(&file, args.print, vec![(String::from("hello"), hello)]) { for err in errs.iter() { println!("{}", err); } @@ -36,3 +37,8 @@ fn parse_args() -> Args { }; args } + +pub fn hello(_parameters: &[Value]) -> Value { + println!("Hello World!"); + Value::Nil +} -- cgit v1.2.1