Skip to content

Commit

Permalink
Merge branch 'main' of https://gitlab.com/mech-lang/mech
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontella committed Sep 2, 2024
2 parents 01ae801 + 28e5c6b commit 6059320
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 39 deletions.
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech"
version = "0.2.8"
version = "0.2.9"
authors = ["Corey Montella <[email protected]>"]
description = "Mech is a reactive programming language for building robots, games, and animations."
documentation = "https://mech-lang.org/docs"
Expand All @@ -18,20 +18,20 @@ gitlab = { repository = "mech-lang/mech", branch = "main" }
maintenance = { status = "actively-developed" }

[dependencies]
mech-core = "0.2.8"
mech-syntax = "0.2.8"
mech-core = "0.2.9"
mech-syntax = "0.2.9"
#mech-program = "0.2.2"
#mech-utilities = "0.2.2"

clap = {version = "4.5.15", features = ["cargo"]}
clap = {version = "4.5.16", features = ["cargo"]}
colored = "2.1.0"
#nom = "7.1.3"
#hashbrown = "0.14.5"
#reqwest = {version = "0.12.4", features = ["blocking"]}
bincode = "1.3.3"
serde = "1.0.207"
serde_derive = "1.0.207"
serde_json = "1.0.124"
serde = "1.0.209"
serde_derive = "1.0.209"
serde_json = "1.0.127"
crossbeam-channel = "0.5.13"
#seahash = "4.1.0"
crossterm = "0.28.1"
Expand Down Expand Up @@ -69,7 +69,7 @@ mech-utilities = { path = 'src/utilities'}
mech-wasm = { path = 'src/wasm'}

[patch.'https://gitlab.com/mech-lang/core']
mech-core = { path = 'src/core', version = '0.2.8' }
mech-core = { path = 'src/core', version = '0.2.9' }

[patch.'https://gitlab.com/mech-lang/syntax']
mech-syntax = { path = 'src/syntax', version = '0.2.8' }
mech-syntax = { path = 'src/syntax', version = '0.2.9' }
2 changes: 1 addition & 1 deletion src/bin/mech.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use serde_json;


