This commit is contained in:
Able 2024-12-10 03:00:19 -06:00
parent d864105507
commit 90d2a140e1
12 changed files with 247 additions and 15 deletions

16
Cargo.lock generated
View file

@ -18,8 +18,22 @@ dependencies = [
]
[[package]]
name = "rlisp"
name = "rlbuild"
version = "0.1.0"
dependencies = [
"rlisp_library",
]
[[package]]
name = "rlisp_library"
version = "0.1.0"
dependencies = [
"hashbrown",
]
[[package]]
name = "rlisp_repl"
version = "0.1.0"
dependencies = [
"rlisp_library",
]

11
Cargo.toml Executable file → Normal file
View file

@ -1,10 +1,3 @@
[package]
name = "rlisp"
version = "0.1.0"
edition = "2021"
[workspace]
[dependencies]
hashbrown = { version = "0.15", default-features = false, features = [
# "alloc",
"default-hasher",
] }
members = [ "rlbuild","rlisp_library", "rlisp_repl"]

7
rlbuild/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "rlbuild"
version = "0.1.0"
edition = "2024"
[dependencies]
rlisp_library = { path = "../rlisp_library" }

126
rlbuild/assets/system.rlisp Normal file
View file

@ -0,0 +1,126 @@
(def use-repo (fn (a b) (print a b)))
;; (def window-system (fn (a) (start-driver a)))
;; (def window-system (fn (a) (start-driver a)))
;;;;;;;;;;;
;; Repos ;;
;;;;;;;;;;;
;; This is the core repo that is used for core things like networking ;;
(use-repo core "https://repo.ablecorp.us/core")
;; Add a secondary repo ;;
;; (use-repo able "https://repo.ablecorp.us/able")
;; Set the default pkg-install to be binary ;;
(pkg-defaults binary:true)
;; Install compilers ;;
;; pkg-install <repo> <pkg-name>
;; pkg-name : A string or atom to search.
(pkg-install core hblang2)
;; Install the rust compiler ;;
(pkg-install core rustc)
(pkg-install core clang)
;;;;;;;;;;;;;;;
;; Compilers ;;
;;;;;;;;;;;;;;;
;; Set default compilers to use ;;
;; the dev tool pulls from this ;;
(compilers
)
;; hblang: 'hblang2
;; rust: 'rustc
;; Clang is not supported :thumbsup:
;; c: 'clang
;;;;;;;;;;;;;;;;;
;; Boot Loader ;;
;;;;;;;;;;;;;;;;;
(pkg-install core limine)
(def limine_res (resolution 1024 768 24))
(boot-loader
(default-entry 1)
(timeout 0)
(interface_resolution: 'limine_res))
(boot-loader-entry "ableos"
(comment "Default AbleOS boot entry.")
(protocol "limine")
(kernel_path "boot:///kernel_${ARCH}")
(kernel_cmdline "")
(resolution 'limine_res))
(boot-loader-entry "ableos-no-cluster"
(comment "Default AbleOS boot entry.")
(protocol "limine")
(kernel_path "boot:///kernel_${ARCH}")
(kernel_cmdline "cluster=false")
(resolution 'limine_res))
;;;;;;;;;;;;;;;;;;;;
;; Kernel Options ;;
;;;;;;;;;;;;;;;;;;;;
;; A kernel package is required
(pkg-install core kernel-rust)
;; Set the kernel to be used by ableOS ;;
;; Maybe set a default if this isn't set? ;;
;; Must be installed already ;;
(kernel 'kernel-rust)
;;;;;;;;;;;;
;; Config ;;
;;;;;;;;;;;;
;; Install packages ;;
(pkg-install core sunset)
(pkg-install core ps2-driver)
;; A list of programs to run on startup ;;
(start ())
;; A list of programs to add to the driver supervisor ;;
(start-driver (ps2-driver))
;; Set the window system to be used by ableOS ;;
;; Must be installed already ;;
;; adds the window system to the driver supervisor ;;
(def window-system (fn (a) (start-driver a)))
(window-system sunset)
;;;;;;;;;;;;;;;;
;; Networking ;;
;;;;;;;;;;;;;;;;
(networking
;; set the network hostname
;; TODO Namespace this somehow ;;
(hostname "ableOS")
;; use dhcp to find an ip ;;
(ipv4 dhcp)
(ipv6 dhcp)
;; Set the time server ;;
(ntp "time.nist.gov")
(dns 'router-dns-steal))
;;;;;;;;;;;;;;;;;;;;;;
;; Cluster Software ;;
;;;;;;;;;;;;;;;;;;;;;;
;; Install the cluster software ;;
(pkg-install core cluster)
;; Defaults to false ;;
(cluster enabled:false)

78
rlbuild/src/main.rs Normal file
View file

@ -0,0 +1,78 @@
#![feature(slice_take)]
#![allow(special_module_name)]
// use std::io;
// use std::io::Write;
use rlisp_library::{Environ, Expr, RispError, default_env, env_get, parse_eval};
fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
"quit".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
// TODO: let this function take in arguments
println!("Exiting.");
std::process::exit(0);
#[allow(unreachable_code)]
Err(RispError::Reason("Cannot exit process".to_string()))
}),
);
env.data.insert(
"print".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = format!("{}", arg);
stri.push_str(&fmted);
stri.push_str(" ")
}
Ok(Expr::Symbol(stri.to_string()))
}),
);
env
}
fn main() {
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
let cfg = include_str!("../assets/system.rlisp");
let mut complete_exprs: Vec<String> = vec![];
let mut left_parens = 0;
let mut idx_of_first_left_paran = 0;
for (i, character) in cfg.chars().enumerate() {
if character == '(' {
// println!("OPEN");
if left_parens == 0 {
idx_of_first_left_paran = i
}
left_parens += 1
}
if character == ')' {
// println!("CLOSE");
if left_parens == 0 {
let idx_of_last_right_paran = i + 1;
complete_exprs
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
}
left_parens -= 1
}
}
for expr in complete_exprs {
println!("{}", expr);
match parse_eval(expr, env) {
Ok(res) => println!("-> {}", res),
Err(e) => match e {
RispError::Reason(msg) => println!("Found Error {}", msg),
},
}
}
}

10
rlisp_library/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "rlisp_library"
version = "0.1.0"
edition = "2024"
[dependencies]
hashbrown = { version = "0.15", default-features = false, features = [
# "alloc",
"default-hasher",
] }

7
rlisp_repl/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "rlisp_repl"
version = "0.1.0"
edition = "2024"
[dependencies]
rlisp_library = { path = "../rlisp_library" }

View file

@ -1,13 +1,10 @@
#![feature(slice_take)]
#![allow(special_module_name)]
#![feature(build_hasher_default_const_new)]
// #![no_std]
use std::io;
use std::io::Write;
mod lib;
use lib::*;
use rlisp_library::{Environ, Expr, RispError, default_env, env_get, parse_eval};
fn slurp_expr() -> String {
let mut expr = String::new();
@ -54,7 +51,7 @@ fn main() {
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
loop {
let prompt = env_get("prompt", env).unwrap_or(lib::Expr::Symbol("rlisp => ".to_string()));
let prompt = env_get("prompt", env).unwrap_or(Expr::Symbol("rlisp => ".to_string()));
print!("{}", prompt);
let _ = std::io::stdout().flush();
let expr = slurp_expr();