interpreter: Break out into a separate crate

My editor's performance was tanking because of macro interpreter::builtins::builtin!

Temporary solution: move the interpreter into a separate crate

If I intended to keep the interpreter around, in the long-term, it might be an idea to make a proc-macro for builtin expansion.
However, the only reason I need the macros is because the interpreter's dynamic typing implementation is so half-baked. After I bang out the new type checker/inference engine, I'll have to rewrite the entire interpreter anyway!
This commit is contained in:
2024-02-29 17:51:38 -06:00
parent 5eb6411d53
commit 421aab3aa2
10 changed files with 492 additions and 478 deletions

View File

@@ -11,4 +11,5 @@ publish.workspace = true
[dependencies]
conlang = { path = "../libconlang" }
cl-interpret = { path = "../cl-interpret" }
crossterm = "0.27.0"

View File

@@ -69,18 +69,17 @@ pub mod args {
}
pub mod program {
use std::{fmt::Display, io::Write};
use cl_interpret::{
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::ConValue,
};
use conlang::{
ast::{self, ast_impl::format::Pretty},
interpreter::{
env::Environment, error::IResult, interpret::Interpret, temp_type_impl::ConValue,
},
// pretty_printer::{PrettyPrintable, Printer},
lexer::Lexer,
parser::{error::PResult, Parser},
resolver::{error::TyResult, Resolver},
};
use std::{fmt::Display, io::Write};
pub struct Parsable;
@@ -190,12 +189,12 @@ pub mod program {
}
pub mod cli {
use conlang::{interpreter::env::Environment, resolver::Resolver, token::Token};
use crate::{
args::Args,
program::{Parsable, Parsed, Program},
};
use cl_interpret::env::Environment;
use conlang::{resolver::Resolver, token::Token};
use std::{
convert::Infallible,
error::Error,
@@ -230,7 +229,7 @@ pub mod cli {
let code = conlang::parser::Parser::new(conlang::lexer::Lexer::new(&prog))
.file()
.unwrap();
let mut env = conlang::interpreter::env::Environment::new();
let mut env = cl_interpret::env::Environment::new();
env.eval(&code).unwrap();
env.call("dump", &[])
.expect("calling dump in the environment shouldn't fail");