fn main() -> Result<(), MechError> {
let version = "0.2.8";
let version = "0.2.9";
let text_logo = r#"
┌─────────┐ ┌──────┐ ┌─┐ ┌──┐ ┌─┐ ┌─┐
└───┐ ┌───┘ └──────┘ │ │ └┐ │ │ │ │ │
Expand Down
8 changes: 4 additions & 4 deletions src/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech-core"
version = "0.2.8"
version = "0.2.9"
authors = ["Corey Montella <[email protected]>"]
description = "The Mech language runtime."
documentation = "http://docs.mech-lang.org"
Expand All @@ -25,12 +25,12 @@ wasm = ["web-sys", "wasm-bindgen"]

[dependencies]
hashbrown = "0.14.5"
serde = {version = "1.0.207", default-features = false, features = ["alloc"] }
serde_derive = "1.0.207"
serde = {version = "1.0.209", default-features = false, features = ["alloc"] }
serde_derive = "1.0.209"
rlibc = { version = "=1.0", optional = true }
lazy_static = "1.5.0"
seahash = "4.1.0"
indexmap = "2.3.0"
indexmap = "2.4.0"
rayon = {version = "1.10.0", optional = true}
time = {version = "0.3.36", optional = true}
ed25519-dalek = {version = "2.1.1", default-features = false, features = ["rand_core"]}
Expand Down
43 changes: 32 additions & 11 deletions src/core/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,18 +594,18 @@ fn table(t: &Table, plan: Plan, symbols: SymbolTableRef, functions: FunctionsRef
for (field_label,(column,knd)) in ids.iter().zip(data.iter().zip(col_kinds)) {
let val = Value::to_matrix(column.clone(),column.len(),1);
match knd {
ValueKind::I8 => handle_value_kind!(knd, val, field_label, data_map, as_i8),
ValueKind::I16 => handle_value_kind!(knd, val, field_label, data_map, as_i16),
ValueKind::I32 => handle_value_kind!(knd, val, field_label, data_map, as_i32),
ValueKind::I64 => handle_value_kind!(knd, val, field_label, data_map, as_i64),
ValueKind::I8 => handle_value_kind!(knd, val, field_label, data_map, as_i8),
ValueKind::I16 => handle_value_kind!(knd, val, field_label, data_map, as_i16),
ValueKind::I32 => handle_value_kind!(knd, val, field_label, data_map, as_i32),
ValueKind::I64 => handle_value_kind!(knd, val, field_label, data_map, as_i64),
ValueKind::I128 => handle_value_kind!(knd, val, field_label, data_map, as_i128),
ValueKind::U8 => handle_value_kind!(knd, val, field_label, data_map, as_u8),
ValueKind::U16 => handle_value_kind!(knd, val, field_label, data_map, as_u16),
ValueKind::U32 => handle_value_kind!(knd, val, field_label, data_map, as_u32),
ValueKind::U64 => handle_value_kind!(knd, val, field_label, data_map, as_u64),
ValueKind::U8 => handle_value_kind!(knd, val, field_label, data_map, as_u8),
ValueKind::U16 => handle_value_kind!(knd, val, field_label, data_map, as_u16),
ValueKind::U32 => handle_value_kind!(knd, val, field_label, data_map, as_u32),
ValueKind::U64 => handle_value_kind!(knd, val, field_label, data_map, as_u64),
ValueKind::U128 => handle_value_kind!(knd, val, field_label, data_map, as_u128),
ValueKind::F32 => handle_value_kind!(knd, val, field_label, data_map, as_f32),
ValueKind::F64 => handle_value_kind!(knd, val, field_label, data_map, as_f64),
ValueKind::F32 => handle_value_kind!(knd, val, field_label, data_map, as_f32),
ValueKind::F64 => handle_value_kind!(knd, val, field_label, data_map, as_f64),
ValueKind::Bool => {
let vals: Vec<Value> = val.as_vec().iter().map(|x| x.as_bool().unwrap().to_value()).collect::<Vec<Value>>();
data_map.insert(field_label.clone(),(knd,Value::to_matrix(vals.clone(),vals.len(),1)));
Expand Down Expand Up @@ -858,11 +858,32 @@ fn real(rl: &RealNumber) -> Value {
RealNumber::Hexadecimal(num) => todo!(),
RealNumber::Octal(num) => todo!(),
RealNumber::Binary(num) => todo!(),
RealNumber::Scientific(num) => todo!(),
RealNumber::Scientific(num) => scientific(num),
RealNumber::Rational(num) => todo!(),
}
}

fn scientific(sci: &(Base,Exponent)) -> Value {
let (base,exp): &(Base,Exponent) = sci;
let (whole,part): &(Whole,Part) = base;
let (sign,exp_whole, exp_part): &(Sign, Whole, Part) = exp;

let a = whole.chars.iter().collect::<String>();
let b = part.chars.iter().collect::<String>();
let c = exp_whole.chars.iter().collect::<String>();
let d = exp_part.chars.iter().collect::<String>();
let num_f64: f64 = format!("{}.{}",a,b).parse::<f64>().unwrap();
let mut exp_f64: f64 = format!("{}.{}",c,d).parse::<f64>().unwrap();
if *sign {
exp_f64 = -exp_f64;
}

let num = num_f64 * 10f64.powf(exp_f64);


Value::F64(new_ref(F64(num)))
}

fn float(flt: &(Token,Token)) -> Value {
let a = flt.0.chars.iter().collect::<String>();
let b = flt.1.chars.iter().collect::<String>();
Expand Down
18 changes: 9 additions & 9 deletions src/core/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,15 @@ pub struct Paragraph {
pub elements: Vec<ParagraphElement>,
}

type Sign = bool;
type Numerator = Token;
type Denominator = Token;
type Whole = Token;
type Part = Token;
type Real = Box<Number>;
type Imaginary = Box<Number>;
type Base = (Whole, Part);
type Exponent = (Sign, Whole, Part);
pub type Sign = bool;
pub type Numerator = Token;
pub type Denominator = Token;
pub type Whole = Token;
pub type Part = Token;
pub type Real = Box<Number>;
pub type Imaginary = Box<Number>;
pub type Base = (Whole, Part);
pub type Exponent = (Sign, Whole, Part);

#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Number {
Expand Down
10 changes: 5 additions & 5 deletions src/syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mech-syntax"
version = "0.2.8"
version = "0.2.9"
authors = ["Corey Montella <[email protected]>"]
description = "A toolchain for compiling textual syntax into Mech blocks."
documentation = "http://docs.mech-lang.org"
Expand All @@ -21,19 +21,19 @@ default = []
no-std = ["mech-core/no-std", "rlibc"]

[dependencies]
mech-core = "0.2.8"
mech-core = "0.2.9"

hashbrown = "0.14.5"
lazy_static = "1.5.0"
nom = "7.1.3"
nom-unicode = "0.3.0"
unicode-segmentation = "1.11.0"
rlibc = { version = "=1.0", optional = true }
serde = "1.0.207"
serde_derive = "1.0.207"
serde = "1.0.209"
serde_derive = "1.0.209"
colored = "2.1.0"
nalgebra = "0.33.0"
indexmap = "2.3.0"
indexmap = "2.4.0"
tabled = "0.16.0"
libm = "0.2.8"
simba = "0.9.0"
Expand Down
1 change: 1 addition & 0 deletions src/syntax/tests/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use na::{Vector3, DVector, RowDVector, Matrix1, Matrix3, Matrix4, RowVector3, Ro
/////////////////////////////////////////////////////////////////////////////////

test_interpreter!(interpret_literal_integer, "123", Value::I64(new_ref(123)));
test_interpreter!(interpret_literal_sci, "1.23e2", Value::F64(new_ref(F64::new(123.0))));
test_interpreter!(interpret_literal_float, "1.23", Value::F64(new_ref(F64::new(1.23))));
test_interpreter!(interpret_literal_string, r#""Hello""#, Value::String("Hello".to_string()));
test_interpreter!(interpret_literal_true, "true", Value::Bool(new_ref(true)));
Expand Down

0 comments on commit 6059320

Please sign in to comment.