From 90d2a140e1a2d22cc38f62dcbe307bd9acb7131d Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 10 Dec 2024 03:00:19 -0600 Subject: [PATCH] comit --- Cargo.lock | 16 ++- Cargo.toml | 11 +- rlbuild/Cargo.toml | 7 ++ rlbuild/assets/system.rlisp | 126 ++++++++++++++++++++++ rlbuild/src/main.rs | 78 ++++++++++++++ rlisp_library/Cargo.toml | 10 ++ {src => rlisp_library/src}/environ.rs | 0 {src => rlisp_library/src}/evaluate.rs | 0 {src => rlisp_library/src}/lib.rs | 0 {src => rlisp_library/src}/parser.rs | 0 rlisp_repl/Cargo.toml | 7 ++ src/main.rs.bak => rlisp_repl/src/main.rs | 7 +- 12 files changed, 247 insertions(+), 15 deletions(-) mode change 100755 => 100644 Cargo.toml create mode 100644 rlbuild/Cargo.toml create mode 100644 rlbuild/assets/system.rlisp create mode 100644 rlbuild/src/main.rs create mode 100644 rlisp_library/Cargo.toml rename {src => rlisp_library/src}/environ.rs (100%) rename {src => rlisp_library/src}/evaluate.rs (100%) rename {src => rlisp_library/src}/lib.rs (100%) rename {src => rlisp_library/src}/parser.rs (100%) create mode 100644 rlisp_repl/Cargo.toml rename src/main.rs.bak => rlisp_repl/src/main.rs (90%) diff --git a/Cargo.lock b/Cargo.lock index 1d8609b..77926e9 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", +] diff --git a/Cargo.toml b/Cargo.toml old mode 100755 new mode 100644 index e3ccda0..148062a --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/rlbuild/Cargo.toml b/rlbuild/Cargo.toml new file mode 100644 index 0000000..d29bb2a --- /dev/null +++ b/rlbuild/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rlbuild" +version = "0.1.0" +edition = "2024" + +[dependencies] +rlisp_library = { path = "../rlisp_library" } diff --git a/rlbuild/assets/system.rlisp b/rlbuild/assets/system.rlisp new file mode 100644 index 0000000..959b44c --- /dev/null +++ b/rlbuild/assets/system.rlisp @@ -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 +;; 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) \ No newline at end of file diff --git a/rlbuild/src/main.rs b/rlbuild/src/main.rs new file mode 100644 index 0000000..46e8c3a --- /dev/null +++ b/rlbuild/src/main.rs @@ -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 { + // 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 { + 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 = 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), + }, + } + } +} diff --git a/rlisp_library/Cargo.toml b/rlisp_library/Cargo.toml new file mode 100644 index 0000000..fd44ecb --- /dev/null +++ b/rlisp_library/Cargo.toml @@ -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", +] } diff --git a/src/environ.rs b/rlisp_library/src/environ.rs similarity index 100% rename from src/environ.rs rename to rlisp_library/src/environ.rs diff --git a/src/evaluate.rs b/rlisp_library/src/evaluate.rs similarity index 100% rename from src/evaluate.rs rename to rlisp_library/src/evaluate.rs diff --git a/src/lib.rs b/rlisp_library/src/lib.rs similarity index 100% rename from src/lib.rs rename to rlisp_library/src/lib.rs diff --git a/src/parser.rs b/rlisp_library/src/parser.rs similarity index 100% rename from src/parser.rs rename to rlisp_library/src/parser.rs diff --git a/rlisp_repl/Cargo.toml b/rlisp_repl/Cargo.toml new file mode 100644 index 0000000..7493f5c --- /dev/null +++ b/rlisp_repl/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rlisp_repl" +version = "0.1.0" +edition = "2024" + +[dependencies] +rlisp_library = { path = "../rlisp_library" } diff --git a/src/main.rs.bak b/rlisp_repl/src/main.rs similarity index 90% rename from src/main.rs.bak rename to rlisp_repl/src/main.rs index ed72326..111e05e 100755 --- a/src/main.rs.bak +++ b/rlisp_repl/src/main.rs @@ -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();