2023-02-18 01:53:48 +01:00
|
|
|
use spl::{lexer::lex, runtime::*};
|
2023-02-17 22:47:45 +01:00
|
|
|
|
2023-02-18 18:45:15 +01:00
|
|
|
use std::{fs, vec};
|
2023-02-17 20:00:39 +01:00
|
|
|
|
2023-02-17 22:47:45 +01:00
|
|
|
fn main() {
|
|
|
|
let rt = Runtime::new();
|
|
|
|
let mut stack = Stack::new();
|
2023-02-17 20:00:39 +01:00
|
|
|
rt.set();
|
|
|
|
Words {
|
|
|
|
words: vec![
|
2023-02-17 22:47:45 +01:00
|
|
|
Word::Key(Keyword::Func(
|
|
|
|
"println".to_owned(),
|
|
|
|
0,
|
|
|
|
Words {
|
|
|
|
words: vec![
|
|
|
|
Word::Call("print".to_owned(), true, 0),
|
2023-02-18 18:43:05 +01:00
|
|
|
Word::Const(Value::Str("\n".to_owned())),
|
2023-02-17 22:47:45 +01:00
|
|
|
Word::Call("print".to_owned(), true, 0),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
Word::Key(Keyword::Def("helloworld".to_owned())),
|
2023-02-18 18:43:05 +01:00
|
|
|
Word::Const(Value::Str("Hello, World".to_owned())),
|
2023-02-17 22:47:45 +01:00
|
|
|
Word::Call("=helloworld".to_owned(), false, 0),
|
|
|
|
Word::Call("helloworld".to_owned(), false, 0),
|
|
|
|
Word::Call("println".to_owned(), true, 0),
|
2023-02-17 20:00:39 +01:00
|
|
|
],
|
|
|
|
}
|
2023-02-17 22:47:45 +01:00
|
|
|
.exec(&mut stack);
|
2023-02-18 18:43:05 +01:00
|
|
|
let words = lex(
|
|
|
|
fs::read_to_string("test.spl").unwrap(),
|
|
|
|
"test.spl".to_owned(),
|
|
|
|
stack.get_frame(),
|
|
|
|
);
|
|
|
|
println!("{words:?}");
|
|
|
|
words.exec(&mut stack);
|
2023-02-17 20:00:39 +01:00
|
|
|
Runtime::reset();
|
|
|
|
}
|