Clean up
This commit is contained in:
parent
b392a4c7aa
commit
7dfc026be5
@ -6,21 +6,9 @@ use std::{
|
||||
use crate::{
|
||||
abstract_tree::{Identifier, Type},
|
||||
error::{RwLockPoisonError, ValidationError},
|
||||
Interpreter, Value,
|
||||
Value,
|
||||
};
|
||||
|
||||
pub fn std_context() -> Context {
|
||||
let context = Context::new();
|
||||
let mut interpreter = Interpreter::new(context.clone());
|
||||
|
||||
interpreter.run(include_str!("../../std/io.ds")).unwrap();
|
||||
interpreter
|
||||
.run(include_str!("../../std/thread.ds"))
|
||||
.unwrap();
|
||||
|
||||
context
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Context {
|
||||
inner: Arc<RwLock<BTreeMap<Identifier, ValueData>>>,
|
||||
|
@ -6,15 +6,17 @@ pub mod lexer;
|
||||
pub mod parser;
|
||||
pub mod value;
|
||||
|
||||
use context::{std_context, Context};
|
||||
use context::Context;
|
||||
use error::Error;
|
||||
use lexer::lex;
|
||||
use parser::parse;
|
||||
pub use value::Value;
|
||||
|
||||
pub fn interpret(source: &str) -> Result<Option<Value>, Vec<Error>> {
|
||||
let mut interpreter = Interpreter::new(std_context());
|
||||
let mut interpreter = Interpreter::new(Context::new());
|
||||
|
||||
interpreter.run(include_str!("../../std/io.ds"))?;
|
||||
interpreter.run(include_str!("../../std/thread.ds"))?;
|
||||
interpreter.run(source)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user