diff --git a/sample/cp.pl.xml b/sample/cp.pl.xml
new file mode 100644
index 0000000..f941bb7
--- /dev/null
+++ b/sample/cp.pl.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/error.rs b/src/error.rs
index b57f360..78e0293 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -24,11 +24,15 @@ impl fmt::Display for MissingAttribute {
impl Error for MissingAttribute {}
#[derive(Clone, Debug)]
-pub struct BadArgumentCount(pub &'static str, pub usize);
+pub struct BadArgumentCount(pub &'static str, pub usize, pub usize);
impl fmt::Display for BadArgumentCount {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "bad argument count ({}) in call to '{}'", self.1, self.0)
+ write!(
+ f,
+ "bad argument count ({}, expected {}) in call to '{}'",
+ self.1, self.2, self.0
+ )
}
}
diff --git a/src/stl.rs b/src/stl.rs
index 96389e5..8396105 100644
--- a/src/stl.rs
+++ b/src/stl.rs
@@ -2,11 +2,13 @@ use super::error::{BadArgumentCount, InvalidArgument};
use super::{Context, Value};
use std::cell::RefCell;
use std::error::Error;
-use std::io;
+use std::fs::{self, OpenOptions};
+use std::io::{stdin, stdout, Write};
use std::rc::Rc;
pub fn inject_all(ctx: &mut Context) {
ctx.assign(String::from("print"), Value::StdFunction(print));
+ ctx.assign(String::from("print-line"), Value::StdFunction(print_line));
ctx.assign(String::from("input"), Value::StdFunction(input));
ctx.assign(
String::from("string-split"),
@@ -23,9 +25,26 @@ pub fn inject_all(ctx: &mut Context) {
ctx.assign(String::from("to-ascii"), Value::StdFunction(to_ascii));
ctx.assign(String::from("from-ascii"), Value::StdFunction(from_ascii));
ctx.assign(String::from("get-args"), Value::StdFunction(get_args));
+ ctx.assign(String::from("write-file"), Value::StdFunction(write_file));
+ ctx.assign(String::from("read-file"), Value::StdFunction(read_file));
}
fn print(vals: Vec) -> Result