Further librarification
This commit is contained in:
parent
90d2a140e1
commit
a9c16ef08d
|
@ -1,126 +1,17 @@
|
||||||
(def use-repo (fn (a b) (print a b)))
|
(def use-repo (fn (a b) (print a b)))
|
||||||
|
(def pkg-install (fn (a b) (print "installed" b "from" a)))
|
||||||
|
(def pkg-defaults (fn ()))
|
||||||
|
|
||||||
|
(def resolution (fn (x y fps) ()))
|
||||||
|
|
||||||
;; (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))
|
(def limine_res (resolution 1024 768 24))
|
||||||
(boot-loader
|
|
||||||
(default-entry 1)
|
|
||||||
(timeout 0)
|
|
||||||
(interface_resolution: 'limine_res))
|
|
||||||
|
|
||||||
(boot-loader-entry "ableos"
|
(use-repo 'core "https://repo.ablecorp.us/core")
|
||||||
(comment "Default AbleOS boot entry.")
|
|
||||||
(protocol "limine")
|
|
||||||
(kernel_path "boot:///kernel_${ARCH}")
|
|
||||||
(kernel_cmdline "")
|
|
||||||
(resolution 'limine_res))
|
|
||||||
|
|
||||||
(boot-loader-entry "ableos-no-cluster"
|
(pkg-install 'core 'limine)
|
||||||
(comment "Default AbleOS boot entry.")
|
(pkg-install 'core 'kernel-rust)
|
||||||
(protocol "limine")
|
|
||||||
(kernel_path "boot:///kernel_${ARCH}")
|
|
||||||
(kernel_cmdline "cluster=false")
|
|
||||||
(resolution 'limine_res))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
(pkg-install 'core 'sunset)
|
||||||
;; Kernel Options ;;
|
(pkg-install 'core 'ps2-driver)
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
;; A kernel package is required
|
(pkg-install 'core 'cluster)
|
||||||
(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)
|
|
||||||
|
|
|
@ -23,12 +23,25 @@ fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
|
||||||
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
|
||||||
let mut stri = String::new();
|
let mut stri = String::new();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
let fmted = format!("{}", arg);
|
let fmted = match arg {
|
||||||
|
Expr::Str(string) => {
|
||||||
|
let string = string.clone();
|
||||||
|
// string.pop();
|
||||||
|
// string.remove(0);
|
||||||
|
|
||||||
|
format!("{}", string)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
format!("{}", arg)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
stri.push_str(&fmted);
|
stri.push_str(&fmted);
|
||||||
stri.push_str(" ")
|
stri.push_str(" ")
|
||||||
}
|
}
|
||||||
|
println!("{}", stri);
|
||||||
|
|
||||||
Ok(Expr::Symbol(stri.to_string()))
|
Ok(Expr::Bool(true))
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
env
|
env
|
||||||
|
@ -46,7 +59,6 @@ fn main() {
|
||||||
|
|
||||||
for (i, character) in cfg.chars().enumerate() {
|
for (i, character) in cfg.chars().enumerate() {
|
||||||
if character == '(' {
|
if character == '(' {
|
||||||
// println!("OPEN");
|
|
||||||
if left_parens == 0 {
|
if left_parens == 0 {
|
||||||
idx_of_first_left_paran = i
|
idx_of_first_left_paran = i
|
||||||
}
|
}
|
||||||
|
@ -54,15 +66,13 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if character == ')' {
|
if character == ')' {
|
||||||
// println!("CLOSE");
|
left_parens -= 1;
|
||||||
if left_parens == 0 {
|
if left_parens == 0 {
|
||||||
let idx_of_last_right_paran = i + 1;
|
let idx_of_last_right_paran = i + 1;
|
||||||
|
|
||||||
complete_exprs
|
complete_exprs
|
||||||
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
|
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
left_parens -= 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@ use alloc::string::String;
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use crate::environ::env_get;
|
|
||||||
use crate::Environ;
|
use crate::Environ;
|
||||||
use crate::Expr;
|
use crate::Expr;
|
||||||
use crate::HashMap;
|
use crate::HashMap;
|
||||||
use crate::RLambda;
|
use crate::RLambda;
|
||||||
use crate::Rc;
|
use crate::Rc;
|
||||||
use crate::RispError;
|
use crate::RispError;
|
||||||
|
use crate::environ::env_get;
|
||||||
|
|
||||||
pub fn eval(exp: &Expr, env: &mut Environ) -> Result<Expr, RispError> {
|
pub fn eval(exp: &Expr, env: &mut Environ) -> Result<Expr, RispError> {
|
||||||
match exp {
|
match exp {
|
||||||
|
@ -45,7 +45,7 @@ pub fn eval(exp: &Expr, env: &mut Environ) -> Result<Expr, RispError> {
|
||||||
}
|
}
|
||||||
Expr::Func(_) => Err(RispError::Reason("unexpected form".to_string())),
|
Expr::Func(_) => Err(RispError::Reason("unexpected form".to_string())),
|
||||||
Expr::Lambda(_) => Err(RispError::Reason("unexpected form".to_string())),
|
Expr::Lambda(_) => Err(RispError::Reason("unexpected form".to_string())),
|
||||||
// Expr::Nil => Err(RispError::Reason("unexpected nil".to_string())),
|
Expr::Atom(_) => Ok(exp.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ fn eval_lambda_args(arg_forms: &[Expr]) -> Result<Expr, RispError> {
|
||||||
let params_exp = arg_forms
|
let params_exp = arg_forms
|
||||||
.first()
|
.first()
|
||||||
.ok_or(RispError::Reason("expected args form".to_string()))?;
|
.ok_or(RispError::Reason("expected args form".to_string()))?;
|
||||||
|
|
||||||
let body_exp = arg_forms
|
let body_exp = arg_forms
|
||||||
.get(1)
|
.get(1)
|
||||||
.ok_or(RispError::Reason("expected second form".to_string()))?;
|
.ok_or(RispError::Reason("expected second form".to_string()))?;
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
#![feature(slice_take)]
|
#![feature(slice_take)]
|
||||||
#![allow(special_module_name)]
|
#![allow(special_module_name)]
|
||||||
#![feature(build_hasher_default_const_new)]
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use core::num::ParseFloatError;
|
use core::num::ParseFloatError;
|
||||||
// use std::hash::DefaultHasher;
|
|
||||||
|
|
||||||
use alloc::fmt::format;
|
pub extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::format;
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
use alloc::vec;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
pub use hashbrown::hash_map::HashMap;
|
pub use hashbrown::hash_map::HashMap;
|
||||||
pub extern crate alloc;
|
|
||||||
use alloc::format;
|
|
||||||
use alloc::vec;
|
|
||||||
// pub use alloc::;
|
|
||||||
// pub use core::rc::Rc;
|
|
||||||
|
|
||||||
mod environ;
|
mod environ;
|
||||||
|
pub use environ::Environ;
|
||||||
pub use environ::default_env;
|
pub use environ::default_env;
|
||||||
pub use environ::env_get;
|
pub use environ::env_get;
|
||||||
pub use environ::Environ;
|
|
||||||
|
|
||||||
mod parser;
|
mod parser;
|
||||||
pub use parser::parse;
|
pub use parser::parse;
|
||||||
|
@ -38,6 +33,7 @@ pub enum RispError {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
|
Atom(String),
|
||||||
Symbol(String),
|
Symbol(String),
|
||||||
Number(f64),
|
Number(f64),
|
||||||
Str(String),
|
Str(String),
|
||||||
|
@ -69,6 +65,7 @@ impl fmt::Display for Expr {
|
||||||
Lambda(lambda) => {
|
Lambda(lambda) => {
|
||||||
format!("(fn {} {})", lambda.params_exp, lambda.body_exp)
|
format!("(fn {} {})", lambda.params_exp, lambda.body_exp)
|
||||||
}
|
}
|
||||||
|
Atom(a) => format!("{}", a),
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(f, "{}", str)
|
write!(f, "{}", str)
|
||||||
|
|
|
@ -2,12 +2,12 @@ use alloc::string::String;
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use crate::evaluate::eval;
|
|
||||||
use crate::read_seq;
|
|
||||||
use crate::Environ;
|
use crate::Environ;
|
||||||
use crate::Expr;
|
use crate::Expr;
|
||||||
use crate::ParseFloatError;
|
use crate::ParseFloatError;
|
||||||
use crate::RispError;
|
use crate::RispError;
|
||||||
|
use crate::evaluate::eval;
|
||||||
|
use crate::read_seq;
|
||||||
|
|
||||||
pub fn tokenize(expr: String) -> Vec<String> {
|
pub fn tokenize(expr: String) -> Vec<String> {
|
||||||
expr.replace("(", " ( ")
|
expr.replace("(", " ( ")
|
||||||
|
@ -55,6 +55,8 @@ fn parse_atom(token: &str) -> Expr {
|
||||||
stri.pop();
|
stri.pop();
|
||||||
|
|
||||||
Str(stri)
|
Str(stri)
|
||||||
|
} else if token.starts_with("'") {
|
||||||
|
Atom(token.to_string().clone())
|
||||||
} else {
|
} else {
|
||||||
Symbol(token.to_string().clone())
|
Symbol(token.to_string().clone())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue